2014-12-27 30 views
0

我试图确定动态剪辑当前处于哪个帧编号(_currentframe)。as2获取动态剪辑的当前帧

在这里,我在库 -

_root.clipName="rabbit"; 

的“_root.clipName”设置剪辑的名称必须是可变的,因为它的变化。

在这里,我将其连接到阶段 - (作品链接库夹“兔子”高度重视的阶段)

 Object(_root).attachMovie("myClip",_root.clipName,_root.getNextHighestDepth(), {_x:200), _y:200)}); 

然后,我想存储帧数不同的功能使用 -

_root.myFrame=_root.clipName._currentframe; <- (doesn't work) 

使用下面的方法跟踪,没有似乎回到帧号 -

trace(_root.clipName._currentframe);  - returns undefined 
trace(_root.clipName[_currentframe]); - returns undefined 
trace(_root.clipName._currentframe);  - returns undefined 
trace(_root['clipName']._currentframe); - returns undefined 

有什么想法我可能在这里做错了吗?

谢谢!

回答

2

myClip是在库中的影片剪辑的linkage nameinstance name

this.attachMovie("myClip", "Rabbit", this.getNextHighestDepth()); 

var myFrame:Number; 

Rabbit.onEnterFrame = function():Void { 
    myFrame = this._currentframe; 
} 

所以你直接测试实例的enterFrame事件,和你的global variablemyframe可以访问来自世界各地。

有了您的clipName变量

你可以打电话给你clipName变量代替。我已经改名了myInstance

this.attachMovie("myClip", "Rabbit", this.getNextHighestDepth()); 

var myFrame:Number; 
var myInstance:MovieClip = Rabbit; 

myInstance.onEnterFrame = function():Void { 
    myFrame = this._currentframe; 
} 
+0

..我想要你的宝宝。非常感谢,它的工作! – cheeseomelete 2014-12-27 20:06:04