-
[RESOLVED] ERROR: DisplayObject must be a child of the caller
Please help me...
I created this simple hitTest on the first frame of my main timeline.
var flash_1g:Flash_1g = new Flash_1g();
stage.addEventListener(Event.ENTER_FRAME, hitTest)
fuction hitTest(yourEvent:Event):void{
if (note1.hitTestObject(key_1g)) {
addChild(new Flash_1g);
}
};
So I have a movieClip (note1) colliding with another movieClip (key_1g) and when collision happens it, a third movieClip from my library (class: Flash_1g) is placed on stage with the addChild cmd. Works fine.
Later I want to remove this movieClip (Flash_1g) again.
But when I try to use
removeChild(flash_1g);
which is the variable name for Flash_1g defined at the beginning.
I get this error:
"The supplied DisplayObject must be a child of the caller."
How should I go about this?
Last edited by Zeicon; 05-06-2012 at 04:44 PM.
-
Total Universe Mod
make sure you are calling removeChild on the actual parent of flash_1g.
For example if you add a child to a display object called myParent with:
myParent.addChild(myChild);
you can only remove it from that object:
myParent.removeChild(myChild);
-
You never added flash_1g. Instead, you created a new instance of Flash_1g and added that.
-
yea, that's what happened.
Thanks guys. This is resolved.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|