So, I have a movieclip named “LoginScreen” with a instance inside called “confirmbutton”.
I want to add the LoginScreen to stage and set a event listener to the button inside it, but I keep getting an error.
This is my code:
var LoginScreen:loginscreen = new loginscreen;
LoginScreen.x = stage.stageWidth / 2;
LoginScreen.y = stage.stageHeight / 2;
addChild(LoginScreen);
LoginScreen.confirmbutton.addEventListener(MouseEvent.CLICK, test);
function test(e:MouseEvent):void{
trace("Sup?");
}
I get the error:
Symbol 'LoginScreen' 1046: Type was not found or was not a compile-time constant: confirmbutton.
I’m pretty sure it exists and its named properly (has that exact name without caps), so I’m guessing its probably a scope problem.
Try using a helper gettter function for getting the inner MovieClip. So where you defined the LoginScreen class put a simple getter function like this one:
Then you can access that MovieClip from the LoginScreen object like this: