I'm writing a Quiz application where the user is automatically
advanced to the next question upon answering the current question.

I'm currently hooking into the CHANGE event on the RadioButtonGroup
object, but this event appears to be fired *before* the component gets
a chance to draw the dot in the relevant RadioButton.  The effect of
this is that the user isn't sure whether or not the Quiz has recorded
her last answer.  

Currently, to achieve the effect I want I'm having to use a timer to
delay the moving on to the next question (see below).  Is there a
better way?


<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml";
layout="vertical">

        <mx:Label text="Reset"/>
        <mx:RadioButtonGroup id="grp1" change="reset()"/>
        <mx:RadioButton id="button1" group="{grp1}" label="Click Me!" />
        <mx:RadioButton id="button2" group="{grp1}" label="Click Me!" />
        <mx:HRule width="100%"/>

        <mx:Script>
                <![CDATA[
                        private function reset():void {
                                button1.selected = false;
                                button2.selected = false;
                        }               
                ]]>
        </mx:Script>

        <mx:Label text="Delayed Reset"/>
        <mx:RadioButtonGroup id="grp2" change="delayedReset()"/>
        <mx:RadioButton id="button3" group="{grp2}" label="Click Me!" />
        <mx:RadioButton id="button4" group="{grp2}" label="Click Me!" />

        <mx:Script>
                <![CDATA[
                        private function delayedReset():void {
                                var t:Timer = new Timer(1000, 1);
                                t.addEventListener(TimerEvent.TIMER, 
timerExpired);
                                t.start();                                      
                
                        }                       
                        
                        private function timerExpired(event:TimerEvent):void {
                                button3.selected = false;
                                button4.selected = false;       
                        }
                ]]>
        </mx:Script>

</mx:Application>


Reply via email to