Advertisement
Guest User

Untitled

a guest
Mar 6th, 2011
242
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package
  2. {
  3.     import flash.display.Sprite;
  4.     import flash.events.Event;
  5.     import flash.events.ProgressEvent;
  6.     import flash.filters.DropShadowFilter;
  7.    
  8.     import mx.events.FlexEvent;
  9.     import mx.preloaders.DownloadProgressBar;
  10.  
  11.     public class Pre extends DownloadProgressBar
  12.     {
  13.         private var cp:customPreloader;
  14.        
  15.         public function Pre()
  16.         {
  17.             cp = new customPreloader();
  18.             cp.filters = [new DropShadowFilter(4, 45, 0, 0.5)];
  19.             addEventListener(Event.ADDED_TO_STAGE, onAdded);
  20.             addChild(cp);
  21.         }
  22.        
  23.         public override function set preloader(preloader:Sprite):void
  24.         {
  25.             preloader.addEventListener(ProgressEvent.PROGRESS, onProgress);
  26.             preloader.addEventListener(FlexEvent.INIT_COMPLETE, initComplete);
  27.         }
  28.        
  29.         private function onProgress(e:ProgressEvent):void
  30.         {
  31.             cp.percent.text = Math.ceil(e.bytesLoaded/e.bytesTotal*100).toString() + "%";
  32.             cp.gotoAndStop(Math.ceil(e.bytesLoaded/e.bytesTotal*100));
  33.         }
  34.        
  35.         private function initComplete(e:Event):void
  36.         {
  37.             dispatchEvent(new Event(Event.COMPLETE));
  38.         }
  39.        
  40.         private function onAdded(e:Event):void
  41.         {
  42.             cp.stop();
  43.             cp.x = stage.stageWidth*0.5 - 135;
  44.             cp.y = stage.stageHeight*0.5 - 34;
  45.         }
  46.        
  47.     }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement