his is how i had it work, sorry no wear near the FlexIDE till tommrrow so
pardon my mistakes
Main Component
<mx:Scrip>
private function initApp():void{
//name of the component in the dataGrid
this.DataGrid.addEventListener(DataGrid.CUSTOM_EVENT_BUBBLING,doWahtever)
</mx:script>
say u want a dataGrid
<mx:dataGrid id="DataGrid"...... ItemRenderer = "com.flexGroups.Item"/>
<mx:vbox>
This would be the com.FlexGroup.item
<mx:metaData>
[Event(name="CUSTOM_EVENT_BUBBLING")]
<mx:scrip>
private function dispatchCustom():void{
this.dispatchEvent(new Event("CUSTOM_EVENT_BUBBLING",true <---So u set this to
true, under bubbling)
</mx:script>
<mx:label text="{data.label}" click=dispatchCustom()/>
</mx:hbox>
----- Original Message ----
From: Troy Simpson <[EMAIL PROTECTED]>
To: [email protected]
Sent: Tuesday, September 11, 2007 6:39:22 PM
Subject: Re: [flexcoders] How to dispatch event from ItemRenderer?
Would you have an example of how to do this with the example code that I
provided?
I was thinking that I could listen for the click event on the radio buttons,
capture the event, and dispatch a new custom event.
Thanks,
On 9/11/07, Sheriff <[EMAIL PROTECTED] com> wrote:
have the event bubble from the itemRenderer, and that is about it. And listen
for it
----- Original Message ----
From: Troy Simpson <[EMAIL PROTECTED] com
>
To: [email protected]
Sent: Tuesday, September 11, 2007 3:40:27 PM
Subject: [flexcoders] How to dispatch event from ItemRenderer?
I have created a List with a custom ItemRenderer. The ItemRenderer creates a
label and two Radio Buttons for each item in the list. When one of the
RadioButtons is selected, how would I notify other components that the a radio
button was selected? Would I capture the click event in the ItemRenderer and
then dispatch it to the parent QuestionList Class or is there another way to do
this?
Here is an example of what I am trying to acomplish. Thanks.
Here is my QuestionList Class:
------------ ------
package
{
import mx.controls. List;
import mx.collections. ArrayCollection;
import mx.core.ClassFactor y;
public class QuestionList extends List
{
private var qItems:ArrayCollect ion;
public function QuestionList( )
{
//TODO: implement function
super();
this.qItems = new ArrayCollection( );
this.itemRenderer = new ClassFactory( ListItemRenderer );
addQItem("Are you tall?");
addQItem("Are you smart?");
addQItem("Are you quick?");
addQItem("Are you slow?");
this.dataProvider = this.qItems;
}
public function addQItem(s:String) :void
{
var o:Object = new Object();
o.label = s;
this.qItems. addItem(o) ;
}
}
------------ ----
ListItemRenderer Class:
------------ ------
package
{
import mx.containers. Canvas;
import mx.controls. RadioButton;
import mx.controls. Label;
import mx.controls. RadioButtonGroup ;
public class ListItemRenderer extends Canvas
{
private var lbl:Label;
private var rdoYes:RadioButton;
private var rdoNo:RadioButton;
private var rdoGrp:RadioButtonG roup;
//
public function ListItemRenderer( )
{
//TODO: implement function
super();
this.lbl = new Label();
this.rdoNo = new RadioButton( );
this.rdoNo.label = "No";
this.rdoNo.setStyle ("right",10);
this.rdoYes = new RadioButton( );
this.rdoYes. label = "Yes";
this.rdoYes. setStyle("right",60);
this.rdoGrp = new RadioButtonGroup( );
this.rdoNo.group = this.rdoGrp;
this.rdoYes. group = this.rdoGrp;
this.addChild
( this.lbl) ;
this.addChild( this.rdoYes) ;
this.addChild( this.rdoNo) ;
}
override public function set data(value:Object) :void
{
this.lbl.text = value.label;
}
}
}
------------ ------
--
Troy Simpson
Shape Yahoo! in your own image. Join our Network Research Panel today!
--
Troy Simpson
<!--
#ygrp-mkp{
border:1px solid #d8d8d8;font-family:Arial;margin:14px 0px;padding:0px 14px;}
#ygrp-mkp hr{
border:1px solid #d8d8d8;}
#ygrp-mkp #hd{
color:#628c2a;font-size:85%;font-weight:bold;line-height:122%;margin:10px 0px;}
#ygrp-mkp #ads{
margin-bottom:10px;}
#ygrp-mkp .ad{
padding:0 0;}
#ygrp-mkp .ad a{
color:#0000ff;text-decoration:none;}
-->
<!--
#ygrp-sponsor #ygrp-lc{
font-family:Arial;}
#ygrp-sponsor #ygrp-lc #hd{
margin:10px 0px;font-weight:bold;font-size:78%;line-height:122%;}
#ygrp-sponsor #ygrp-lc .ad{
margin-bottom:10px;padding:0 0;}
-->
<!--
#ygrp-mlmsg {font-size:13px;font-family:arial, helvetica, clean, sans-serif;}
#ygrp-mlmsg table {font-size:inherit;font:100%;}
#ygrp-mlmsg select, input, textarea {font:99% arial, helvetica, clean,
sans-serif;}
#ygrp-mlmsg pre, code {font:115% monospace;}
#ygrp-mlmsg * {line-height:1.22em;}
#ygrp-text{
font-family:Georgia;
}
#ygrp-text p{
margin:0 0 1em 0;}
#ygrp-tpmsgs{
font-family:Arial;
clear:both;}
#ygrp-vitnav{
padding-top:10px;font-family:Verdana;font-size:77%;margin:0;}
#ygrp-vitnav a{
padding:0 1px;}
#ygrp-actbar{
clear:both;margin:25px 0;white-space:nowrap;color:#666;text-align:right;}
#ygrp-actbar .left{
float:left;white-space:nowrap;}
.bld{font-weight:bold;}
#ygrp-grft{
font-family:Verdana;font-size:77%;padding:15px 0;}
#ygrp-ft{
font-family:verdana;font-size:77%;border-top:1px solid #666;
padding:5px 0;
}
#ygrp-mlmsg #logo{
padding-bottom:10px;}
#ygrp-vital{
background-color:#e0ecee;margin-bottom:20px;padding:2px 0 8px 8px;}
#ygrp-vital #vithd{
font-size:77%;font-family:Verdana;font-weight:bold;color:#333;text-transform:uppercase;}
#ygrp-vital ul{
padding:0;margin:2px 0;}
#ygrp-vital ul li{
list-style-type:none;clear:both;border:1px solid #e0ecee;
}
#ygrp-vital ul li .ct{
font-weight:bold;color:#ff7900;float:right;width:2em;text-align:right;padding-right:.5em;}
#ygrp-vital ul li .cat{
font-weight:bold;}
#ygrp-vital a{
text-decoration:none;}
#ygrp-vital a:hover{
text-decoration:underline;}
#ygrp-sponsor #hd{
color:#999;font-size:77%;}
#ygrp-sponsor #ov{
padding:6px 13px;background-color:#e0ecee;margin-bottom:20px;}
#ygrp-sponsor #ov ul{
padding:0 0 0 8px;margin:0;}
#ygrp-sponsor #ov li{
list-style-type:square;padding:6px 0;font-size:77%;}
#ygrp-sponsor #ov li a{
text-decoration:none;font-size:130%;}
#ygrp-sponsor #nc{
background-color:#eee;margin-bottom:20px;padding:0 8px;}
#ygrp-sponsor .ad{
padding:8px 0;}
#ygrp-sponsor .ad #hd1{
font-family:Arial;font-weight:bold;color:#628c2a;font-size:100%;line-height:122%;}
#ygrp-sponsor .ad a{
text-decoration:none;}
#ygrp-sponsor .ad a:hover{
text-decoration:underline;}
#ygrp-sponsor .ad p{
margin:0;}
o{font-size:0;}
.MsoNormal{
margin:0 0 0 0;}
#ygrp-text tt{
font-size:120%;}
blockquote{margin:0 0 0 4px;}
.replbq{margin:4;}
-->
____________________________________________________________________________________
Fussy? Opinionated? Impossible to please? Perfect. Join Yahoo!'s user panel
and lay it on us. http://surveylink.yahoo.com/gmrs/yahoo_panel_invite.asp?a=7