Zurück   Flashforum > Flash > ActionScript > ActionScript 1

Antwort
 
LinkBack Themen-Optionen Ansicht
Alt 13-11-2003, 13:52   #1 (permalink)
Neuer User
 
Registriert seit: Dec 2002
Ort: Hamburg
Beiträge: 61
duplicateMovieClip - wer hilft?

Hi,

ich habe folgendes Problem und zwar möchte ich Symbole dynamisch generieren.

Ich habe mir mehrere Funktionen gebaut, mit denen ich per Zufall ein Startsymbol aufwählen möchte und diese dann bewegen möchte, so das es so aussieht, als sei es eine Rolle die sich dreht.

Ich habe mir ein Array angelegt, wo die Reihenfolge der Symbole festgelegt ist und wenn eine max Y-Höhe erreicht ist, soll dieses wieder gelöscht werden und an das letzte der Reihe wieder von vorne mit der Array reihenfolge begonnen werden.

Ich sitze hier schon jetzt eine ganze Weile vor diesem Script und irgendwo ist ein Fehler, leider finde ich ihn nicht. :-(

Vielleicht entdeckt Ihn ja einer von euch.

Hier das Script:

ActionScript:
  1. gfxArray = ["gfx1", "gfx2", "gfx3", "gfx4", "gfx5", "gfx6","gfx1","gfx2"];
  2. gfxID = [1,2,3,4,5,6];
  3. firststart = 1;
  4. startX = 164;
  5. startY = 225;
  6. maxY = (startY+10);
  7. maskX = 236;
  8. maskY = 190;
  9. abstand = 34;
  10. speed = 2;
  11. startsymbol = random(3);
  12. maxsymbole = 6;
  13.  
  14. function generateSymbols(){
  15.     if(firststart == 1){
  16.         for(i=startsymbol;i<(startsymbol+maxsymbole);i++){
  17.             duplicateMovieClip(_root.gfxArray[i], "neu"+gfxArray[i]+"ID"+gfxID[i],i);
  18.             duplicateMovieClip(_root.mask, "neuemask"+i,(i+10));
  19.             this["neuemask"+i]._x = maskX;
  20.             this["neuemask"+i]._y = maskY;
  21.             this["neuemask"+i]._visible = false;
  22.             this["neu"+gfxArray[i]+"ID"+gfxID[i]]._x = startX;
  23.             this["neu"+gfxArray[i]+"ID"+gfxID[i]].setMask(this["neuemask"+i]);
  24.             firststart = 0;
  25.             if(i==startsymbol){
  26.                 myname = this["neu"+gfxArray[i]+"ID"+gfxID[i]]._name.substring(9,10);
  27.                
  28.                 this["neu"+gfxArray[i]+"ID"+gfxID[i]]._y = startY;
  29.                 }else{
  30.                     this["neu"+gfxArray[i]+"ID"+gfxID[i]]._y = (this["neu"+gfxArray[i-1]+"ID"+gfxID[i-1]]._y - abstand);
  31.                     }
  32.                 this["neu"+gfxArray[i]+"ID"+gfxID[i]].onEnterFrame = function (){
  33.                     if(this._y < maxY){
  34.                         this._y += speed;
  35.                         }else{
  36.                            
  37.                             if(this._name == "neu"+gfxArray[((startsymbol+maxsymbole)-4)]+"ID"+gfxID[((startsymbol+maxsymbole)-4)]){
  38.                                 myname = this._name.substring(9,10);
  39.                                
  40.                                 attach(this._name,myname);
  41.                                 }
  42.                             removeMovieClip(this);
  43.                             }
  44.                             }
  45.                
  46.             }
  47.         }
  48.     }
  49.  
  50. function attach(an,welches){
  51.    
  52.    
  53.     for(i=welches;i<(welches+maxsymbole);i++){
  54.         duplicateMovieClip(_root.gfxArray[i], "neu"+gfxArray[i]+"ID"+gfxID[i],(i+30));
  55.         this["neu"+gfxArray[i]+"ID"+gfxID[i]]._x = startX;
  56.         if(i==welches){
  57.         this["neu"+gfxArray[i]+"ID"+gfxID[i]]._y = (_root.an._y - abstand);
  58.         }else{
  59.             this["neu"+gfxArray[i]+"ID"+gfxID[i]]._y = (this["neu"+gfxArray[i-1]+"ID"+gfxID[i-1]]._y - abstand);
  60.             }
  61.         this["neu"+gfxArray[i]+"ID"+gfxID[i]].onEnterFrame = function (){
  62.             if(this._y < maxY){
  63.                 this._y += speed;
  64.                 }else{
  65.                 if(this._name == "neu"+gfxArray[((startsymbol+maxsymbole)-3)]+"ID"+gfxID[((startsymbol+maxsymbole)-3)]){
  66.                     myname = this._name.substring(9,10);
  67.                    
  68.                     attach(this._name,myname);
  69.                         }
  70.                         removeMovieClip(this);
  71.                         }
  72.                         }
  73.         }
  74.    
  75.     }

Leider ist in diesem Script irgendwo der Fehler, im zweiten durchgang werden die Symbole nicht an die alte Reihe angegliedert und beginnen am oberen Bühnenrand.

Und sobald der zweite Aufruf passiert, verschwindet die erste Reihe, die sich aber bis zum letzten Symbol bewegen soll und das obwohl ich beim zweiten Aufruf das _level um 20 gesteigert habe.

Wäre sehr froh, wenn mir jemand sagen könnte, wo hier mein Fehler ist.

Vielen Dank!
BaRt4EvEr ist offline   Mit Zitat antworten
Antwort

Lesezeichen

Themen-Optionen
Ansicht

Forumregeln
Es ist Ihnen nicht erlaubt, neue Themen zu verfassen.
Es ist Ihnen nicht erlaubt, auf Beiträge zu antworten.
Es ist Ihnen nicht erlaubt, Anhänge hochzuladen.
Es ist Ihnen nicht erlaubt, Ihre Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks sind an
Pingbacks sind an
Refbacks sind an



Alle Zeitangaben in WEZ +1. Es ist jetzt 04:52 Uhr.

Domains, Webhosting & Vserver von Host Europe
Unterstützt das Flashforum!
Adobe User Group


Copyright ©1999 – 2012 Marc Thiele