[haXe] accessing the current Stage in Flash v9

Thomas D'Urso tjdurso at mindspring.com
Mon Sep 11 22:11:38 CEST 2006


I am attempting to access the Stage in Flash v9 but am stuck.
The goal is to access/set these property in the (current) stage:

flash.display.Stage.align
flash.display.Stage.scaleMode
flash.display.Stage.height
flash.display.Stage.width

----------

according to:

http://livedocs.macromedia.com/flex/2/langref/flash/display/DisplayObject.html#stage

class flash.display has a property: flash.display.stage (read only)

and Strite and MovieClip classes are subclasses to flash.display

----------

Here are some interesting links about Stage & the Flash9 display 
architecture).

http://livedocs.macromedia.com/flex/2/docs/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts&file=00001850.html

http://livedocs.macromedia.com/flex/2/docs/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts&file=00001851.html#137132

http://livedocs.macromedia.com/flex/2/docs/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts&file=00001853.html#138725

----------

The TestSprite and TestMC classes, in the test code, are based on the 
example found on the bottom of:
http://livedocs.macromedia.com/flex/2/langref/flash/display/Stage.html

Tested with Haxe 1.0.7.


class TestClass {

     static function main() {

		trace("starting program");

     	new Test2();

		trace("ending program");		
	}
	
	
	public function new () : Void {
	
		// these 2 lines do not compile (leason learned, need to create an 
object):
		
		// flash.display.Stage.align = StageAlign.TOP_LEFT;
		// flash.display.Stage.scaleMode = flash.display.StageScaleMode.NO_SCALE;

		// these lines compile but do not execute:
		
		//  new flash.display.Stage();
		//  var temp : flash.display.Stage = new flash.display.Stage();
		//  temp.scaleMode = flash.display.StageScaleMode.NO_SCALE;
		//  temp.align = flash.display.StageAlign.TOP_LEFT;

		new TestSprite();				
		new TestMC();				

	}
}



class TestMC extends flash.display.MovieClip {	
	
	public function new () : Void {
	
		super();
		
		trace("start TestMC ");	
		trace(" ~ " + flash.display.StageScaleMode.NO_SCALE);	//  prints out: 
"... ~ noScale"

		// these lines compile but do not execute:

		// trace(" ~~ " + stage.scaleMode);	
		// trace(" ~~ " + this.stage.scaleMode);			
		// this.stage.scaleMode = flash.display.StageScaleMode.NO_SCALE;
		// stage.scaleMode = flash.display.StageScaleMode.NO_SCALE;

		trace("TestMC works");			
	}
}


class TestSprite extends flash.display.Sprite {	
	
	public function new () : Void {
	
		super();
		
		trace("start TestSprite ");	
		
		trace(" * " + flash.display.StageScaleMode.NO_SCALE);	//  prints out: 
"... * noScale"

		// these lines compile but do not execute:

		// trace(" ** " + this.stage.scaleMode);			
		// this.stage.scaleMode = flash.display.StageScaleMode.NO_SCALE;
		// stage.scaleMode = flash.display.StageScaleMode.NO_SCALE;

		trace("TestSprite works");			
	}
}





More information about the Haxe mailing list