开发者

AS3.0 wait until tween has finished

开发者 https://www.devze.com 2023-04-06 01:44 出处:网络
When I click my button I wish one of mc\'s disapear completely(first alpha changes from 1 to 0) then removeChild.

When I click my button I wish one of mc's disapear completely(first alpha changes from 1 to 0) then removeChild.

import fl.transitions.Tween;
import fl.transitions.easing.*;
import fl.transitions.TweenEvent;
main.btn.addEventListener(MouseEvent.CLICK, buttonClickHandler);

function buttonClickHandler(event:MouseEvent):void 
{

var aBlend = new Tween(main, "alpha", Strong.easeOut, 1, 0, 3, true);

aBlend.addEventListener(TweenEvent.MOTION_FINISH, end);   //doesnt work
}
function end()
{
    this.removeChild(mc);
}

I dicided to use events but it doesnt 开发者_StackOverflow中文版work, can anyone help me?


Try moving the aBlend declaration outside of the buttonClickHandler as suggested by this post:

http://www.actionscript.org/forums/showpost.php3?s=e4e6512ae627e7810c4e991691324b9f&p=735466&postcount=4

i.e.

import fl.transitions.Tween;
import fl.transitions.easing.*;
import fl.transitions.TweenEvent;
main.btn.addEventListener(MouseEvent.CLICK, buttonClickHandler);

var aBlend;

function buttonClickHandler(event:MouseEvent):void 
{

aBlend = new Tween(main, "alpha", Strong.easeOut, 1, 0, 3, true);

aBlend.addEventListener(TweenEvent.MOTION_FINISH, end);   //doesnt work
}
function end(event:TweenEvent)
{
    this.removeChild(mc);
}
0

精彩评论

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

关注公众号