00:00
00:00
Newgrounds Background Image Theme

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

Error 1009 (tried everything) AS3

4,780 Views | 39 Replies
New Topic Respond to this Topic

Response to Error 1009 (tried everything) AS3 2012-07-28 03:05:56


At 7/28/12 03:01 AM, milchreis wrote: When you loop forward through an array while removing objects at the same time, you will skip elements.

if you adjust your index everytime you remove an element it wont happen that way.

Response to Error 1009 (tried everything) AS3 2012-07-28 03:27:31


At 7/28/12 03:05 AM, PMMurphy wrote: if you adjust your index everytime you remove an element it wont happen that way.

An unnecessary fix, I'd say.

Response to Error 1009 (tried everything) AS3 2012-07-28 03:34:16


If your game is firing bullets from the first bullet to the last in the array. it makes logical sense to have your code iterate forward.

Response to Error 1009 (tried everything) AS3 2012-07-28 03:46:20


At 7/28/12 03:34 AM, PMMurphy wrote: If your game is firing bullets from the first bullet to the last in the array. it makes logical sense to have your code iterate forward.

Not really. The enemy object could be everywhere and because you have to iterate over all of them anyway, it doesn't matter. The for-each-in just works, no additional workaround required.

Response to Error 1009 (tried everything) AS3 2012-07-28 03:59:33


Thats kinda like hardcoding to your situation. What if it wasn't just bullets in your array and you needed to make sure you accessed certain elements and not others? It may not be exactly nescessary for this exact application but that doesn't mean logic should be ignored. People read left to right. So you should code left to right and have things function left to right.

It may make sense, function, and be easy to read. But you need to also pay mind somebody else reading it, maybe they wont understand it. Maybe it doesn't make sense to them?

Unless you are specifically wanting to go from right to left for a good logical reason.

Response to Error 1009 (tried everything) AS3 2012-07-28 04:08:26


well, I completely misread this topic. I thought we were offering a break statement as a normal-case solution, in which I would be gung-ho to say "yes" to. However, the "war" seems to be over the fact that the break; is being used to skip over the problem lines.

No, break statements shouldn't really be used to "skip over" problem code. It's a temporary solution used to debug.
If you're debugging another area and that code is getting in the way, you simply skip over it- though honestly I would use code comments to comment it out. Easier to find than a single break;

though, again, there really isn't an "improper" way to use a break statement. Even used as described above, it's still doing the job it was designed in the fashion it was designed.


Programming stuffs (tutorials and extras)

PM me (instead of MintPaw) if you're confuzzled.

thank Skaren for the sig :P

BBS Signature

Response to Error 1009 (tried everything) AS3 2012-07-28 04:40:03


At 7/28/12 03:59 AM, PMMurphy wrote: Thats kinda like hardcoding to your situation.

I disagree.
The for-each-in loop works, regardless of the removal, it is general purpose.
Opposed to the need to adjust the index, which is situational.

What if it wasn't just bullets in your array and you needed to make sure you accessed certain elements and not others?

Those wouldn't be identified by the index, especially not in an array that happens to change quite often.
You'd either cast them, put them in separate arrays or just treat them in a uniform way.

It may not be exactly nescessary for this exact application but that doesn't mean logic should be ignored.
People read left to right. So you should code left to right and have things function left to right.

There is no left or right. Just a basket with enemies and another one with bullets.

Maybe it doesn't make sense to them?

That's not an argument.

Response to Error 1009 (tried everything) AS3 2012-07-28 09:23:25


Ok, you win. No need to explain anymore. You obviously know everything your talking about.

Response to Error 1009 (tried everything) AS3 2012-09-29 19:52:15


I think you mean 9001, not to be a smartass though.

Response to Error 1009 (tried everything) AS3 2012-09-29 20:28:22


Since this thread got renewed here's something I wanted to say from the moment I read this:

At 7/28/12 09:23 AM, PMMurphy wrote: Ok, you win. No need to explain anymore. You obviously know everything your talking about.

*You're

At 9/29/12 07:52 PM, BB-7 wrote: I think you mean 9001, not to be a smartass though.

What comes after the comma is only there so you yourself feel better, not to be a smartass though.