// forked from ppc's forked from: 外部SWFからのクラス定義の取り出し // forked from mtok's 外部SWFからのクラス定義の取り出し /* fetch class definition from external swf author: motoki matsumoto email: mtmotoki(at)gmail.com */ package { import flash.text.TextField; import flash.display.*; import flash.events.*; import flash.net.URLRequest; import flash.system.ApplicationDomain; import flash.utils.getQualifiedClassName; [SWF(width="465", height="465", backgroundColor="0x000000", frameRate="24")] public class DynamicClassLoading extends MovieClip { private var output:TextField; private var avatar:Loader; private var _textField : TextField = new TextField(); public function DynamicClassLoading() { initOutput(); println('Construct ' + getQualifiedClassName(this)); addEventListener(Event.ADDED_TO_STAGE, addedToStage); addEventListener(MouseEvent.CLICK, clickHandler); _textField.wordWrap = true; _textField.textColor = 0xffffff; _textField.border = true; _textField.borderColor = 0x888800 _textField.textColor = 0xffffff; _textField.selectable = false; _textField.width = 445; _textField.height = 100; _textField.x = 10; _textField.y = 350; _textField.text = ""; addChild(_textField); } public function init():void { avatar = new Loader(); var req:URLRequest = new URLRequest("http://www23.tok2.com/home/ppc/avatar.swf"); //var req:URLRequest = new URLRequest("http://img.atgames.jp/event/campaign/200904/img/090403_ohanamiCP/01.swf"); avatar.load(req); avatar.contentLoaderInfo.addEventListener(Event.COMPLETE, completeHandler); } private function completeHandler(e:Event):void { addChild(avatar); avatar.x = 100; avatar.y = 100; _textField.appendText(avatar.contentLoaderInfo.contentType + "\n"); if(avatar.contentLoaderInfo.contentType == "application/x-shockwave-flash") { _textField.appendText("version:" + avatar.contentLoaderInfo.swfVersion.toString() + "\n"); } _textField.appendText("hoge"); //avatar.content.avatar.sit(); } private function clickHandler(event:MouseEvent):void { //avatar.sit(); } private function addedToStage(e:Event):void { removeEventListener(e.type, arguments.callee); stage.scaleMode = StageScaleMode.NO_SCALE; stage.align = StageAlign.TOP_LEFT; init(); } //////////////// // 出力 /////////////// private function initOutput():void { var margin:Number = 10; addChild(output = new TextField()); output.selectable = false; output.multiline = true; output.width = stage.stageWidth - margin * 2; output.height = stage.stageHeight - margin * 2; } public function print(... args):void { output.appendText(args.join(", ")); } public function println(... args):void { output.appendText(args.join(", ")); output.appendText("\n"); } } } forked from: forked from: 外部SWFからのクラス定義の取り出し