actionscript 3 - as3 check if child exists - removeChild(); -


the code below creates movieclip called "circle" , checks if exists , deletes via removechild(); removed circle [object movieclip] still there.

how can check if child "on stage" or removed using removechild?

import flash.display.movieclip; import flash.events.mouseevent;  var circle:movieclip  = new movieclip(); circle.graphics.beginfill(0xff794b); circle.graphics.drawcircle(50, 50, 30); circle.graphics.endfill(); addchild(circle); circle.addeventlistener(mouseevent.click, test);  function test(event:mouseevent) {     trace(circle);     if(circle)     {      trace("called if circle");      removechild(circle);     }     trace(circle); } 

check circle.stage property:

    if(circle.stage)     {         trace("circle in display list");         circle.parent.removechild(circle);  //remove circle display list         circle = null //remove reference circle, mark garbage collection     }     else     {         trace("circle isn't in display list");     } 

Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -