股墓山庄

专注于AS3,JavaScript 每天一点进步,坚持...
  博客园  :: 首页  :: 新随笔  :: 联系 :: 管理

反射完整代码

Posted on 2012-03-21 17:30  股墓山庄庄主  阅读(211)  评论(0编辑  收藏  举报
package {
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.net.URLRequest;
	import flash.system.ApplicationDomain;
	import flash.display.MovieClip;
	import flash.display.Loader;
	public class SampleLoadSWF extends Sprite {
		private const FILE_PATH:String="2008-4.swf";
		private const CLASS_NAME:String="Ball";//这里是swf中库元件链接名
		private var loader:Loader;
		private var _request:URLRequest;
		public function SampleLoadSWF() {
			loader=new Loader();
			_request=new URLRequest(FILE_PATH);
			loader.contentLoaderInfo.addEventListener(Event.COMPLETE,onComplete);
			loader.load(_request);
		}
		private function onComplete(event:Event):void {
			var loadedSWF=event.target;
			var domain:ApplicationDomain=loadedSWF.applicationDomain as ApplicationDomain;
			var BallClass:Class=domain.getDefinition(CLASS_NAME) as Class;
			var ballA:MovieClip=(new BallClass()) as MovieClip;
			var ballB:MovieClip=(new BallClass()) as MovieClip;
			ballA.x=0,ballA.y=100;
			ballB.x=100,ballB.y=100;
			ballB.scaleX=2;
			addChild(ballA);
			addChild(ballB);

		}
	}
}