如何在ActionScript中声明组件状态? [英] How do you declare component states in ActionScript?

查看:151
本文介绍了如何在ActionScript中声明组件状态?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在mxml中,你声明了这样的状态:

 < box:states> 
< / box:states>

如何在ActionScript类中实现同样的效果?显然,在Flex 3和Flex 4中是一样的,不管它是什么。

解决方案

感谢您的回答。这是我想出来的:

pre $ constructor $ b $ public function MyBox(){
states = new Array(); (var'name':['working','active','disabled']中的字符串){
var state:State = new State();


state.name = name;
states.push(state);
}
}


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.

解决方案

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);
    }
}

这篇关于如何在ActionScript中声明组件状态?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆