![o_Flex%20Runing%20Screen.jpg](https://i-blog.csdnimg.cn/blog_migrate/1747bd70d07564d3b2b8e53245278fa9.jpeg)
1)先创建一个Flex Project
![](https://i-blog.csdnimg.cn/blog_migrate/531a7a9f7604c215ee9ea434b9de4b69.jpeg)
按着向导一步一步做就可以了。
2)开始设计GUI
1
<?
xml version="1.0" encoding="utf-8"
?>
2
3 < mx:Application xmlns:mx ="http://www.adobe.com/2006/mxml" backgroundAlpha ="0" layout ="absolute" >
4 < mx:TextInput width ="136" id ="src" text ="Hello world!" x ="184" y ="24" />
5 < mx:TextInput id ="dest" height ="22" width ="136" x ="184" y ="132" />
6 < mx:Button label ="Copy" id ="copy" click ="dest.text=src.text" x ="184" y ="77" />
7 </ mx:Application >
8
这是最简单的Mxml代码,就是实现将scr的文本copy至dest中。
2
3 < mx:Application xmlns:mx ="http://www.adobe.com/2006/mxml" backgroundAlpha ="0" layout ="absolute" >
4 < mx:TextInput width ="136" id ="src" text ="Hello world!" x ="184" y ="24" />
5 < mx:TextInput id ="dest" height ="22" width ="136" x ="184" y ="132" />
6 < mx:Button label ="Copy" id ="copy" click ="dest.text=src.text" x ="184" y ="77" />
7 </ mx:Application >
8
其界面如下:
![](https://i-blog.csdnimg.cn/blog_migrate/7f73e1665442beaf44b208a6e6b8d696.jpeg)
3)加上动态绑定
1
<?
xml version="1.0" encoding="utf-8"
?>
2
3 < mx:Application xmlns:mx ="http://www.adobe.com/2006/mxml" backgroundAlpha ="0" layout ="absolute" >
4 < mx:Model id ="bean" >
5 < data >
6 < text > {dest.text} </ text >
7 </ data >
8 </ mx:Model >
9 < mx:TextInput width ="136" id ="src" text ="Hello world!" x ="184" y ="24" />
10 < mx:TextInput id ="dest" height ="22" width ="136" x ="184" y ="132" />
11 < mx:Button label ="Copy" id ="copy" click ="dest.text=src.text" x ="184" y ="77" />
12 < mx:Box autoLayout ="true" x ="184" y ="183" >
13 < mx:Label text ="Binding dest:" x ="135" y ="169" >
14 </ mx:Label >
15 < mx:TextInput id ="bindText" text ="{bean.text}" width ="138" />
16 </ mx:Box >
17
18 </ mx:Application >
19
到目前就可以思考将View 和Model分离了,下次学完在发上来。
2
3 < mx:Application xmlns:mx ="http://www.adobe.com/2006/mxml" backgroundAlpha ="0" layout ="absolute" >
4 < mx:Model id ="bean" >
5 < data >
6 < text > {dest.text} </ text >
7 </ data >
8 </ mx:Model >
9 < mx:TextInput width ="136" id ="src" text ="Hello world!" x ="184" y ="24" />
10 < mx:TextInput id ="dest" height ="22" width ="136" x ="184" y ="132" />
11 < mx:Button label ="Copy" id ="copy" click ="dest.text=src.text" x ="184" y ="77" />
12 < mx:Box autoLayout ="true" x ="184" y ="183" >
13 < mx:Label text ="Binding dest:" x ="135" y ="169" >
14 </ mx:Label >
15 < mx:TextInput id ="bindText" text ="{bean.text}" width ="138" />
16 </ mx:Box >
17
18 </ mx:Application >
19