Flex4:如何在 class 中创建视图状态(代码隐藏)
Flex4: how to create the view states in as class (code-behind)
根据 Adobe 的这份文档,Create and apply view states 是 <s:State/>
一个状态对象。
如何在代码隐藏 ActionScript 中创建视图状态 class?
我找到了一个简单的解决方案,而且我不必使用蒙皮架构来声明状态。我什至不在扩展 WindowedApplication 的 ApplicationClass 中声明状态。
解决方案是:仅在 Main.MXML 中声明状态,并且一定要使用正确的命名空间,在我的例子中它应该是 "custom"。
这是 Main.MXML:
<?xml version="1.0" encoding="utf-8"?>
<custom:ApplicationClass xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
xmlns:custom="components.*">
<custom:states>
<s:State name="loginState"/>
<s:State name="infoState"/>
</custom:states>
<s:Panel id="loginPanel" title="Login" includeIn="loginState" />
</custom:ApplicationClass>
我只想在不同的面板之间切换,所以这个方法很适合我。当然还有其他情况需要在剥皮中声明状态。
我从这个link得到了这个解决方案:Error: Could not resolve to a component implementation.
根据 Adobe 的这份文档,Create and apply view states 是 <s:State/>
一个状态对象。
如何在代码隐藏 ActionScript 中创建视图状态 class?
我找到了一个简单的解决方案,而且我不必使用蒙皮架构来声明状态。我什至不在扩展 WindowedApplication 的 ApplicationClass 中声明状态。 解决方案是:仅在 Main.MXML 中声明状态,并且一定要使用正确的命名空间,在我的例子中它应该是 "custom"。 这是 Main.MXML:
<?xml version="1.0" encoding="utf-8"?>
<custom:ApplicationClass xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
xmlns:custom="components.*">
<custom:states>
<s:State name="loginState"/>
<s:State name="infoState"/>
</custom:states>
<s:Panel id="loginPanel" title="Login" includeIn="loginState" />
</custom:ApplicationClass>
我只想在不同的面板之间切换,所以这个方法很适合我。当然还有其他情况需要在剥皮中声明状态。 我从这个link得到了这个解决方案:Error: Could not resolve to a component implementation.