5D艺术网首页
商城
|
资讯
|
作品
|
博客
|
教程
|
论坛
登录
注册
加为好友
发短消息
来自:
性别:秘密
最后登录:2010-03-02
http://wyongedu.5d.cn/
Love is like a butterfly. It goes where it pleases and it pleases where it goes
首页
|
新闻
|
话题
|
博客
|
相册
|
艺术作品
|
社交关系
|
留言板
|
社交圈
2005/10/26 | Actionscript 3 - First steps VII
类别(失落的学习)
|
评论
(1)
|
阅读(38)
|
发表于 09:20
Interactivity is the soul of real experience. How can we interact with our new friend Flash 8.5? In the old days we could add handlers like on(release){} or this.onRelease = function(){} to our MovieClip instances. In ActionScript 3 we have to use a way, which is similar to that of the v2 components - addEventListener.
As we learned before, we use a Sprite object now, instead of a MovieClip.
package {
import flash.events.Event;
import flash.events.MouseEventType;
import flash.util.trace;
import flash.display.Sprite;
public class Test extends Sprite {
public function Test() {
graphics.beginFill(0xff0000);
graphics.drawRect(0, 0, 100, 100);
graphics.endFill();
this.addEventListener(MouseEventType.MOUSE_UP, mouseUpListener);
}
public function mouseUpListener( evt:Event){
trace( "Test::mouseUpListener " + this + ":" + evt);
}
}
}
In contrast to the old addEventListener in Actionscript 2 we don't have to use Delegate.create to bind a function to the scope of a handler, this is done implicitely now.
0
评论
Comments
日志分类
首页
[192]
失落的感情
[27]
失落的学习
[30]
失落的时间
[5]
失落的网络
[85]
失落的自己
[42]
失落的朋友
[3]