{lang: 'de'}
Flashhilfe.de - Flash Community

Prototype: transform [Flash 8]

 


AntwortenRegistrieren Seite1  

max0matic#1
Benutzerbild von max0matic
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...");
}

Schlagwörter: Movieclip, prototype
toaotc#2
Benutzerbild von toaotc
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


AntwortenRegistrieren Seite1  

Schnellantwort

Du musst registriert sein, um diese Funktion nutzen zu können.

 
Ähnliche Beiträge zum Thema
Partner Webseiten: art-and-law.de  Mediengestalter.info   phpwelt.de   Scubacube.de  
Haftungsausschluss   Datenschutzerklärung   Impressum
© 1999-2024 Sebastian Wichmann - Flashhilfe.de