我似乎无法使用fl.findObjectInDocByType()
with返回的信息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