A Flash Developer Resource Site

Page 2 of 2 FirstFirst 12
Results 21 to 29 of 29

Thread: Playing a movie clip in reverse

  1. #21
    FK's Geezer Mod Ask The Geezer's Avatar
    Join Date
    Jul 2002
    Location
    Out In The Pasture
    Posts
    20,488
    Well, it interested me, and I got it. Very elegant oldnewbie. Similar in some ways to making a slideshow wrap from the last pic back to the first, by way of around the horn.

  2. #22
    Junior Member
    Join Date
    Sep 2002
    Posts
    27
    Tyard et al.,

    I thought the code you posted could go inside the movie clip to improve it: So I stuck the button ("forward") in the clip on its own layer and put this in frame 1 of scroller

    Code:
    stop();
    forward.onRollOver =  function() {_root.scroller.onEnterFrame = function() {
    			var newframe = this._currentframe + 1;
    			if (newframe > this._totalframes) {
    				this.gotoAndStop(1);
    			} else {
    				this.nextFrame();
    			} }};
    			
    			
    forward.onRollOut = function() { delete _root.scroller.onEnterFrame };
    Is this any better? Can I get rid of mention of "scroller"?

    Cheers,

    Mark

  3. #23
    Senior Member
    Join Date
    Jan 2001
    Posts
    472
    Confused. You put forward INSIDE of scroller? If that's true, you can't get rid of the reference, though you can change it to a relative path:

    this._parent.onEnterFrame

    would refer to scroller if forward is now inside it. However, one of the reasons I set it up as I did was to centralize all of the code. This rather defeats the purpose.

    Again, I might be misunderstanding, so any elaboration would be appreciated.

  4. #24
    HELP>>>ACTIONSCRIPT DICTIONARY
    Join Date
    Feb 2000
    Location
    In the Present Moment
    Posts
    1,041
    Here is another version:

    1) clip - can be any clip that has an animation in it, just write a nice path, _root.someClip.someClip

    2) dir - 0 or false, 1 or true, "stop" - 0 or false will play the clip in the forward direction, 1 or true will play the clip in the reverse direction, "stop" will stop the clip by deleting the onEnterFrame event.

    Code:
    function reverseMe (clip, dir) {
    	clip.onEnterFrame = function () {
    		if (dir == 0) {
    			clip.nextFrame ();
    		} else if (dir == 1) {
    			clip.prevFrame ();
    		} else if (dir == "stop") {
    			delete clip.onEnterFrame;
    		}
    	};
    }
    forward.onRollOver = function () {
    	_root.reverseMe (_root.scroller, 0);// 0 or false works
    };
    reverse.onRollOver = function () {
    	_root.reverseMe (_root.scroller, 1);//1 or true works
    };
    forward.onRollOut = reverse.onRollOut = function (){
    	_root.reverseMe (_root.scroller, "stop");
    };
    Basically in the step by step I provided, ditch the "mt" clip out of the scroller clip. Replace the code on frame 1 with the code from above and you should be good to go.


    Good Luck!


    [Edited by Antibody on 09-29-2002 at 03:03 PM]

  5. #25
    Junior Member
    Join Date
    Sep 2002
    Posts
    27

    Antibody,

    The onrollover works, but not the onrollout (below). I cannot fix it no matter what.

    forward.onRollOut = function (){
    root.reverseMe (_root.scroller, "stop");
    };

    If I say this its okay:

    forward.onRollOut = function (){
    delete scroller.onEnterFrame;
    };

    but that defeats having the fuction.

    Any thoughts?

    Mark


  6. #26
    HELP>>>ACTIONSCRIPT DICTIONARY
    Join Date
    Feb 2000
    Location
    In the Present Moment
    Posts
    1,041
    oops that is a typo.. it should be _root not root. Sorry bout that.. fixin it in my post too

  7. #27
    Junior Member
    Join Date
    Sep 2002
    Posts
    27

    My eyes must be diabolical. Or my Flash skills.

    Thanks for correcting it,

    Mark

  8. #28
    FK's Geezer Mod Ask The Geezer's Avatar
    Join Date
    Jul 2002
    Location
    Out In The Pasture
    Posts
    20,488
    Just an aside, I am nowhere near the ability to just write AS. I have an advanced book that I am working through, and I am learning it, but..... I find myself doing a lesson and the exact script is in the book, all I got to do is type it out, character by character. Every mistake I make is from a typo. It's uncanny.

  9. #29
    HELP>>>ACTIONSCRIPT DICTIONARY
    Join Date
    Feb 2000
    Location
    In the Present Moment
    Posts
    1,041
    No problem man.. I actually cut n paste the code from Flash but I didn't have the _root's in my original code.. I added them into the post though because I think it is important to note the paths.

    iaskwhy-

    Believe me man you can be as careful writing your code as you want but typos are like cockroaches, they're everywhere. ;p

    Keep on keepin on guys.

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