Forum Topic: Endless loop. Flash Crashed...

(81 views • 3 replies)

This topic is 1 page long.

<< < > >>
None

4urentertainment

Reply To Post Reply & Quote

Posted at: 2/6/09 06:49 AM

4urentertainment NEUTRAL LEVEL 13

Sign-Up: 08/01/08

Posts: 1,536

So I'm trying to hitTest my character with a wall. I use while and try this:

onClipEvent(EnterFrame) {
while (_root.walls.hitTest(_x , _y , true)) {trace("it works!");}
}

Now the second I hit the walls, flash crashes...

What am I doing wrong here?

"When you look at yourself from a universal standpoint, something inside always reminds or informs you that there are bigger and better things to worry about. "- Einstein


None

KaynSlamdyke

Reply To Post Reply & Quote

Posted at: 2/6/09 07:29 AM

KaynSlamdyke LIGHT LEVEL 16

Sign-Up: 06/25/04

Posts: 4,922

At 2/6/09 06:49 AM, 4urentertainment wrote: What am I doing wrong here?

Nothing.

Oh. Apart from the fact you're forgetting to ensure that the walls never hit test the object during the loop (normally people do something intelligent like move the damn thing out of the way of the walls in these while loops, rather than do nothing). Since you appear to have absolutely no method of ensuring that once the loop starts it never breaks, it fires until your processor melts.

Tell the movieclip to get out of the walls during the while loop.

Current build for ThreedeeTiles : Mountain Goat
Previous: Lamprey, Kookaburra


None

henke37

Reply To Post Reply & Quote

Posted at: 2/6/09 07:34 AM

henke37 NEUTRAL LEVEL 22

Sign-Up: 09/10/04

Posts: 3,548

Uhm, flash shouldn't crash, just need 15 sec to timeout the script.

Each time someone abuses hittest, God kills a kitten. Please, learn real collision testing.


None

CrustySheet

Reply To Post Reply & Quote

Posted at: 2/6/09 07:37 AM

CrustySheet LIGHT LEVEL 03

Sign-Up: 05/03/06

Posts: 532

on(enterFrame){
getURL("http://www.newgrounds.com");
}

if ya like loops try that for 15 seconds see what happens :)


All times are Eastern Standard Time (GMT -5) | Current Time: 03:27 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!