1&1 Webhosting
Flashhilfe.de - Flash Community

Prototype: attachAbove / attachUnder [Flash 8]

Forum > Tipps & Tricks zu Flash, Flex und Adobe AIR > Prototype: attachAbove / attachUnder

 


AntwortenRegistrieren Seite1  

 30.07.2003, 20:21 
Beiträge: 510
Wohnort: Bonn
Registriert: Apr 2002

Prototype: attachAbove / attachUnder
Tiefenmanagement der einfachen Art

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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/*
*
* COPYRIGHT MAX KLATTE, NUR FÜR NICHT KOMMERZIELLE NUTZUNG! (ansonten rücksprache);
*
* Diese Funtkion erleichtert ein "Tiefenmanegment" ohne den gebrauch von leveln.
* So wird auch Beispielsweise das Anordnen von Spielfiguren etc. vor oder hinter
* anderen Clips erleichtert, ohne das Risiko Clips auszublenden, die diese ebenen
* bereits besetzen:
*/

// in diesem Array wird die Anordnung der Clips gespeichert, jedes Element steht für
// eine Tiefe. Element wie Tiefen können nur Einfach besetzt sein.
_global.blockedDepth = new Array();
// dieser Prototyp registriert ein Movie im Array
// ANWENDUNG: this.attacMovieClip(idName, newName, depth [,initObject]).regMovie();
MovieClip.prototype.regMovie = function() {
   blockedDepth[this.getDepth()] = this._name;
};
/*
* attachMovieAbove ordnet einen MovieClip über einem MovieClip, dessen ID als
* Parameter "lowerName" übergeben wird, an. Dies geschieht indem Zunächst der
* Array angepasst wird, eine weiter Funktion ordnet die Clips dann so an, wie
* sie schon im Array festgeschrieben sind.
*/

MovieClip.prototype.attachMovieAbove = function(idName, newName, lowerName) {
    var depth = this[lowerName].getDepth();
   // Auslesen der Tiefe, für weiter Rechung
   blockedDepth.splice(depth+1, 0, newName);
   // Anpassung des Arrays
   this.sortMovies(blockedDepth, depth, blockedDepth.length);
   return (this.attachMovie(idName, newName, depth+1));
};
// siehe AttacMovieAbove, nur das der Clip unter dem Clip "higherName" angeordnet wird.
MovieClip.prototype.attachMovieUnder = function(idName, newName, higherName) {
   var depth = this[higherName].getDepth();
   // Auslesen der Tiefe, für weiter Rechung
   blockedDepth.splice(depth, 0, newName);
   // Anpassung des Arrays
   this.sortMovies(blockedDepth, depth, blockedDepth.length);
   return (this.attachMovie(idName, newName, depth));
};
// diese funktion bringt die Clips in die im Array angegebene Tiefen.
MovieClip.prototype.sortMovies = function(orderArray, begin, end) {
   if (begin-end<0) {
      // Movies werden auf höhre ebenen verschoben;
      for (var i = end; i>=begin; i--) {
         this[orderArray[i]].swapDepths(i);
      }
   }
};
//diese Funktion ist identisch attachMovie(..), nur das der Clip sofort registriert wird.
MovieClip.prototype.attachRegMovie = function(idName, newName, depth) {
   this.attachMovie(idName, newName, depth).regMovie();
   return this;
};
// regestrierung aller Movies, ideal zum "Nachrüsten" langer scripts; (siehe TotalAction)
MovieClip.prototype.regAllMovies = function() {
   blockedDepth = new Array();
   for (var i in this) {
      if (typeof (this[i]) == "movieclip") {
         this[i].regMovie();
      }
   }
};


Beispiel Aufruf:
ActionScript:
1
2
3
4
5
6
7
8
9
10
11
12
//BEISPIEL:
this.regAllMovies();
this.attachRegMovie("testMC", "hello_world", 7); //Movie wird in depth 7 gelegt & registriert.
this.attachMovieAbove("testMC", "hello_clouds", "hello_world"); //Movie wird über "hello_world" gelegt;
this.attachMovieUnder("testMC", "hello_rain", "hello_space"); /*Movie wird unter "hello_clouds" gelegt.
* Am ende ensteht also Folgende abfolge:
* 7:hello_world;
* 8:hello_rain;
* 9:hello_clouds;
*/


// Viel Spass, petalustik (shittakind), Schüler, 17.

Gruß
PetaLustiK

Chemiker, 19
Schlagwörter: Movieclip, prototype
 
Themen
Ähnliche Beiträge zum Thema
 

AntwortenRegistrieren Seite1  

Schnellantwort

Du musst registriert sein, um diese Funktion nutzen zu können.
Partner Webseiten: DesignerInAction.de   Designnation.de   Mediengestalter.info   php-resource.de   phpforum.de   phpwelt.de   Pixelio.de   PSD-Tutorials.de   Tutorials.de

Haftungsausschluss   Datenschutzerklärung   Hier Werben   Impressum
© 1999-2012 Sebastian Wichmann - Flashhilfe.de