PDA

View Full Version : simple actionscript command? pls help...


chal7ds
11-23-2004, 05:39 AM
Hey All,

Ok, bear with me, I'm new here to the flash thing.

Okay, I have a scene where it gets to a certain frame (frame 73 in this case)..and it starts a animation at this frame that is a nice little repetitive animation that lasts until frame 88. Now, on frame 88, I put in an actionscript (on the frame, not on a mc or button) that says to go back to frame 73 (gotoandplay(73);) which is fine...but here's what i really want it to do...

..when it gets to frame 88 for the FIRST TIME in the movie, i'd like the actionscript to somehow tell flash to go through a revolution of frame 73 to frame 88 FIVE times...and then when the playhead hits frame 88 for the fifth time..i'd like the actionscript to somehow re-direct the playhead to frame 93.

Is this possible? It would seem like a better option, than just adding 5 times the amount of frames and then entering into 93 after all those created frames! alotto memory, in my opinion. if i could somehow add the code i mentioned above, i could save a lot of added frames.

Okay..any help on this kind've script, pls let me know! :)

thanx,
chal7ds
chal7ds@yahoo.com :D

GarbageKing
11-23-2004, 06:13 AM
Hi, I am a newbie too. Okay, here is my solution:
first I declare a variable in frame 1 of _root:
var times = 1;
then in the frame 88 I put:
times++;
if (times<=5) {
_root.gotoAndPlay(73);
} else {
_root.gotoAndPlay(93);
}
that's all. Anyway if I didn't turn the loop off the second time the movie playback it runs from frame 1 to the last frame, don't know why. I solved it by added a "stop()" in the last frame of the movie.
hmm, hope it helps. cheers.

skjc
11-23-2004, 08:17 AM
hi again.

I would be tempted to put the animation into an mc and call it from frame 73. As far as running it 5 times is concerned then you can put it in a simple loop in frame 73 which means you retain a good control of the movie.

One other tip is to label the important frames especially when you have quite a number of them. Create a new layer in the main timeline called "label" and label the frames so instead of gotoAndPlay (73) you have gotoAndPlay (framelabel).

If you start looping through the frames and you want to include more frames etc. it can get a bit tiresome changing your variables, statements and re-testing all of the time.

chal7ds
11-23-2004, 11:53 PM
hey garbageking,

your code didn't work for me. maybe i'm doing it wrong. When you say _root: what does that mean? 1st frame of the scene, first frame of the entire movie? and is the first frame at the far upper left of the timeline?


Here's what i put in the first frame of the scene in question:
var times = 1;

and here's what i put in frame 88:
times++;
if (times<=5) {
_root.gotoAndPlay(73);
} else {
_root.gotoAndPlay(93);
}

and then i put a stop(); in the very last frame of the scene in question.

...but it didn't loop...

chal7ds
chal7ds@yahoo.com