Advertisement
henke37

PerformanceMonitor test

Apr 11th, 2014
356
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import HTools.FPS.PerformanceMonitor;
  2. import flash.events.*;
  3. import flash.display.*;
  4.  
  5. const filePath:String="";
  6. const fileName:String="";
  7.  
  8. //[Embed(source="",mimeType="application/octet-stream")]
  9. //var cl:Class;
  10.  
  11. var l:Loader=new Loader();
  12. addChildAt(l,0);
  13. l.load(new URLRequest(filePath+fileName));
  14. //l.loadBytes(new cl());
  15. l.contentLoaderInfo.addEventListener(Event.COMPLETE,start);
  16.  
  17. stage.align=StageAlign.TOP_LEFT;
  18. stage.scaleMode=StageScaleMode.NO_SCALE;
  19.  
  20. function start(e:Event) {
  21.     stage.frameRate=l.contentLoaderInfo.frameRate;
  22.     //trace(l.contentLoaderInfo.width,l.contentLoaderInfo.height,l.contentLoaderInfo.frameRate);
  23.     //l.content.play();
  24.     //log.checkTimeline=l.content;
  25.     stage.color=colorForMovie(l.contentLoaderInfo.bytes);
  26.    
  27.     stage.addEventListener(Event.RESIZE,size);
  28.    
  29.     size();
  30. }
  31.  
  32. function size(e:Event=null):void {
  33.     var arMovie:Number=l.contentLoaderInfo.width/l.contentLoaderInfo.height;
  34.     var arStage:Number=stage.stageWidth/stage.stageHeight;
  35.    
  36.     var scale:Number;
  37.     if(arMovie<arStage) {
  38.         scale=stage.stageHeight/l.contentLoaderInfo.height;
  39.     } else {
  40.         scale=stage.stageWidth/l.contentLoaderInfo.width;
  41.     }
  42.     l.scaleX=scale;
  43.     l.scaleY=scale;
  44.    
  45.     log.scaleY=log.scaleX=scale;
  46.    
  47.     var scaledWidth:Number=l.contentLoaderInfo.width*scale;
  48.     var scaledHeight:Number=l.contentLoaderInfo.height*scale;
  49.    
  50.     l.x=(stage.stageWidth-scaledWidth)/2;
  51.     l.y=(stage.stageHeight-scaledHeight)/2;
  52. }
  53.  
  54. var log=new PerformanceMonitor();
  55. addChild(log);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement