有帮助?打赏吧!

FLASH CC 2015 CANVAS (一) 与AS3的写法区别

 

注意 此贴 为个人边“开荒”边写,所以不保证就是最佳做法,也难免有错误! 正式教程会在后续开始更新

 

AS3                            JS
stop()                    this.stop();
mc.stop()                  this.mc.stop();
gotoAndStop(x)               this.gotoAndStop(x-1);
mc.x=100                   this.mc.x=100;
mc.visible=false              this.mc.visible=false;

function clickF(e:MouseEvent):void{}    function clickF(e){}
MouseEvent.CLICK              "click"
MouseEvent.MOUSE_DOWN           "pressdown"
MouseEvent.MOUSE_UP            "pressup"
MouseEvent.ENTER_FRAME           "tick"
MouseEvent.ADDED               "added"

 

 

另外注意一点:

AS3 :

mc.addEventListener(MouseEvent.CLICK,clF)
function clF(e:MouseEvent)
{
  trace(this);
  //输出的是 mc的父级
}

CANVAS JS:
this.mc.on('click',clF)
function clF(e)
{
  console.log(this);//输出的是 function()
  //如果要输入mc 或者mc 的父级则需要
  //在绑定事件的时候 this.mc.on('click',clF.bind(this)) }

 

如果你写的是 

this.mc.addEventListener('click',clF)   
function clF(e)
{
  console.log(this.parent);  // 大家可以自己输出看看结果。
}

 

posted @ 2015-08-04 15:20  luoeeyang  Views(1781)  Comments(0Edit  收藏  举报