Home Tutorials Forums Articles Blogs Movies Library Employment Press

Go Back   ActionScript.org Forums > ActionScript Forums Group > ActionScript 3.0

Reply
 
Thread Tools Rate Thread Display Modes
Old 07-04-2009, 02:27 AM   #1
Axonn
A Burst Of Light
 
Axonn's Avatar
 
Join Date: Apr 2004
Location: Stockholm, Sweden
Posts: 131
Send a message via MSN to Axonn
Default addChild fails randomly

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.
__________________
"The Greater Mind Balance"
- = E C H Y S T T A S = -

My applications:
http://www.axonnsd.org/ASDClock
My games:
http://www.kongregate.com/games/Kyliathy/thunderbirdz
Axonn is offline   Reply With Quote
Old 07-04-2009, 04:29 AM   #2
dcaccavella
Member
 
Join Date: Jun 2009
Posts: 73
Default

How does it fail? What is the error? Not enough specifics
dcaccavella is offline   Reply With Quote
Old 07-04-2009, 11:20 AM   #3
Axonn
A Burst Of Light
 
Axonn's Avatar
 
Join Date: Apr 2004
Location: Stockholm, Sweden
Posts: 131
Send a message via MSN to Axonn
Default Weird

Quote:
Originally Posted by dcaccavella View Post
How does it fail? What is the error? Not enough specifics
I narrowed down the problem a bit. I have 2 functions which add and remove ALL OBJECTS from / to the stage. All stage work is done there:

addObject (movie)
removeObject (movie)

I monitor function calls on those. And here is the interesting result:
start with stage.numChildren = 0
addObject = 1200 calls.
removeObject = 1000 calls.
end with stage.numChildren = 6 (!?!?!?!?!?!)

Now... how is it possible for 1200 calls to addObject and only 1000 removals, to result in only 6 kids on the stage !? I don't get it!!!

I have no errors whatsoever when running this, I have not supressed any error with try/catch and I always provide valid movie clips to addObject and I actually SEE THEM appear on the stage.

Is it possible that an object is removed by Flash BEFORE I REMOVE IT?
__________________
"The Greater Mind Balance"
- = E C H Y S T T A S = -

My applications:
http://www.axonnsd.org/ASDClock
My games:
http://www.kongregate.com/games/Kyliathy/thunderbirdz
Axonn is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 07:51 PM.


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2010 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.