Link to home
Start Free TrialLog in
Avatar of dryad
dryad

asked on

play backward in flash

i would like to get a flash script to play backward a movie click. the script should work as "when mouse within right part of the movie, movie play forward; when mouse within left part of the movie, play backward; when mouse out of the movie, pause."
if anybody know how to do it, please help.
Avatar of henryww
henryww

depends on how ur movieclip is arranged, if u have the origin in the middle (ie 0,0 ) there it will be very easy with the calculation

the sample code is for MX

eg. the movieclip instance name is myClip, and the origin (0,0) is in the middle of the movieclip, ie: left & right has the same lenght

// very simple function
myClip.onEnterFrame = function () {
if ( myClip._xmouse  > 0 ) {
myClip.gotoAndPlay(nextFrame);
} else {
myClip.gotoAndPlay(prevFrame);
}
}

// a bit better ... only play on the edges but stop when the mouse is in the middle
// again center is the origin
myClip.onEnterFrame = function () {
if ( myClip._xmouse  > (myClip._width)/2 ) {
myClip.gotoAndPlay(nextFrame);
} else if ( myClip._xmouse  < (-myClip._width)/2 ) {
myClip.gotoAndPlay(prevFrame);
}
}

see if that helps

cheers
sorry ... missed the "()" for prevFrame() and nextFrame()
first make a 'hotspot' button
go..insert>new symbol>button
put a keyframe (F7) in the Hit frame..
draw a square in that keyframe..(fairly small..say 100x100)
drag and drop 2 instances of the button to the stage and
rezize and position them one on the left side of the movie
one on the right.
put another one on the bottom layer( this is the one around the movie that will pause it)....the same size as
your stage..use the info panel to size it..you will see turquoise coloured shapes on the stage to help
you with this..you can't see them when the movie runs.

on the left hotspot put the code..

on (rollOver) {
     _root.direction = "reverse";
}
on (rollOut) {
     _root.direction = "";
}

on the right hotspot..

on (rollOver) {
     this.play();
}

on the background one..

on (rollOver) {
  this.stop();
}

back to the main timeline..
drop an instance of the movie on the stage..

with the movie selected put the code..

onClipEvent (enterFrame) {
    if (_root.direction == "reverse"){
        gotoAndStop (this._currentframe - 1);
    }
}

that's it..
download a .fla if you need more help (MX)
www.redpearl.co.nz/misc/reverse_movie.zip

Z

 

Avatar of rascalpants
dryad,

I think all you need to do is make a movieclip move back and forth right?  you don't need to play your actual movie frames in reverse...

if you are just trying to have a movieclip scroll left and right, then you can take a look at the example I made for you...

http://www.rascalpants.com/h_scroller.fla


let me know if you need more help...

rp
cool guys ...

that's right, my code doesn't work if the movieclip is not solid and the _width is not right ...

well, i have this one see if that's ok :)
http://www.smartclever.net/example/flash/backforth/backforth.swf
http://www.smartclever.net/example/flash/backforth/backforth.fla

cheers
very svelte henry:)

Z
he he he ....  thanks ... i am not a fat boy in real life :)

cheers
Avatar of dryad

ASKER

thanks for all of you. i still have a small problem. in all the example you gave me, the animation only play once. how can i get the animation looping?
ASKER CERTIFIED SOLUTION
Avatar of henryww
henryww

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
what do you mean by looping?  do you want the animation to start from the beginning again?


rp
Avatar of dryad

ASKER

lot of thanks for all of you. i will have a look the new example.

rascalpants: you are right,that is what i mean.

henrywww:i just had a look your example, backforth2.swf. why does the movie stop when the mouse enter the middle part of the white box?