用haXe 代码生成flash(flash7_AS2 API)

Main.hx:
package ;

import flash.MovieClip;
import flash.Lib;

class Main
{
	private var mc:MovieClip;
	
	static function main()
	{
		new Main();
	}
	
	public function new()
	{
		new data.GData(flash.Lib.current);
		mc = flash.Lib.current;

		var tmc:MovieClip = mc.createEmptyMovieClip("s1_", mc.getNextHighestDepth());
		tmc._x = tmc._y = 20;
		
		tmc.lineStyle(1,0xFF0000,100);
		tmc.lineTo(200,150);
	}
	
}


data/GData.hx:
package data;

import flash.MovieClip;
import flash.Stage;

/**
 * 单例模式, 保存全局变量
 * _inst: 返回实例
 * _stg: 返回_root
 */
class GData
{
	public static var _inst:GData = null;

	public var _stg:MovieClip; // Stage

	public function new(root:MovieClip)
	{
		if(_inst!=null)
		{
			trace("Error: GData init2.");
		}
		_stg = root;
		
		Stage.scaleMode = "noScale";
		Stage.align = "TL";

		_inst = this;
	}
}


compile.hxml:
# Flash
-swf main.swf
-swf-version 7
-main Main
-swf-header 240:320:20:FFFFFF
--no-traces

你可能感兴趣的:(Flash)