dcsimg
A Flash Developer Resource Site

Results 1 to 7 of 7

Thread: how do you remove an object

  1. #1
    Senior Member
    Join Date
    Jul 2008
    Posts
    418

    how do you remove an object

    how do you remove an object? and also remove it from the child list?
    (after u typed addChild()

  2. #2
    Mod cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,448
    removeChild(object);
    - The right of the People to create Flash movies shall not be infringed. -
    | www.Flashscript.biz | Flashscript Biz Classes/Components |

  3. #3
    Senior Member
    Join Date
    Jul 2008
    Posts
    418
    but that doesn't completely remove the object, right? that only removes it from the child list?

  4. #4
    Mod cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,448
    What is the child list? It removes the object and puts it on the removal list for the garbage collector. If you trace the object it will be null.
    - The right of the People to create Flash movies shall not be infringed. -
    | www.Flashscript.biz | Flashscript Biz Classes/Components |

  5. #5
    Senior Member
    Join Date
    Jan 2007
    Location
    Nottingham, England
    Posts
    263
    just curious - wouldnt the garbage collector only remove the object as long as there's no reference to it in the main script? i.e, you can remove a button from the display list with removeChild(), but the garbage collector wont delete the object completely if the script still has active listeners attached to that button like button.addEventListener(...onClick);?

  6. #6
    Mod cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,448
    I have to correct myself. If you trace it it will not be null. What you can do is you can set the variable for the object equal to null. Then any property or function associated with the object afterwards will lead to a compiler error and you have to remove those.
    but the garbage collector wont delete the object completely if the script still has active listeners attached to that button like button.addEventListener(...onClick);?
    I am not sure about that. They are now useless, when the object is physically removed from the movie.
    - The right of the People to create Flash movies shall not be infringed. -
    | www.Flashscript.biz | Flashscript Biz Classes/Components |

  7. #7
    Ө_ө sleepy mod
    Join Date
    Mar 2003
    Location
    Oregon, USA
    Posts
    2,441
    Event listeners will hold an object in memory even if there's no other linkage to the object. You can pass a flag in your addEventListener call that will attach the listener 'weakly' - meaning it can still be garbage collected. (You'll have to look up the documentation in your F1 help - I couldn't get livedocs to load).

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