RE: [flexcoders] Cannot assign selected value from a radiobutton that was created dynamically.

2005-08-18 Thread Matt Chotin










addEventListener(click, mx.utils.Delegate.create(this,
clickRadioButton);











From: flexcoders@yahoogroups.com [mailto:flexcoders@yahoogroups.com] On Behalf Of [EMAIL PROTECTED]
Sent: Tuesday, August 16, 2005
12:23 PM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Cannot
assign selected value from a radiobutton that was created dynamically.







I am creating radioButtons dynamically using an
array. When I try to
assign the selected value into a Text or TextArea
it doesn't work. It seems
that I am using addEventListener correctly since I
am able to see the
event.target.data in an Alert.

 This application shows what I mean:

1. The radiobuttons are created out of an array.
2. When you click on any of them you get an Alert
showing the data you
have clicked. However, it doesn't change the text
of the TextArea.
Eventually I want to assign this value, to some
place else.
3. If you execute the same code
txtReceipt.text=Button - by clicking on
the Button it does change the text.

the code below is runnable and shows the problem
...

Thanks 

?xml version=1.0
encoding=utf-8?

mx:Application xmlns:mx=http://www.macromedia.com/2003/mxml

 mx:Script
 ![CDATA[

 public
var arrayList:Array= new Array();


 private
function getmyList(): Void
 {
 arrayList[0]=item1;

arrayList[1]=item2;

arrayList[2]=item3;

addElement();
 }

 // Add
radiobuttons dynamically
public function addElement() {
 var
totalOptions:Number = arrayList.length;

var isSelected:Boolean;

//mx.controls.Alert.show(String(totalOptions),Total Options);
 for(var
i:Number=0;itotalOptions;i++) {

if (i==0) // Selects the first Radio Button

isSelected=true

else

isSelected=false

receiptHBox.createChild(mx.controls.RadioButton, undefined,
{label:item+i ,
data:item+i ,groupName:group1 ,selected:isSelected}
).addEventListener(click,clickRadioButton);

 }
 }
 public function
clickRadioButton(event)
 {

txtReceipt.text=event.target.data; // This doesn't work

mx.controls.Alert.show(event.target.data,Test); // But the
the data is there .

 }
 public function
changeText()
 {

txtReceipt.text=Button;
 }


 ]]
 /mx:Script



 mx:TextArea
id=txtReceipt /
 mx:HBox
id=receiptHBox initialize=getmyList()

!-- Radio buttons are created dynamically --
 /mx:HBox

 mx:Button
label=Button click=changeText()/


 /mx:Application



---
This e-mail message (including attachments, if
any) is intended for the use
of the individual or entity to which it is
addressed and may contain
information that is privileged, proprietary ,
confidential and exempt from
disclosure. If you are not the intended
recipient, you are notified that
any dissemination, distribution or copying of this
communication is
strictly prohibited. If you have received
this communication in error,
please notify the sender and erase this e-mail
message immediately.
---












--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com





  




  
  
  YAHOO! GROUPS LINKS



  Visit your group "flexcoders" on the web.
  To unsubscribe from this group, send an email to:[EMAIL PROTECTED]
  Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.



  











RE: [flexcoders] Cannot assign selected value from a radiobutton that was created dynamically.

2005-08-18 Thread Oscar . Cortes


Thanks, this worked. I will read more about EventListener and Delegate



   

   
 Matt Chotin To: flexcoders@yahoogroups.com   
   
 [EMAIL PROTECTED]  cc:   
  
 Sent by:  Subject:  RE: [flexcoders] 
Cannot assign selected value from a  
 flexcoders@yahoogroups.com  radiobutton that was created 
dynamically. 
 08/18/2005 02:33 AM
   
 Please respond to  
   
 flexcoders 
   

   

   




addEventListener(click, mx.utils.Delegate.create(this, clickRadioButton);


From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of [EMAIL PROTECTED]
Sent: Tuesday, August 16, 2005 12:23 PM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Cannot assign selected value from a radiobutton that
was created dynamically.



I am creating radioButtons dynamically using an array. When I try to
assign the selected value into a Text or TextArea it doesn't work. It seems
that I am using addEventListener correctly since I am able to see the
event.target.data in an Alert.

  This application shows what I mean:

1. The radiobuttons are created out of an array.
2. When you click on any of them you get an Alert showing the data you
have clicked. However, it doesn't change the text of the TextArea.
Eventually I want to assign this value, to some place else.
3. If you execute the same code  txtReceipt.text=Button - by clicking on
the Button it does change the text.

the code below is runnable and shows the problem ...

Thanks 

?xml version=1.0 encoding=utf-8?

mx:Application xmlns:mx=http://www.macromedia.com/2003/mxml; 
mx:Script
![CDATA[

 Yahoo! Groups Sponsor ~-- 
font face=arial size=-1a 
href=http://us.ard.yahoo.com/SIG=12h750kns/M=362335.6886445.7839731.1510227/D=groups/S=1705007207:TM/Y=YAHOO/EXP=1124384081/A=2894361/R=0/SIG=13jmebhbo/*http://www.networkforgood.org/topics/education/digitaldivide/?source=YAHOOcmpgn=GRPRTP=http://groups.yahoo.com/;In
 low income neighborhoods, 84% do not own computers. At Network for Good, help 
bridge the Digital Divide!/a./font
~- 

--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com 
Yahoo! Groups Links

* To visit your group on the web, go to:
http://groups.yahoo.com/group/flexcoders/

* To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]

* Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/