Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > pause flash movie for random amount of time?

pause flash movie for random amount of time?
Thread Tools
Senior User
Join Date: Mar 2002
Location: Chicago, IL
Status: Offline
Reply With Quote
Nov 13, 2002, 03:01 AM
 
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
Reply With Quote
Nov 13, 2002, 04:20 AM
 
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.
     
york28  (op)
Senior User
Join Date: Mar 2002
Location: Chicago, IL
Status: Offline
Reply With Quote
Nov 13, 2002, 10:34 AM
 
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
Reply With Quote
Nov 13, 2002, 10:59 AM
 
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.
     
york28  (op)
Senior User
Join Date: Mar 2002
Location: Chicago, IL
Status: Offline
Reply With Quote
Nov 13, 2002, 11:57 AM
 
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
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 06:20 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2