| 3.AS3.0中的事件模型和AS2.0大不一样了。简而言之,就是“规范”。不再直接使用字符串来定义事件名称了。又要讲深一点了,都是使用了新的const型变量来定义事件字符串名称,一旦定义,不能再更改。
 如:
 
 
 public static const MOVE:String = "move"; 极大的避免了我们因为手误,打错字符串,而花上一个下午找bug。使用了这种模式,我们一旦打错,编译器立刻会发现并告诉我们。多好。给出一些鼠标事件列表,大家可以替换上面源码中的事件类型,自己试着玩儿。
 如,你可以换成MouseEvent.MOUSE_OVER就变成了以前的onRollOver效果。
 
 
     CLICK : String = "click"
 [static] Dispatched when a user presses and releases the main button of the user's pointing device over the same InteractiveObject. MouseEvent
 
 DOUBLE_CLICK : String = "doubleClick"
 
 [static] Dispatched when a user presses and releases the main button of a pointing device twice in rapid succession over the same InteractiveObject when that object's doubleClickEnabled flag is set to true. MouseEvent
 
 MOUSE_DOWN : String = "mouseDown"
 
 [static] Dispatched when a user presses the pointing device button over an InteractiveObject instance in the Flash Player window. MouseEvent
 
 MOUSE_LEAVE : String = "mouseLeave"
 
 [static] Dispatched by the Stage object when the mouse pointer moves out of the Flash Player window area. Event
 
 MOUSE_MOVE : String = "mouseMove"
 
 [static] Dispatched when a user moves the pointing device while it is over an InteractiveObject. MouseEvent
 
 MOUSE_OUT : String = "mouseOut"
 
 [static] Dispatched when the user moves a pointing device away from an InteractiveObject instance. MouseEvent
 
 MOUSE_OVER : String = "mouseOver"
 
 [static] Dispatched when the user moves a pointing device over an InteractiveObject instance in the Flash Player window. MouseEvent
 
 MOUSE_UP : String = "mouseUp"
 
 [static] Dispatched when a user releases the pointing device button over an InteractiveObject instance in the Flash Player window. MouseEvent
 
 MOUSE_WHEEL : String = "mouseWheel"
 
 //支持鼠标滚轮喽,霍霍。
 指出一点,在我给出的例子中,使用了双击这个事件。这个有点特殊,在使用双击事件之前,要加上一句: kingda_mc.doubleClickEnabled = true; 因为MovieClip对于双击事件默认是false,关闭的。 4.侦听器的不同。在AS2.0中我们通常要新建一个对象做侦听器。也可以像我的例子中用function做侦听器。但是,很可惜,由于AS2.0的设计缺陷,使得function中的this指向常常给我们带来困扰。于是有了Delegate类来解决。
 而如今,AS3.0中采用了优秀的Traits Object架构(唔,这个,就暂不解释了),使得它能记住this的指向。所以,兄弟们,放心大胆使用Function作为侦听器使用吧。
 今天就写这么多了,主要是Flash 9出来,我老人家激动了一下,一下子写了这么多东东。希望对大家有所帮助,希望大家狂顶支持一把,不然没动力,本系列教程会变成太监贴!霍哈哈! ^_^ 快回帖支持! 本篇主要涉及了一下AS3.0中的事件模型部分,这是很重要的。以后会有更深入的教程来详细介绍。本篇的目的就是让大家使用一下Flash 9和AS3,消除陌生感。写的浅了,还请包涵。 下一篇介绍非常实用的东东,类和MovieClip的绑定,和Flash 9中一大特色:Document Class。用来替代在时间轴写代码的好东东。 出处:蓝色理想
责任编辑:moby
 上一页 与Flash9的一次亲密接触 [1] 下一页 ◎进入论坛Flash专栏版块参加讨论
	      |