The My Opera forums have been replaced with forums.opera.com. Please head over there to discuss Opera's products and features

See the new Forums

Giải bài tập Prop_Moving (dùng MouseEvent)

Forums » Học actionscript3 » Bài tập actionscript Về nhà

You need to be logged in to post in the forums. If you do not have an account, please sign up first.

Go to last post

30. November 2011, 19:40:13

Giải bài tập Prop_Moving (dùng MouseEvent)

Để di chuyển đối tượng ta dùng 2 phương thức:
+startDrag() : gọi phương thức này để duy chuyển đối tượng
+stopDrag() : Gọi phương thức này để dừng di chuyển đối tượng

Áp dụng cho bài tập:
+dùng startDrag() : dùng cho đối tượng với sự kiện MOUSE_DOWN
+dùng stopDrag() : dùng cho đối tượng với sự kiện MOUSE_UP
code tổng quát như sau:
function start_mc(e:Event):void{
	e.target.startDrag();
}
function stop_mc(e:Event):void{
	e.target.stopDrag();
}
mc.addEventListener(MouseEvent.MOUSE_DOWN,start_mc);
mc.addEventListener(MouseEvent.MOUSE_UP,stop_mc);

-Tải code soucre ở đây: http://www.mediafire.com/?czra8eahhk7np7u

Forums » Học actionscript3 » Bài tập actionscript Về nhà