【你不知道的flex】-【state状态切换之初始化方法】
来源:互联网 发布:mac不能用酷狗输入法么 编辑:程序博客网 时间:2024/06/06 23:59
一:背景
flex全屏切换的效果
二:目的
1:状态2=》状态1
2:切换执行状态1的初始化方法(某方法,我们一般是init方法,你懂得)
注:看似很简单,那么来试试吧。
三:code
<mx:states>
<mx:State name=”s1″ >
<mx:AddChild position=”lastChild” >
<local:s1 id=”mainapp” horizontalCenter=”0″ verticalCenter=”0″ width=”100%” height=”100%”>
</local:s1>
</mx:AddChild>
</mx:State>
<mx:State name=”s2″>
<mx:AddChild position=”lastChild”>
<local:s2 />
</mx:AddChild>
</mx:State>
</mx:states>
状态s1,状态s2两个状态
s1,s2是两个自定义组件
关键代码:请看红色部分
<?xml version=”1.0″ encoding=”utf-8″?>
<mx:Canvas xmlns:mx=”http://www.adobe.com/2006/mxml” width=”100%” height=”100%” creationComplete=”init()”addedToStage=”init2()” >
<mx:Script >
<![CDATA[
private function init():void{
trace("s1 init");
}
private function init2():void{
trace("s1 init2");
}
]]>
</mx:Script>
<mx:Label x=”106″ y=”115″ text=”S1=状态1″ fontSize=”36″ fontWeight=”bold”/>
</mx:Canvas>
四:输出
s1 init
s1 init2
s1 init2
s1 init2
s1 init2
s1 init2
s1 init2
s1 init2
s1 init2
init只是第一次执行,init2每次切换的时候都执行
五:结论
状态切换时候initialize,creationComplete的方法,都只是执行一次,多次切换,仅执行一次。
如果需要每次切换,请将方法写到addedToStage=“init()”。
六:源码下载
点我下载
- 【你不知道的flex】-【state状态切换之初始化方法】
- 【你不知道的Java】-【初始化】
- 学习收藏: Flex之State状态的…
- [待添加]swift3.0 初始化方法中,你所不知道的事 Designated, Convenience, required
- 你不知道的EcmaScript5数组方法
- 你所不知道的Activity方法
- 你所不知道的Activity方法
- 你所不知道的Activity方法
- flex状态之间的切换
- 【就你不知道-Flex 共享数据】
- 学习收藏: Flex之State状态的使用 …
- 【就你不知道-Flex 自定义事件-龙骑士之死】(2012-05-25 08:29)
- 一种你不知道的解决窗体闪烁的方法
- 也许你还不知道的类型转换方法
- 你所不知道的SQL排序方法
- 你所不知道的SQL排序方法
- 你不知道的用例编写方法
- 你不知道的用例编写方法
- PHP缓存技术
- 对快速排序的简单分析
- 使用Android NDK编译ffmpeg
- Objective-C: delegate的那点事儿
- Linux系统学习备忘系列3
- 【你不知道的flex】-【state状态切换之初始化方法】
- __attribute__详解
- java内部类
- js方式的页面跳转
- sgu——340(字符串模拟)
- aspectj annotation- used in spring
- VMware+Ubuntu环境安装配置SLURM
- ssh整合:spring与hibernate的整合
- Nginx 常见应用