Je crée un script d'action pour simuler 3 états de bouton et charger dans les clips en conséquence.Flash AS3: Le DisplayObject fourni doit être un enfant de l'erreur de l'appelant
Je reçois cette erreur
ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.
at flash.display::DisplayObjectContainer/removeChild()
at Untitled_fla::MainTimeline/sack_btnMouseOut()
Lorsque vous essayez de le faire
//get the objects
var addSackStill:sack_still = new sack_still();
var addSackHover:sack_hover = new sack_hover();
var addSackClick:sack_click = new sack_click();
//add the still object to the stage
addChild(addSackStill);
var SACK_X = 570.55;
var SACK_Y = 603.95;
addSackStill.x = SACK_X;
addSackStill.y = SACK_Y;
addSackHover.x = SACK_X;
addSackHover.y = SACK_Y;
addSackClick.x = SACK_X;
addSackClick.y = SACK_Y;
//create the event listeners
addSackStill.addEventListener(MouseEvent.MOUSE_OVER, sack_btnMouseOver);
addSackHover.addEventListener(MouseEvent.MOUSE_OUT, sack_btnMouseOut);
addSackHover.addEventListener(MouseEvent.CLICK, sack_btnClick);
//here are the functions for mouse over, mouse off, and click
function sack_btnMouseOver(event:MouseEvent):void {
trace("mouse over");
removeChild(addSackStill); //remove the movie clip
addChild(addSackHover); //add sackclick to the stage
}
function sack_btnMouseOut(event:MouseEvent):void {
trace("mouse out");
removeChild(addSackHover); //remove the movie clip
addChild(addSackStill); //add sackclick to the stage
}
function sack_btnClick(event:MouseEvent):void {
trace("Click");
removeChild(addSackHover); //remove the movie clip
addChild(addSackStill); //add sackclick to the stage
}
Est-ce que je fais quelque chose de mal?
Je normalement obtenir cette erreur si je vous appelle removeChild de l'objet que j'essaie de supprimer .. Essayez d'envelopper removeChild si (chose .parent) thing.parent.removeChild (chose); – Marty