Method

DEV_FLASH 2007. 6. 11. 17:15 |

청소해(철수);

철수.청소해(); --> 이렇게 쓴다.

ex) _root.bird.play();


메서드의 선언- 무비클립에 관련된건 무조건 이렇게 써보자.

MovieClip.prototype.메서드명 = function(매개변수){


};


=======================================

메서드 선언문에 있는 this는 메서드를 호출한 무비클립을 가리킴...

MovieClip.prototype.moveX = function(dx){
 this._x=this._x +dx;
};


_root.bird.moveX(20);  //this 는 _root.bird 얘를 가르킴


부드러운 움직임이 필요할때는...

MovieClip.prototype.smoothMove = function(sp,tx,ty){
 this._x=this._x + sp*(tx-this._x);
 this._y=this._y + sp*(ty-this._y);
}

 


Posted by 으니가저아
: