Flash AS2 simple question

Discussion in 'Graphics & Multimedia' started by satrebor, Jun 18, 2013.

  1. #1
    I have simple animation in flash cs4, I have created a code: on(rollOver){goToAndPlay(1);}. Everything is good, but how to play same layer animation but REVERSE once mouse rollOuts?
     
    satrebor, Jun 18, 2013 IP
  2. nagarajdh

    nagarajdh Member

    Messages:
    53
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    36
    #2
    This is simple.
    1. Copy all the frames, ex if you have 1 to 10 frames copy those frames, place a stop() action on frame 10.
    2. Create a new layer select frame 11 and paste previously selected 1 to 10 frames, select all these frames in layer 2 and got to tab Modify-Timeline and click Reverse Frame. This will reverse all your animation.
    3. Now write the Mouse Roll out action to play animation in layer 2 that starts from Key Frame 11.

    Hope this helps, soot me message if you get struck. Will Help.
     
    nagarajdh, Jul 10, 2013 IP
  3. ViolentAJ

    ViolentAJ Well-Known Member

    Messages:
    581
    Likes Received:
    19
    Best Answers:
    0
    Trophy Points:
    128
    #3
    What you can do is create a boolean and an onEnterFrame function.

    Replace "theMovie" and "theButton" with the instance names of the MovieClip and Button respectively.
    
     
    var inReverse:Boolean = false; // keep it false it first; it becomes true when you want to reverse
     
    //What you already have
     
    theButton.on(rollOver){
    [INDENT=1]theMovie.gotoAndPlay(1);[/INDENT]
    }
     
     
    //The onEnterFrame function 
     
    theMovie.onEnterFrame = function(){
    [INDENT=1]if(inReverse){ //If the movie is in reverse...[/INDENT]
    [INDENT=2]theMovie.prevFrame(); //Go backwards[/INDENT]
    [INDENT=2] [/INDENT]
    [INDENT=2]if(theMovie._currentframe == 1){ //Check to see if the first frame has been reached...[/INDENT]
    [INDENT=3]theMovie.stop(); //If so, stop...[/INDENT]
    [INDENT=3]inReverse = false; //And you're no longer in reverse.[/INDENT]
    [INDENT=2]}[/INDENT]
    [INDENT=1]} else { //If the movie is not in reverse...[/INDENT]
    [INDENT=2]if(theMovie._currentframe == theMovie._totalframes){ //If it has reached its end...[/INDENT]
    [INDENT=3]theMovie.stop(); //Stop...[/INDENT]
    [INDENT=3] [/INDENT]
    [INDENT=3] [/INDENT]
    theButton.on(rollOut){ // Set up your rollOut listener
    [INDENT=1]inReverse = true; //It will cause the movie to go in reverse[/INDENT]
    }
     
    [INDENT=2]}[/INDENT]
    [INDENT=1]}[/INDENT]
    }
    
    Code (markup):
    That should work. Let me know if it helps or if it doesn't work properly.
     
    ViolentAJ, Jul 10, 2013 IP