Prototype: transform [Flash 8]
| Beiträge: 32 Registriert: Jun 2003
| 29.06.2003, 01:31
Eventgesteuerte Animation
Prototype:
ActionScript:1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | MovieClip.prototype.transform = function( $tobj , $ref) {
//lokal ablegen
this.$tobj = $tobj;
this.$ref = $ref;
//transformieren
this.onEnterFrame = function() {
var count = 0;
for (var prop in this.$tobj) {
// loops zählen
count++;
// annähren/bewegen
this[prop] += (this.$tobj[prop]-this[prop]) / 3;
// Falls am Ziel... Einrasten lassen und
// aus der Liste $tobj entfernen.
if (Math.round(this[prop]) == Math.round(this.$tobj[prop])) {
this[prop] = this.$tobj[prop];
delete (this.$tobj[prop]);
}
}
// alles am Ziel also aufräumen und onTransform triggern
if (count==0) {
this.onEnterFrame = undefined;
delete (this.$tobj);
this.onTransform();
}
}
}
|
Beispiel Aufruf:
ActionScript:1 2 3 4 5 6 7 8 9 | // include diese prototype
#include "transform.as"
// kleines beispiel mit einem
// MC names "redbox"
redbox.transform( { _x:100, _y:200, _xscale:200, _yscale:50, cc:30000 });
redbox.onTransform = function() {
trace ("bin da...");
}
|
| | | Beiträge: 3 Registriert: Jul 2003
| 13.07.2003, 19:09
So etwas ähnliches hab' ich auch schon mal gebaut:
http://www.flashforum.de/forum/showthread.php?s=&threadid=85709
Bei Deiner Variante kann man transform allerdings nicht doppelt für den selben MC aufrufen, weil dann onEnterFrame überschrieben wird.
Gruß TOAOTC
| |
| Ähnliche Beiträge zum Thema | |
|
Flashhilfe.de Flash Platform Tipps & Tutorials Flash Platform Andere Programmiersprachen Jobangebote Diskussionen
Flashhilfe News
Regeln & Bedingungen
|