Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I'm not quite sure what you're asking, but hopefully this'll answer your question -- from the Flex docs:</p> <blockquote> <p><strong>RadioButtonGroup.selection</strong><br>Contains a reference to the currently selected RadioButton control in the group. You can access the property in ActionScript only; <em>it is not settable in MXML</em>. Setting this property to null deselects the currently selected RadioButton control.</p> </blockquote> <p>In general, though, making component references in MXML is totally fine; that's how effects are often handled, among many other things. For example:</p> <pre><code>&lt;mx:Glow id="g" /&gt; &lt;mx:Label showEffect="{g}" /&gt; </code></pre> <p>However in your case, assuming you're having trouble setting the selected item, it might be because you haven't specified the <code>group</code> attribute on the radio buttons; omitting that detaches the group component from the individual buttons. Once you add that, you can bind the group's selection property using a <code>Bindable</code> variable containing a reference to a component, like so:</p> <pre><code>&lt;mx:Script&gt; &lt;![CDATA[ [Bindable] private var selectedRadioButton:RadioButton; private function this_creationComplete(event:Event):void { selectedRadioButton = rb1; } private function btn_click(event:Event):void { selectedRadioButton = rb2; } ]]&gt; &lt;/mx:Script&gt; &lt;mx:VBox&gt; &lt;mx:RadioButtonGroup id="rbg" selection="{selectedRadioButton}" /&gt; &lt;mx:RadioButton id="rb1" group="{rbg}" label="Radio Button 1" /&gt; &lt;mx:RadioButton id="rb2" group="{rbg}" label="Radio Button 2" /&gt; &lt;mx:RadioButton id="rb3" group="{rbg}" label="Radio Button 3" /&gt; &lt;mx:Button label="Choose a Different Button" click="btn_click(event)" /&gt; &lt;/mx:VBox&gt; </code></pre> <p>Does this make sense? Hopefully it's not completely off the mark; post back and let me know and I'll try to help out as best I can.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload