How do you declare component states in ActionScript?

喜欢而已 提交于 2019-12-11 13:54:57

问题


In mxml you declare states like this:

<box:states>
    <s:State name="active"/>
    <s:State name="disabled"/>
</box:states>

How do you acheive the same in an ActionScript class? Apparently it's the same in Flex 3 and Flex 4, whatever it is.


回答1:


If you can avoid it, do!

That said, hold your breath!

That said, take a look at the State Class. Create a new instance and define the overrides. I believe all the overrides are link in the "see also" link.

Each component has a "states" array.

So, just create the states manually. Add the relevant overrides, and add that state to the states array.

It isn't hard, but it can be pretty tedious. I did this for the Flextras Calendar.




回答2:


Thanks for the answers. Here's what I came up with:

// constructor
public function MyBox() {
    states = new Array();

    for each (var name:String in ['working', 'active', 'disabled']) {
        var state:State = new State();
        state.name = name;
        states.push(state);
    }
}


来源:https://stackoverflow.com/questions/3718952/how-do-you-declare-component-states-in-actionscript

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!