flex中的addEventListener方法
flex控件对象、RemoteObject等都有一个共同的方法addEventListener。
addEventListener方法如下:
public function addEventListener(type:String, listener:Function,
useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void
{
eventDispatcher.addEventListener(type, listener, useCapture, priority, useWeakReference);
}
@param type:String 触发事件的类型,flex预定义的事件类型和处理方式。
@param listener:Function 事件触发时的回调函数。
@param useCapture:Boolean 事件处理的顺序
@param priority:int 事件优先权,我的理解是如果添加了多个listener则按照priority的顺序执行:(没多大用
@param useWeakReference:Boolean 是否设为弱引用
重点讲进后面三个参数。
useCapture 参数只有用实例才能表达清楚。
useCapture例:
<?xml version=”1.0″ encoding=”utf-8″?>
<mx:Application xmlns:mx=”http://www.adobe.com/2006/mxml” layout=”absolute” applicationComplete=”init()”>
<mx:HBox id=”hbox” >
<mx:Button id=”button” label=”click”/>
</mx:HBox>
<mx:Script>
import mx.controls.*;
public function init():void
{
// 注意:这里的useCapture:Boolean值应加到一个包含内部元素的控件上,这样才能让flex运行时识别事件顺序的范围!!!
// 由于 flex的Alert控件是重叠方式显示,所以最外一层才是最后弹出的一层
hbox.addEventListener(MouseEvent.CLICK,hboxClick,true);
button.addEventListener(MouseEvent.CLICK,buttonClick);
}
public function hboxClick(e:MouseEvent):void
{
Alert.show(”外HBox事件。”);
}
public function buttonClick(e:MouseEvent):void
{
Alert.show(”内Button事件。”);
}
</mx:Script>
</mx:Application>
原文地址:http://blog.sina.com.cn/s/blog_5c4558600100d39q.html
相关文档:
Top 10 things new Flex developers should know
By Michael Portuesi | Published: November 27, 2009
While helping a coworker get started with Flash and Flex development, I thought it would be a good time to cover the list of things that I have found pretty essential to know about Flex development, co ......
//获得屏幕的分辨率
var x:Number=Capabilities.screenResolutionX;
var y:Number=Capabilities.screenResolutionY;
Alert.show("x="+x+"y="+y);
第二种方法
Alert.show(stage.fullScreenWidth+"=="+stage.fullScreenHeight);
//获得stage(工作区)的宽、高
Alert.show(stage.stageWidth+"=="+stage.stageHei ......
登陆页面
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="init()">
<mx:Script>
<![CDATA[
import flash.net.navigateToURL;
private function setCookie():void{
&nb ......
性能测试是一项浩大的工程,若你只想随便找台机器装上ld后,造几条数据,弄几个并发用户简单跑一下出来结果就可以万事大吉了,那你就大错特错了!(这样得出的测试结果没有任何价值和意义,当然更无法依此评估出你贵公司系统的性能了。
性能测试真正开始执行之前 ......