Skip to content

Instantly share code, notes, and snippets.

@wouterds
Created December 9, 2012 14:00
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save wouterds/4245010 to your computer and use it in GitHub Desktop.
Vb navigation via AppModel
/**
* Created with IntelliJ IDEA.
* User: WouterDS
* Date: 19/11/12
* Time: 23:43
* To change this template use File | Settings | File Templates.
*/
package be.wouterds.cubetester.model {
import flash.events.Event;
import flash.events.EventDispatcher;
public class AppModel extends EventDispatcher {
/************************************
* Properties
************************************/
private static var instance:AppModel;
private var _showNavigation:Boolean = false;
private var _navigationAnimation:Boolean = false;
public static const NAVIGATION_VISIBILITY_CHANGED:String = "navigationVisibilityChanged";
/************************************
* Methods
************************************/
public static function getInstance():AppModel {
if(instance == null) {
trace("[AppModel.getInstance] Creating AppModel instance");
instance = new AppModel(new Enforcer());
}
return instance;
}
public function AppModel(e:Enforcer):void {
if(e == null)
throw new Error("AppModel is a Singleton.");
}
/************************************
* Handlers
************************************/
/************************************
* Getters & Setters
************************************/
public function get showNavigation():Boolean {
return _showNavigation;
}
public function set showNavigation(value:Boolean):void {
if(_showNavigation !== value && !navigationAnimation) {
_showNavigation = value;
navigationAnimation = true;
dispatchEvent(new Event(NAVIGATION_VISIBILITY_CHANGED));
}
}
public function get navigationAnimation():Boolean {
return _navigationAnimation;
}
public function set navigationAnimation(value:Boolean):void {
if(_navigationAnimation !== value)
_navigationAnimation = value;
}
}
}
// Trick for Singletons in AS3
internal class Enforcer {};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment