Forum Topic: Action-script question.

(161 views • 5 replies)

This topic is 1 page long.

<< < > >>
Shouting

Jack-Mace

Reply To Post Reply & Quote

Posted at: 8/20/06 04:21 AM

Jack-Mace NEUTRAL LEVEL 29

Sign-Up: 04/13/04

Posts: 34

Hello

I'm in need of a script for my new project.
There is a part when i want my movie to go randomly to 1 of 4 scenes.
Sinds scripting confuses me, i don know what to do. :(

Jack_Mace

P.S. ( yes, its a worm parodie, and i realy need this script for a weapon i developt )


None

Rock-Dido-God

Reply To Post Reply & Quote

Posted at: 8/20/06 04:26 AM

Rock-Dido-God NEUTRAL LEVEL 07

Sign-Up: 03/15/06

Posts: 515

if you hit the gun and it goes random it would be this
onClipEvent (enterFrame) {
if (this.hitTest(_root.worm)) {
Math.random()4;
}
Put it in the gun mc


None

edit-undo

Reply To Post Reply & Quote

Posted at: 8/20/06 04:27 AM

edit-undo LIGHT LEVEL 18

Sign-Up: 01/17/06

Posts: 1,759

onClipEvent(enterFrame)[
number = math.round(random(4));
if(number == 1)[
gotoAndPlay("scene 1",1);
]
if(number == 2)[
gotoAndPlay("scene 2",1);
]

and so on and so forth...
sorry, but this gay spanish keyboard doesnt have the squiggly brackets so you´ll have to replace that square brackets before it will work. hope it helps.

lolsigtrend
i just wanna fit in :'(

BBS Signature

None

ImpotentBoy2

Reply To Post Reply & Quote

Posted at: 8/20/06 09:26 AM

ImpotentBoy2 LIGHT LEVEL 18

Sign-Up: 04/01/03

Posts: 5,039

At 8/20/06 04:27 AM, cool_dood_3000 wrote: onClipEvent(enterFrame)[
number = math.round(random(4));
if(number == 1)[
gotoAndPlay("scene 1",1);
]
if(number == 2)[
gotoAndPlay("scene 2",1);
]

accually yo could just do

onClipEvent(enterFrame){
number = math.round(random(4));
gotoAndPlay("scene" + number,1);
}


None

Fat-Lifeguard

Reply To Post Reply & Quote

Posted at: 8/20/06 10:52 AM

Fat-Lifeguard EVIL LEVEL 16

Sign-Up: 07/23/06

Posts: 278

The probelm with the above is that you would have to name each scene "scene1" or "scene2" and so forth. This is definitely a switch situation.

switch (Math.ceil(Math.random() * THE NUMBER OF SCENES YOU HAVE)) {
case 1:
gotoAndPlay("scenename",1);
break;
case 2:
gotoAndPlay("otherscene",1);
break;
case 3:
gotoAndPlay("goodscene",1);
break;
case 4:
gotoAndPlay("lastscene",1);
break;
//Keep inserting case statements just like the ones above until you reach the number of scenes you have, then finish with a close bracket.
}


None

Jack-Mace

Reply To Post Reply & Quote

Posted at: 9/2/06 06:58 AM

Jack-Mace NEUTRAL LEVEL 29

Sign-Up: 04/13/04

Posts: 34

I tested it.. it worked the best... THANKS ALLOT.. you realy helped me out


All times are Eastern Standard Time (GMT -5) | Current Time: 09:21 AM

<< 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!