Hello!
I’ve done a very simple fullscreen test application which worked while everything was in the document class. Now I want to try having the fullscreenswitch-code in an external class but I get an “1120: Access of undefined property stage.” error.
Sorry if this is a really dumb question (I’m new to flash/as3/and the process of working with classes) but how do you access stage from an external class? :puzzled:
This is the document class
package com {
import flash.display.Stage;
import flash.events.Event;
import flash.display.StageScaleMode;
import flash.display.StageAlign;
import flash.display.MovieClip;
import flash.text.TextField;
import flash.text.TextFieldAutoSize;
import flash.events.TextEvent;
import com.FullscreenSwitch;
public class FullscreenTest extends MovieClip {
// Constants:
// Public Properties:
public var txtFullscreen:TextField = new TextField();
// Private Properties:
// Initialization:
public function FullscreenTest() {
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;
txtFullscreen.multiline = true;
txtFullscreen.autoSize = TextFieldAutoSize.LEFT;
txtFullscreen.htmlText = "<p><a href='event: aaaaaa'>Fullscreen</a></p>";
txtFullscreen.x = 12;
txtFullscreen.y = 12;
addChild(txtFullscreen);
txtFullscreen.addEventListener(TextEvent.LINK, FullscreenSwitch);
}
}
}
And this is the fullscreenSwitch which is called upon from the documentclass
package com {
import flash.display.Stage;
public class FullscreenSwitch extends MovieClip{
// Constants:
// Public Properties:
// Private Properties:
// Initialization:
public function FullscreenSwitch() {
switch(stage.displayState) {
case "normal":
stage.displayState = "fullScreen";
break;
case "fullScreen":
default:
stage.displayState = "normal";
break;
}
}
// Public Methods:
// Protected Methods:
}
}
http://www.kirupa.com/forum/showthread.php?p=1952513 seems to be the solution to the problem but I’m not sure how to explicitly give a reference to a non-display object classes…