Right Taka, thinking the same thing, and I was just assuming he was doing something more (not shown) in the draw function other than just adding the child - otherwise, you're just adding blank things to the screen.
Jason Merrill Bank of America Instructional Technology & Media · GCIB & Staff Support L&LD Interested in Flash Platform technologies? Join the Bank of America Flash Platform Developer Community Interested in innovative ideas in Learning? Check out the Innovative Learning Blog and subscribe. -----Original Message----- From: [email protected] [mailto:[email protected]] On Behalf Of Taka Kojima Sent: Wednesday, January 14, 2009 3:09 PM To: Flash Coders List Subject: Re: [Flashcoders] recursive question? I would probably just do something like... private function renderAxis(which:String, doRemove:Boolean = true):void if(doRemove){removePrevious();} switch (which) { case ("X") : xAxis = new Sprite(); addChild(xAxis); break; case ("Y") : yAxis = new Sprite(); addChild(yAxis); break; case ("both") : renderAxis("X",false); renderAxis("Y",false); break; } } On Wed, Jan 14, 2009 at 11:27 AM, Mendelsohn, Michael < [email protected]> wrote: > Hi list... > > I have two functions, where either an X is rendered, a Y is rendered, or > both an X and a Y. removePrevious() is called before anything gets > rendered, so as to clear the stage. The problem is when "both" are > rendered, removePrevious() is called twice. It first clears the stage, > renders a new x, then renders a new y -- but not before removing that > newly just created X. How can I avoid this? > > Thanks, > - Michael M. > > private function removePrevious():void { > if (xAxis!=null) { > removeChild(xAxis); > xAxis = null; > } > if (yAxis!=null) { > removeChild(yAxis); > yAxis = null; > } > } > private function renderAxis(which:String):void > removePrevious(); > switch (which) { > case ("X") : > xAxis = new Sprite(); > addChild(xAxis); > break; > case ("Y") : > yAxis = new Sprite(); > addChild(yAxis); > break; > case ("both") : > renderAxis("X"); > renderAxis("Y"); > break; > } > } > > _______________________________________________ > Flashcoders mailing list > [email protected] > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders > _______________________________________________ Flashcoders mailing list [email protected] http://chattyfig.figleaf.com/mailman/listinfo/flashcoders _______________________________________________ Flashcoders mailing list [email protected] http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

