small Action Script Problem
ich versuche gerade einen passwortschutz mit flash mx zu machen, dabei muss man name und pass angeben,also,ich habe zwei texteingabefelder!
"benutzername" und "passwort"!
im einen bild habe ich 2 arrays:
habe mal die srm namen genommen!
dann habe ich eine schaltfläche mit folgendem code:
das script funktioniert eigentlich aber wenn es nimmt bei jedem benutzernamen jedes der 3 passwörter, woran liegts?
"benutzername" und "passwort"!
im einen bild habe ich 2 arrays:
|
|
Quellcode |
1 2 3 |
stop(); benutzer = ["Sascha", "Roman", "Maik"] paesse = ["test1", "test2", "test3"] |
habe mal die srm namen genommen!
dann habe ich eine schaltfläche mit folgendem code:
|
|
Quellcode |
1 2 3 4 5 6 7 8 9 10 11 12 |
on (release) {
if (benutzername == benutzer[0], passwort == paesse[0]) {
gotoAndPlay(2);
} else if (benutzername == benutzer[1], passwort == paesse[1]) {
gotoAndPlay(2);
} else if (benutzername == benutzer[2], passwort == paesse[2]) {
gotoAndPlay(2);
} else {
gotoAndPlay(3);
}
}
|
das script funktioniert eigentlich aber wenn es nimmt bei jedem benutzernamen jedes der 3 passwörter, woran liegts?
RE: small Action Script Problem
Hast du's mal mit 'ner AND verknüpfung versucht, etwa so:
|
|
Quellcode |
1 2 3 4 5 6 7 8 9 10 11 12 |
on (release) {
if (benutzername == benutzer[0] AND passwort == paesse[0]) {
gotoAndPlay(2);
} else if (benutzername == benutzer[1] AND passwort == paesse[1]) {
gotoAndPlay(2);
} else if (benutzername == benutzer[2] AND passwort == paesse[2]) {
gotoAndPlay(2);
} else {
gotoAndPlay(3);
}
}
|
Auf jede Frage gibt es eine Antwort, man muss nur lange genug danach suchen.
z.B. auf www.netscripter.de :-P
Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von »OnkelJürgen« (30. April 2003, 16:34)
dadurch kommt im ausgabe fenster:
Szene=Szene 1, Ebene=Ebene 1, Bild=1: Zeile 2: )' erwartet
if (benutzername == benutzer[0] AND passwort == paesse[0]) {
Szene=Szene 1, Ebene=Ebene 1, Bild=1: Zeile 3: Anweisung muss innerhalb einer on-Prozedur vorliegen
gotoAndPlay(2);
Szene=Szene 1, Ebene=Ebene 1, Bild=1: Zeile 4: Unerwartetes Auftreten von '}'
} else if (benutzername == benutzer[1] AND passwort == paesse[1]) {
Szene=Szene 1, Ebene=Ebene 1, Bild=1: Zeile 2: )' erwartet
if (benutzername == benutzer[0] AND passwort == paesse[0]) {
Szene=Szene 1, Ebene=Ebene 1, Bild=1: Zeile 3: Anweisung muss innerhalb einer on-Prozedur vorliegen
gotoAndPlay(2);
Szene=Szene 1, Ebene=Ebene 1, Bild=1: Zeile 4: Unerwartetes Auftreten von '}'
} else if (benutzername == benutzer[1] AND passwort == paesse[1]) {
Und so?
|
|
Quellcode |
1 2 3 4 5 6 7 8 9 10 11 12 |
on (release) {
if ((benutzername == benutzer[0]) AND (passwort == paesse[0])) {
gotoAndPlay(2);
} else if ((benutzername == benutzer[1]) AND (passwort == paesse[1])) {
gotoAndPlay(2);
} else if ((benutzername == benutzer[2]) AND (passwort == paesse[2])) {
gotoAndPlay(2);
} else {
gotoAndPlay(3);
}
}
|
Auf jede Frage gibt es eine Antwort, man muss nur lange genug danach suchen.
z.B. auf www.netscripter.de :-P
Zitat
Original von Exuro
'&&' und 'and' ist das gleiche. nur mit 'AND' und 'and' hast FlashMX so seine Schwierigkeiten. Einfach 'and' klein schreiben oder durch '&&' ersetzen, dann funktionierts.
das ging mit "and"!
danke!aber habe ein neues problem!
Also ich habe da ein Zufallszahlscript!Habe 6 Dynamische Textfelden und einen Button mit Folgenden Code:
ActionScript:
on (release) {
zufall = Math.floor(Math.random()*49+1);
zufall1 = Math.floor(Math.random()*49+1);
zufall2 = Math.floor(Math.random()*49)+1;
zufall3 = Math.floor(Math.random()*49+1);
zufall4 = Math.floor(Math.random()*49+1);
zufall5 = Math.floor(Math.random()*49+1);
}
was muss ich hinzufügen, damit 2 zahlen in den feldern net gleichzeitig vorkommen?
nix hinzufuegen. ersetzen.
|
|
Quellcode |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
// array mit 50 Zahlen erstellen
menge = new Array();
for (a=0; a<50; a++) {
menge[a] = a;
}
// Zahlen an die Variablen verteilen und aus dem Array loeschen
for (b=1; b<=6; b++) {
rnd = random(menge.length);
_root["zufall"+b] = menge[rnd];
menge.splice(rnd, 1);
}
// Ausgabe der variablen
trace(zufall1);
trace(zufall2);
trace(zufall3);
trace(zufall4);
trace(zufall5);
trace(zufall6);
|
Ich glaube ich hab was du brauchs, probier einfach mal die FLA im Anhang aus. Einfach die Endung in FLA ändern.
Auf jede Frage gibt es eine Antwort, man muss nur lange genug danach suchen.
z.B. auf www.netscripter.de :-P
Zitat
Original von Exuro
Soll ich mein Script etwas genauer erklären? Ich könnte ein ausführliches Tutorial draus machen, falls es wirklich interessiert.
also mich würde es sehr ineressieren, beschäftige mich zur zeit mit action script!ich lese auch gerade "Action Script - Professional Series" von Franzis' Verlag!Also wär nett von dir!
also ich habe das jetzt auf meine weise gemacht, mit einer if-else-if anweisung!
beispiel: http://thesphinx.gu1.info/srmtuts/Random.swf
kann man diese if-else-if anweisung vereinfachen?
|
|
PHP-Quelltext |
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 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
//Variablen Definieren
on (press, keyPress "<Space>"){
//Random
Zahl1r = Math.floor(Math.random()*49+1);
Zahl2r = Math.floor(Math.random()*49+1);
Zahl3r = Math.floor(Math.random()*49+1);
Zahl4r = Math.floor(Math.random()*49+1);
Zahl5r = Math.floor(Math.random()*49+1);
Zahl6r = Math.floor(Math.random()*49+1);
if (Zahl1r == Zahl2r) {
Zahl1r = Math.floor(Math.random()*49+1);
} else if (Zahl1r == Zahl3r) {
Zahl1r = Math.floor(Math.random()*49+1);
} else if (Zahl1r == Zahl4r) {
Zahl1r = Math.floor(Math.random()*49+1);
} else if (Zahl1r == Zahl5r) {
Zahl1r = Math.floor(Math.random()*49+1);
} else if (Zahl1r == Zahl6r) {
Zahl1r = Math.floor(Math.random()*49+1);
} else if (Zahl2r == Zahl1r) {
Zahl2r = Math.floor(Math.random()*49+1);
} else if (Zahl2r == Zahl3r) {
Zahl2r = Math.floor(Math.random()*49+1);
} else if (Zahl2r == Zahl4r) {
Zahl2r = Math.floor(Math.random()*49+1);
} else if (Zahl2r == Zahl5r) {
Zahl2r = Math.floor(Math.random()*49+1);
} else if (Zahl2r == Zahl6r) {
Zahl2r = Math.floor(Math.random()*49+1);
} else if (Zahl3r == Zahl1r) {
Zahl3r = Math.floor(Math.random()*49+1);
} else if (Zahl3r == Zahl2r) {
Zahl3r = Math.floor(Math.random()*49+1);
} else if (Zahl3r == Zahl4r) {
Zahl3r = Math.floor(Math.random()*49+1);
} else if (Zahl3r == Zahl5r) {
Zahl3r = Math.floor(Math.random()*49+1);
} else if (Zahl3r == Zahl6r) {
Zahl3r = Math.floor(Math.random()*49+1);
} else if (Zahl4r == Zahl1r) {
Zahl4r = Math.floor(Math.random()*49+1);
} else if (Zahl4r == Zahl2r) {
Zahl4r = Math.floor(Math.random()*49+1);
} else if (Zahl4r == Zahl3r) {
Zahl4r = Math.floor(Math.random()*49+1);
} else if (Zahl4r == Zahl5r) {
Zahl4r = Math.floor(Math.random()*49+1);
} else if (Zahl4r == Zahl6r) {
Zahl4r = Math.floor(Math.random()*49+1);
} else if (Zahl5r == Zahl1r) {
Zahl5r = Math.floor(Math.random()*49+1);
} else if (Zahl5r == Zahl2r) {
Zahl5r = Math.floor(Math.random()*49+1);
} else if (Zahl5r == Zahl4r) {
Zahl5r = Math.floor(Math.random()*49+1);
} else if (Zahl5r == Zahl3r) {
Zahl5r = Math.floor(Math.random()*49+1);
} else if (Zahl5r == Zahl6r) {
Zahl5r = Math.floor(Math.random()*49+1);
} else if (Zahl6r == Zahl1r) {
Zahl6r = Math.floor(Math.random()*49+1);
} else if (Zahl6r == Zahl2r) {
Zahl6r = Math.floor(Math.random()*49+1);
} else if (Zahl6r == Zahl3r) {
Zahl6r = Math.floor(Math.random()*49+1);
} else if (Zahl6r == Zahl5r) {
Zahl6r = Math.floor(Math.random()*49+1);
} else if (Zahl6r == Zahl4r) {
Zahl6r = Math.floor(Math.random()*49+1);
} else {
Zahl1 = Zahl1r;
Zahl2 = Zahl2r;
Zahl3 = Zahl3r;
Zahl4 = Zahl4r;
Zahl5 = Zahl5r;
Zahl6 = Zahl6r;
}
}
|
beispiel: http://thesphinx.gu1.info/srmtuts/Random.swf
kann man diese if-else-if anweisung vereinfachen?
Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von »Silent Assassin« (17. Mai 2003, 19:59)
Gima
unregistriert
ja so
if(zahl1==zahl2 || zahl1==zahl3 || ......)
{
bla bla
}
und dann das für die 2te 3te und so weiter zahl
dann haste nämlich nur 6 if schleifen..... wo alles abgecheckt wird... anstatt ein 100 zeiler aufzubauen..-.
if(zahl1==zahl2 || zahl1==zahl3 || ......)
{
bla bla
}
und dann das für die 2te 3te und so weiter zahl
dann haste nämlich nur 6 if schleifen..... wo alles abgecheckt wird... anstatt ein 100 zeiler aufzubauen..-.
Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von »Gima« (17. Mai 2003, 21:12)
Ähnliche Themen
-
Archiv: Software »-
AntiVir
(29. Januar 2005, 13:05)
-
Archiv: Software »-
cmd32.exe überlastet das System .. Virus?
(2. Februar 2005, 10:47)
-
Flash »-
Flash einbinden + 1 Frage
(10. Juli 2004, 23:37)
-
Flash »-
Bilder verlinken
(9. April 2003, 17:51)
-
(X)HTML & CSS & DHTML & Javascript »-
Diese CSS-Datei geht net
(9. Dezember 2002, 14:58)



&& um die beiden Ausdrücke zu verbinden.