I'd say it is a bug.  Why are you listening to each button instead of
the group?

 

________________________________

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of Samuel Neff
Sent: Wednesday, June 25, 2008 1:11 PM
To: [email protected]
Subject: [flexcoders] RadioButton change event not firing in Flex 3 when
button in group is deselected

 

In Flex 3 when you have radio buttons in a group and click on one of the
radio buttons, only the change event for the clicked-on radio button
fires.  The radio button that was previously selected does not dispatch
a change event (it did in Flex 2).

This behavior can be overridden by the Flex 2 compatibility flag, but
it's not mentioned in the compatibility document as far as I can tell

http://learn.adobe.com/wiki/display/Flex/Backwards+Compatibility+Issues
<http://learn.adobe.com/wiki/display/Flex/Backwards+Compatibility+Issues
> 

For example, run the following code with Flex 2 SDK:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml
<http://www.adobe.com/2006/mxml> " layout="vertical">
    <mx:RadioButton id="b1" label="1" change="trace('1 changed:' +
b1.selected);" />
    <mx:RadioButton id="b2" label="2" change="trace('2 changed:' +
b2.selected);" />
    <mx:RadioButton id="b3" label="3" change="trace('3 changed:' +
b3.selected);" />
</mx:Application>

click on one gives..

1 changed:true

then clicking on 2 gives...

2 changed:true
1 changed:false

and clicking on 3 gives...

3 changed:true
2 changed:false


however, if you then run the same code with Flex 3 SDK, you get:


click on one gives..

1 changed:true

then clicking on 2 gives...

2 changed:true

and clicking on 3 gives...

3 changed:true

so in Flex 3 you never get the change events when the old radio buttons
are set to selected=false.

Here's the changed code that I think causes the problem.


            if (FlexVersion.compatibilityVersion <
FlexVersion.VERSION_3_0)
            {
                 if (toggle)
                    dispatchEvent(new Event(Event.CHANGE));
            }
            else
            {
                if (toggle && !isProgrammatic)
                    dispatchEvent(new Event(Event.CHANGE));
            }


is this really correct behavior?  Why wouldn't you want the change event
to fire when the value changed?  There's an isProgrammatic check in
there, but this is not really a programmatic change, it's in response to
a user clicking on a different radio button in the group.

Thanks,

Sam


-----------------------------------------------------------------
We're Hiring! Seeking passionate Flex, C#, or C++ (RTSP, H264) developer
in the Washington D.C. Contact [EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]>  

 

Reply via email to