Skip to content

Instantly share code, notes, and snippets.

@davidortinau
Created May 30, 2011 14:43
Show Gist options
  • Save davidortinau/998990 to your computer and use it in GitHub Desktop.
Save davidortinau/998990 to your computer and use it in GitHub Desktop.
AS3 AIR Application w/ Swiz and NativeWindow
package {
// imports removed for brevity
import org.swizframework.core.BeanProvider;
import org.swizframework.core.ISwiz;
import org.swizframework.core.ISwizAware;
import org.swizframework.core.Swiz;
import org.swizframework.core.SwizConfig;
[SWF(width='1080', height='1920', backgroundColor='0xFFFFFF', frameRate='30')]
public class PGESaveKiosk extends Sprite
{
[Inject]
public var languageController:LanguageController;
[Inject]
public var model:AppModel;
[Inject]
public var service:ConfigService;
[Inject]
public var subscriptionManager:SubscriptionManager;
public var mainWindow:NativeWindow;
public var idleView:IdleView;
public var mainView:MainView;
public var currentIView:IView;
public var destinationIView:IView;
// swiz bits
private var mp : MediateSignalProcessor;
private var config : SwizConfig;
private var cp : Array;
private var bp : BeanProvider;
private var swiz : Swiz;
public function PGESaveKiosk()
{
configureSwiz();
init();
}
protected function configureSwiz():void
{
mp = new MediateSignalProcessor();
mp.signalPackages = [ "com.app.control.signals" ];
cp = [ mp ];
config = new SwizConfig();
config.viewPackages = [ "", "com.app.views", "com.app.views.components","com.app.views.modals" ];
var beans:Array = [];
beans.push( new AppModel() );
beans.push( new LanguageController() );
beans.push( new ConfigService() );
beans.push( new DataService() );
// signals
beans.push( new LogAnalyticsSignal() );
bp = new BeanProvider( beans );
swiz = new Swiz(this, config, null, [bp], cp);
swiz.init();
}
protected function init(event:Event=null):void
{
model.currentLanguage = Constants.LANGUAGE_EN;
mainWindow = new NativeWindow(new NativeWindowInitOptions());
mainWindow.activate();
mainWindow.addEventListener(Event.CLOSE, function():void {
NativeApplication.nativeApplication.exit(0);
});
swiz.registerWindow(mainWindow);
mainWindow.stage.addChild(this);
}
// removed a bunch of other setup
protected function draw():void
{
background = BackgroundAsset(mainWindow.stage.addChild(new BackgroundAsset()));
mainView = MainView(mainWindow.stage.addChild(new MainView()));
mainView.visible = false;
}
// removed other unrelated code
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment