Results 1 to 4 of 4

Thread: AS3-How to remove all children from Display Object Container

  1. #1
    Join Date
    Apr 2009
    Posts
    65

    AS3-How to remove all children from Display Object Container

    I have some problem with image uploading in my gallery, some times single image gets replicated 1 or more times which overburdens my database, so i wanted to get rid of this problem, Is there anybody who can help me out in removing duplicates in ActionScript3.0 removeChild works and removeChildAt also works but removeAllChildren it shows an error. i want to remove all the children imageclips that have been duplicated within the container at once ... but using removeAllChildren shows error that -- removeAllChildren is not a function. I am using Flash CS3 removeAllChildren works in Flex but not working in Flash CS 3. Any help wouid be appriciated. Thanks in advance.

  2. #2
    Join Date
    Dec 2008
    Posts
    161

    Re: AS3-How to remove all children from Display Object Container

    Here I am giving you a little code through which you can remove all children's but it will removes children's in an opposite order it will removes them from the top same as we keep items at the top of the stack instead of the bottom which may be slightly quicker if you have a lot of child objects that need to be removed.

    Code:
    var children:Array = new Array();
    
         trace ('before : '+holder.numChildren);
                 while(holder.numChildren)
                    {
                      holder.removeChildAt(0);
                    }
    
        var i:int = holder.numChildren;
                 while( i -- )
                    {
                      holder.removeChildAt( i );
                    }
    
         trace ('after : '+holder.numChildren);
    
         trace ('after : '+holder.numChildren);
    
         trace ('-------------------------');

  3. #3
    Join Date
    Jan 2006
    Posts
    211

    Re: AS3-How to remove all children from Display Object Container

    Sorry for interruption but i also had the same problem so i tried using the above code, After trying the above code several times it did not work to clear all the clips.

    This is because i think the reason will be the numChildren changes every loop. I did not want to try too hard to think about why it did not work for me but willing to find out the actual reason behind it and rewrote the above in a recursive function to make sure all clips are removed. It works every time to get rid of all child child clips.

    It always remains in the mind why does not offer a collection Array of the children like in Visual Studio so we could use a for each loop.

  4. #4
    Join Date
    Jan 2009
    Posts
    99

    Re: AS3-How to remove all children from Display Object Container

    Something like this would remove all children of a displayObjectContainer.

    Code:
    while( nameOfContainer.numChildren > 0 )
           nameOfContainer.removeChildAt( 0 );

Similar Threads

  1. How to remove plug-in container.exe from Mozilla Firefox 5
    By Anchal in forum Technology & Internet
    Replies: 3
    Last Post: 22-06-2011, 09:33 PM
  2. Replies: 6
    Last Post: 06-06-2011, 01:34 AM
  3. Replies: 3
    Last Post: 08-01-2011, 06:20 AM
  4. How can you remove and insert an object in the array list ?
    By GOOL in forum Software Development
    Replies: 4
    Last Post: 03-01-2011, 11:29 PM
  5. Remove object from pictures
    By Jokerz in forum Customize Desktop
    Replies: 4
    Last Post: 13-12-2008, 02:58 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,877,477.66466 seconds with 16 queries