?
Solved

Flash move playing in reverse

Posted on 2009-05-07
5
Medium Priority
?
295 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

This is a very simple example to help those of you who are still migrating from AS2 to AS3 understand the redesigned event model in AS3. In AS2.0, event functions (that is, the function to be performed when an event is fired) were stored as a pro…
I have been doing hardcore actionscripting for some time; and needless to say I have faced a lot of problems in just understanding others' code rather than understanding what the code executes. A programmer's life can become hell when there are a lo…
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 how to record live broadcast.

719 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