开发者

GotoAndPlay not working

I have a movieclip with labels "normal" and "mouseover" . I am using the following code :

 开发者_如何学编程       var thisButton:MovieClip = this.getChildByName(e.currentTarget.name) as MovieClip;
        thisButton.gotoAndPlay("mouseOver");

On debugging "thisButton" does goto mouseover and the frame changes. But visually there is no change and the animation is not played. Any ideas?


Try:

var thisButton:MovieClip = e.currentTarget as MovieClip;
if(thisButton == null) return log.error("Error: thisButton does not appear to be"
                                         + "a MovieClip: " + thisButton);
thisButton.gotoAndPlay("mouseOver");

There's a couple of things I'm trying to say here:

  1. You don't really need to use getChildByName
  2. the call on line 1 will return null if the cast fails. Depending on how/where you're running your code, this could fail silently (run in debug mode and check your output to be sure)

Beyond these minor adjustments, the only other thing I can think of that might be causing you trouble is other actionscript. Is all your code in one place? Do you have code inside the movieclip? Are there calls to stop()? Are the parent clips stopped?

Check these things and report back and we can help you from there...

Hope that helps,
~gMale

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜