Hi,
First post here, read some stuff and tips but I’d like your help!
package {
import flash.display.Sprite;
import flash.events.MouseEvent;
import flash.events.Event;
public class Main extends Sprite {
public var myKnop1:Knop1;
public var myKnop2:Knop2;
public var myKnop3:Knop3;
public var myKnop4:Knop4;
public var myCat:Cat;
public function Main() {
myKnop1 = new Knop1();
myKnop1.x = 0;
myKnop1.y = 0;
addChild(myKnop1);
addEventListener(MouseEvent.MOUSE_UP, opKnop2);
}
public function opKnop2(e:Event):void {
removeChild(myKnop1);
myKnop2 = new Knop2();
myKnop2.x = 0;
myKnop2.y = 0;
addChild(myKnop2);
addEventListener(MouseEvent.MOUSE_UP, opKnop3);
}
public function opKnop3(e:Event):void {
removeChild(myKnop2);
myKnop3 = new Knop3();
myKnop3.x = 0;
myKnop3.y = 0;
addChild(myKnop3);
addEventListener(MouseEvent.MOUSE_UP, opKnop4);
}
public function opKnop4(e:Event):void {
removeEventListener(MouseEvent.MOUSE_UP, opKnop3);
removeChild(myKnop3);
myKnop4 = new Knop4();
myKnop4.x = 0;
myKnop4.y = 0;
addChild(myKnop4);
}
}
}
If I compile this, I just keep getting
ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.
at flash.display::DisplayObjectContainer/removeChild()
at Main/opKnop4()
But if I’m right, it’s in the right section?
I searched alot on this forum and google, but the cases where all different then mine.
With kind regards,
Rubenos