单击按钮播放动画。动作脚本

时间:2013-11-19 12:40:31

标签: actionscript-3

嗨,我一直收到错误:

TypeError: Error #1010: A term is undefined and has no properties.
at Untitled_fla::MainTimeline/myPlay_clickHandler()

当我执行我的代码时。有人可以帮助我,我看不出我哪里出错了?

myAnimation.stop();
myPlayButton.stop();
myPlayButton.addEventListener(MouseEvent.CLICK, myPlay_clickHandler);

function myPlay_clickHandler(event:MouseEvent)//Creating function for the Click Event      handler
{
    if(myPlayButton.MovieClip.currentFrame ==1)
    {
        myPlayButton.gotoAndStop(2);
        myAnimation.play();
    }

    trace("myPlay was clicked on");
}

1 个答案:

答案 0 :(得分:2)

你不需要'if(myPlayButton.MovieClip.currentFrame == 1)'中的'MovieClip'。如果'myPlayButton'是MovieClip,您可以直接访问其currentFrame,即:

if (myPlayButton.currentFrame == 1)