Flex4:如何在类中创建视图状态(代码隐藏) [英] Flex4: how to create the view states in as class (code-behind)
问题描述
根据 Adobe 的这份文档创建和应用视图状态 是
一个状态对象.如何在代码隐藏的 ActionScript 类中创建视图状态?
According to this document from Adobe Create and apply view states is <s:State/>
a state object.
How to create the view states in code-behind ActionScript class?
推荐答案
我找到了一个简单的解决方案,而且我不必使用蒙皮架构来声明状态.我什至没有在扩展 WindowedApplication 的 ApplicationClass 中声明状态.解决方案是:仅在 Main.MXML 中声明状态,并且一定要使用正确的命名空间,在我的情况下它应该是自定义".这是 Main.MXML:
I have found a simple solution, and I don't have to declare the states using skinning architecture. I don't even to declare the states in my ApplicationClass which extends WindowedApplication. The solution is: declare the states only in the Main.MXML and by all means with the right namespace, in my case it should be "custom". Here is the 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>
我只想在不同的面板之间切换,所以这个方法很适合我.当然还有其他情况,需要在蒙皮中声明状态.我从这个链接得到了这个解决方案:错误:无法解析为组件实现.
I only want to change between different Panels, so this method works well for me. There are certainly other cases, in which the states need to be declared in skinning. I have got this solution form this link: Error: Could not resolve to a component implementation.
这篇关于Flex4:如何在类中创建视图状态(代码隐藏)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!