Zurück   Flashforum > Flash > ActionScript > ActionScript 1

Antwort
 
LinkBack Themen-Optionen Ansicht
Alt 04-10-2003, 01:38   #1 (permalink)
KEINE AHNUNG
 
Benutzerbild von MalcomX
 
Registriert seit: Jun 2001
Ort: Germany
Beiträge: 967
Vars aus Textdatei in Array ?

Hi Hi ! ! !

Kann man die Variablen einer Textdatei in ein Array einlesen?

meine Textdatei enthält folgendes:
___________________

&anzahlpc=12

&pc1ip=0.0.0.0
&pc1cpu=Pentium 4
&pc1os=Windows XP
&pc2ip=1.1.1.1
&pc2cpu=AMD Athlon
&pc2os=Linux
___________________

Wie man ja sehen kann is an 1.Stelle die Anzahl der PC's verzeichnet. Jetzt möchte ich das, das Array die Anzahl der PC's berücksichtigt und dann die einzelnen Werte der einz. PC's einliest.

Is dat 'n riesen Akt bzw. is so wat überhaupt möglich? Muß noch hinzufügen das ich bis jetzt noch nich so viel mit Arrays zu tun hatte.

Gruß
MalcomX
MalcomX ist offline   Mit Zitat antworten
Alt 04-10-2003, 02:16   #2 (permalink)
Geomatik-Flasher
 
Benutzerbild von Totty
 
Registriert seit: Aug 2002
Ort: Karlsruhe
Beiträge: 162
Klar geht das!

Wenn Du die Textdatei mit loadVariablesNum auf _root geladen hast, dann geht's ungefähr so weiter:
ActionScript:
  1. pcArray = new Array(Number(anzahlpc));
  2. for (i=0;i<pcArray.length;i++) {
  3. pcArray[i] = new Array(3);
  4. pcArray[i][0] = _root["pc"+i+"ip"];
  5. pcArray[i][1] = _root["pc"+i+"cpu"];
  6. pcArray[i][2] = _root["pc"+i+"os"];
  7. }
Das sollte dann passen...

MfG

Totty
__________________
Where in this small-thinking world can I find a longitude without a platitude?
Totty ist offline   Mit Zitat antworten
Alt 04-10-2003, 13:44   #3 (permalink)
KEINE AHNUNG
 
Benutzerbild von MalcomX
 
Registriert seit: Jun 2001
Ort: Germany
Beiträge: 967
Hi Hi ! ! !

Danke erst ma für deinen Tipp !

Ich versteh's einfach nicht, denn wie kann es sein das sobald wie ich ne neue Var in der Texdatei hinzufüge mein ganzer Clip nich mehr funtzt ? Und das komische daran ist ich kann den neuen Wert in der .txt auch wieder rauslöschen, trotzdem funtzt mein Clip nich mehr.Flash kann und will mir einfach nicht verzeihn, das ich nen neuen Wert hinzugef. habe

Vielleicht könnte sich ja das mal jemand anschaun ! habs mal angehängt.

Gruß und Danke schon mal im voraus
Malcom
Angehängte Dateien
Dateityp: zip test.zip (11,2 KB, 2x aufgerufen)
MalcomX ist offline   Mit Zitat antworten
Alt 04-10-2003, 18:15   #4 (permalink)
Geomatik-Flasher
 
Benutzerbild von Totty
 
Registriert seit: Aug 2002
Ort: Karlsruhe
Beiträge: 162
So geht's!

ActionScript:
  1. stop();
  2. //Intervall ob Variable ausgelesen
  3. obj = new Object();
  4. obj.interval = function() {
  5.     trace(my_load.anzahlpc);
  6.     if(my_load.anzahlpc>0){
  7.         trace("Variable verfügbar");
  8.         trace("_root.anzpc= "+_root.anzpc);
  9.         anzeige();
  10.         clearInterval(inter);
  11.     }
  12. }
  13. var inter = setInterval(obj,"interval",1000);
  14. //_____________________________________________________
  15. //VARS auslesen
  16. var my_load=new LoadVars();
  17. my_load.onLoad=function(success){
  18.         if(success){
  19.                 trace("anzahl: "+this.anzahlpc);
  20.                 _root.anzpc=this.anzahlpc;
  21.                 trace("Name: "+this.name);
  22.                 _root.pcArray = new Array(Number(_root.my_load.anzahlpc));
  23.                 for (i=1;i<=_root.my_load.anzahlpc;i++) {
  24.                         _root.pcArray[i] = new Array();
  25.                         _root.pcArray[i][0] = _root.my_load["pc"+i+"ip"];
  26.                         _root.pcArray[i][1] = _root.my_load["pc"+i+"cpu"];
  27.                         _root.pcArray[i][2] = _root.my_load["pc"+i+"os"];
  28.                 }
  29.         }else{
  30.                 trace("fehler beim laden");
  31.         }
  32. }
  33. my_load.load("name.txt");
  34. //_____________________________________________________
  35. //Filme auf Bühne
  36. buehnenbreite=1024;
  37. buehnenhoehe=768;
  38. line=200;
  39. function anzeige(){
  40.     for(i=1;i<=_root.anzpc;i++){
  41.         pcmc.duplicateMovieClip("pc"+i,i);
  42.         this["pc"+i]._y=line;
  43.         this["pc"+i]._x=xpos+120;
  44.         pchoehe=this["pc"+i]._width;
  45.         xpos=this["pc"+i]._x;
  46.         trace(xpos);
  47.         //Variablen verteilen
  48.         _root["pc"+i].ip = _root.pcArray[i][0];
  49.         _root["pc"+i].cpu = _root.pcArray[i][1];
  50.         _root["pc"+i].os = _root.pcArray[i][2];
  51.     (xpos>=800)?(line+=150)&&(xpos=0):{};
  52.     }
  53. }
__________________
Where in this small-thinking world can I find a longitude without a platitude?
Totty 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 11:00 Uhr.

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


Copyright ©1999 – 2012 Marc Thiele