Solved

Flash move playing in reverse

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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
YouTube Link 10 370
Failed download 57 591
Where to download Acrobat flash offline installer? 2 268
Adobe Flash Player won't run in IE or Firefox but will in Chrome 20 345
In my long career of working as an actionscript developer, I had spent sleepless night often working hard to solve some small problems which actually took a lot of my development time; later found out the solutions to be a line or two. Here are s…
While working over numerous projects I often had the requirement for doing a screen capture in AS3.0. Unfortunately I found no "ready made" solutions in google search that suited my requirements. But I did come across some great resources which help…
The goal of the tutorial is to teach the user how to live broadcast using Flash Media Live Encoder and connecting it to YouTube to broadcast. Log into your Youtube account, choose live stream settings, start live stream from Flash Media Live Enc…
The goal of the tutorial is to teach the user how to select the video input device. Make sure you have an input device that in connected and work and recognized by Adobe Flash Media Live Encoder and select it in the “video input” menu.

733 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