dcsimg
A Flash Developer Resource Site

Results 1 to 8 of 8

Thread: [F8] Playing movie clip backwards?

  1. #1
    Junior Member
    Join Date
    Mar 2008
    Posts
    8

    [F8] Playing movie clip backwards?

    is it possible to play a movie clip in reverse?

    what i'm trying to do is have a selection of images that scroll by one by one in an animation, making a button to scroll forward was simple, but making a scroll button to go backwards has got me kind of stumped.

    I noticed there is a reverse command, but i couldn't get it to work.

  2. #2
    Developing For Dunkets mneil's Avatar
    Join Date
    Mar 2007
    Location
    Lincoln City
    Posts
    2,156
    yeah, you need to make an onEnterFrame for the clip, something like

    PHP Code:
    myBtn.onPress = function(){//when you click on myBtn
      
    myMC.onEnterFrame = function(){//mc you want to play backward
        
    var frame:Number this._currentframe;//cant remember if a _ goes before currentframe
        
    this.gotoAndStop(frame-1);
      }

    http://code.mneilsworld.com/
    Text Effects | Bubbles | Dynamic Resize
    4 weeks , 20 papers ... thats 2 dollars .....Caassshhh!

  3. #3
    Senior Member EQFlash's Avatar
    Join Date
    Jun 2002
    Location
    where i'm at
    Posts
    2,735
    PHP Code:
    on (press) { 
        
    onEnterFrame = function () { 
            
    _root.movieclip.prevFrame(); 
            
    _root.movieclip.stop(); 
            if (
    _root.movieclip._currentframe == 1) { 
                
    onEnterFrame null
            } 
        }; 

    on (release) { 
        
    _root.movieclip.stop(); 
         
    onEnterFrame null

    Last edited by EQFlash; 04-07-2008 at 12:27 AM.
    If you don't think you're going to like the answer, then don't ask the question.

  4. #4
    Junior Member
    Join Date
    Mar 2008
    Posts
    8
    mneil thnks for your reply,

    your script worked quite well but i've noticed two problems so far, and there's something i'm confused about. the stop(); commands i have at the tops of my separate labels in my Movie clip don't register while playing backwards so my clip just plays to the beginning instead of stopping at the right times like going forward, also there are some frames i don't want to play at the beginning of the clip, but rather have it loop back around to the beginning like i have it setup for going forwards with a gotoAndStop("label").

    Is there something i need to do to make script work for when it's moving in reverse this way?
    ---------------------------------------------------------------------
    EQFlash thanks for your post also,

    your script works well also, except for this particular application i would like to get the video to stop on a specific previous frame, the previous labeled frame if that can be somehow useful, rather than stopping the video on release.

    is there a way i could do this and also loop back to the final label of my movie ?

    __________________________________________________ ____
    thx again guys

  5. #5
    Senior Member EQFlash's Avatar
    Join Date
    Jun 2002
    Location
    where i'm at
    Posts
    2,735
    this makes it stop on a frame number, but i can't get it to stop on a labeled frame.
    PHP Code:
    on (release) {
        
    onEnterFrame = function () {
            
    _root.mc.prevFrame();
            
    //_root.mc.stop();
            
    if (_root.mc._currentframe == 25) {
                
    _root.mc.stop();
                
    onEnterFrame null;
            }
        };

    If you don't think you're going to like the answer, then don't ask the question.

  6. #6
    Developing For Dunkets mneil's Avatar
    Join Date
    Mar 2007
    Location
    Lincoln City
    Posts
    2,156
    Flash isn't set up to play movieclips backwards so there is no straight way to accomplish what you're doing. But you can check for a certain frame like EQFlash has put. And, of course the stop() command doesn't work, your FORCING the movieclip to play backwards; no commands like that will work.
    http://code.mneilsworld.com/
    Text Effects | Bubbles | Dynamic Resize
    4 weeks , 20 papers ... thats 2 dollars .....Caassshhh!

  7. #7
    trace("AKA: Biro Barna");
    Join Date
    Oct 2007
    Location
    RO.Timişoara
    Posts
    1,403
    You are not forcing anything. It can be done, quite easily, I'll post an example in a couple of hours ( don't have Flash installed here ). Regarding the frame labels, it's possible to make that work too although I have to look up the function name in AS 2.0 ( in AS 3.0 it can be done 100% ).



    | Windows MSN: birobarna [at] hotmail [dot] com | Skype: barna.biro |
    WebLog: http://blog.wisebisoft.com/ |
    | Software Developer / Flash & Flex Developer | Student ( Computer Science ) | Interested in: Sharing Knowledge |
    |
    Romanian Adobe Flash, Flex, AIR Forum: http://www.flashforum.ro/
    | By perseverance the snail reached the ark. |


  8. #8
    trace("AKA: Biro Barna");
    Join Date
    Oct 2007
    Location
    RO.Timişoara
    Posts
    1,403
    Ok, here I am again. So, a bit of correction on the "getting the label" problem. I wasn't right about that one, it's not possible to get the current label in AS 2.0, it only works in AS 3.0 ; but regarding the reverse animation, well, you can simply do something like this ( if you ever heard of movie clip buttons then this won't be anything new ):

    PHP Code:
    // all code goes on frame ( not on a symbol )

    var rew:Boolean;

    // disable the default hand cursor for your movie clip
    animation_mc.useHandCursor false;
    // stop animation_mc from playing
    animation_mc.stop();

    animation_mc.onRollOver = function():Void
    {
        
    rew false;
        
        
    animation_mc.onEnterFrame = function():Void
        
    {
            if(
    rew)
            {
                if(
    animation_mc._currentframe == 1)
                {
                    
    // remove the enter frame listener
                    
    animation_mc.onEnterFrame null;
                    
                }
                else
                {
                    
    // step one frame back
                    
    animation_mc.prevFrame();
                
                } 
    // end if
                
            
    }
            else
            {
                
    // step one frame forth
                
    animation_mc.nextFrame();
            
            } 
    // end if

        
    }; // end of onEnterFrame
        
    }; // end of onRollOver

    animation_mc.onRollOut = function():Void
    {
        
    rew true;
        
    }; 
    // end of onRollOut 
    The idea is to listen for a variable change. This variable is called "rew" and the whole thing is quite simple. We have an enter frame event listening for changes in "rew"; if we roll over our movie clip then "rew = false" meaning that it's not yet time to rewind your animation. Once we move off the desired movie clip ( in our case called "animation_mc" ) then rew is set to "true" signaling the event listener that the user has rolled off the movie clip and "it has to rewind it ( play it in reverse )".

    You could try a work around for the label problem. It's not as efficient as if it would have been with a label but if you won't change the number of frames in the animation then you won't run into problems. Simple add 1 more condition that checks if the "currentframe == 5" ( 5 being the frame that has the label on it ) and once that conditions is true then "do something".

    Hope that cleared things up,
    Good luck
    Last edited by fx.barrett; 04-09-2008 at 12:50 PM.



    | Windows MSN: birobarna [at] hotmail [dot] com | Skype: barna.biro |
    WebLog: http://blog.wisebisoft.com/ |
    | Software Developer / Flash & Flex Developer | Student ( Computer Science ) | Interested in: Sharing Knowledge |
    |
    Romanian Adobe Flash, Flex, AIR Forum: http://www.flashforum.ro/
    | By perseverance the snail reached the ark. |


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