views:

73

answers:

2

Hello.

I'm trying to get a projector file to run full screen when it starts, without needing to click anything. My main class inherits from MovieClip, so as far as I can tell I get access to stage... yeah right :)

package
{
    import flash.display.MovieClip;
    import flash.events.MouseEvent;
    import flash.display.StageDisplayState;
    import flash.display.Stage;
    import flash.ui.Mouse;


    public class PhoneDemo extends MovieClip
    {
        Stage.displayState=StageDisplayState.FULL_SCREEN;
        //declare variables
        public var scoreArray:Array = [null];

This simply doesn't work, I can't gain access to stage, I get error 1120. I'm sure I've gained access to the stage before, I'm really confused.

+2  A: 

stage is a property of DisplayObject; Stage is the class.

Try accessing it in lowercase instead. Also, if you access the stage in the constructor it won't have been assigned yet.

Richard Szalay
+1  A: 
public class PhoneDemo extends MovieClip{
   addEventListener(Event.ADDED_TO_STAGE, addedToStage);
   // you cannot access the stage here, because the stage relation has not been established
}

internal function addedToStage(e:Event){
    removeEventListener(Event.ADDED_TO_STAGE, addedToStage);
    // you  can access the stage here
}
Daniel