• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Animation for Exit

Participant ,
Jul 19, 2012 Jul 19, 2012

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


TOPICS
ActionScript

Views

646

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Jul 19, 2012 Jul 19, 2012

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.

Votes

Translate

Translate
LEGEND ,
Jul 19, 2012 Jul 19, 2012

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jul 19, 2012 Jul 19, 2012

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);

}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 19, 2012 Jul 19, 2012

Copy link to clipboard

Copied

LATEST

You're welcome

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines