简体   繁体   English

将按钮链接到影片剪辑…gotoAndPlay()不起作用!

[英]Linking a button to a movie clip… gotoAndPlay() doesn't work!

I have a button, "pb". 我有一个按钮“ pb”。

I have a movieclip, "pm". 我有一个动画片段,“ pm”。

I want the clip to play certain frames when I press the button. 我希望剪辑在按下按钮时播放某些帧。

I have a layer on top of every other layer, with only one frame. 我在每隔一层的上面都有一层,只有一帧。 In the ActionScript for that frame, I have put: 在该框架的ActionScript中,我输入了:

stop();

pb.addEventListener(MouseEvent.CLICK, onMouseClick);

function onMouseClick(event:MouseEvent):void 
{
    trace("I've been clicked!");
    pm.gotoAndPlay(10);
}

When I click the button, the message comes up BUT THE MOVIE DOES NOT PLAY. 当我单击按钮时,出现消息,但电影不播放。

What have I done wrong? 我做错了什么? This should work. 这应该工作。 I've been looking online all day and this is what everyone says to do... I'm at a loss. 我整天都在网上寻找东西,这就是每个人都在说的...我很茫然。 Thanks. 谢谢。

well the code you have there is correct for what you want to do. 很好,您所拥有的代码对于您要执行的操作是正确的。 I guess from what you have said I would do the following: 我想根据您所说的,我会执行以下操作:

  1. check your pm MovieClip that it does not have a stop on the frames you are playing. 检查您的pm MovieClip是否在您正在播放的帧上没有停止。 If it has no scripts then I guess check that it actually has enough frames for what you are doing. 如果它没有脚本,那么我想检查一下它是否确实有足够的帧来满足您的需求。 Maybe copy that movieclip somewhere and just let it run through. 也许将那个动画片段复制到某个地方,然后使其通过。

  2. check that you don't have any other code somewhere telling it to stop playing. 检查您是否没有其他代码告诉它停止播放。

  3. create another MovieClip, with 2 frames, place a stop() only on the first frame, and play it after you try to play the pm. 创建另一个具有2帧的MovieClip,仅在第一帧上放置一个stop(),然后在尝试播放pm后播放它。 It should play, if it does not then you need to have a look at what you are doing. 它应该播放,如果没有播放,则需要查看正在执行的操作。

  4. lastly just make sure you created a MovieClip and did not create a button and then changed the button to a MovieClip 最后,只需确保您创建了MovieClip并没有创建按钮,然后将按钮更改为MovieClip

Above all else - make sure those two items - "pb" and "pm" have actually been assigned those instance names in the properties panel. 首先,请确保在属性面板中为这两个项目(“ pb”和“ pm”)实际分配了这些实例名称。 Are you getting any compiler errors? 您是否遇到任何编译器错误?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM