Hi,
I ran into this issue as well. I wrote a static eventhandler class:
package {
import flash.events.Event;
import flash.events.EventDispatcher;
public class StaticEventDispatcher {
protected static var disp:EventDispatcher;
public static function addEventListener(type:String, listener:Function,
useCapture:Boolean=false, priority:int=0, useWeakReference:Boolean=false):void {
if (disp == null) disp = new EventDispatcher();
disp.addEventListener(type, listener, useCapture, priority,
useWeakReference);
}
public static function removeEventListener(type:String,
listener:Function, useCapture:Boolean=false):void {
if (disp == null) return;
disp.removeEventListener(type, listener, useCapture);
}
public static function dispatchEvent(event:Event):void {
if (disp == null) return;
disp.dispatchEvent(event);
}
}
}
In the renderer:
<fx:Script>
<![CDATA[
import StaticEventDispatcher;
import spark.components.gridClasses.IGridItemRenderer;
private function onClick(event:MouseEvent):void {
do something...
StaticEventDispatcher.addEventListener(yourEvent.type,
doSomething);
}
private function doSomething(event:youEvent):void {
//you must remove the listener
StaticEventDispatcher.removeEventListener(yourEvent.type,
doSomething);
do something...
}
]]>
</fx:Script>
<s:Button id="buttonName" styleName="youStyle" click="onClick(event)" />
Hope it will help.
Robert
________________________________
From: Sumudu Chinthaka <[email protected]>
To: [email protected]
Sent: Monday, June 10, 2013 6:38 AM
Subject: Event Handling inside a custom ItemRenderer
hi
i have a list with a custom ItemRenderer with a button on it
when the button click inside a renderer i want to update all other
renderers with some specific value
so what i did was add a event listener and the handler inside the
itemrendere to response to button click event
this works fine for the items that are displayed on the screen
i think due to item renderer recycling what ever items that are not
displayed in the screen does not receive this event
as i scroll down the list i could see those items not being update and only
the top items of the list that were displayed on the screen updated
how can i force to update all items upon my event
thanks
Sumudu