-
Hi,
I would like to loop a movie twice. How should I write the script?
I add an action to the last frame of the movie, a ball jumping for example which has one layer only. Below are the codes I wrote:
Set Variable:"index" = "1"
If (index < 3)
Go to and Play (1)
Set Variable:"index" = "index + 1"
End If
The above codes seems to cause the movie to loop infinitely. How should I loop a movie twice? And how should I loop a movie that has a lot of layers?
Thanks for your help.
-
The Supreme Shaman and Keeper of Polar Lights
Hi !
Just say in last keyframe
If (something=1)
Stop
Else
Set Variable: "something" = "1"
End If
------------------
Good luck !
Ilya. -Polar Lights Studios-
Flash sources page
-
<BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by Ilya:
Hi !
Just say in last keyframe
If (something=1)
Stop
Else
Set Variable: "something" = "1"
End If
<HR></BLOCKQUOTE>
==============================
Thanks Ilya. It works.
However, why when it is replayed, it won't loop twice?
-
The Supreme Shaman and Keeper of Polar Lights
Hi !
Before replaying try say
Set Variable: "something" = "0"
------------------
Good luck !
Ilya. -Polar Lights Studios-
Flash sources page
-
Hi Ilya,
I have tried putting this line:
Set Variable:"something" = "0"
before the if..else statements. But this will cause the movie to loop infinitely.
What could be wrong?
-
Set Variable:"index" = "1"
If (index < 3)
Go to and Play (1)
Set Variable:"index" = "index + 1"
End If
You need to remove some quotes:
Set Variable:"index" = 1
If (index < 3)
Go to and Play (1)
Set Variable:"index" = index + 1
End If
Try That...
DD
-
your problem is;
Set Variable:"index" = "1"
every time it get to the frame it resets "index" to 1 so it will never be 3
you don't need;
Set Variable:"index" = "1"
has it will assume that it is zero
you just need
if (index < 2)
Go to and Play (1)
Set Variable:"index" = "index + 1"
End If
This should work
CheerZ
rosie
-
Didnt see that problem with setting index to 1 every loop. That's a problem too.
Good luck in fixing it
DD
-
I recommend incrementing your index before your go to and play...better coding practice, plus I'm not sure how flash interprets commands after a Goto statment..
if (index < 2)
Set Variable:"index" = "index + 1"
Go to and Play (1)
End If
-
The Supreme Shaman and Keeper of Polar Lights
-
Hi all,
Thanks for your help. It still loops infinitely.
The following code works but it will not loop when it is replayed:
If(index = 1)
stop
Else
Set Variable:"index" = "1"
End If
So the following statement is added before the if...else statement:
Set Variable:"index" = "0"
But this cause the infinite loop again.
I think the reason is because....
when the index is first set to 0, it will enter the else loop, so index will become 1 and come out of the loop. Then it will start from the begining of the coding again. And the index is set to 0 again and went into the else loop again.
This will cause it to loop infinitely.
So I tried to search Flash Help whether it has while loop. I think it doesn't, only have Loop While(). So I tried the following:
Set Variable:"index" = "0"
Loop While(index < 2)
If(index = 1)
stop
Else
Set Variable:"index" = "1"
End If
End Loop
However, this doesn't help too. Anyway, my assignment is done. Just want to know why it cannot loop twice when it is replayed.
Thanks a lot. If you have a better way to loop a movie, do let me know.
-
I assume when you say "loop a movie twice", what you want is to play your movie 2 times and stop it. Following that theory:
Last frame of movie:
If (count < 1)...(or N)
Set Variable: "count" = count + 1
Go to and Play(1)
Else
Stop
End If
Where "count" will always = (boolean)0 if it hasn't been initialized, as in the first play of the movie. This makes the movie into a 2 frame loop...another way to loop instead of using "Loop While"...you can also control the speed of the loop by adding frames between the keyframes.
For frame 1's initializing of "count" = 1 (or more):
Frame 1:
Set Variable: "count" = 1 (or n)
Frame 2:
No actions
Frame 3
If (count < N)
Set Variable: "count" = count + 1
Go to and Play(2)
Else
Stop
End If
------------------
Count ends at N, movie stops.
------------------
Wright Internet Solutions
productions@wisolutions.london.on.ca
DickeeDive: Your Stringed Instruments Connection
[This message has been edited by Dickee (edited 28 April 2000).]
-
Make the 1rst and 2nd frames of your movie identical.
Use the loop code that was working for you without reseting the variable to 0 at the beginning.
Except have the go to pointing at frame 2.
have variable = 0
at frame 1
then a go to a play frame 3
(so that you don't play the duplicate frame in 2)
Hope this works for you.
-
Guys, allways use initialisiton frames, and whole bunch of such problems simply go away.
Just use some dummy keyframes before *real* start to setup global vars (vars that should be static) and youre done. In the example above do:
1st dummy keyframe - Set Variable "z" = 1
(movie starts at 2nd - label "Start")
last keyframe - If (z=2)
Stop
Else
Set variable "z" = z + 1
Go to and Play (Start)
EndIf
It will loop exactly twice.
Best,
Igor
-
Best solution
Answer of all answers
===============
Create a new layer in your flash file, name it Actionscript. On the first frame of the movie on the actionscript layer, insert this :
_global.z = 0;
Now, move the rest of your movie layers (not actionscript layer) so that there is nothing else on frame 1 besides the actionscript layer.
Now, make a new keyframe one frame after the last frame of your movie on the actionscript layer. Insert this code :
if (_global.z == 3)
{
stop();
}
else
{
_global.z = _global.z + 1;
gotoAndPlay(2);
}
You can change 3 to be however many times you want the movie to loop. That's all.
-
Flashmatics
Just put this in the last frame of you movie..u dont need to do anything else:
Code:
var noOfLoops = 2;
if (loop == undefined) {
loop = 1;
} else {
loop++;
if (loop == noOfLoops) {
stop();
}
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|