Hi, I'm working on a game that needs certain pages to be loaded depending on a random generated number.
Here's what I've done to make each room load up
Actionscript Code:
function onEssenButtonClick(event:MouseEvent):void
{
if (1 == theNumber){
addChild(essenPage1);
removeChild(mapPage);
}
if (2 == theNumber){
addChild(essenPage2);
removeChild(mapPage);
}
}
function onLibButtonClick(event:MouseEvent):void
{
if (1 == theNumber){
addChild(libPage1);
removeChild(mapPage);
}
if (2 == theNumber){
addChild(libPage2);
removeChild(mapPage);
}
}
Each of these rooms have the 'mapButton' on it and here's what I'm using to back out of the room.
Actionscript Code:
function onMapButtonClick(event:MouseEvent):void
{
addChild(mapPage);
removeChild(this);
}
I'm getting this error:
Code:
ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.
at flash.display::DisplayObjectContainer/removeChild()
at Main/onMapButtonClick()
I know I'm meant to put the relevant page inside removeChild"(this)" but the 'mapButton' applies to all pages and there is in total, 36 of them.
Please help.