-
New To Action Script - Random # generator
So I am new to flash and totally confusing php syntax and other syntax when trying to join together variables with static strings.
Here is my code below.
var ranimage = "images/good";
var rannumimage = ranimage + [Math.floor(Math.random() * 3) + 1] + ".gif";
loadMovie(rannumimage, luck);
Pretty much this is what I want to happen....
runnuimage should create
images/good1.gif
images/good2.gif
images/good3.gif
Am I on the correct path?
-
Ok so I kind of got it.
var i:Number = Math.floor(Math.random() * 3) + 1;
var mcname:String = "images/good" + i + ".gif";
This works when I trace it.... But now I am loading this into my movie.... I will tell you guys if I have any other issues!
Thanks
-
Senior Member
yes you are..
this what you';d get:
var ranimage = "images/good";
var rannumimage = ranimage + [Math.floor(Math.random() * 3) + 1] + ".gif";
trace(rannumimage); //ie: images/good2.gif
now it will NOT load those images in the order you posted.. (as you have it randomly getting the image name)..
you will also have duplicates possibly..
I suggest getting used to using TRACE() actions..so you can follow your code..
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
|