Return to Snippet

Revision: 30675
at August 19, 2010 04:15 by derrekwayne


Updated Code
package com.neonsunburst {
	
	import flash.events.*;
	
	public class Controller {
		
		var model:Model;
		
		public function Controller (aModel:Model)
		{
			model= aModel;
			model.addEventListener(Event.CHANGE, update);
			if (model.hasEventListener(Event.CHANGE)) { trace ("Event.CHANGE regestered in controller"); };

		}

			public function forward() : void { // VIEW GESTURE IN
				if (model.getCurrentPage() == model.getTotalPages()) { model.setCurrentPage(1); }
				else { model.setCurrentPage(model.getCurrentPage() + 1 ); }
			}
			
			public function backward() : void { // VIEW GESTURE IN
				if (model.getCurrentPage() == 1) { model.setCurrentPage( model.getTotalPages() ); }
				else { model.setCurrentPage( model.getCurrentPage() - 1 ); }
			}
	}
}

Revision: 30674
at August 19, 2010 04:12 by derrekwayne


Initial Code
package com.neonsunburst {
	
	import flash.events.*;
	
	public class Controller {
		
		var model:Model;
		
		public function Controller (aModel:Model)
		{
			//model= new Model();
			model= aModel;
			model.addEventListener(Event.CHANGE, update);
			if (model.hasEventListener(Event.CHANGE)) { trace ("Event.CHANGE regestered in controller"); };

		}

			public function forward() : void { // VIEW GESTURE IN
				if (model.getCurrentPage() == model.getTotalPages()) { model.setCurrentPage(1); }
				else { model.setCurrentPage(model.getCurrentPage() + 1 ); }
			}
			
			public function backward() : void { // VIEW GESTURE IN
				if (model.getCurrentPage() == 1) { model.setCurrentPage( model.getTotalPages() ); }
				else { model.setCurrentPage( model.getCurrentPage() - 1 ); }
			}
			
			//// UPDATE FROM MODEL ////
			public function update(event:Event) : void {
				//trace (this + " model updated");
			}
	}
}

Initial URL
neonsunburst.com

Initial Description
The Controller class handles user gestures through navigation logic and updates the Model.

Initial Title
Neonsunburst Controller Class

Initial Tags
actionscript

Initial Language
ActionScript 3