A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: Ping-Pong playback of movies possible?

  1. #1
    Junior Member
    Join Date
    Dec 2000
    Posts
    2
    Hey guys, hope you can help the newbie out.

    I have made a 2 second clip that I need to play back pingpong style and not just repeat. Is is possible?

    If so, can you tell me how please.... Or at least point me in the direction of where to find this info!

    Hope you can help out soon

    Nick

  2. #2
    HELP>>>ACTIONSCRIPT DICTIONARY
    Join Date
    Feb 2000
    Location
    In the Present Moment
    Posts
    1,041
    NP bro -

    Inside of the movieClip that you want to have ping-pong, place an empty movieClip with the following code on it.

    Code:
    onClipEvent (enterFrame) {
    	if (_parent.mode == "reverse") {
    		_parent.prevFrame();
    	} else {
    		_parent.nextFrame();
    	}
    }
    This clip has to appear over the whole of the animation you want to ping-pong. On the last frame of the animation put this line:

    mode="reverse";

    and on the first frame of the animation (or on the frame where you want the direction to change again) place this line:

    mode="forward";

    That should be enought to get you started.

    Good Luck!

  3. #3
    Junior Member
    Join Date
    Dec 2000
    Posts
    2

    Thanks man, but.......

    Thanks very much for the prompt answer, but really I dont have a clue how to do what you told me... I aint stupid, its just I have never used Flash before.....

    Is there an online step by step guide i would be able to follow? I really am stuck here, but really want to learn how to do this... Its seems to simple to be this complicated lol

    Thanks!

    Nick

  4. #4
    HELP>>>ACTIONSCRIPT DICTIONARY
    Join Date
    Feb 2000
    Location
    In the Present Moment
    Posts
    1,041
    For this tute I am assuming that you have put your animation in a movieClip. I am also assuming that your animation runs from frame 1 to someEndFrame of this movieClip.

    1) First let's make an empty movieClip, hit CTRL+F8 or Insert>New Symbol, select movieClip, name it mt, and finally select OK

    2) You will be in edit mode of this new symbol. To get out of edit mode, look just underneath the timeline, on the left. You will see Scene1 (if you haven't named the Scene, that is), click that (or the SceneName). mt will now be in your library.

    3)Now we need to edit the movieClip that contains your animation. So, drag an instance of the animation clip to your stage and double click it to start editing it.

    4)Okay, I need you to insert 2 layers to this movieClip, they can be the top 2 layers. Name one ACTIONS and one controlClip.

    5)Select frame 1 of the ACTIONS layer, hit F9 (to open the ActionScript Window) and add this code:

    mode="forward";

    6) Select the last frame of the animation and add these lines to the ActionScript window:

    stop();
    mode="reverse";

    7)Select frame 1 of the controlClip layer, open up your library (Ctrl+L) and drag an instance of mt to the stage. For convenience, just center it.

    8)Select the mt clip and hit F9 to open up the ActionScript Window (if not open from above )and add the code from my previous post. Cut n Paste will work, as long as you grab the text between the lines.

    9)Make sure that the controlClip's layer is colored gray over the entire span of the animation.

    10)Test the movie and that clip should be ping-ponging


    Basically what happens is that the two frame actions determine whether or not that clip should be playing forward or reverse. The mt clip is continually checking whether the clip that is holding it (_parent ) should be going forward or reverse. As soon as the mt clip sees that the _parent is in "reverse" mode, it tells the _parent to hit the previous frame ( _prevFrame ), and it will do that until it hits frame 1 which sets mode back to forward. Because onClipEvent(enterFrame) runs at the the same frames per second as your movie, the clip will play backwards at the same frame rate as it did forward.

    You dig? If you don't, let me know and I'll bring the shovel.

    Good Luck!



  5. #5
    human
    Join Date
    May 2000
    Posts
    132
    I thought I would let you know that your code worked perfectly for me!
    I did a search for reverse timeline, and Wala!!!!
    Thanks ever so much!

  6. #6
    Senior Member flashPlaya's Avatar
    Join Date
    Sep 2001
    Location
    >>WESTSIDE<<
    Posts
    235

    Me too

    Works great!! thanks!!
    ////FLASHPLAYER//

    MY SITE>>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center