Zaloguj się, by sprawdzić wiadomości
Strona główna Grupy Użytkownicy Twoje konto Statystyki Rejestracja Zaloguj

TWOJA STRONA NA NASZYM SERWISIE! Wiecej info --> http://osin.ovh.org/stronadlaciebie.php !

TWOJA STRONA NA NASZYM SERWISIE! Wiecej info --> http://osin.ovh.org/index1.php !


Poprzedni temat «» Następny temat
ProgressBar
Autor Wiadomość
Jurk 
Administrator
Admin/Programista ;]


Dołączył: 23 Kwi 2008
Posty: 291
Skąd: Wawa
Wysłany: 2008-04-24, 19:33   ProgressBar

Kod należy umieścić w pliku ProgressBar.as w katalogu pl/burzaone/website/preloader/bar.

Kod:
/**
* ...
* @author burzaone
* @version 0.1
* @license: freeware
*
* How to use this class?
*
*     import pl.burzaone.website.preloader.bar.ProgressBar;
*     var progressBar:ProgressBar = new ProgressBar( 300 , 15 , 0x000000 , 1 , 0x0000ff , 0xffffff , new TextFormat( "Arial" , 8 , 0xffff00 , true , false, false, null , null , "center" ) , new TextFormat( "Arial" , 8 , 0xffffff , true , false, false, null , null , "center" ) , 1 , false );
*     progressBar.update( bytesLoaded , bytesTotal ); // in body event
*/

package pl.burzaone.website.preloader.bar
{
   import flash.display.GradientType;
   import flash.display.Shape;
   import flash.display.Sprite;
   import flash.geom.Matrix;
   import flash.text.TextField;
   import flash.text.TextFieldAutoSize;
   import flash.text.TextFormat;
   
   public class ProgressBar extends Sprite
   {
      private var _width:uint;
      private var _height:uint;
      private var _alpha:uint;
      private var _borderColor:uint;
      private var _borderWeight:uint;
      private var _barColor1:uint;
      private var _barColor2:uint;
      private var _textFormat1:TextFormat;
      private var _textFormat2:TextFormat;
      private var _roundCorner:uint;
      private var _autoHide:Boolean = false;
      private var _embed:Boolean
      private var _showText:Boolean = true;
     
      private var _tfInBar:Boolean = false;
     
      private var _bg:Shape;
      private var _bar:Shape = new Shape();
      private var _mask_bottom:Shape;
      private var _mask_top:Shape;
     
      private var _tf_bottom:TextField;
      private var _tf_top:TextField;
     
      public function ProgressBar( width_:uint , height_:uint , borderColor:uint , borderWeight:uint , barColor1:uint , barColor2:uint , textFormat1:TextFormat , textFormat2:TextFormat , alpha_:Number , autoHide:Boolean = false , showText:Boolean = true , roundCorner:uint = 0 , embededFonts:Boolean = false ):void
      {
         alpha = alpha_;
         
         _width = width_;
         _height = height_;
         _borderColor = borderColor;
         _borderWeight = borderWeight;
         _barColor1 = barColor1;
         _barColor2 = barColor2;
         _textFormat1 = textFormat1;
         _textFormat2 = textFormat2;
         _roundCorner = roundCorner;
         _autoHide = autoHide;
         _embed = embededFonts;
         _showText = showText;
         
         generateLayout();
         
         visible = false;
         
      }
     
      public function show():void
      {
         visible = true;
         return;
      }
      public function hide():void
      {
         visible = false;
         return;
      }
      public function update( bytesLoaded:uint , bytesTotal:uint ):void
      {
         var procent:uint = Math.round( ( bytesLoaded / bytesTotal ) * 100 );
         var skala:Number = bytesLoaded / bytesTotal ;
         
         var w:Number = Math.round( _width * skala ) - _borderWeight * 2;
         
         var matrix:Matrix = new Matrix();
         matrix.createGradientBox( w , _height - _borderWeight * 2 );
         
         if( _tfInBar && _showText )
         {
            _tf_bottom.x = ( _width - _tf_bottom.width ) / 2 ;
            _tf_bottom.y = - _tf_bottom.height ;
         }
         else if( _showText )
         {
            _tf_bottom.x = ( _width - _tf_bottom.width ) / 2 ;
            _tf_bottom.y = ( _height - _tf_bottom.height ) / 2 ;
            _tf_top.x = ( _width - _tf_top.width ) / 2 ;
            _tf_top.y = ( _height - _tf_top.height ) / 2 ;
           
            _mask_top.graphics.clear();
            _mask_top.graphics.beginFill( _barColor2 , 1 );
            if( _roundCorner != 0 )
            _mask_top.graphics.drawRoundRect( 0 , 0 , w , _height - _borderWeight * 2 , _roundCorner - _borderWeight , _roundCorner - _borderWeight );
            else
            _mask_top.graphics.drawRect( 0 , 0 , w , _height - _borderWeight * 2 );
            _mask_top.graphics.endFill();
           
            _mask_bottom.graphics.clear();
            _mask_bottom.graphics.beginFill( _barColor1 , 1 );
            if( _roundCorner != 0 )
            _mask_bottom.graphics.drawRoundRect( 0 , 0 , _width - w , _height - _borderWeight * 2 , _roundCorner - _borderWeight , _roundCorner - _borderWeight );
            else
            _mask_bottom.graphics.drawRect( 0 , 0 , _width - w , _height - _borderWeight * 2 );
            _mask_bottom.graphics.endFill();
         }
         
         _bar.graphics.clear();
         _bar.graphics.beginGradientFill( GradientType.LINEAR , [ _barColor1 , _barColor2 ] , [ 1 , 1 ] , [ 0 , 255 ] , matrix );
         if( _roundCorner != 0 )
         _bar.graphics.drawRoundRect( 0 , 0 , w , _height - _borderWeight * 2 , _roundCorner - _borderWeight * 2 , _roundCorner - _borderWeight * 2 );
         else
         _bar.graphics.drawRect( 0 , 0 , w , _height - _borderWeight * 2 );
         _bar.graphics.endFill();
         
         if( _tfInBar && _showText )
         {
            _tf_bottom.text = ( procent >= 100 )? "Complete" : "Downloading... " + procent + "%" ;
         }
         else if( _showText )
         {
            _mask_bottom.x = _bar.width + _bar.x ;
           
            _tf_bottom.text = _tf_top.text = ( procent >= 100 )? "Complete" : "Downloading... " + procent + "%" ;
         }
         
         if( _autoHide && procent == 100 )
         hide();
         
         return;
      }
     
     
      private function generateLayout():void
      {
         _bg = new Shape();
         
         _bg.graphics.beginFill( _borderColor , 1 );
         if( _roundCorner == 0 )
         _bg.graphics.drawRect( 0 , 0 , _width , _height );
         else
         _bg.graphics.drawRoundRect( 0 , 0 , _width , _height , _roundCorner , _roundCorner );
         _bg.graphics.endFill();
         addChild( _bg );
         
         _bar.x = _borderWeight;
         _bar.y = _borderWeight;
         addChild( _bar );
         
         _tf_bottom = new TextField();
         addChild( _tf_bottom );
         _mask_bottom = new Shape();
         addChild( _mask_bottom );
         _tf_bottom.mask = _mask_bottom;
         
         _tf_top = new TextField();
         addChild( _tf_top );
         _mask_top = new Shape();
         addChild( _mask_top );
         _tf_top.mask = _mask_top;
         
         _mask_bottom.y = _mask_bottom.y = _borderWeight;
         _mask_bottom.x = _mask_bottom.x = _borderWeight;
         
         _tf_bottom.width = _tf_top.width = _width;
         _tf_bottom.height = _tf_top.height = _height;
         _tf_bottom.selectable = _tf_top.selectable = false;
         _tf_bottom.wordWrap = _tf_top.wordWrap = false;
         _tf_bottom.multiline = _tf_top.multiline = false;
         _tf_bottom.autoSize = _tf_top.autoSize = TextFieldAutoSize.LEFT;
         _tf_bottom.embedFonts = _tf_top.embedFonts = _embed;
         
         _tf_bottom.defaultTextFormat = _textFormat1;
         _tf_top.defaultTextFormat = _textFormat2;
         
         _tf_bottom.text = "Test passing...";
         
         if( _tf_bottom.height > _height )
         {
            _tfInBar = true;
            _tf_bottom.mask = null;
            _mask_top.visible = _mask_bottom.visible = _tf_top.visible = false;
         }
         _tf_bottom.text = "";
         
         return;
      }
   }
   
}
 
 
     
Grafiak

Dołączył: 23 Kwi 2009
Posty: 1
Wysłany: 2009-04-23, 20:12   

moze sie przydac :) dzieki :)
 
     
Wyświetl posty z ostatnich:   
Odpowiedz do tematu
Nie możesz pisać nowych tematów
Nie możesz odpowiadać w tematach
Nie możesz zmieniać swoich postów
Nie możesz usuwać swoich postów
Nie możesz głosować w ankietach
Dodaj temat do Ulubionych
Wersja do druku

Skocz do:  

Powered by phpBB modified by Przemo © 2003 phpBB Group

page rank
Strona wygenerowana w 0,33 sekundy. Zapytań do SQL: 8


=====
=======================================================================
Wymiana Linkow:

Najwieksza wyszukiwarka craków w sieci
Wymiana linków Ogloszenia motoryzacyjne Domy Bezpłatne ogłoszenia Praktyki Noclegi Anonse matrymonialne Darmowe galerie Szablony stron Wizytówki www Web templates Strony internetowe Baza stron www Darmowe domeny Check Link Popularity Darmowe porady prawne Plany miast Przedruk artykułów

=======================================================================
Katalogi:

Polski Katalog Stron Internetowych Falenica - katalog stron internetowych Katalog Stron www Katalog Stron DARMOWY KATALOG STRON | DODAJ DARMOWY WPIS katalog stron internetowych www Katalog Stron SEO Katalog 3CO

Katalog stron, toplisty, narzędzia webmastera Noclegi w Polsce Katalog Stron Hurricane jaclaw Darmowy wpis Katalog stron Natal Sznurkownia - Katalog www, sznurków i linków dla pajšków i pingwinków