Zurück   Flashforum > Flash > ActionScript > ActionScript 1

Antwort
 
LinkBack Themen-Optionen Ansicht
Alt 06-05-2004, 13:49   #1 (permalink)
Neuer User
 
Benutzerbild von stekke
 
Registriert seit: Sep 2001
Beiträge: 622
Var. vergleichen in Flash 5

hi zusammen,

habe folgendes Problem:

möchte gerne 6 Felder miteinander vergleichen. Sollte z.B. 3 mal innerhalb dieser 6 Felder ein "*" vorkommen,dann soll er jeweils dieses Feld mit einem Rahmen(mc) versehen.

so sollte es grob sein:

ActionScript:
  1. if (_root.f1=="*"&&_root.f3=="*"&&_root.f5=="*") {
  2.         _root.u1._visible = true;
  3.         _root.u3._visible = true;
  4.         _root.u5._visible = true;
  5.     }

nun sollte das noch veralgemeinert werden,also alle Möglichkeiten abdecken.

wäre dies die richtige + einfache Lösung? :



ActionScript:
  1. for (m=2; m<7; m++) {
  2.         for (n=3; n<7; n++) {
  3.             if (_root.f1=="*"&&_root["f"+m]=="*"&&_root["f"+n]=="*") {
  4.                 _root.u1._visible = true;
  5.                 _root["u"+m]._visible = true;
  6.                 _root["u"+n]._visible = true;
  7.             }
  8.         }
  9.     }
__________________
von allen Gedanken schätze ich doch am meisten,die interessanten....
(Sterne)

Geändert von stekke (06-05-2004 um 13:56 Uhr)
stekke ist offline   Mit Zitat antworten
Alt 06-05-2004, 14:57   #2 (permalink)
Neuer User
 
Benutzerbild von stekke
 
Registriert seit: Sep 2001
Beiträge: 622
habe es jetzt erstamal so:
funtzt aber nicht richtig...wo ist mein Fehler?

ActionScript:
  1. for (m=1; m<7; m++) {
  2.         for (n=2; n<7; n++) {
  3.             for (o=3; o<7; o++) {
  4.                 if (_root["f"+o]=="*"&&_root["f"+m]=="*"&&_root["f"+n]=="*") {
  5.                     _root["u"+m]._visible = true;
  6.                     _root["u"+m].play();
  7.                     _root["u"+n]._visible = true;
  8.                     _root["u"+n].play();
  9.                     _root["u"+o]._visible = true;
  10.                     _root["u"+o].play();
  11.                 }
  12.             }
  13.         }
  14.     }
  15.     for (m=1; m<7; m++) {
  16.         for (n=2; n<7; n++) {
  17.             for (o=3; o<7; o++) {
  18.                 if (_root["f"+o]=="2,00 €"&&_root["f"+m]=="2,00 €"&&_root["f"+n]=="2,00 €") {
  19.                     _root["u"+m]._visible = true;
  20.                     _root["u"+m].play();
  21.                     _root["u"+n]._visible = true;
  22.                     _root["u"+n].play();
  23.                     _root["u"+o]._visible = true;
  24.                     _root["u"+o].play();
  25.                 }
  26.             }
  27.         }
  28.     }
  29.     for (m=1; m<7; m++) {
  30.         for (n=2; n<7; n++) {
  31.             for (o=3; o<7; o++) {
  32.                 if (_root["f"+o]=="5,00 €"&&_root["f"+m]=="5,00 €"&&_root["f"+n]=="5,00 €") {
  33.                     _root["u"+m]._visible = true;
  34.                     _root["u"+m].play();
  35.                     _root["u"+n]._visible = true;
  36.                     _root["u"+n].play();
  37.                     _root["u"+o]._visible = true;
  38.                     _root["u"+o].play();
  39.                 }
  40.             }
  41.         }
  42.     }
  43.     for (m=1; m<7; m++) {
  44.         for (n=2; n<7; n++) {
  45.             for (o=3; o<7; o++) {
  46.                 if (_root["f"+o]=="10,00 €"&&_root["f"+m]=="10,00 €"&&_root["f"+n]=="10,00 €") {
  47.                     _root["u"+m]._visible = true;
  48.                     _root["u"+m].play();
  49.                     _root["u"+n]._visible = true;
  50.                     _root["u"+n].play();
  51.                     _root["u"+o]._visible = true;
  52.                     _root["u"+o].play();
  53.                 }
  54.             }
  55.         }
  56.     }
  57.     for (m=1; m<7; m++) {
  58.         for (n=2; n<7; n++) {
  59.             for (o=3; o<7; o++) {
  60.                 if (_root["f"+o]=="500,00 €"&&_root["f"+m]=="500,00 €"&&_root["f"+n]=="500,00 €") {
  61.                     _root["u"+m]._visible = true;
  62.                     _root["u"+m].play();
  63.                     _root["u"+n]._visible = true;
  64.                     _root["u"+n].play();
  65.                     _root["u"+o]._visible = true;
  66.                     _root["u"+o].play();
  67.                 }
  68.             }
  69.         }
  70.     }
  71.     for (m=1; m<7; m++) {
  72.         for (n=2; n<7; n++) {
  73.             for (o=3; o<7; o++) {
  74.                 if (_root["f"+o]=="50000,00 €"&&_root["f"+m]=="50000,00 €"&&_root["f"+n]=="50000,00 €") {
  75.                     _root["u"+m]._visible = true;
  76.                     _root["u"+m].play();
  77.                     _root["u"+n]._visible = true;
  78.                     _root["u"+n].play();
  79.                     _root["u"+o]._visible = true;
  80.                     _root["u"+o].play();
  81.                 }
  82.             }
  83.         }
  84.     }
  85.     for (m=1; m<7; m++) {
  86.         for (n=2; n<7; n++) {
  87.             for (o=3; o<7; o++) {
  88.                 if (_root["f"+o]=="25000,00 €"&&_root["f"+m]=="25000,00 €"&&_root["f"+n]=="25000,00 €") {
  89.                     _root["u"+m]._visible = true;
  90.                     _root["u"+m].play();
  91.                     _root["u"+n]._visible = true;
  92.                     _root["u"+n].play();
  93.                     _root["u"+o]._visible = true;
  94.                     _root["u"+o].play();
  95.                 }
  96.             }
  97.         }
  98.     }
  99.     for (m=1; m<7; m++) {
  100.         for (n=2; n<7; n++) {
  101.             for (o=3; o<7; o++) {
  102.                 if (_root["auto"+o]=="F"&&_root["auto"+m]=="F"&&_root["auto"+n]=="F") {
  103.                     _root["u"+m]._visible = true;
  104.                     _root["u"+m].play();
  105.                     _root["u"+n]._visible = true;
  106.                     _root["u"+n].play();
  107.                     _root["u"+o]._visible = true;
  108.                     _root["u"+o].play();
  109.                 }
  110.             }
  111.         }
  112.     }
__________________
von allen Gedanken schätze ich doch am meisten,die interessanten....
(Sterne)
stekke ist offline   Mit Zitat antworten
Alt 06-05-2004, 15:03   #3 (permalink)
meistens harmlos
 
Benutzerbild von rena
 
Registriert seit: Jun 2001
Ort: Stuttgart
Beiträge: 17.643
Prüf doch zuerst mal in einer Schleife durch ob's überhaupt drei oder mehr sind -> Zählvariable hochzählen.

Ist die Zählvariable über drei, dann gehst dieselbe Schleife nochmal durch, prüfst jedes Feld auf das Sternchen und wenn es das hat, machst dessen Rahmen sichtbar.

So hast du im Höchstfall zwei Schleifenblöcke.

Gruß
rena
__________________
www.rena-hermann.de

The angels have the phone box
rena ist offline   Mit Zitat antworten
Alt 06-05-2004, 15:07   #4 (permalink)
Neuer User
 
Benutzerbild von stekke
 
Registriert seit: Sep 2001
Beiträge: 622
und wie mach ich das?:-) var. hochzählen?

häng da schon den ganzen Tag dran,mein Hirn ist schon wie ein Brötchen.....
__________________
von allen Gedanken schätze ich doch am meisten,die interessanten....
(Sterne)
stekke ist offline   Mit Zitat antworten
Alt 06-05-2004, 15:15   #5 (permalink)
meistens harmlos
 
Benutzerbild von rena
 
Registriert seit: Jun 2001
Ort: Stuttgart
Beiträge: 17.643
So sollte das ganze gehen:
ActionScript:
  1. //die Funktion
  2. pruef = function () {
  3.     zaehler = 0;
  4.     for (i=1; i<=6; i++) {
  5.         if (_root["f"+i] == "*") {
  6.             zaehler++;
  7.         }
  8.     }
  9.     if (zaehler>=3) {
  10.         for (i=1; i<=6; i++) {
  11.             if (_root["f"+i] == "*") {
  12.                 _root["u"+i]._visible = true;
  13.             }
  14.         }
  15.     }
  16. };
  17. //aufruf
  18. pruef()
__________________
www.rena-hermann.de

The angels have the phone box
rena ist offline   Mit Zitat antworten
Alt 06-05-2004, 15:21   #6 (permalink)
Neuer User
 
Benutzerbild von stekke
 
Registriert seit: Sep 2001
Beiträge: 622
diese function gilt aber so erstmal nur für den Fall "*" oder?
Vielen Dank schonmal
Gruss

stekke
__________________
von allen Gedanken schätze ich doch am meisten,die interessanten....
(Sterne)
stekke ist offline   Mit Zitat antworten
Alt 06-05-2004, 15:28   #7 (permalink)
meistens harmlos
 
Benutzerbild von rena
 
Registriert seit: Jun 2001
Ort: Stuttgart
Beiträge: 17.643
Wenn nach beliebigem geprüft werden soll, gibst der Funktin einen parameter mit
ActionScript:
  1. //die Funktion
  2. pruef = function (was) {
  3.         zaehler = 0;
  4.         for (i=1; i<=6; i++) {
  5.                 if (_root["f"+i] == was) {
  6.                         zaehler++;
  7.                 }
  8.         }
  9.         if (zaehler>=3) {
  10.                 for (i=1; i<=6; i++) {
  11.                         if (_root["f"+i] == was) {
  12.                                 _root["u"+i]._visible = true;
  13.                         }
  14.                 }
  15.         }
  16. };
  17. //aufruf
  18. pruef("*") //<- hier nach was geprüft werden soll
  19.  

pruef(parameter) kannst ja dann auch wieder mehrmals aufrufen falls du nacheinander mehrere mögliche Einträge vergleichen möchtest.
__________________
www.rena-hermann.de

The angels have the phone box
rena ist offline   Mit Zitat antworten
Alt 06-05-2004, 15:43   #8 (permalink)
Neuer User
 
Benutzerbild von stekke
 
Registriert seit: Sep 2001
Beiträge: 622
vielen Dank für die Hilfe,scheint zu funktionieren
__________________
von allen Gedanken schätze ich doch am meisten,die interessanten....
(Sterne)
stekke 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 08:18 Uhr.

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


Copyright ©1999 – 2012 Marc Thiele