I have been trying
to dynamically create RadioButtonGroup (due to the problem I posted earlier). I
managed to create the group but getting access to the RadioButtonGroup object
seems to be quite hard. I create the group during initialize event,
but when I try to access the group, it seems to be totally different object. For
example, if I set id property for the group during initialization it has
disappeared when accessed later.
Here's some
sample code demonstrating the problem:
RadioProblem.mxml:
<?xml
version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml"
xmlns:my="*">
<my:RadioGroup width="500" height="200"/>
</mx:Application>
<mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml"
xmlns:my="*">
<my:RadioGroup width="500" height="200"/>
</mx:Application>
RadioGroup.as:
import
mx.controls.*;
import mx.containers.*;
import mx.containers.*;
class RadioGroup
extends Panel
{
public var radioTrue;
public var radioFalse;
public var radioUnknown;
public var radioGroup;
public var label1;
public var label2;
public function RadioGroup()
{
super();
addEventListener( "initialize", mx.utils.Delegate.create( this, onInitialization ) );
addEventListener( "creationComplete", mx.utils.Delegate.create( this, onCreationComplete ) );
}
private function onInitialization()
{
var id:String = getId();
radioGroup = createChild( RadioButtonGroup, undefined, { id:id } );
radioTrue = createChild( RadioButton, undefined, { groupName:id, id:"radioTrue", marginRight:20 } );
radioFalse = createChild( RadioButton, undefined, { groupName:id, id:"radioFalse", marginRight:20 } );
radioUnknown = createChild( RadioButton, undefined, { groupName:id, id:"radioUnknown", marginRight:20 } );
label1 = createChild( Label, undefined, {} );
label2 = createChild( Label, undefined, {} );
{
public var radioTrue;
public var radioFalse;
public var radioUnknown;
public var radioGroup;
public var label1;
public var label2;
public function RadioGroup()
{
super();
addEventListener( "initialize", mx.utils.Delegate.create( this, onInitialization ) );
addEventListener( "creationComplete", mx.utils.Delegate.create( this, onCreationComplete ) );
}
private function onInitialization()
{
var id:String = getId();
radioGroup = createChild( RadioButtonGroup, undefined, { id:id } );
radioTrue = createChild( RadioButton, undefined, { groupName:id, id:"radioTrue", marginRight:20 } );
radioFalse = createChild( RadioButton, undefined, { groupName:id, id:"radioFalse", marginRight:20 } );
radioUnknown = createChild( RadioButton, undefined, { groupName:id, id:"radioUnknown", marginRight:20 } );
label1 = createChild( Label, undefined, {} );
label2 = createChild( Label, undefined, {} );
label1.text = "label1: " + radioGroup.id; // "myId"
}
private function onCreationComplete()
{
label2.text = "label2: " + radioGroup.id; // undefined
}
private function getId():String
{
return "myId";
}
}
--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
SPONSORED LINKS
| Web site design development | Software design and development | Macromedia flex |
| Software development best practice |
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.

