【发布时间】:2012-01-09 03:23:45
【问题描述】:
我似乎无法将fl.findObjectInDocByType() 返回的信息与fl.getDocumentDOM().selection 一起使用。
我想使用document.setTextRectangle 重新调整使用fl.findObjectInDocByType() 生成的数组中的一些文本字段的大小。
我可以轻松访问所有 textObject 属性,但由于 document.setTextRectangle 需要当前选择,我不知所措。
文档中设置选择的例子是:
fl.getDocumentDOM().selection = fl.getDocumentDOM().getTimeline().layers[0].frames[0].elements[0];
fl.findObjectInDocByType() 返回具有以下属性的对象数组:(object.timeline, object.layer, object.frame, object.parent)
但这些是对象,没有fl.getDocumentDOM().selection= 所需的数组索引号属性...
var doc = fl.getDocumentDOM();
var textFieldArray = fl.findObjectInDocByType("text", doc);
for (var i=0; i < textFieldArray.length; i ++){
fnResizeTheTextField(textFieldArray[i]);
}
function fnResizeTheTextField(theTextField){
//force current selection to be theTextField
//doc.selection MUST be an array, so assign theTextField to an array...
var selectArray = new Array();
selectArray[0] = theTextField.obj;
var theTimeline =theTextField.timeline;
var theLayer =theTextField.layer;
var theFrame =theTextField.frame;
doc.currentTimeline =theTextField.timeline;
doc.selection = doc.getTimeline().theLayer.theFrame.selectArray;//error
//resize the text rectangle
doc.setTextRectangle({left:0, top:0, right:1000, bottom:1000});
}
}
结果:Error:doc.getTimeline().theLayer has no properties
【问题讨论】:
标签: jsfl