我正在使用4张照片,其中两张照片隐藏在另外两张照片后面。 如果你点击前两个,它们应该消失,然后你可以点击隐藏在下面的两个。 然而,在补间之后它们仍然处于活动状态,如果我移除了鼠标监听器,它们也会挡路。如果我使用pic.visible = false,它会在没有补间的情况下消失。 我该如何解决这个问题?
我的代码:
//pic4 and pic5 are on top layer
//pic2 and pic3 are on bottom layer
import fl.transitions.Tween;
import fl.transitions.easing.*;
pic2.addEventListener(MouseEvent.CLICK, mouseHandler1);
pic3.addEventListener(MouseEvent.CLICK, mouseHandler2);
pic4.addEventListener(MouseEvent.CLICK, mouseHandler3);
pic5.addEventListener(MouseEvent.CLICK, mouseHandler4);
function mouseHandler3(event:MouseEvent):void{
var t3:Tween = new Tween(pic4, "alpha", Strong.easeOut, 1, 0, 1, true);
}
function mouseHandler4(event:MouseEvent):void{
var t4:Tween = new Tween(pic5, "alpha", Strong.easeOut, 1, 0, 1, true);
}
function mouseHandler1(event:MouseEvent):void{
var t1:Tween = new Tween(pic2, "alpha", Strong.easeOut, 1, 0, 1, true);
}
function mouseHandler2(event:MouseEvent):void{
var t2:Tween = new Tween(pic3, "alpha", Strong.easeOut, 1, 0, 1, true);
}
答案 0 :(得分:0)
导入补间事件:
import fl.transitions.TweenEvent;
然后你可以这样做:
function mouseHandler3(event:MouseEvent):void
{
var t3:Tween = new Tween(pic4, "alpha", Strong.easeOut, 1, 0, 1, true);
t3.addEventListener(TweenEvent.MOTION_FINISH, onTweenEnd );
}
function onTweenEnd (e:TweenEvent) : void
{
pic4.visible = false;
//Do whatever else
}
这位初学者 guide 可能会对您有所帮助。此外,如果出现任何错误问题,则在任何函数之外声明var t3:Tween;
(特别是鼠标事件中的不),然后在您只使用的函数内创建一个新的补间:t3 = new Tween(pic4, etc ...)