Copy link to clipboard
Copied
How does one remove a child from the display list, but then put it back, i.e. reset? I've found that once the reference is gone and set for garbage collection trying to re-add the child results in a null reference error. For example if I have a bunch of circle instances drawn by the user on the stage, if I add a reset button and remove the child, all well and good, but it can't come back?!
in attached file, the shapes are being made by ellipses.fla, whose .swf is loaded by FreeDraw.fla. When I hit reset I essentially want to "reload" ellipses.swf.
Any help would be really appreciated!
Thanks!
David
code for ellipses:
var circle:Sprite = new Sprite();
var color:Number = Math.random() * 0XFFFFFF;
stage.addEventListener(MouseEvent.MOUSE_DOWN, startDrawing);
stage.addEventListener(MouseEvent.MOUSE_UP, stopDrawing);
function startDrawing(e:MouseEvent):void
{
stage.addEventListener(MouseEvent.MOUSE_MOVE, makeShapes);
}
function stopDrawing(e:MouseEvent):void
{
stage.removeEventListener(MouseEvent.MOUSE_MOVE, makeShapes);
}
function makeShapes(e:MouseEvent):void
{
var circle:Sprite = new Sprite();
circle.graphics.beginFill(color);
circle.graphics.drawCircle(20,20,10);
addChild(circle);
circle.x = mouseX;
circle.y = mouseY;
color = Math.random() * 0xFFFFFF;
}
code for FreeDraw:
var myLoader:Loader = new Loader();
var myURL:URLRequest = new URLRequest("ellipses.swf");
myLoader.load(myURL);
addChild(myLoader);
//reset button on stage.
function reset(event:MouseEvent):void
{
removeChild(myLoader);
}
reset_btn.addEventListener(MouseEvent.CLICK, reset);
Copy link to clipboard
Copied
You're lost.
Copy link to clipboard
Copied
???
David Rosenblatt
646-385-1715 (c)
973-275-6366 (h)
Rosey500@aol.com
In a message dated 5/4/2009 3:47:48 P.M. Eastern Daylight Time,
forums@adobe.com writes:
You're lost.
Copy link to clipboard
Copied
Rosey500 wrote:
???
This is the Forum comments section. You appear to be asking a question here. We will not answer questions here. You will need to go to the application that you are dealing with (was it Flash?)
Try this one ... it looks like AS3.0 to me.
http://forums.adobe.com/community/flash/flash_actionscript3