开发者

manually set check box selected in as3

开发者 https://www.devze.com 2023-03-08 08:07 出处:网络
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

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
    }
}
0

精彩评论

暂无评论...
验证码 换一张
取 消