I have a canvas container with several custom containers added to it. I have a 
context menu so that when you right click on the containers, you can remove it 
from the canvas container. When I go to remove a child, I get an error, below.

Code:
private function menuSelectHandler(event:ContextMenuEvent):void {
     var remChild:Number;
     var target:String = event.mouseTarget.toString();
     trace (target);
     if (target.match("UIComponent") == null && target.match("resizeBar") == 
null) {
          trace ("  True 1");
          trace ("        "+event.mouseTarget);
          remChild = cal0Day.getChildIndex(event.mouseTarget);
                                        
     }
     else {
          trace ("  True 2");
          trace ("        "+event.mouseTarget.parent);
          remChild = myCanvas.getChildIndex(event.mouseTarget.parent);
     }
     trace (remChild);
     trace (myCanvas.getChildAt(remChild));
     myCanvas.removeChildAt(remChild);
     myAC.removeChildAt(remChild);
     updateLayout();
}

TestApp0.canvasShell.myCanvas.myContainer592
  True 1
        TestApp0.canvasShell.myCanvas.myContainer592
12
TestApp0.canvasShell.myCanvas.myContainer592

Then I get the following error:
ArgumentError: Error #2025: The supplied DisplayObject must be a child of the 
caller.
        at flash.display::DisplayObjectContainer/getChildIndex()


How do I do this?

Reply via email to