call a custom event from an item renderer in flex 4

Posted by john on Stack Overflow See other posts from Stack Overflow or by john
Published on 2010-06-17T17:29:08Z Indexed on 2010/06/17 17:33 UTC
Read the original article Hit count: 383

Filed under:
|

I have a Renderer:

[Event(name="addToCart",type="event.ProductEvent")]

  import mx.collections.ArrayCollection;


  protected function button1_clickHandler(event:MouseEvent):void
  {
    var eventObj:ProductEvent=new ProductEvent("addToCart",data.price,data.descript);

    dispatchEvent(eventObj);

  }
]]>

<s:Label text="{data.descript}"/>
<mx:Image source="{data.url}" width="50" height="50" width.hovered="100" height.hovered="100"/>
<s:Label text="{data.price}"/>
<s:Button includeIn="hovered" click="button1_clickHandler(event)" label="buy"/>

and the custom event class:

package events { import flash.events.Event; [Bindable] public class ProductEvent extends Event {

public var price:String;
public var descript:String;

public function ProductEvent(type:String,price:String, descript:String)
{
  super(type);
  this.price=price;
  this.descript=descript;
}
override public function clone():Event
{
  return new ProductEvent(type,price,descript);

}

} }

but a cannot call that event in :

any ideas?

thanks

© Stack Overflow or respective owner

Related posts about flex4

Related posts about as3