Groups | Blog | Home
all groups > flash actionscript > march 2006 >

flash actionscript : rewind frame by frame


bB_
3/4/2006 4:55:37 PM
i'm creating a situation on a website where if you click on a button it goes to
a certain scene and plays and animation. i want to add another button that
rewinds through the previous frames to create the illusion of a seamless
animation (ie. instead of just jumping back from frame 51 to 41....rewind from
51 to 41 - 51,50,49,48,etc..) is there a script i can use to do this?

help would be muhc appreciated!
kglad
3/4/2006 5:03:59 PM
the attached code adds a new method to movieclips, playF() that allows you to
play from frame m to frame n at fps frames per second. to use on movieclip mc1:

mc1.playF(m,n,fps);

MovieClip.prototype.playF = function(m, n, fps) {
function playF2(mc) {
if (mc.m<mc.n) {
mc.nextFrame();
} else {
mc.prevFrame();
}
if (mc._currentframe == mc.n) {
clearInterval(mc.int);
}
updateAfterEvent();
}
this.m = m;
this.n = n;
this.fps = fps;
this.gotoAndStop(this.m);
clearInterval(this.int);
this.int = setInterval(playF2, 1000/this.fps, this);
};
bB_
3/4/2006 5:24:26 PM
i need help with this..i'm trying to go from frame 60 - 1 in the movie clip
polkemmetgallery.swf at 30 fps. is this code correct as i am having errors with
it

MovieClip.prototype.playF = function(60, 1, 30) {
function playF2(polkemmetgallery.swf) {
if (polkemmetgallery.swf.60<polkemmetgallery.swf.1) {
polkemmetgallery.swf.nextFrame();
} else {
polkemmetgallery.swf.prevFrame();
}
if (polkemmetgallery.swf._currentframe == polkemmetgallery.swf.1) {
clearInterval(polkemmetgallery.swf.int);
}
updateAfterEvent();
}
this.60 = 60;
this.1 = 1;
this.30 = 30;
this.gotoAndStop(this.60);
clearInterval(this.int);
this.int = setInterval(playF2, 1000/this.30, this);
};
blemmo
3/4/2006 6:07:07 PM
Hi,
there's no need to change the method, leave it like it was posted by kglad.
You just have to call that method with the right parameters, e.g.:
on(release){
myMC.playF(60,1,30);
}

cheers,
blemmo
kglad
3/4/2006 6:09:50 PM
don't change anything in the attached code. just copy and paste that to the
first frame of your _root timeline so it's ready to use at any time.

now, polkemmetgallery.swf is not a movieclip. it's a swf file. if it's
loaded into a movieclip, you can reference it by using the target movieclip and
you can rewind the target movieclip. but i'm not sure that's what you're doing.

if you have a movieclip called polkemmetgallery that you want to rewind from
60 to 1 at 30 fps use:

polkemmetgallery.playF(60,1,30);
bB_
3/5/2006 12:00:00 AM
thanks for the help guys/girls. i think i understand. i may post here again for further help if i still have probs!!

bB_
3/5/2006 12:00:00 AM
ok........ im getting all muddled up.....i've created the button i want to
rewind a movie clip.....i copy and paste the code from kglad into the actions
panel for the button and change only the first line of code..am i right??
kglad
3/5/2006 3:25:41 PM
the only code you need to tailor to your needs is:

mc1.playF(m,n,fps);

bB_
3/5/2006 4:55:44 PM
kglad
3/5/2006 5:02:06 PM
bB_
3/5/2006 5:10:20 PM
kglad
3/5/2006 5:13:33 PM
yes, the first frame in the main or _root timeline in scene 1. (but it really
doesn't matter: that attached code just needs to execute before playF() is
executed so it can define the playF() method.)
bB_
3/5/2006 5:16:38 PM
thanks for all ur help & patience...this will definately save me a lot of work & time.

kglad
3/5/2006 5:19:08 PM
AddThis Social Bookmark Button