Prototype: rotateTo [Flash 8]
| Beiträge: 1443 Wohnort: bei Kiel Registriert: Aug 2005
| 16.03.2007, 23:06
Drehung mit Angabe des Zielwinkels, der Drehrichtung und der easing-Funktion
Prototype:
ActionScript:1 2 3 4 5 6 7 8 9 10 11 12 13 14 | // === dir ===
// short: den kurzen weg
// long: den langen weg
// ccw: gegen den uhrzeigersinn
// cw: mit dem uhrzeigersinn
MovieClip.prototype.rotateTo = function(endAngle:Number, time:Number, dir:String, easing:Function) {
var angleDif = (endAngle - this._rotation) % 360;
if (angleDif <= -180) angleDif += 360;
else if (angleDif > 180) angleDif -= 360;
if (angleDif < 0 && (dir == "long" || dir == "cw")) angleDif += 360;
else if (angleDif > 0 && (dir == "long" || dir == "ccw")) angleDif -= 360;
this.rotationTween.stop();
this.rotationTween = new mx.transitions.Tween(this, "_rotation", easing, this._rotation, this._rotation + angleDif, time, true);
};
|
Beispiel Aufruf:
ActionScript:1 2 3 4 5 | function rotate(){
mc.rotateTo(Math.random()*360, 1.5, "long", mx.transitions.easing.Strong.easeInOut);
}
rotate();
setInterval(rotate, 2000);
|
| |
| Ähnliche Beiträge zum Thema | |
|
Flashhilfe.de Flash Platform Tipps & Tutorials Flash Platform Andere Programmiersprachen Jobangebote Diskussionen
Flashhilfe News
Regeln & Bedingungen
|