Solved

Flash move playing in reverse

Posted on 2009-05-07
5
294 Views
Last Modified: 2012-05-06
I have a basic but ok knowledge of Flash however cant seem to figure out this:

On Click of this myButton pay in reverse.
Can anyone help?
Cheers,
N
0
Comment
Question by:Neil_Bradley
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 3

Expert Comment

by:mharfouch
ID: 24333435
Add this to your main timeline;

//will stop 'play', 'gotoAndPlay' and 'rewind', 'gotoAndRewind' functions
MovieClip.prototype.stopAll = function () {
        delete this.onEnterFrame;
        this.stop();
}

//will stop 'rewind', 'gotoAndRewind' functions
MovieClip.prototype.stopRewind = function () {
        delete this.onEnterFrame;
}

//will play the timeline backwards and continal to loop until 'stopAll', 'stopRewind' or 'pause' are called
//note: the 'rewind' function will cancel the 'play' function BUT the 'play' function will not cancel the 'rewind' function
//you must call 'stopAll' or 'stopRewind' before using 'play' when your timeline is playing backwards
MovieClip.prototype.rewind = function () {
        this.stop();
        this.onEnterFrame = function () {
                if (this._currentframe > 0) {
                        this.prevFrame ();
                } else {
                        this.gotoAndStop (this._totalframes);
                }
        }
}

//will goto the specified frame and play the timeline backwards and continal to loop until 'stopAll', 'stopRewind' or 'pause' are called
MovieClip.prototype.gotoAndRewind = function (frame) {
        this.gotoAndStop (frame);
        this.rewind();
}

//will pause the timeline for the specified amount of time. will always play forwards when the pause has finished
MovieClip.prototype.pause = function (time) {
        delete this.onEnterFrame;
        secondsToPause = time;
        pauseInt = setInterval (this, "restart", secondsToPause * 1000);
}

restart = function () {
        clearInterval (pauseInt);
        play();
}




And then put this after your onClick function:
instancename.stopAll();
instancename.rewind();
0
 
LVL 5

Author Comment

by:Neil_Bradley
ID: 24340382
Thanks for your responce. I have put together a basic forward and reverse FLA file with your script running however I cant it working. Can you take a look and see where the issue is? I have uploaded the FLA file here http://www.beaconhilldesign.co.nz/experts_exchange/reverse.zip

N
0
 
LVL 3

Expert Comment

by:mharfouch
ID: 24343541
Can not open the file in CS4?

What did you use to make it?
0
 
LVL 5

Author Comment

by:Neil_Bradley
ID: 24345586
CS3, I will take another look it it today and see if fresh eyes helps. Did you use AS2 or 3 to write your script?
Cheers,
N
0
 
LVL 5

Accepted Solution

by:
Neil_Bradley earned 0 total points
ID: 24382449
I tried a few ways but could not get your solution to work. After a bit of reaserach I found this (see attached).
The script is dropped into the button works a treat.
Cheers,
N

var rewind:Boolean = false; 
btn_back.addEventListener(MouseEvent.CLICK, forward); 
btn_back.addEventListener(MouseEvent.CLICK, backwards); 
 
function forward(event:MouseEvent):void{ 
    rewind = false; 
    addEventListener(Event.ENTER_FRAME, eFrame); 
} 
 
function backwards(event:MouseEvent):void{ 
    rewind = true; 
    addEventListener(Event.ENTER_FRAME, eFrame); 
} 
 
function eFrame(e:Event):void{ 
    if(currentFrame <= 1 || currentFrame >= 60){ 
        //  limit movement between frame 1-60 
        removeEventListener(Event.ENTER_FRAME, eFrame); 
    } else { 
        //  move forward or back depending on rewind 
        (rewind) ? prevFrame() : nextFrame(); 
    } 
} 

Open in new window

0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are times in your Flash CS4 application when you want more than a simple pointer or a hand, and it's hard to find an ideal walk-through to tell you what to do.  I spent a few days recently learning my way around making custom cursors in Flash,…
Recently, I was asked to recommend a tracking system to be implemented on a clients website. As the entire site was built on flash, my first thought was to suggest custom built tracking system. However, our company at that point of time didn't h…
The goal of the tutorial is to teach the user how to how to load their YouTube profile onto Flash Media Live Encoder.
The goal of the tutorial is to teach the user how to select which audio input to use. Once you have an audio input plugged into the laptop or computer, you will go into the audio input settings and choose which audio input you want to use.

628 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question