URL: https://www.overclockers.at/coding-stuff/flash_as2_bei_click_variable_aendern_laden_206477/page_1 - zur Vollversion wechseln!
Hallo liebe Coder,
stehe wieder vor einem kleinen Problem (ja ich bin zu blöd fürs coden lol).
Folgendes, ich hab eine Textbox in die beim Laden ein zufallstext geladen wird, soweit ja ganz einfach weils ja genügen Anleitungen dazu gibt:
Code:Array.prototype.rand = function(nr,i,temp_1,temp_2) { if(temp_1.length == undefined) { var i = 0, temp_1 = [], temp_2 = []; for(var j in this) temp_2.push(this[j]); } i++; if(i<temp_2.length && i<nr) temp_2.rand(nr,i,temp_2,temp_2); temp_1.push(temp_2.splice(random(temp_2.length),1)); return temp_1; } ASSetPropFlags(Array.prototype,"rand",1,1); var tipp = new Array() tipp[1] = "1..." tipp[2] = "2..." tipp[3] = "3..." tipp[4] = "4..." tipp[5] = "5..." var tipps = (tipp.rand()) txt.variable = "tipps";
Hi
so hab es nun gelöst bekommen, ich muss das ganze etwas anders angehen (wie vermutet).
So sieht der Hauptteil aus mit dem Array usw.:
Code:var tipp = new Array(); tipp[0] = "1..."; tipp[1] = "2..."; tipp[2] = "3..."; tipp[3] = "4..."; tipp[4] = "5..."; // Gibt mir in einer Variablen die Anzahl der Einträge arrend = ((tipp.length)-1) // Funktion um eine zufällige Zahl zwischen 2 Zahlen auszugeben function rand(min,max){ return random(max-min+1)+min } // Variable mit der zufäligen Zahl wobei "max" mit der Anzahl der Einträge im Arr. // befüllt wird. var count = rand(0,arrend) // Variuable für das Dyn. Textfeld die dann auf das Array verweißt wobei das Arr. Element in der Var. count definiert ist (die zu Beginn eine Zufallszahl ist). mytxt = tipp[count];
Code:on (release) { if (count == arrend) { count = 0; mytxt = tipp[count]; } else { count = count+1; mytxt = tipp[count]; trace(count) } }
Code:on (release) { if (count == 0) { count = arrend; mytxt = tipp[count]; } else { count = count-1; mytxt = tipp[count]; trace(count) } }

overclockers.at v4.thecommunity
© all rights reserved by overclockers.at 2000-2026