5D艺术网首页
商城
|
资讯
|
作品
|
博客
|
教程
|
论坛
登录
注册
加为好友
发短消息
来自:山东
性别:先生
最后登录:2011-01-05
http://xbzg.5d.cn/
专注于Flash+FMS开发...通过Google搜索西部之光Software
首页
|
新闻
|
话题
|
博客
|
相册
|
艺术作品
|
社交关系
|
留言板
|
社交圈
2006/02/14 | 体验AS3.0(八)
类别(Flash)
|
评论
(1)
|
阅读(189)
|
发表于 13:44
交互性是FLASH的灵魂,那我们如何在FP8.5实现交互呢?以往我们可以通过添加on(release){} 或 this.onRelease = function(){}之类的语句来和MovieClip进行交互。在AS3.0中,我们必须通过类似以往V2组件的交互方式addEventListener来实现这一功能。
就象我们前面提到的一样,现在我们要用Sprite来代替MovieClip了。
//TEST6.as
package {
import flash.events.MouseEvent;
import flash.events.MouseEventType;
import flash.util.trace;
import flash.display.Sprite;
public class Test extends Sprite {
public function Test() {
addChild( new MySprite());
}
}
private class MySprite extends Sprite
{
public function MySprite(){
createUI();
}
private function createUI(){
graphics.beginFill(0xff0000);
graphics.drawRect(0, 0, 100, 100);
graphics.endFill();
useHandCursor = true;
addEventListener( MouseEventType.MOUSE_UP, mouseListener);
}
public function mouseListener( evt:MouseEvent){
trace( "Test::mouseListener " + this + ":" + evt);
}
}
}
同AS2.0中的addEventListener比较一下,我们不再需要用Delegate.create将一个function绑定到handler上,这大大简化了我们的编码过程。
0
评论
Comments
日志分类
首页
[186]
Flash
[84]
FMS
[41]
AIR
[2]
ASP
[11]
作品区
[12]
其他
[36]