Forum Topic: Random flash script

(166 views • 8 replies)

This topic is 1 page long.

<< < > >>
None

Slimy-Slayer

Reply To Post Reply & Quote

Posted at: 1/12/06 12:24 PM

Slimy-Slayer EVIL LEVEL 10

Sign-Up: 06/20/05

Posts: 238

Can someone tell me the actionscript to do a random number and make a choice based on it

This is what im doing:

I'm making the Splash page of a website, and id like it to each time it loads, run a random and based on the random, go to the proper frame.

So does flash actionscript have a random function? i assume so..

and some sort of switch statement to make the choice so i can jump to the right frame.

I plan for 3 different splashes, im sure once i see the code i can figure out how to change it for more splashes.

Assistence anyone? im really bad at understanding flash tutorials so just the code to do it would be fine, a random number and a switch statement to figure out the number and go to the correct frame.


None

Slimy-Slayer

Reply To Post Reply & Quote

Posted at: 1/12/06 12:39 PM

Slimy-Slayer EVIL LEVEL 10

Sign-Up: 06/20/05

Posts: 238

I need help so im bumping this topic


None

Rantzien

Reply To Post Reply & Quote

Posted at: 1/12/06 12:43 PM

Rantzien FAB LEVEL 15

Sign-Up: 01/27/05

Posts: 3,422

Math.random () is the function you want. It returns the number n, where 0 <= n < 1.

Multiply it and round it for your wanted range.

For example, Math.floor (Math.random () * 2) returns either 0 or 1.

AS: Random by -Reedo11-
AS: Random - More by Spamburger

BBS Signature

None

jmtb02

Reply To Post Reply & Quote

Posted at: 1/12/06 12:45 PM

jmtb02 LIGHT LEVEL 29

Sign-Up: 03/01/04

Posts: 5,527

Put this on the frame you want to have random code...

num = random(3);
//insert your number here, will be rand from 0 and your number-1
switch (num) {
case 0 :
//do something
break;
case 1 :
//do something else
break;
case 2 :
//do something
break;
}

That help?

NOM NOM NOM NOM NOM

BBS Signature

None

Slimy-Slayer

Reply To Post Reply & Quote

Posted at: 1/12/06 12:46 PM

Slimy-Slayer EVIL LEVEL 10

Sign-Up: 06/20/05

Posts: 238

At 1/12/06 12:45 PM, jmtb02 wrote: Put this on the frame you want to have random code...

num = random(3);
//insert your number here, will be rand from 0 and your number-1
switch (num) {
case 0 :
//do something
break;
case 1 :
//do something else
break;
case 2 :
//do something
break;
}

That help?

thankyou very much


None

Rantzien

Reply To Post Reply & Quote

Posted at: 1/12/06 12:53 PM

Rantzien FAB LEVEL 15

Sign-Up: 01/27/05

Posts: 3,422

At 1/12/06 12:45 PM, jmtb02 wrote: Put this on the frame you want to have random code...

I advice not to teach people about random () anymore. Keep using it yourself if you wish, but random () is fully removed in AS 3.0, so when people are learning they might as well get updated information immediately.

BBS Signature

None

jmtb02

Reply To Post Reply & Quote

Posted at: 1/12/06 12:58 PM

jmtb02 LIGHT LEVEL 29

Sign-Up: 03/01/04

Posts: 5,527

At 1/12/06 12:53 PM, Rantzien wrote:
At 1/12/06 12:45 PM, jmtb02 wrote: Put this on the frame you want to have random code...
I advice not to teach people about random () anymore. Keep using it yourself if you wish, but random () is fully removed in AS 3.0, so when people are learning they might as well get updated information immediately.

Really? I didn't know that! So I assume they are sticking to the Math. class of functions?

NOM NOM NOM NOM NOM

BBS Signature

None

Rantzien

Reply To Post Reply & Quote

Posted at: 1/12/06 01:01 PM

Rantzien FAB LEVEL 15

Sign-Up: 01/27/05

Posts: 3,422

At 1/12/06 12:58 PM, jmtb02 wrote: Really? I didn't know that! So I assume they are sticking to the Math. class of functions?

Yeah. If you want to know more about what's changing, here's Macromedia's migration list. I don't know if it covers everything that will change, but it covers a whole deal =)

BBS Signature

None

Inglor

Reply To Post Reply & Quote

Posted at: 1/12/06 01:03 PM

Inglor NEUTRAL LEVEL 17

Sign-Up: 01/26/03

Posts: 10,957

At 1/12/06 12:58 PM, jmtb02 wrote: Really? I didn't know that! So I assume they are sticking to the Math. class of functions?

Macromedia Blaze AS Dictionary 0.02 (Alpha)

random() - Status : Removed. Use Math.random() instead.

flex documentation is similar

then again a lot of others are removed as well

duplicateMovieClip
attachMovie
removeMovieClip
_quality
_url
setTransform()
getTransform()
toString()
_target
attachBitmap()
getURL()

the list is long :D


All times are Eastern Standard Time (GMT -5) | Current Time: 12:33 PM

<< Back

This topic is 1 page long.

<< < > >>
You need a Grounds Gold Account to post on the NG BBS! If you don't have one, click here to sign up now! It's fast, free, and easy — and opens up tons of great NG features!