Be a Supporter!

Error 1009 (tried everything) AS3

  • 2,791 Views
  • 39 Replies
New Topic Respond to this Topic
PMMurphy
PMMurphy
  • Member since: May. 27, 2012
  • Offline.
Forum Stats
Member
Level 01
Programmer
Response to Error 1009 (tried everything) AS3 Jul. 28th, 2012 @ 03:05 AM Reply

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.

milchreis
milchreis
  • Member since: Jan. 11, 2008
  • Offline.
Forum Stats
Member
Level 26
Programmer
Response to Error 1009 (tried everything) AS3 Jul. 28th, 2012 @ 03:27 AM Reply

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.

PMMurphy
PMMurphy
  • Member since: May. 27, 2012
  • Offline.
Forum Stats
Member
Level 01
Programmer
Response to Error 1009 (tried everything) AS3 Jul. 28th, 2012 @ 03:34 AM Reply

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.

milchreis
milchreis
  • Member since: Jan. 11, 2008
  • Offline.
Forum Stats
Member
Level 26
Programmer
Response to Error 1009 (tried everything) AS3 Jul. 28th, 2012 @ 03:46 AM Reply

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.

PMMurphy
PMMurphy
  • Member since: May. 27, 2012
  • Offline.
Forum Stats
Member
Level 01
Programmer
Response to Error 1009 (tried everything) AS3 Jul. 28th, 2012 @ 03:59 AM Reply

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.

egg82
egg82
  • Member since: Jun. 24, 2006
  • Offline.
Forum Stats
Supporter
Level 05
Game Developer
Response to Error 1009 (tried everything) AS3 Jul. 28th, 2012 @ 04:08 AM Reply

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
milchreis
milchreis
  • Member since: Jan. 11, 2008
  • Offline.
Forum Stats
Member
Level 26
Programmer
Response to Error 1009 (tried everything) AS3 Jul. 28th, 2012 @ 04:40 AM Reply

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.

PMMurphy
PMMurphy
  • Member since: May. 27, 2012
  • Offline.
Forum Stats
Member
Level 01
Programmer
Response to Error 1009 (tried everything) AS3 Jul. 28th, 2012 @ 09:23 AM Reply

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

BB-7
BB-7
  • Member since: Nov. 11, 2011
  • Offline.
Forum Stats
Member
Level 05
Melancholy
Response to Error 1009 (tried everything) AS3 Sep. 29th, 2012 @ 07:52 PM Reply

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

Sandremss128
Sandremss128
  • Member since: Aug. 22, 2009
  • Offline.
Forum Stats
Supporter
Level 11
Programmer
Response to Error 1009 (tried everything) AS3 Sep. 29th, 2012 @ 08:28 PM Reply

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.