as2获取动态剪辑的当前帧

时间:2014-12-27 19:00:27

标签: actionscript-2

我正在尝试确定动态剪辑当前所在的帧编号(_currentframe)。

在这里,我在库中设置剪辑的名称 -

_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 

知道我在这里做错了什么吗?

谢谢!

1 个答案:

答案 0 :(得分:2)

myClip 是库中MovieClip的linkage name Rabbit instance name

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

var myFrame:Number;

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

因此,您可以直接测试实例的enterFrame,并且可以从任何地方访问您的global variable myframe

使用您的clipName变量

您可以调用 clipName 变量而不是 Rabbit 。我已将其重命名为 myInstance

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

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

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