跟我StepByStep学FLEX教程------Demo5之事件Event
说明:该文系作者原创,请勿商用或者用于论文发表,转载必须经作者同意并且注明出处。
Demo的运行效果:
源码如下:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="creationBtnHandler(event)">
<mx:Script>
<![CDATA[
import mx.controls.Alert;
private function test1ClickHandler(e:MouseEvent):void {
mxmlRegInp.text= "MXML 中注册事件";
Alert.show(e.currentTarget.toString());
}
private function creationBtnHandler(e:Event):void {
eventTes3Btn.addEventListener(MouseEvent.CLICK, test3ClickHandler);
}
private function test3ClickHandler(e:Event):void {
mxmlRegInp.text= "ActionScript 注册事件监听器";
}
]]>
</mx:Script>
<mx:Button x="59" y="32" label="MXML 中注册事件" id="eventTes1Btn" click="test1ClickHandler(event)" fontSize="12" width="140"/>
<mx:Button x="207" y="32" label="MXML 定义中创建线上事件" id="eventTes2Btn" click="mxmlRegInp.text='MXML 定义中创建线上事件'" fontSize="12" width="185"/>
<mx:TextInput x="59" y="82" id="mxmlRegInp" fontSize="12" width="333" enabled="true" color="#13E409" fontWeight="bold" fontStyle="italic" editable="false"/>
<mx:Button x="59" y="127" label="ActionScript 注册事件监听器" fontSize="12" width="333" id="eventTes3Btn"/>
</mx:Application>
这个Demo演示了Flex的三种事件方式,也就是按钮上写的名称:
1、MXML 中注册事件;
2、MXML 定义中创建线上事件;
3、ActionScript 注册事件监听器;
其中第2种方式仅供大家理解,作者不建议读者使用第2种方式在项目中实际应用,这种方式代码生硬,不易维护。
大家可以做一下这个Demo,下一讲将对事件event进行一些理论上的补充。
- 大小: 10 KB
分享到:
相关推荐
1 10 跟我StepByStep学FLEX教程------Demo5之事件Event 1 11 跟我StepByStep学FLEX教程------Event事件机制 1 12 跟我StepByStep学FLEX教程------Demo6之自定义事件&自定义组件 1 13 跟我StepByStep学FLEX教程---...
跟我StepByStep学FLEX教程------王一松.pdf
跟我StepByStep学FLEX教程------王一松
跟我StepByStep学FLEX教程 跟我StepByStep学FLEX教程 跟我StepByStep学FLEX教程 跟我StepByStep学FLEX教程 跟我StepByStep学FLEX教程
跟我StepByStep学FLEX教程.pdf 跟我StepByStep学FLEX教程.pdf 跟我StepByStep学FLEX教程.pdf 跟我StepByStep学FLEX教程.pdf 跟我StepByStep学FLEX教程.pdf
跟我StepByStep学FLEX教程 flex教程 flex大全
跟我StepByStep学FLEX教程------王一松
跟我StepByStep学FLEX,个人觉得比较好的一本关于flex书了,我最近也是刚开始学,网上没发现什么好资料,个人觉得这个不错,就传上来大家分享。设置资源分是迫不得已啊,喜欢在csdn上面下载东西,最近快没分了!
很详细的flex教程,适合新手入门很详细的flex教程,适合新手入门
安装算量(实例体验)入门教程(StepByStep)---消防水篇借鉴.pdf
安装算量(实例体验)入门教程(StepByStep)---消防报警篇分析.pdf
安装算量(实例体验)入门教程(StepByStep)---消防报警篇(2).pdf
安装算量(实例体验)入门教程(StepByStep)---消防报警篇(2)借鉴.pdf