| Ultrashock Forums
• AS2 - Random Display |
|||
![]() |
||||
| Search this Thread | Thread Tools | Display Modes |
|
|
|||||||||||||||||||||||||
![]() |
Ultrashock Member Comments:
|
2008-02-19
#2 |
||
|
|
2008-02-19
#3 |
||
|
It worked! Thanks for pointing me in the right direction! I ended up creating a 5-frame .swf. In the first fram I put this code... Code: function randRange(min:Number, max:Number):Number { var randomNum:Number = Math.floor(Math.random() * (max - min + 1)) + min; return randomNum; } for (var i = 0; i < 4; i++) { var n:Number = randRange(1, 4) } gotoAndPlay("anim"+randRange(1,4)); In frames 2 through 5, I named them anim1 through anim4, and I did a loadMovie of each of the four animations. Works great. Thanks again for your help. -e |
|
|
2008-02-20
#4 |
||
|
Check this out. Now that I have a proof of this posted on our FTP server, it's not evenly distributing the four animations. In fact, it appears Firefox plays only three of them, and Explorer plays only three of them (but not the same three as Firefox). I'm completely baffled. Has anyone else run in to this problem or have any idea why it's not generating a truely random selection? Thanks!
|
|
|
|
2008-02-20
#5 |
||
|
I've done this pretty successfully a few times using random swfs. That way only one swf loads - one site is www.rawhideco.com. If you want the code get back to me. regards, David.
|
|
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|


4 comments
| 1312 views



Linear Mode
But if you do put them all on the same timeline, you could use labels.... make lables like anim1, anim2, anim3, anim4
/*--- Taken from Flash Help Doc's ---*/ function randRange(min:Number, max:Number):Number { var randomNum:Number = Math.floor(Math.random() * (max - min + 1)) + min; return randomNum; } gotoAndPlay("anim"+randRange(1,4));Or if you want to load seperate .swf's
/*--- Taken from Flash Help Doc's ---*/ function randRange(min:Number, max:Number):Number { var randomNum:Number = Math.floor(Math.random() * (max - min + 1)) + min; return randomNum; } loadMovie("anim"+randRange(1,4)+".swf");