Error 2025: The supplied DisplayObject must be a child of the caller

Posted by Mocca on Stack Overflow See other posts from Stack Overflow or by Mocca
Published on 2010-04-06T09:47:04Z Indexed on 2010/04/06 9:53 UTC
Read the original article Hit count: 225

Filed under:
|
|
|

Hi,

sorry, new to actionscript 3.

I have a display() function for an object rotator(image based like a QT object movie). It first saves the current image in a helper variable and then allocates a new image, from the library, beneath the old one. To get a nice crossfade effect, the old image's alpha is looped down via enter_frame and then removed.

Which is where there seems to be an issue with the display list, maybe recognizing oldImg's value as being already added? (it's not a first pass error)

Btw, do i have to remove the old image or can i leave it, for when it's being called up via the mouse position again? (the image number can get fairly large)

Does anyone have further insight? Thanks!

function display(num:Number):void   //num: image number
{
   ...    
   oldImg = newImg;   

   ClassReference = getDefinitionByName("Class"+num) as Class;
   imgBD = new ClassReference(0,0);
   newImg = new Bitmap(imgBD);

   images.addChild(newImg); 
   newImg.x=0;
   newImg.y=0;

}


function onEnter(evt:Event):void
{
    if (oldImg) 
    {
        if (oldImg.alpha > 0) oldImg.alpha -= 0.15; 
        **else images.removeChild(oldImg);**              
    }
        ...
}

© Stack Overflow or respective owner

Related posts about actionscript

Related posts about 3