0 Replies Latest reply on Mar 12, 2014 2:33 AM by slesin

    Gauge with timer

    slesin

      I would like to make a gauge that shows the current value. What to add to the current value of the indication showed? How do I make a indication was a graphic? Because he is just an ordinary rectangle. And something timer.

      package {
         
      import flash.display.Sprite;
         
      import flash.events.Event;

         
      public class Main extends Sprite {
             
      var gauge:Sprite;
             
      var target:Number;
             
      var wait:int;
             
      var time:int;

             
      function Main():void {
                  gauge
      = new Sprite();
                  gauge
      .graphics.beginFill(0x000000);
                  gauge
      .graphics.drawRect(0,-5,-140,10);
                  gauge
      .graphics.endFill();
                  gauge
      .x = stage.stageWidth * 0.5;
                  gauge
      .y = stage.stageHeight * 0.5;
                  addChild
      (gauge);
                 
      //
                  target
      = Math.random() * 180;
                  wait
      = int(Math.random() * 62 + 24);
                  time
      = 0;
                  addEventListener
      (Event.ENTER_FRAME, go);
             
      }

             
      public function go(e:Event):void {
                 
      if (time < wait) {
                      gauge
      .rotation +=  (target - gauge.rotation) * 0.15;
                      time
      ++;
                 
      } else {
                      time
      = 0;
                      target
      = Math.random() * 180;
                      wait
      = int(Math.random() * 62 + 24);
                 
      }
             
      }
         
      }
      }

      Simply, i would like a gauge as here: http://visunetdemos.demos.ibm.com/tourdeflex30/blackgauges/blackgauges.html.

      Do not manually set the value, just random.