[as3] stage error.... i think

Subscribe to [as3] stage error.... i think 3 posts, 3 voices

Sign in to reply


 
avatar for Omrelap Omrelap 33 posts
Flag Post

im getting this error and i cant figure out why.

Discription:
1119: Access of possibly undefined property screenManager through a reference with static type flash.display:Stage.

Source:
stage.screenManager.changeScreens( new PregameMenu() , ScreenManager.FADE );

 
avatar for MyLuckyDay MyLuckyDay 112 posts
Flag Post

“screenManager” is not a property of Stage. You need to find another way to access it.

option 1: keep a reference to screenManager in your document class, then call it with


MovieClip(root).screenManagerReference.changeScreens(yada, yada);

of course this can only be called by a DisplayObject that is currently in the display list.

option 2: pass around a reference to screenManager when you instantiate your objects.

 
avatar for BillysGames BillysGames 25 posts
Flag Post

Well, I can see why stage.screenManager wouldn’t be defined. What even IS ScreenManager? is it a custom class of some sort? Even so, I would find it odd for an instance of it to be a property of the stage. More likely I would think you would either create a new instance of it in a variable, or it would be a static class where you just call all methods on the class itself.

That is,

var manager:ScreenManager = new ScreenManager();
manager.changeScreens( new PregameMenu() , ScreenManager.FADE );

or simply

ScreenManager.changeScreens( new PregameMenu() , ScreenManager.FADE );

edit: Slow billy is slow

Sign in to reply


Click Here