NEU: Alle Visual Codes als Code Snippets für Flash CS5:
jetzt hier downloaden .

Drehknopf

Code Actionscript 2.0

Instanz-Aktion

on (press) {
mousepressed = 1;
}
on (release, releaseOutside) {
mousepressed = 0;
}
onClipEvent (enterFrame) {
dx = _root._xmouse - this._x;
dy = _root._ymouse - this._y;
angle = Math.atan2(dy , dx) * 180 / Math.PI;
if (mousepressed == 1) {
this._rotation = angle;
_root.target._y = 110 + angle;
}
}

Code Actionscript 3.0

addEventListener(Event.ENTER_FRAME, enterFrame); addEventListener(MouseEvent.MOUSE_UP, releaseOutside); square.addEventListener(MouseEvent.MOUSE_DOWN, press); square.addEventListener(MouseEvent.MOUSE_UP, release); var mousepressed = 0; function press(e:MouseEvent) { mousepressed = 1; } function release(e:MouseEvent){ mousepressed = 0; } function releaseOutside(e:MouseEvent) { mousepressed = 0; } function enterFrame(event:Event) { var dx = mouseX - square.x; var dy = mouseY - square.y; var angle = Math.atan2(dy, dx) * 180 / Math.PI ; if (mousepressed == 1) { square.rotation = angle; this.target.y = 200+angle ; } }

Infos

Der Winkel der Maus in Bezug auf den Drehknopf kontrolliert dessen Rotationswinkel angle. Durch diesen Winkel wird die vertikale Position des Quadrates _root.target._y gesteuert. Die Funktion Arcustangens (atan2) verwandelt die Koordinaten dy und dx in einen Winkel.

verwandt mit: Maus rotation

Download

Right click: Flashfile AS 2.0 | Flashfile AS 3.0 | SWF-File


Share