如何以声明方式将 Spark State 的 name 属性设置为字符串变量值

发布于 2024-11-08 03:50:13 字数 384 浏览 2 评论 0原文

我在 mxml 中声明了 Spark 状态。我还有一个带有字符串常量的类。我希望我的州名称与字符串常量匹配。是否可以直接在 mxml 中执行此操作以及如何执行? 我不想使用相同的字符串,我想将 name 属性设置为常量的值。

代码:

public static const create:String = 'create';
public static const edit:String = 'edit';

mxml:

<s:State name="new"/>
<s:State name="edit"/>

据我所知,状态名称需要在编译时进行处理,所以可能这是不可能的。

I have spark States declared in mxml. I also have a class with string constants. I want my states names to match the string constants. Is it possible to do that directly in mxml and how?
I don't want to use the same string, I want to set the name property to the constant's value.

code:

public static const create:String = 'create';
public static const edit:String = 'edit';

mxml:

<s:State name="new"/>
<s:State name="edit"/>

As far as I know state names need to be processed at compile time so probably it's not possible.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

梦与时光遇 2024-11-15 03:50:13

是的,问题是你不能在状态声明中包含常量:(

Yes, the problem is you cannot include constants in state declarations :(

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文