addChild fails randomly

Commenta 4th July , 2009
Hi everybody. I’m coding a game and have run into a weird issue. addChild fails. RANDOMLY.

I keep creating enemies and objects in a rather fast loop, calling addChild(object). Each time I call addChild I increase a variable X.

After 5 minutes:

stage.numChildren = 50
X = 60

I must also specify that I am sometimes adding objects at a rate of 5/second. I’m also removing them, of course, otherwise the FlashPlayer would freeze. When I am removing objects, I, of course, decrease X. Still, things get out of sync and I cannot understand why this happens. Also worth mentioning is that I never have more than 200 objects on the stage. I always remove them and add them in a single place so I got everything very "centralized" so to speak.

What’s even weirder is that apparently AS skips some instructions when it’s too loaded. I have a request for an animation to go and play at a certain frame, and it doesn’t. I’m very puzzled by this behavior.

Original post by axonn

Lascia un Commento