Zurück   Flashforum > Flash > ActionScript > ActionScript 1

Antwort
 
LinkBack Themen-Optionen Ansicht
Alt 02-01-2004, 18:13   #1 (permalink)
#no.991 @ MM
 
Benutzerbild von hugeinc
 
Registriert seit: Apr 2003
Ort: München
Beiträge: 327
SWF und XML Loader

HI zusammen,
ich hab mir mal nen komplett dynamischen SWF und nen XML Loader ausgedacht.
Trotzdem hab ich noch ne Frage dazu.
Das Script sieht so aus:
ActionScript:
  1. // zwei Textfelder erzeugen
  2. _root.createTextField("showLoadSWF", 1, 0, 15, 300, 100);
  3. _root.createTextField("showLoadXML", 2, 0, 30, 300, 100);
  4.  
  5. // Textdarstellung festlegen
  6. textformat = new TextFormat();
  7. textformat.font = "Arial";
  8. textformat.size = 10;
  9. textformat.color = 0x000000;
  10.  
  11. // los gehts
  12. this.onEnterFrame = function() {
  13. // movieloader
  14.     gesamtSWF = getBytesTotal();
  15.     bereitsSWF = getBytesLoaded();
  16.     prozentSWF = int(bereitsSWF*100/gesamtSWF);
  17.     anzeigeSWF = "loading movie data | " add prozentSWF+"% | " add int(bereitsSWF/1000) add "kB | " add int(gesamtSWF/1000) add "kB";
  18.     showLoadSWF.text = anzeigeSWF;
  19.     showLoadSWF.setTextFormat(textformat);
  20.    
  21. // xml loader
  22.     gesamtXML = dataXML.getBytesTotal();
  23.     bereitsXML = dataXML.getBytesLoaded();
  24.     prozentXML = int(bereitsXML*100/gesamtXML);
  25.     anzeigeXML = "loading xml data | " add prozentXML+"% | " add int(bereitsXML/1000) add "kB | " add int(gesamtXML/1000) add "kB";
  26.     showLoadXML.text = anzeigeXML;
  27.     showLoadXML.setTextFormat(textformat);
  28.    
  29. // Balken aus beiden Prozentangaben erzeugen und skalieren
  30.     prozent = (prozentSWF+prozentXML)/2;
  31.     this.drawRect(0, 0, prozent, 5, 0x000000, prozent);
  32.    
  33. // wenn SWF geladen, neue Anzeige
  34.     if (prozentSWF == 100) {
  35.     showLoadSWF.text = "complete";
  36.     showLoadSWF.setTextFormat(textformat);
  37.     }
  38.  
  39. // wenn XML geladen, neue Anzeige
  40.     if (prozentXML == 100) {
  41.     showLoadXML.text = "complete";
  42.     showLoadXML.setTextFormat(textformat);
  43.     }
  44.  
  45. // wenn alles geladen, alle Clips wieder entfernen
  46.     if (prozent == 100) {
  47.     removeMovieClip("showLoadSWF")
  48.     removeMovieClip("showLoadXML")
  49.     removeMovieClip(this.drawRect) // das hier geht nicht
  50.     }
  51. }
  52.  
  53. // MovieClip fuer Balkenanzeige
  54. MovieClip.prototype.drawRect = function(x, y, w, h, RGB, alpha) {
  55.     this.moveTo(x, y);
  56.     this.beginFill(RGB, alpha);
  57.     this.lineTo(x+w, y);
  58.     this.lineTo(x+w, y+h);
  59.     this.lineTo(x, y+h);
  60.     this.lineTo(x, y);
  61.     this.endFill;
  62. }
  63.  
  64. // XML + Pfad
  65. dataXML = new XML();
  66. dataXML.load("data.xml");
  67.  
  68. dataXML.onLoad = function(status) {
  69.     if (status) {
  70.         // mach dies
  71.     } else {
  72.         // mach jenes
  73.     }
  74. }
Zwei Fragen noch dazu.
Ich krieg den Balken einfach nicht mehr weg

Und - dass müsste doch noch einfacher gehen.
Ich finds noch ein bisschen viel Script

Greets, Micha
__________________
Arbeit ist keine Lösung...
hugeinc ist offline   Mit Zitat antworten
Alt 02-01-2004, 22:24   #2 (permalink)
nerdig working
 
Benutzerbild von michael
 
Registriert seit: Jul 2001
Ort: Hamburg
Beiträge: 5.832
du versuchst auch eine movieclipmethode zu entfernen

anstelle von removeMovieClip(this.drawRect) benutze

ActionScript:
  1. this.clear();

das entfernt mit drawingAPI erzeugtes.

das script wird viel kürzer nicht gehen

gruß
michael
michael ist offline   Mit Zitat antworten
Alt 03-01-2004, 11:12   #3 (permalink)
#no.991 @ MM
 
Benutzerbild von hugeinc
 
Registriert seit: Apr 2003
Ort: München
Beiträge: 327
Hi Micha
> this.clear();
Du lieber Gott, die einfachsten Dinge.
Hatte aber den Vorteil, dass ich darurch noch auf ne Idee fürs Design gekommen bin

> AS kürzer
Das muss doch gehen?
Ich hatte mir vorgestellt, dass z.B. der Loader in einem Prototype liegt etc.

Greets, Micha
__________________
Arbeit ist keine Lösung...
hugeinc 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 09:08 Uhr.

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


Copyright ©1999 – 2012 Marc Thiele