public var topView:String;
public function bringToFront ( viewName:String ):Boolean
{
if (topView == viewName) return false;
var view:DisplayObject = getChildByName( viewName );
removeChild(view);
displayView(view);
return true;
}
private function displayView( view:DisplayObject ):void
{
view.x = 0;
view.y = 0;
view.visible=true;
addChild(view);
topView=view.name;
}
Here's some code snatched from a Flex app I had laying around. I wiped out the Flexyness, and I think it should work in pure AS3. You may need to tailor it to fit your needs.
Use the displayView method to add any DisplayObject to the view and it ends up on the top of the stack. Then always use bringToFront to specifically pull the navigation object to the top of the stack, like this:
// Adding the navigation view
navView.name = 'navigationView';
displayView(navView as DisplayObject);
.
. Later...
.
// Add a new view
displayView(myNewView as DisplayObject);
bringToFront('navigationView');
It's one way of doing it...
-=Cliff>