 |
 |
pause flash movie for random amount of time?
|
 |
|
 |
|
Senior User
Join Date: Mar 2002
Location: Chicago, IL
Status:
Offline
|
|
I have a simple ten frame animation of an eye blinking that I want to have loop after random interals of time. Any ideas how this could be done? I'm fairly new to flash and haven't learned much action script yet.
|
We need less Democrats and Republicans, and more people that think for themselves.
infinite expanse
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Mar 2002
Location: Clogland
Status:
Offline
|
|
Probably many ways to do this, here's what I'd do......
Create a loop where nothing happens, on the first frame generate a random variable.....
RandomVariable = Math.floor(Math.random( ) * 10);
......will give you a number between 1 and 10
Then do something like......
if (RandomVariable == 3){
gotoAndPlay("wink");
}
.............."wink" being the number or label of the frame that's starts the wink loop, return to the first frame of the nothing happens loop.
Edit: forgot the "floor" command, that turns the random number into an integer.
|
|
|
| |
|
|
|
 |
|
 |
|
Senior User
Join Date: Mar 2002
Location: Chicago, IL
Status:
Offline
|
|
Thanks a lot.
I was reading up on ways to do this and several sources said not to use if or while loops because they can gobble cpu cycles and render the computer viewing the movie very slow.
Any facts behind this?
|
We need less Democrats and Republicans, and more people that think for themselves.
infinite expanse
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Mar 2002
Location: Clogland
Status:
Offline
|
|
if and while loops will use the processor I guess ( I'm a bit of a luddite when it comes to how things tick), but in any of your reading did they mention an alternative?
Maybe you could post the urls of what you read, I'd be interested.
|
|
|
| |
|
|
|
 |
|
 |
|
Senior User
Join Date: Mar 2002
Location: Chicago, IL
Status:
Offline
|
|
Nevermind, I got a little mixed up. I guess what is a bad idea is to just have a logic loop that checks the value of a variable constantly, such as by using an infinite loop that is only exited by a conditional statement.
The solution above, however, only test the variable once in a while, most of the time is spent playing an empty loop, so I'm guessing that this is fine.
Thanks for the help, skalie. If you want to see what I've done so far you can check it out here:
eo
|
We need less Democrats and Republicans, and more people that think for themselves.
infinite expanse
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |
|