Preloader (AS) (MX)

Matthias Kannengiesser

Erfahrenes Mitglied
Hi Folks,

Hier ein Preloader, welcher rein aus AS Anweisungen besteht - inklusive Wartefunktion:

PHP:
/*

Flash MX - Preloader v1
(Inklusive Warteschleife)

posX = loader Position X-Achse
posY = loader Position Y-Achse
Breite = Entgültige Breite des Balken in Pixel
Hoehe = Höhe des Balken
Farbe = Farbe des Balken
Warten = Wartezeit in Sekunden
Bild = Zu welchem Bild gesprungen werden soll
Signal = Bildsprung (1: GotoAndPlay oder 0: GotoAndStop)

*/

Movieclip.prototype.loader = function (posX,posY,Breite,Hoehe,Farbe,Warten,Bild,Signal) {
	
this.createEmptyMovieClip("pre",1);

pre.onEnterFrame = function () {
	
   // Position Preloader
   this._x = posX;
   this._y = posY;
   
   // Gesamt & Geladen 
   this.gesamt = _root.getBytesTotal();
   this.geladen = _root.getBytesLoaded();   
   
   // Prozentberechnung
   prozent = (int((this.geladen/this.gesamt)*100));
   
   // Statusbalken
   this.createEmptyMovieClip("bar", 2);   
   this.bar.beginFill (Farbe,100)
   this.bar.moveto(prozent*Breite/100,Hoehe);
   this.bar.lineto(prozent*Breite/100,0);
   this.bar.lineto(0,0);
   this.bar.lineto(0,Hoehe);
   this.bar.lineto(Hoehe,Hoehe);
   this.bar.endFill();
   
   // Textfeld
   this.createTextField("pFeld", 1, 0, 0, 100, 16);   
   this.pFeld.autoSize = "left";
   this.pFeld.selectable = false;
   this.pFeld._y += (Hoehe);   
   
   // Textfeld Format
   this.mForm = new TextFormat();
   this.mForm.font = "Arial";   
   this.mForm.size = 10;
   this.mForm.color = 0x000000;   
   this.pFeld.text = prozent + "%";
   this.pFeld.setTextFormat(this.mForm);   
   
   if (this.gesamt == this.geladen) {
	  _root.Pause(Warten,Bild,Signal);      	  
   }
}
}

MovieClip.prototype.Pause = function(pzeit,bild,Sig) {        
        this.stop();
		var go = function(obj) {				
      			pre.removeMovieClip();
				if (Sig) {
                	obj.gotoAndPlay(bild);
				} else {
					obj.gotoAndStop(bild);
				}
                clearInterval(id);
        }		
        var id = setInterval(go,pzeit*1000,this);
}

loader(200,200,150,10,0xFF0000,2,5,0);
stop();

Beispiel:
Preloader (Beispiel mit 2 Sek Wartezeit)

Be inspired...

mfg
Matze K.
 

Neue Beiträge

Zurück