AS3时间轴变量问题 [英] AS3 Timeline Variable issues

查看:250
本文介绍了AS3时间轴变量问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从时间线动态影片剪辑。

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);
}

和看/被创建时

这篇关于AS3时间轴变量问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆