简体   繁体   English

无法从舞台as3删除movieclip本身

[英]unable to remove movieclip itself from stage as3

I had a button, with that button a movieclip is called on the stage and it is working fine with the below script. 我有一个按钮,在该按钮上,在舞台上调用了动画片段 ,并且在以下脚本中工作正常。
I just updated the script and it is now working fine with the removing of movieclip from the stage, but now the issue came with playing the movieclip . 我刚刚更新了脚本,现在可以从舞台上删除movieclip了,它可以正常工作,但是现在问题出在播放movieclip上 Now the movieclip is not playing well. 现在, 影片剪辑的播放效果不佳。

var btn: btn_Lemon = new btn_Lemon();
var mc: mc_lemon = new mc_lemon();

    addChild(btn);

    btn.x = 304.45;
    btn.y = 209.8;

btn.addEventListener(MouseEvent.MOUSE_DOWN, login, false, 0, true);

    function login(event: MouseEvent): void {
    stage.addChild(mc);
    mc.x = 304.45;
    mc.y = 209.8;
    mc.addEventListener(Event.ENTER_FRAME, fadeOver, false, 0, true);
}

function fadeOver(event: Event): void {

    if (event.currentTarget.currentFrame == 25) {
        event.currentTarget.removeEventListener(Event.ENTER_FRAME, fadeOver);
        stage.removeChild(mc);
    }
}

What is going on please help somebody 发生了什么事请帮助某人

Presuming it's a timeline you're trying to play inside lemon_mc and it's the play method that doesn't seem to run properly. 假设这是您要在Lemon_mc中播放的时间表,并且该play方法似乎无法正常运行。 In my experience Flash can sometimes be a bit fickle with playing as I recall. 根据我的经验,Flash 有时在玩游戏时有些变幻无常。

Here are some pointers for pushing the MC to play: 以下是推动MC播放的一些提示:


  1. Force the a mc to play at the end of the 强制MC在末尾播放

     function login(event: MouseEvent): void { stage.addChild(mc); mc.x = 304.45; mc.y = 209.8; mc.addEventListener(Event.ENTER_FRAME, fadeOver, false, 0, true); mc.play(); 

    } }

  2. Simple add 简单添加

    play(); 玩();

at the first frame inside the movie clip you want to play. 在您要播放的影片剪辑内的第一帧。

  1. Also if the playback is a bit fickle at certain scenarios you can define with code, then you can use a test: 同样,如果可以在某些情况下使用代码定义回放的情况,则可以使用测试:

    if (mc.isPlaying == false) { mc.play(); 如果(mc.isPlaying == false){mc.play(); } }

As a beginner I found the as3 documentation from adobe to be easy to understand and apply. 作为一个初学者,我发现adobe的as3文档很容易理解和应用。 You might find some other properties to read or methods you can manipulate to force the play method: http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/MovieClip.html 您可能会找到其他一些要读取的属性,或者可以操纵以强制使用play方法的方法: http : //help.adobe.com/zh_CN/FlashPlatform/reference/actionscript/3/flash/display/MovieClip.html

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

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