Range Error.How can make the movieclip always on the top
I want to make the bar on the top at all time but it seems not work when I addChild. When I add container. it occurs an error.
RangeError: Error #2006: The supplied index is out of bounds.
at flash.display::DisplayObjectContainer/setChildIndex()
var container:MovieClip=new MovieClip();
addChild(container);
var menubar:MovieClip=new Menubar();
menubar.x=0;
menubar.y=859;
menubar.name="menubar";
container.setChildIndex(menubar,(numChildren-1));
addChild(menubar);
menubar.recipe_btn.addEventListener(MouseEvent.CLICK, onRecipeClick);
function onRecipeClick(evt:MouseEvent):void{
addChildAt(recipe,1);
}
recipe.foodIcon.addEventListener(MouseEvent.CLICK, onFoodIconClick);
function onFoodIconClick(evt:MouseEvent):void{
removeChild(recipe);
addChildAt(recipeFood,2);
}
menubar.product_btn.addEventListener(MouseEvent.CLICK, onProductClick);
function onProductClick(evt:MouseEvent):void{
addChildAt(product,3);
}
menubar.cupon_btn.addEventListener(MouseEvent.CLICK, onCuponClick);
function onCuponClick(evt:MouseEvent):void{
addChildAt(cupon,3);
}
menubar.location_btn.addEventListener(MouseEvent.CLICK, onLocationClick);
function onLocationClick (evt:MouseEvent): void{
addChildAt(location,3);
}
