我刚刚开始在 Adobe Flash 中使用 JSFL,我正在尝试向新创建的图层添加一个文本字段,然后将其实例名称更改为“属性”。
这是我的代码:
fl.outputPanel.clear();
var document = fl.getDocumentDOM();
var timeline = document.getTimeline();
var layers = timeline.layers;
var propertiesLayer = null;
var propertiesTextBox = null;
var layerIndex = 0;
fl.trace("Searching For Properties Layer");
for (var index in layers)
{
if(layers[index].name == "properties")
{
propertiesLayer = layers[index];
layerIndex = index;
}
}
if(!propertiesLayer)
{
fl.trace("Creating Properties Layer");
timeline.addNewLayer("properties");
layerIndex = timeline.findLayerIndex("properties");
fl.trace("Properties Layer Index is " + layerIndex);
propertiesLayer = layers[layerIndex];
timeline.setSelectedLayers(layerIndex * 1);
fl.trace("Creating Properties Text Field");
document.addNewText({left:0, top:-100, right:100, bottom:0});
propertiesLayer.frames[0].elements[0].name = "properties";
fl.trace("Setting Properties Text Field's Instance Name");
//propertiesTextBox.name = "properties";
fl.trace("Setting Properties Text Field");
document.setTextString("test");
}
我的输出窗口显示: Searching For Properties Layer Creating Properties Layer Properties Layer Index is 0 Creating Properties Text Field
在测试新的 Flash 文档 TypeError:propertiesLayer.frames[0].elements[0] has no properties 时出现以下错误
我很茫然,任何帮助将不胜感激。