manually set check box selected in as3
I have a CheckBox in as3 that i need to set as checked with code. Do 开发者_开发技巧I dispatch an event? If so, how do I create an event, and give it a target (target is read only). Or is there another way to do it? thanks.
my_checkbox.selected = true;
And of course:
my_checkbox.selected = false;
To handle the box being checked/unchecked:
my_checkbox.addEventListener(MouseEvent.CLICK, _selected);
function _selected(e:MouseEvent):void
{
var bool:Boolean = e.target.selected;
if(bool)
{
trace("was checked");
// more code
}
else
{
trace("was unchecked");
// more code
}
}
精彩评论