Alright, so I have a button when clicked goes to frame 15. If xpsafety is 0 I want a child to be created and xpsafety to be set to 1. So if the button is clicked again it wont display the child and do the calculation
Fame 10:
var xpsafety:int = 0;
var xpclip:MovieClip = new xp();
RememberButton.addEventListener(MouseEvent.CLICK, GoToRemember);
function GoToRemember(evt:MouseEvent):void {
gotoAndPlay(15, "Scene 1");
if (xpsafety == 0) {
addChild(xpclip);
xpclip.x=41;
xpclip.y=835;
calculateExp(8);
xpsafety = xpsafety +1;
}
}
Frame 15:
stop();
BackButton.addEventListener(MouseEvent.CLICK, GoBackSafety);
function GoBackSafety(evt:MouseEvent):void {
gotoAndPlay(10, "Scene 1");
removeChild(xpclip);
}
The error I get is this: ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.
I don't understand what it means, any tips? Please and thank you.
Other issue but it's probably related, despite xpsafety being not equal to 0 the function still goes off ( I know because calculateExp(8) happens.