Skip to content

Instantly share code, notes, and snippets.

@matt-curtis
Created March 26, 2014 13:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matt-curtis/9783030 to your computer and use it in GitHub Desktop.
Save matt-curtis/9783030 to your computer and use it in GitHub Desktop.
Application Subclass for...switching between application instances...
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);
}
}
}
<?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