00:00
00:00
Newgrounds Background Image Theme

ESCANOR2169 just joined the crew!

We need you on the team, too.

Support Newgrounds and get tons of perks for just $2.99!

Create a Free Account and then..

Become a Supporter!

As:Bad Ideas

12,409 Views | 67 Replies
New Topic Respond to this Topic

Response to As:Bad Ideas 2006-05-09 18:50:38


hahah.. even worse...

While(1){
}

=P


At first there was nothing, then it exploded. - Big bang

Response to As:Bad Ideas 2006-05-22 03:00:58


At 12/5/05 04:06 PM, -dELta- wrote: oh also, another deprecated function is random(#) which sucks since its a great easy function, in AS3 it has been removed and you must use Math.random() which to create the same function as random(#) would be Math.round(Math.random()*#) (# is an integer) which is quite obviously slower to compute, and Math.random() is slower to compute than random(#) in the first place anyways

Yeah... but AS3 is much faster just due to the fact that they now require you to use OOP. They optimized the language so that Math.random() would compute faster in AS3 than random() would in AS2.

Response to As:Bad Ideas 2006-05-22 12:14:12


At 5/22/06 03:00 AM, Daedro wrote: Yeah... but AS3 is much faster just due to the fact that they now require you to use OOP. They optimized the language so that Math.random() would compute faster in AS3 than random() would in AS2.

Nice first post. Nive AS I have done some of these before, here's another one.

i=2;
if(i<=2){
poo;
} else if(i>=2){
poop;
}

That gives your PC a headache, well mine, mines crap :(


BBS Signature

Response to As:Bad Ideas 2006-05-22 13:00:56


Just when you thought for loops were all cute and safe:

for(var i = 0; i <= 10; i ++){
i --;
}

One line :P

while(true){}


BBS Signature

Response to As:Bad Ideas 2006-05-22 19:02:21


Infinite loops been posted enough? :P

Alright, heres one. In a loop you might forget you're already incrementing an index variable, and decide to increment it inside the for loop. Or maybe you meant to increment twice. Basically that means every loop you'd be skipping an index. This wouldn't be a problem if you use i++, but sometimes ++i is necessary when accessing array indexs. Which means if the length is an odd number you'd reach an undefined index.

eg. You might be loading multiple swfs and after the first one, on trying to load another the swf freezes. This may be why.

[code]var arr:Array = new Array("a","b","c","d","e","f","g","h","i")
;

for(var i:Number = 0; i < arr.length; ++i)
{
trace(arr[++i]);
}[/code]

Note that in the for arguments, ++i and i++ both work. I use ++i because it's a little bit faster, since a temporary variable doesn't need to be created.

[quote="output"]b
d
f
h
undefined[/quote]

What does it all mean joey?!? Loops are anything but cute: watch them with a suspicious eye.

Response to As:Bad Ideas 2006-05-22 19:05:34


Are you serious? No BB code, formatting, or edit button? Hahahaha interesting.

[B]CODE:[/B]
[I]var arr:Array = new Array("a","b","c","d","e","f","g","h","i")
;

for(var i:Number = 0; i < arr.length; ++i)
{
trace(arr[++i]);
}[/I]

[B]OUTPUT:[/B]
[I]b
d
f
h
undefined[/I]

Response to As:Bad Ideas 2006-05-22 19:07:59


WTF, HTML brackets, I give up. :(

Response to As:Bad Ideas 2007-10-05 07:27:44


Very very bad for my computer , everytime i run this , Flash will Crash(LOL ,IT RYMES!):
while(hitTest(_root.ground)){
//This part below is what causes the crash
_y = _y-1;
}
//PS: DON'T EVER USE THIS CODE! I LOST ONE OF MY DOCUMENTS ONCE!

This is what it should be:
while(hitTest(_root.ground)){
_y--;
}
//This code is part of my platformer engine