Groups | Blog | Home
all groups > flash actionscript > august 2005 >

flash actionscript : won't stop playing


DrEv1l
8/20/2005 9:28:14 PM
var teller
this.onEnterFrame = function(){
teller = teller +1
if(teller == 10){
teller = 0
stop()
}}
this is a piece of code in _parent.kop_mc
on the 3rd frame I put this code so it will repeat the 3 frames until teller =
10 then it should stop and put teller back on 0.
It does this once. But the second time it should repeat 10 times it doesn't
repeat as much. it only does it very shortly. like 3 times or so
I can't seem to get my head around why he does that
kglad
8/20/2005 9:34:30 PM
DrEv1l
8/20/2005 9:36:10 PM
in my root there is a button and when I click on it I wont to go in the
movieclip kop_mc
and play a 3frame timeline. after he's played does 3 frames 10 times I want
him to go back to the root. but he also won't do that
kglad
8/20/2005 9:43:49 PM
there is no such thing as "going from one timeline to another". the flash
playhead plays any and all timelines when it's instructed to do so. it's
common to play many timelines simultaneously.

if you want to stop() the _root timeline while allowing kop_mc to play() its 3
frames 10 times and then instruct kop_mc to stop() and _root to play(),
attached to your _root timeline try:

yourBtn.onPress=function(){ // where yourBtn is your button
_root.stop();
_root.kop_mc.teller=0;
_root.kop_mc.onEnterFrame=function(){
if(this.teller==10){
delete this.onEnterFrame;
_root.play();
}
}

and on frame 3 of _root.kop_mc, attach

teller++;
digital_monkey
8/20/2005 9:53:44 PM
Hi,

kglad has a point. But the code is salvageable.

I assume if your code is already working one time round that you have
somewhere defined teller to be 0, otherwise I can't see how it would even work
the first time, as you havent even set teller at 0 to start with. Anyway, let's
assume that the teller variable isn't the problem.

The onEnterFrame event handler executes whether the clip is playing or not.
You can see this by placing a ' trace(teller) ' statement into your function
and playing the movie. See how even after the clip has stopped playing, we
still get output? So even though you tell the clip to stop() (ie, stop playing
the 3 frames), the onClipEvent handler is still called at regular intervals
(the frame rate of the movie).

What you want to do is stop the movie AND stop the onEnterFrame from invoking.

Inside your if statement, after "stop()", put:

delete this.onEnterFrame

This will delete the event handler and stop it from executing, but if you come
round to frame 3 again the onEnterFrame event handler should start up again
from scratch.

Hope that helps.
DrEv1l
8/20/2005 10:02:16 PM
it doesn't work. When I hit the button nothing happens. But i see in the code that there is nowhere to start the 3 frames playing
DrEv1l
8/20/2005 10:06:54 PM
thx guys its working. I just had to put the delete this.onEnterFrame in
kglad
8/21/2005 10:56:03 PM
AddThis Social Bookmark Button