Assign variable to MXML component ID

馋奶兔 提交于 2019-12-06 12:31:02

No you can't. You have to understand that when you write an mxml component like

<s:Group>
    <s:Label id="myLabel" />
</s:Group>

it will generate ActionScript code like

public class MyClass extends Group {
    public var myLabel:Label;
}

(Mind you, I grossly oversimplify the code here to convey the most important part).

As you can see your 'id' is in fact a property name. And you can't change a property's name at runtime can you?

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