Solved

Flash move playing in reverse

Posted on 2009-05-07
5
288 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
  • 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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

This is intended to introduce all collision detection principles in flash, their strengths, weaknesses and workarounds. The main method for Collision Detection in flash is using hitTestObject. But unless you'll be pushing rectangular shapes without …
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 set there setting in Adobe Flash Media Live Encoder and YouTube for optimal video and audio quality.
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.

762 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now