Forum Topic: Random Gotoandplay

(558 views • 36 replies)

This topic is 2 pages long. [ 1 | 2 ]

<< < > >>
None

aso-products

Reply To Post Reply & Quote

Posted at: 8/26/06 05:17 AM

aso-products NEUTRAL LEVEL 05

Sign-Up: 07/07/06

Posts: 74

Okay, the normal script with the frame numbers.
Do i already know.
But i prefer to use frame labels instead of frame numbers.
So could someone just give me the code with the example labels:
frame1, frame2, frame3, and frame4.
O i don't need the explaination, i get used to it myself.


None

AngryFaic

Reply To Post Reply & Quote

Posted at: 8/26/06 05:21 AM

AngryFaic NEUTRAL LEVEL 07

Sign-Up: 06/26/06

Posts: 790

Excuse me?

Random Gotoandplay


None

aso-products

Reply To Post Reply & Quote

Posted at: 8/26/06 05:23 AM

aso-products NEUTRAL LEVEL 05

Sign-Up: 07/07/06

Posts: 74

Shut up asshole.
All the words i said are English, and not your fuckin nerd language.


None

AngryFaic

Reply To Post Reply & Quote

Posted at: 8/26/06 05:28 AM

AngryFaic NEUTRAL LEVEL 07

Sign-Up: 06/26/06

Posts: 790

Okay, the normal script with the frame numbers I already know, but I prefer to use frame labels instead of numbers. Could someone just give me a code with the example labels:

frame1, frame1, frame1 and frame1.

Oh, I don't need the explanation, I get used to it, myself.

That's English.

I don't understand what you need.


None

AngryFaic

Reply To Post Reply & Quote

Posted at: 8/26/06 05:30 AM

AngryFaic NEUTRAL LEVEL 07

Sign-Up: 06/26/06

Posts: 790

At 8/26/06 05:28 AM, TechnoTrepidity wrote: frame1, frame1, frame1 and frame1.

And yes, I fail at copy and paste.

frame1, frame2, frame3 and frame4. Fixed!

None

Toast

Reply To Post Reply & Quote

Posted at: 8/26/06 05:31 AM

Toast DARK LEVEL 09

Sign-Up: 04/02/05

Posts: 8,414

var myFrames:Array = ['frame1','frame2','frame3','frame4'];
frame = random(4);
this.gotoAndStop(myFrames[frame]);

Should work :)

I put on my robe and wizard hat

Why don't you check out my check out my userpage?

BBS Signature

None

Cybex

Reply To Post Reply & Quote

Posted at: 8/26/06 05:32 AM

Cybex NEUTRAL LEVEL 20

Sign-Up: 03/04/05

Posts: 7,744

instead of doing gotoAndPlay(1);
do gotoAndPlay("poopoo");
(Thats assuming your frame is labelled poopoo).


None

Cybex

Reply To Post Reply & Quote

Posted at: 8/26/06 05:33 AM

Cybex NEUTRAL LEVEL 20

Sign-Up: 03/04/05

Posts: 7,744

At 8/26/06 05:32 AM, Cybex wrote: instead of doing gotoAndPlay(1);
do gotoAndPlay("poopoo");
(Thats assuming your frame is labelled poopoo).

Ohhhh RANDOM gotoAndPlay. Sorry.


None

Toast

Reply To Post Reply & Quote

Posted at: 8/26/06 05:35 AM

Toast DARK LEVEL 09

Sign-Up: 04/02/05

Posts: 8,414

At 8/26/06 05:32 AM, Cybex wrote: (Thats assuming your frame is labelled poopoo).

Lol @ puzz.

*shuts up*

I put on my robe and wizard hat

Why don't you check out my check out my userpage?

BBS Signature

None

Go0gley

Reply To Post Reply & Quote

Posted at: 8/26/06 05:41 AM

Go0gley LIGHT LEVEL 19

Sign-Up: 07/08/04

Posts: 218

At 8/26/06 05:28 AM, TechnoTrepidity wrote: Okay, the normal script with the frame numbers I already know, but I prefer to use frame labels instead of numbers. Could someone just give me a code with the example labels:

frame1, frame1, frame1 and frame1.

Oh, I don't need the explanation, I get used to it, myself.

That's English.

I don't understand what you need.

What's wrong with that? I understood it totally.

gotoAndPlay("frame"+(random(4)+1));


None

Toast

Reply To Post Reply & Quote

Posted at: 8/26/06 05:46 AM

Toast DARK LEVEL 09

Sign-Up: 04/02/05

Posts: 8,414

At 8/26/06 05:41 AM, Go0gley wrote: gotoAndPlay("frame"+(random(4)+1));

Noes I think the frame1 frame2 were just an example. Your code wouldn't work if he uses labels like 'poopoo'. He's gonna see your code is shorter, use it, nothing will happen and the poor innocent newb would get confused :(

I put on my robe and wizard hat

Why don't you check out my check out my userpage?

BBS Signature

None

Go0gley

Reply To Post Reply & Quote

Posted at: 8/26/06 05:52 AM

Go0gley LIGHT LEVEL 19

Sign-Up: 07/08/04

Posts: 218

Yours wasn't much better - mine works no matter how many frames he has, yours only works for 4. :P

var myFrames:Array = ['frame1','frame2','frame3','frame4'];
gotoAndStop(random(myFrames.length)]);


None

Cybex

Reply To Post Reply & Quote

Posted at: 8/26/06 05:58 AM

Cybex NEUTRAL LEVEL 20

Sign-Up: 03/04/05

Posts: 7,744

At 8/26/06 05:52 AM, Go0gley wrote: Yours wasn't much better - mine works no matter how many frames he has, yours only works for 4. :P

var myFrames:Array = ['frame1','frame2','frame3','frame4'];
gotoAndStop(random(myFrames.length)]);

Yours just works for 4 too.


None

Go0gley

Reply To Post Reply & Quote

Posted at: 8/26/06 06:00 AM

Go0gley LIGHT LEVEL 19

Sign-Up: 07/08/04

Posts: 218

shhh I was seeing if Toast was awake

The correction doesn't ;D


None

Toast

Reply To Post Reply & Quote

Posted at: 8/26/06 06:00 AM

Toast DARK LEVEL 09

Sign-Up: 04/02/05

Posts: 8,414

Yours doesn't work :p

**Error** Scene=Scene 1, layer=Layer 1, frame=2:Line 1: Go0gley can't code. He's just a big big nub.
var myFrames:Array = ['frame1','frame2','frame3','frame4'];

**Error** Scene=Scene 1, layer=Layer 1, frame=2:Line 2: ')' or ',' expected
gotoAndStop(random(myFrames.length)]);

Total ActionScript Errors: 2 Reported Errors: 2

The second error is true though :P. u suxxors. I fixed it:

var myFrames:Array = ['frame1','frame2','frame3','frame4'];
gotoAndStop(myFrames[random(myFrames.lengt
h)]);

I put on my robe and wizard hat

Why don't you check out my check out my userpage?

BBS Signature

None

Go0gley

Reply To Post Reply & Quote

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

Go0gley LIGHT LEVEL 19

Sign-Up: 07/08/04

Posts: 218

Screw it.. heres a better code

[b]gotoAndPlay(random(_totalframes)+1);[/b
]


None

Vengeance

Reply To Post Reply & Quote

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

Vengeance EVIL LEVEL 28

Sign-Up: 03/18/05

Posts: 5,049

god, so many people confusing him:
var frames:Array=new Array("attack", "defend", "walk", "pooOnToast");
gotoAndStop(frames[random(frames.length)])
;

========|| WWWWWWWW>[-[Blog] - [Audio] - [Userpage] - [Flash] - [Last.fm]-]<WWWWWWWW ||========

BBS Signature

None

Toast

Reply To Post Reply & Quote

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

Toast DARK LEVEL 09

Sign-Up: 04/02/05

Posts: 8,414

At 8/26/06 06:04 AM, Go0gley wrote: Screw it.. heres a better code

[b]gotoAndPlay(random(_totalframes)+1);[/b
]

Yeah but what if he has an MC with standing, walking, and jumping animation, plus the four random ones? Unfortunatly there are no commands that allow you to return frames' labels... but I can still make the code shorter :P

gotoAndStop(myFrames=['frame1', 'frame2', 'frame3', 'frame4'][random(myFrames.length)]);

I put on my robe and wizard hat

Why don't you check out my check out my userpage?

BBS Signature

None

Toast

Reply To Post Reply & Quote

Posted at: 8/26/06 06:15 AM

Toast DARK LEVEL 09

Sign-Up: 04/02/05

Posts: 8,414

Or if you have a lot of MCs...

mcs=['mc1','mc2','mc3'][random(mc.length)]
.gotoAndStop(frames=['frame1','frame2','fr
ame3'][random(frames.length)]);

I put on my robe and wizard hat

Why don't you check out my check out my userpage?

BBS Signature

None

Go0gley

Reply To Post Reply & Quote

Posted at: 8/26/06 06:16 AM

Go0gley LIGHT LEVEL 19

Sign-Up: 07/08/04

Posts: 218

lol I owned myself.. you win

Though my code runs 5.5x faster than yours :P


None

Toast

Reply To Post Reply & Quote

Posted at: 8/26/06 06:19 AM

Toast DARK LEVEL 09

Sign-Up: 04/02/05

Posts: 8,414

At 8/26/06 06:16 AM, Go0gley wrote: lol I owned myself.. you win

Though my code runs 5.5x faster than yours :P

No I don't think so. You posted 3 codes, 2 work only with frame1, frame2 etc labels instead of poopoo, lolol, etc, and the one that does work with custom labels doesn't work. :P Post a valid one and then we'll calculate how many times faster it's run.

I put on my robe and wizard hat

Why don't you check out my check out my userpage?

BBS Signature

None

Go0gley

Reply To Post Reply & Quote

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

Go0gley LIGHT LEVEL 19

Sign-Up: 07/08/04

Posts: 218

gotoAndPlay(mf=['frame1', 'frame2', 'frame3', 'frame4'][random(mf.length)]);

shorter variable names does the trick.. and btw IT'S GOTOANDPLAY


None

Toast

Reply To Post Reply & Quote

Posted at: 8/26/06 06:32 AM

Toast DARK LEVEL 09

Sign-Up: 04/02/05

Posts: 8,414

Now let's see your code (with error corrected by me :P) compared to mine and how many times faster it runs.
gotoAndStop(myFrames=['frame1', 'frame2', 'frame3', 'frame4'][random(myFrames.length)]);
gotoandstop run once, with 4 values in MyFrames defined, and a random value ran 4 times.
var myFrames:Array = ['frame1','frame2','frame3','frame4'];
gotoAndStop(myFrames[random(myFrames.lengt
h)]);

array declared with four values, gotoandstop run once (myFrames label being read by flash player twice more times than in mine) and a random value ran 4 times.

I put on my robe and wizard hat

Why don't you check out my check out my userpage?

BBS Signature

None

Cybex

Reply To Post Reply & Quote

Posted at: 8/26/06 06:34 AM

Cybex NEUTRAL LEVEL 20

Sign-Up: 03/04/05

Posts: 7,744

At 8/26/06 06:26 AM, Go0gley wrote: GOTOANDPLAY

Actually it's gotoAndPlay :P


None

Go0gley

Reply To Post Reply & Quote

Posted at: 8/26/06 06:52 AM

Go0gley LIGHT LEVEL 19

Sign-Up: 07/08/04

Posts: 218

Meh, both worked on my Flash 8

At 8/26/06 06:32 AM, -Toast- wrote: Now let's see your code (with error corrected by me :P) compared to mine and how many times faster it runs.
gotoAndStop(myFrames=['frame1', 'frame2', 'frame3', 'frame4'][random(myFrames.length)]);
gotoandstop run once, with 4 values in MyFrames defined, and a random value ran 4 times.
var myFrames:Array = ['frame1','frame2','frame3','frame4'];
gotoAndStop(myFrames[random(myFrames.lengt
h)]);
array declared with four values, gotoandstop run once (myFrames label being read by flash player twice more times than in mine) and a random value ran 4 times.

WTF is all that BS? Here are my results for both codes from 10000 iterations using getTimer.

Mine:
152 158 156 156 156 156 156 156 158 154 158 156 155 159 158 158 157 158 158 158 156
average 156.6 ms

Yours:
207 207 209 211 203 207 207 211 205 211 203 211 207 211 209 209 207 209 209 209 209
average 208.1 ms


None

Toast

Reply To Post Reply & Quote

Posted at: 8/26/06 07:05 AM

Toast DARK LEVEL 09

Sign-Up: 04/02/05

Posts: 8,414

Well none of those gotoAndPlay(array=[][]); work. Try it, try mine, they don't work :P

I put on my robe and wizard hat

Why don't you check out my check out my userpage?

BBS Signature

None

Go0gley

Reply To Post Reply & Quote

Posted at: 8/26/06 07:17 AM

Go0gley LIGHT LEVEL 19

Sign-Up: 07/08/04

Posts: 218

They work =P just not as flow as my script... anyway "aso-products" here's your code:

var mf:Array = ['frame1', 'frame2', 'frame3', 'frame4', 'poopoo', 'etc'];
gotoAndStop(myFrames[random(mf.length)]);


None

Cybex

Reply To Post Reply & Quote

Posted at: 8/26/06 07:19 AM

Cybex NEUTRAL LEVEL 20

Sign-Up: 03/04/05

Posts: 7,744

At 8/26/06 06:52 AM, Go0gley wrote: Mine:
average 156.6 ms

Yours:
average 208.1 ms

You're right, Toast, yours is wasting 0.05 seconds. How dare you waste peoples time like that!


None

Go0gley

Reply To Post Reply & Quote

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

Go0gley LIGHT LEVEL 19

Sign-Up: 07/08/04

Posts: 218

heheh. Damn I mistyped my code again >:(

var mf:Array = ['frame1', 'frame2', 'frame3', 'frame4', 'poopoo', 'etc'];
gotoAndStop(mf[random(mf.length)]);

final version that actually works


None

Toast

Reply To Post Reply & Quote

Posted at: 8/26/06 07:23 AM

Toast DARK LEVEL 09

Sign-Up: 04/02/05

Posts: 8,414

At 8/26/06 07:19 AM, Cybex wrote: You're right, Toast, yours is wasting 0.05 seconds. How dare you waste peoples time like that!

Oh I'm so sorry, how could I not notice it takes 0.05 more second? :(

To all you big nubs, the correct spelling is second, and not seconds, because it's < 2. :p

I put on my robe and wizard hat

Why don't you check out my check out my userpage?

BBS Signature

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

<< Back

This topic is 2 pages long. [ 1 | 2 ]

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