dcsimg
A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: removeChild from an array

  1. #1
    Member
    Join Date
    May 2009
    Posts
    37

    removeChild from an array

    I'm trying to figure out why I can't remove the child of the meteors immediately after they have hit the planet or a building so that it would only damage the building once. When I try to just 'removeChild(meteorArray[k])' AS says that the 'object must be a child of the caller'. I'm not sure what that means, but I thought that the meteor was the child of the main document class.
    Attached Files Attached Files

  2. #2
    a.k.a gltovar deadlock32's Avatar
    Join Date
    May 2001
    Location
    Naperville,IL
    Posts
    489
    you can try using:

    PHP Code:
    if(meteorArray[k].parent == this)
    {
         
    this.removeChild(meteorArray[k]);
    }
    else
    {
        
    trace(meteorArray[k].parent.name);  // optional code


  3. #3
    Member
    Join Date
    May 2009
    Posts
    37
    thanks for the reply man...I actually figured it out. I had to not only remove the object from the display list, but also remove it from the array. I was trying to do each of them at separate times.

    PHP Code:
    removechild(meteorArray[k]);
    meteorArray.splice (k1); 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center