shuga
September 1, 2004, 4:41pm
1
i’m trying to figure out how to create a script that will perform a stop(); after the frame has been hit 3 times
so i think i need to set a variable and add 1 to it each time the frame is hit until it gets to 3 and then when it hits 3 stop();
so would it look like this?
i=0
onEnterFrame{
if (i>=3){
stop();
}else{
i+=1;
}
}
system
September 1, 2004, 4:44pm
2
Looks good to me. What happens when you try it? :beam:
system
September 1, 2004, 4:46pm
3
This is the error it produces when I put the code on the frame where I want the animation to stop
Symbol=image anim, Layer=stop script, Frame=465: Line 2: ‘;’ expected
onEnterFrame{
system
September 1, 2004, 5:08pm
4
I think you are missing a {
i=0
onEnterFrame{
if (i>=3){
stop();
}else{
i+=1;
}
**}** //<-- add this to the bottom
system
September 1, 2004, 6:45pm
5
i see no difference between the code you posted and the code i posted except you bolded one of the curly brackets and told me to put it at the bottom … but it’s already there … i’m confused
system
September 1, 2004, 6:50pm
6
this is what i have now and it works … sorta … well it doesn’t throw up an error
i = 0;
onEnterFrame = function () {
if (i>=3) {
stop();
} else {
i += 1;
}
};
what it does do is stop after it’s gone through the animation 1.25 times … basically it goes through it once and then starts going through again and stops … not even on the frame where the action is.
it’s like the action starts and then every frame it increments ‘i’ and stops after 3 frames b/c i = 3
system
September 1, 2004, 9:43pm
7
shuga:
this is what i have now and it works … sorta … well it doesn’t throw up an error
i = 0;
onEnterFrame = function () {
if (i>=3) {
stop();
} else {
i += 1;
}
};
what it does do is stop after it’s gone through the animation 1.25 times … basically it goes through it once and then starts going through again and stops … not even on the frame where the action is.
it’s like the action starts and then every frame it increments ‘i’ and stops after 3 frames b/c i = 3
if your animation is looping on its own, just type this in the first frame (of the animation)
i == undefined ? i=0 : i++;
i == 3 ? stop() : play();
EDIT/
if you want it to stop in the last frame, type this in the last frame
i == undefined ? i=0 : i++;
i == 2 ? stop() : play();
system
September 1, 2004, 9:58pm
8
oops, sorry - I meant to add another bracket at the end but I was in a rush. Did stringy’s code work?
:hr:
system
September 1, 2004, 11:44pm
9
it did work … thank you so much stringy
that code looks really condensed … if you have a free moment, an explanation of what you typed would be so helpful in my studies
thank you again
system
September 1, 2004, 11:51pm
10
if I understand it correctly the ‘if’ is implied (due to the other symbols), the ? stands for ‘then’ and the ‘:’ stands for ‘else’.
iow:
i == undefined ? i=0 : i++;
i == 3 ? stop() : play();
is equivalent to
if(i == undefined){
i=0;
}
else {
i++;
}
if(i == 3){
stop();
}
else {
play();
}
:hr:
system
September 2, 2004, 1:03am
12
[homer voice] WOO HOO!! [/homer voice]
:beam: