My simple example of using Event Listeners.
There is an instance of MovieClip called a box.
I applied three Mouse Events Listeners:
for events MouseEvent.MOUSE_UP for the button btn and for events MouseEvent.MOUSE_DOWN, MouseEvent.MOUSE_UP for the box.
The code is simple, but as a result you can rotate, drag and drop the object.
The code is simple (That it's. Nothing else):
btn.addEventListener(MouseEvent.MOUSE_UP, onRotateRight);
function onRotateRight(evt:MouseEvent):void {
box.rotation += 20;
}
box.addEventListener(MouseEvent.MOUSE_DOWN, onStartDrag);
box.addEventListener(MouseEvent.MOUSE_UP, onStopDrag);
function onStartDrag(evnt:MouseEvent):void {
evnt.target.startDrag();
}
function onStopDrag(evnt:MouseEvent): void {
stopDrag();
}
There is an instance of MovieClip called a box.
I applied three Mouse Events Listeners:
for events MouseEvent.MOUSE_UP for the button btn and for events MouseEvent.MOUSE_DOWN, MouseEvent.MOUSE_UP for the box.
The code is simple, but as a result you can rotate, drag and drop the object.
The code is simple (That it's. Nothing else):
btn.addEventListener(MouseEvent.MOUSE_UP, onRotateRight);
function onRotateRight(evt:MouseEvent):void {
box.rotation += 20;
}
box.addEventListener(MouseEvent.MOUSE_DOWN, onStartDrag);
box.addEventListener(MouseEvent.MOUSE_UP, onStopDrag);
function onStartDrag(evnt:MouseEvent):void {
evnt.target.startDrag();
}
function onStopDrag(evnt:MouseEvent): void {
stopDrag();
}
No comments:
Post a Comment