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 05-07-2007, 10:48 AM   #1
panel
AS3
 
panel's Avatar
 
Join Date: Mar 2007
Location: Warsaw
Posts: 1,815
Send a message via Skype™ to panel
Default Remove All Childrens

Hi
How to remove all childrens in display object?
panel is offline   Reply With Quote
Old 05-07-2007, 11:48 AM   #2
Morg
1st party software!
 
Morg's Avatar
 
Join Date: Nov 2003
Location: South Africa
Posts: 908
Default

Hey

What is the display object?
Morg is offline   Reply With Quote
Old 05-07-2007, 01:57 PM   #3
Tink
Addict
 
Tink's Avatar
 
Join Date: Nov 2001
Location: London
Posts: 2,128
Default

DisplayObjectContainer.removeAllChildren();
Tink is offline   Reply With Quote
Old 05-07-2007, 02:16 PM   #4
senocular
six eyes
 
senocular's Avatar
 
Join Date: Jan 2003
Location: San Francisco, CA (USA)
Posts: 7,784
Send a message via ICQ to senocular Send a message via AIM to senocular Send a message via MSN to senocular Send a message via Yahoo to senocular
Default

ActionScript Code:
while(container.numChildren){     container.removeChildAt(0); }

Of course to be more robust, it would be even better if you weren't dependant on numChildren in the case that maybe the container has overriden remove methods to prevent the removal of some objects. Then, you could use something like

ActionScript Code:
var i:int = container.numChildren; while(i--){     container.removeChildAt(i); }
Otherwise, with the first example, it would be possible to get caught in an infinite loop.
__________________
(6)
senocular is offline   Reply With Quote
Old 05-07-2007, 04:17 PM   #5
Assertnfailure
as[org].addListener(this)
 
Assertnfailure's Avatar
 
Join Date: Dec 2005
Location: LA, California
Posts: 838
Default

I think you've got bigger problems if other developers are going around overriding method behaviors in such a way that previously common implementations stop working.
Assertnfailure is offline   Reply With Quote
Old 05-07-2007, 06:21 PM   #6
springframework
Senior Member
 
Join Date: Mar 2006
Posts: 381
Default

watch out with

DisplayObjectContainer.removeAllChildren();

for some reason it takes longer then looping through the list yourself.

i ran into problems where the the next line of code after removeAllChildren() did work correctly.

http://www.jessecouch.com

Last edited by springframework; 05-07-2007 at 06:58 PM.
springframework is offline   Reply With Quote
Old 05-07-2007, 06:38 PM   #7
senocular
six eyes
 
senocular's Avatar
 
Join Date: Jan 2003
Location: San Francisco, CA (USA)
Posts: 7,784
Send a message via ICQ to senocular Send a message via AIM to senocular Send a message via MSN to senocular Send a message via Yahoo to senocular
Default

removeAllChildren is actually a method of Flex's Container class, not the Flash Player's core DisplayObjectContainer (so if you're using Flash, it won't be available).
__________________
(6)
senocular 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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Remove a selected row in a dataGrid?? chrishosch Components 7 10-16-2008 02:33 PM
Remove property from Object arkum ActionScript 2.0 0 05-01-2007 05:36 PM
Want to remove only 1 filter (no filters = []) pointer ActionScript 2.0 3 03-08-2007 10:38 AM
How do i remove New Components Shilling Components 0 06-15-2005 06:50 PM
can't remove object instances with removeMoveClip jben.net ActionScript 1.0 (and below) 0 09-23-2003 02:26 PM


All times are GMT. The time now is 03:34 AM.


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.