Created
March 26, 2014 13:23
-
-
Save matt-curtis/9783030 to your computer and use it in GitHub Desktop.
Application Subclass for...switching between application instances...
This file contains hidden or 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 mx.controls.SWFLoader; | |
import mx.core.Application; | |
import mx.managers.SystemManager; | |
public class AppSwitcher extends Application | |
{ | |
public var appLoader:SWFLoader; | |
public function AppSwitcher() | |
{ | |
super(); | |
// Visual stuff, no preloader, removing padding, set background color... | |
this.usePreloader = false; | |
var style:Object = | |
{ paddingTop: 0, paddingBottom: 0, paddingRight: 0, paddingLeft: 0, | |
backgroundColor: "#D6D6D6", backgroundImage: "none" }; | |
for(var prop in style) setStyle(prop, style[prop]); | |
// Create event listener for preInit | |
appLoader = new SWFLoader(); | |
appLoader.percentWidth = appLoader.percentHeight = 100; | |
appLoader.visible = false; | |
appLoader.addEventListener(Event.COMPLETE, function():void { | |
//Otherwise we see an incomplete version of the SWF, before it's ready... | |
SystemManager(appLoader.content).addEventListener("applicationComplete", function():void { | |
appLoader.callLater(function():void { appLoader.visible = true; }); | |
}); | |
}); | |
this.addChild(appLoader); | |
} | |
} | |
} |
This file contains hidden or 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
<?xml version="1.0" encoding="utf-8"?> | |
<local:AppSwitcher xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:local="*" preinitialize="appInit()"> | |
<mx:Script> | |
<![CDATA[ | |
public function appInit():void { | |
// Switch between applications here... | |
this.appLoader.load("FileExplorer.swf"); | |
} | |
]]> | |
</mx:Script> | |
</local:AppSwitcher> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment