• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Display List Question

New Here ,
May 04, 2009 May 04, 2009

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);

Views

811

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
May 04, 2009 May 04, 2009

Copy link to clipboard

Copied

You're lost.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 04, 2009 May 04, 2009

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
May 04, 2009 May 04, 2009

Copy link to clipboard

Copied

LATEST

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines