Instructions

An Instruction is a custom event that is able to bubble and bring with him information like

  • any kind of parameters
  • the component from which it has been dispatched (i.e. the origin)

A sample instruction is implemented like the following class

package com.gnstudio.rikorda.templateditor.instructions
{
	import com.gnstudio.nabiro.mvp.instructions.Instruction;
	import flash.events.IEventDispatcher;
        import flash.events.Event;

	public class SampleInstruction extends Instruction
	{
		
		public static const DO_HANDLE:String = "onSampleInstruction";
		

		public function SampleInstruction(o:IEventDispatcher, params:*=null, bubbles:Boolean=true, cancelable:Boolean=false){

			super(o, DO_HANDLE, params, bubbles, cancelable);

		}

		override public  function clone():Event {

			return new SampleInstruction(origin, parameters);

		} 
		
	}
}


Remember to add a null variable with the Instruction data type to your mapper in order to avoid that the build generate an exception due to the lack of the class

/**
 * Compsition bugs fix.
 */
 private var sampleInstruction:SampleInstruction; 


An Instruction is sent to the event bus with a simple dispatch operation

dispatchEvent(new TemplateEditorInstructionEvent("SampleInstruction"));


And a component that have to react to the instruction has to implement the IMapperCandidate empty interface and have a listener for the instruction defined

addEventListener(SampleInstruction.DO_HANDLE, onSampleInstruction);


1.1.2-pro © 2008-2009 agile42 all rights reserved (this page was served in: 0.31000 sec.)