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:
gfxArray = ["gfx1", "gfx2", "gfx3", "gfx4", "gfx5", "gfx6","gfx1","gfx2"];
gfxID = [1,2,3,4,5,6];
firststart = 1;
startX = 164;
startY = 225;
maxY = (startY+10);
maskX = 236;
maskY = 190;
abstand = 34;
speed = 2;
startsymbol = random(3);
maxsymbole = 6;
function generateSymbols(){
if(firststart == 1){
for(i=startsymbol;i<(startsymbol+maxsymbole);i++){
duplicateMovieClip(_root.gfxArray[i], "neu"+gfxArray[i]+"ID"+gfxID[i],i);
duplicateMovieClip(_root.mask, "neuemask"+i,(i+10));
this["neuemask"+i]._x = maskX;
this["neuemask"+i]._y = maskY;
this["neuemask"+i]._visible = false;
this["neu"+gfxArray[i]+"ID"+gfxID[i]]._x = startX;
this["neu"+gfxArray[i]+"ID"+gfxID[i]].setMask(this["neuemask"+i]);
firststart = 0;
if(i==startsymbol){
myname = this["neu"+gfxArray[i]+"ID"+gfxID[i]]._name.substring(9,10);
this["neu"+gfxArray[i]+"ID"+gfxID[i]]._y = startY;
}else{
this["neu"+gfxArray[i]+"ID"+gfxID[i]]._y = (this["neu"+gfxArray[i-1]+"ID"+gfxID[i-1]]._y - abstand);
}
this["neu"+gfxArray[i]+"ID"+gfxID[i]].onEnterFrame = function (){
if(this._y < maxY){
this._y += speed;
}else{
if(this._name == "neu"+gfxArray[((startsymbol+maxsymbole)-4)]+"ID"+gfxID[((startsymbol+maxsymbole)-4)]){
myname = this._name.substring(9,10);
attach(this._name,myname);
}
removeMovieClip(this);
}
}
}
}
}
function attach(an,welches){
for(i=welches;i<(welches+maxsymbole);i++){
duplicateMovieClip(_root.gfxArray[i], "neu"+gfxArray[i]+"ID"+gfxID[i],(i+30));
this["neu"+gfxArray[i]+"ID"+gfxID[i]]._x = startX;
if(i==welches){
this["neu"+gfxArray[i]+"ID"+gfxID[i]]._y = (_root.an._y - abstand);
}else{
this["neu"+gfxArray[i]+"ID"+gfxID[i]]._y = (this["neu"+gfxArray[i-1]+"ID"+gfxID[i-1]]._y - abstand);
}
this["neu"+gfxArray[i]+"ID"+gfxID[i]].onEnterFrame = function (){
if(this._y < maxY){
this._y += speed;
}else{
if(this._name == "neu"+gfxArray[((startsymbol+maxsymbole)-3)]+"ID"+gfxID[((startsymbol+maxsymbole)-3)]){
myname = this._name.substring(9,10);
attach(this._name,myname);
}
removeMovieClip(this);
}
}
}
}
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!