我想从时间线动态影片剪辑。
I'm trying to get a dynamic movie clip from the timeline.
我有未知长度的影片剪辑实例名称嗒嗒的时间轴上的关键帧(假设在这种情况下,88)之一。 无论我做什么,我不能让一个参照上述影片剪辑。
I have a timeline of unknown length with a movie clip with instance name "blah" on one of the key frames (assumed 88 in this case). No matter what I do, I cannot get a reference to the said movie clip.
下面是我的尝试:
trace(blah); // null
trace(this.blah); // null
trace(getChildByName("blah")); // null
if(currentFrame == 88)
trace(getChildByName("blah")); // null
for(var i:int=0; i<numChildren; ++i)
trace(getChildAt(i));
/* Returns:
* [object MovieClip]
* [object Shape]
* null
* [object TextField]
*/
// Assuming the first movie clip is the correct one
trace(getChildAt(0).name); // instance?? where ?? are random digits, I'm expecting "blah"
是否有人可以揭示如何通过code导入时间表生成的对象?
Can someone please shed light on how to import timeline generated objects through code?
如果你才刚刚导航到框架88这可能是因为你试图使用它之前,它已经初始化。试着增加:
If you have only just navigated to frame 88 it could be that you are trying to use it before it has initialised. Try adding:
stage.addEventListener(Event.ADDED, onAdded);
function onAdded(event:Event):void
{
trace("new object "+event.target);
trace("new object name "+event.target.name);
}
和看/被创建时