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
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to