Return to Snippet

Revision: 12063
at February 28, 2009 20:04 by vip4lyf


Updated Code
package {
	/*  Imports  */
	import flash.display.Sprite;
	import com.OtherClass;
	
	public class Main extends Sprite {
		/*  Private Properties  */
		private static var _instance:Main;
		private var otherClass:OtherClass;
		
		/*  Constructor  */
		public function Main() {
			_instance = this;
			otherClass = new OtherClass();
		}
		
		/*  Public Methods  */
		public static function get instance():Main { 
			return _instance; 
		}

	}
}

/************       ***************/

package com {
	/*  Imports  */
	import flash.display.Sprite;
	public class OtherClass {
		/*  Private Properties  */
		private var _dc:Sprite;
		private var _sh:uint;
		private var _sw:uint;	
		/*  Constructor  */
		public function OtherClass() {
			_dc = Main.instance;
			_sh = _dc.stage.stageHeight;
			_sw = _dc.stage.stageWidth;
		}
	}
}

Revision: 12062
at February 28, 2009 19:56 by vip4lyf


Initial Code
package {
	/*  Imports  */
	import flash.display.Sprite;
	import com.OtherClass;
	
	public class Main extends Sprite {
		/*  Private Properties  */
		private static var _instance:Main;
		private var otherClass:OtherClass;
		
		/*  Public Properties  */
		
		/*  Constructor  */
		public function Main() {
			_instance = this;
			otherClass = new OtherClass();
		}
		

		
		/*  Public Methods  */
		public static function get instance():Main { 
			return _instance; 
		}

	}
}

//
package com {
	/*  Imports  */
	import flash.display.Sprite;
	public class OtherClass {
		/*  Private Properties  */
		private var _dc:Sprite;
		private var _sh:uint;
		private var _sw:uint;	
		/*  Constructor  */
		public function OtherClass() {
			_dc = Main.instance;
			_sh = _dc.stage.stageHeight;
			_sw = _dc.stage.stageWidth;
		}
	}
}

Initial URL

                                

Initial Description

                                

Initial Title
AS3 - How to access the Document Class from another class

Initial Tags

                                

Initial Language
ActionScript 3