Archive for the ‘ Cairngorm View Listner ’ Category

Cairngorm Command Result Dispatching Event to View

Cairngorm !!!!!!!!! I am New It and was looking for listening event in view to change style of my flex application, after lot of trying i found out its fairly simple.

Write on the top of command:

[Event(name=”enableChange”, type=”com.adobe.cairngorm.control.CairngormEvent”)]

Result Method of Command:

public function result(data:Object):void
{
var e:CairngormEvent=new CairngormEvent(“enableChange”);
CairngormEventDispatcher.getInstance().dispatchEvent(e);
}

Listen for that in a view :



height=”100%”
creationComplete=”creationComplete()”
layout=”absolute” backgroundGradientAlphas=”[1.0, 1.0]”
backgroundGradientColors=”[#FFFFFF, #FFFFFF]”
xmlns:components=”components.*”
xmlns:business=”business.*”
xmlns:view=”view.*”
xmlns:control=”control.*”>

<!–[CDATA[
import com.adobe.cairngorm.control.CairngormEventDispatcher;
import mx.controls.Alert;
import com.adobe.cairngorm.control.CairngormEvent;

import flash.events.Event;


private function creationComplete ():void {
CairngormEventDispatcher.getInstance().addEventListener(“enableChange”, enableChangedListener);
}



public function enableChangedListener(eventOb:CairngormEvent):void {
Alert.show(“Event Fired”, “Catch”);
// Handle event.
}


]]–>
import com.adobe.cairngorm.control.CairngormEventDispatcher;
import mx.controls.Alert;
import com.adobe.cairngorm.control.CairngormEvent;

import flash.events.Event;

private function creationComplete ():void {
CairngormEventDispatcher.getInstance().addEventListener(“enableChange”, enableChangedListener);
}

public function enableChangedListener(eventOb:CairngormEvent):void {
Alert.show(“Handle Event”, “Catch”);
// Handle event.
}