Skip to main content
federicopyramid
Known Participant
April 13, 2010
Question

stupid error #2025 - How can I solve it?

  • April 13, 2010
  • 1 reply
  • 464 views

Hi! How Are you guys! I'm having a problem while I'm trying to remove a Child.  I have a button that loads the loader and a next and back button that let you navigate through the images in it. And last the MENU button that brings into the stage the menu bar. I would like that when you click the menu an action to remove the images from the loader. I can do that, but only if there were some images there in the loader, otherwise I get this error:

ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.     at flash.display:

:DisplayObjectContainer/removeChild()

It seems that the IF STATEMENT doesn't work properly. I guess that it must have an error, but I can't figure it out which.

Thanks in advance!!

Here is my code:

menuBra.addEventListener (MouseEvent.CLICK, onClickBra);

function onClickBra (event:MouseEvent):void {

if(contains(loaderBrand)) {

removeChild(loaderBrand);

var TweenPrint1:Tween = new Tween(menu_mc,"x", Strong.easeOut, -4000, 0, 1, true);

}

else          {

var TweenPrint2:Tween = new Tween(menu_mc,"x", Strong.easeOut, -4000, 0, 1, true);

}

trace ("menu was clicked"); }

This topic has been closed for replies.

1 reply

Kartik_Mehta
Inspiring
April 13, 2010

Hi,

try to check that if(loaderbrand != null) before ur original if condition

or

Can u pls put your full code so that i can understand it

federicopyramid
Known Participant
April 13, 2010

It worked with this:

if(loaderBrand.parent != null && loaderBrand.parent == this) {

removeChild(loaderBrand);

var TweenPrint1:Tween = new Tween(menu_mc,"x", Strong.easeOut, -4000, 0, 1, true); }

Thanks!!