Steve Abaffy wrote:
> Why doesn't this work?? > > In the same function > > Var Mort:movieClip = new Mort(); > > addChild(Mort); > > removeChild(Mort); > > I get this error > > The supplied DisplayObject must be a child of the caller. > It's likely that Mort hasn't had time to instantiate. Either that, or Mort, being a local variable, isn't there if you leave the function and call it again. For example: public function doMort(add:Boolean):void { var Mort:MovieClip; if (add == true) { Mort = new Mort(); addChild(Mort); } else { removeChild(Mort); } } Mort only survives while the function is running. He's still on the display list, but the function doesn't know who Mort is when you call him with false. Or, it could be something as simple as using an upper-case Var instead of var. Have you looked in the debugger, or with trace statements, to be sure Mort is being created? If instantiation fails, it won't be a valid MC. Cordially, Kerry Thompson _______________________________________________ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders