dasPoda

now with 12% more Poda

Un-checking Radio Buttons in AS3

No comments

Radio Buttons and Un-checking in AS3

There is no direct way of un-checking a radio burron. However here's a work-around: create an invisible radio button and don't include it as a child but do add it to the radio button group.

Example:

// Let’s say you have a radio button group (RBGroup) and three radio Buttons (RB1, RB2 and RB3)
// First thing you need to do is add the RB’s to the group and add them as chilren
RB1.group = RBGroup ;
RB2.group = RBGroup ;
RB3.group = RBGroup ;

addChild(RB1) ;
addChild(RB2) ;
addChild(RB3) ;

//To change the selection you would…
RBGroup.selection = RB1 ;

//And to to check the selection you can do this
trace(RB1.selected);
 
// However, 'RB1.selected' This is a read-only parameter, so you couldn’t set all to false to un-check them
// Create another radio button and add it to the group
RBnone.group = RBGroup;

// Then you can change the selection to RBnone
RBGroup.selection = RBnone;

And as long as this radio button is NOT ADDED as child (invisible) it will appear to be unselecting all.

Radio Buttons and Un-checking in AS3

there is no direct way of un-checking a radio burron. However here's a work-around: create an invisible radio button and don't include it as a child but do add it to the radio button group.

Example:

// Let’s say you have a radio button group (RBGroup) and three radio Buttons (RB1, RB2 and RB3)
// First thing you need to do is add the RB’s to the group and add them as chilren
RB1.group = RBGroup ; RB2.group = RBGroup ; RB3.group = RBGroup ; addChild(RB1) ; addChild(RB2) ; addChild(RB3) ; //To change the selection you would… RBGroup.selection = RB1 ; //And to to check the selection you can do this trace(RB1.selected); // However, 'RB1.selected' This is a read-only parameter, so you couldn’t set all to false to un-check them // Create another radio button and add it to the group RBnone.group = RBGroup; // Then you can change the selection to RBnone RBGroup.selection = RBnone;

And as long as this radio button is NOT ADDED as child (invisible) it will appear to be unselecting all.

Written by dasPoda

Tuesday 24 February 2009 at 7:07 pm

Posted in flash

Used tags: , , ,

No comments

Leave a Reply

(optional field)
(optional field)
Remember personal info?
Small print: All html tags except <b> and <i> will be removed from your comment. You can make links by just typing the url or mail-address.