Copy link to clipboard
Copied
I have ths code to attach a MovieClip to my main movie:
em_mc.addEventListener(MouseEvent.CLICK, fem3, false, 0, true);
function fem3(e:MouseEvent):void{
var mc:section1=new section1();
mc.y= 306;
addChild(mc);
var myTween:Tween = new Tween(mc, "x", Elastic.easeInOut, -500, 481, 1, true);
};
The movieclip attaches with an animation.
When I close (or exit) the attachd MovieClip I do not get an animation for exit.
This is the code for exiting the attached Movieclip:
home_mcb.addEventListener(MouseEvent.CLICK, exitinteraction);
function exitinteraction(event:MouseEvent):void{
this.parent.removeChild(this);
}
How Could I add a similar animation for exiting before removing the MovieClip from the main movie?
Currently the MovieClip just dissapears
Any help..thanks
What you should do is look into the Tween class so that you can understand what the parameters in it are indicating. Then you should be able to create a tween that does the opposite. If you need to have the object removed still, then you will need to add an event listener to the Tween for it MOTION_FINISH event... you can use that events handler function to do the this.parent.removeChild(this); that you have now.
Copy link to clipboard
Copied
What you should do is look into the Tween class so that you can understand what the parameters in it are indicating. Then you should be able to create a tween that does the opposite. If you need to have the object removed still, then you will need to add an event listener to the Tween for it MOTION_FINISH event... you can use that events handler function to do the this.parent.removeChild(this); that you have now.
Copy link to clipboard
Copied
Thank You Ned!!
Totally forgot about MOTION_FINISH.
I solved the isuue with this on the attached movieclip:
import fl.transitions.Tween;
import fl.transitions.easing.*;
import fl.transitions.TweenEvent;
function onFinish (e:TweenEvent):void {
this.parent.removeChild(this);
}
function exitinteraction(event:MouseEvent):void{
var myTween:Tween = new Tween(this, "x", Strong.easeOut, 481, -500, 2, true);
myTween.addEventListener(TweenEvent.MOTION_FINISH, onFinish);
}
Copy link to clipboard
Copied
You're welcome