Created
February 7, 2010 11:49
-
-
Save usagi/297390 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package | |
{ | |
import flash.events.Event; | |
import flash.events.MouseEvent; | |
import flash.net.URLRequest; | |
import flash.display.Loader; | |
import flash.display.DisplayObject; | |
import flash.display.Sprite; | |
import flash.display.MovieClip; | |
public class Sample_Includer | |
extends MovieClip | |
{ | |
protected static const default_external_swf_path: String = "hogehoge.swf"; | |
protected var count: int = 0; | |
protected function load_external_swf(external_swf_path: String = default_external_swf_path): void | |
{ | |
trace("load_external_swf: begin"); | |
while (numChildren) | |
removeChildAt(0); | |
var loader: Loader = new Loader(); | |
loader.contentLoaderInfo.addEventListener( | |
Event.COMPLETE, | |
function (event: Event): void | |
{ | |
trace("load_external_swf -> loader_complete: begin"); | |
loader.removeEventListener(Event.COMPLETE, arguments.callee); | |
var child: * = event.currentTarget.content as DisplayObject; | |
trace("=== What's type of the external swf ==="); | |
trace(child); | |
trace("is DisplayObject?", child is DisplayObject); | |
trace("is Sprite?", child is Sprite) | |
trace("is MovieClip?", child is MovieClip); | |
trace("======================================="); | |
child.addEventListener( | |
Event.ADDED_TO_STAGE, | |
function(event: Event): void | |
{ | |
trace("load_external_swf -> loader_complete -> added_to_stage: begin"); | |
var mc: * = event.currentTarget; | |
//* | |
mc.navi_mc.x = (stage.stageWidth - mc.navi_mc.width) / 2; | |
mc.navi_mc.y = stage.stageHeight - 50; | |
mc.bottom_bar.width = stage.stageWidth; | |
mc.bottom_bar.x = stage.stageWidth / 2; | |
mc.bottom_bar.y = stage.stageHeight - 60; | |
mc.help_mc.x = stage.stageWidth / 2 + 55; | |
mc.help_mc.y = stage.stageHeight - 213; | |
//*/ | |
trace("load_external_swf -> loader_complete -> added_to_stage: end"); | |
} | |
); | |
addChild(child); | |
trace("load_external_swf -> loader_complete: end"); | |
} | |
); | |
loader.load(new URLRequest(default_external_swf_path)); | |
trace("load_external_swf: end"); | |
} | |
protected function on_stage_mouse_click(event: MouseEvent): void | |
{ | |
trace("on_stage_mouse_click: begin"); | |
load_external_swf(); | |
trace("on_stage_mouse_click: end"); | |
} | |
protected function on_added_to_stage(event: Event): void | |
{ | |
trace("on_added_to_stage: begin"); | |
stage.addEventListener(MouseEvent.CLICK, on_stage_mouse_click); | |
trace("on_added_to_stage: end"); | |
} | |
public function Sample_Includer(external_swf_path: String = default_external_swf_path) | |
{ | |
trace("Simple_Include: begin"); | |
addEventListener(Event.ADDED_TO_STAGE, on_added_to_stage); | |
trace("Simple_Include: end"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment