Advertisement
Scriv07

Untitled

Sep 2nd, 2017
422
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package  {
  2.    
  3.     import flash.display.MovieClip;
  4.     import flash.text.TextField;
  5.    
  6.     import hudframework.IHUDWidget;
  7.    
  8.     /**
  9.     */
  10.            import flash.geom.*;
  11.  
  12.  
  13.  
  14.        
  15.     public class WeapDeg extends MovieClip implements IHUDWidget{
  16.         // HUDFramework Config
  17.         private static const WIDGET_IDENTIFIER:String = "WeaponDegWidget.swf";
  18.        
  19.         // Command IDs
  20.         private static const Command_UpdateCount:int = 100;
  21.        
  22.         // Hello World Textfield
  23.         public var count_tf:TextField;
  24.        
  25.         public function WeapDeg() {}
  26.        
  27.        
  28.         var ct_white = new ColorTransform(0, 0, 0, 1, 255, 255, 255, 0);
  29.         var ct_red = new ColorTransform(0, 0, 0, 1, 255, 32, 32, 0);
  30.         var ct_yellow = new ColorTransform(0, 0, 0, 1, 255, 255, 32, 0);
  31.         var ct_green = new ColorTransform(0, 0, 0, 1, 32, 255, 32, 0);
  32.        
  33.                
  34.       public function processMessage(param1:String, param2:Array) : void
  35.       {
  36.          switch(param1)
  37.          {
  38.             case String(Command_UpdateCount):
  39.                this.count_tf.text = String(int(param2[0]));
  40.                if    (int(param2[0])>75) {
  41.                     this.transform.colorTransform = ct_green;
  42.                } else if (int(param2[0])>25) {
  43.                     this.transform.colorTransform = ct_yellow;
  44.                } else {
  45.                     this.transform.colorTransform = ct_red;
  46.                }
  47.                break;
  48.          }
  49.       }
  50.       public function getCTF(aiValue: int):ColorTransform
  51.         {
  52.             // you cannot use a variable without declaring it first..
  53.             // well maybe you can in shitty actionscript?
  54.             var tempCTF:ColorTransform;
  55.  
  56.             if (aiValue == 0) {
  57.                 tempCTF = new ColorTransform(0, 0, 0, 0.05, 0, 0, 0, 0);
  58.             } else if (aiValue < 50) {
  59.                 tempCTF = new ColorTransform(0, 0, 0, 1, 255, 32+aiValue*4.46, 32, 0);
  60.             } else if (aiValue == 50) {
  61.                 tempCTF = new ColorTransform(0, 0, 0, 1, 255, 255, 32, 0);
  62.             } else {
  63.                 tempCTF = new ColorTransform(0, 0, 0, 1, 32 + (100-aiValue)*4.46, 255, 32, 0);
  64.             }
  65.             return tempCTF;
  66.         }
  67.        
  68.     }
  69.    
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement