Volume Control : Controls : Graphics Flash / Flex / ActionScript examples


Flash / Flex / ActionScript examples » Graphics » Controls »

 

Volume Control


 
package{
   import flash.display.*;
   import flash.events.*;
   
    public class Main extends Sprite {
        public var volume:Number = 1.0;
        
        public function Main(  ){
            addEventListener(MouseEvent.CLICK, onClick);
            draw(  );
        }
        
        public function onClick(event:MouseEvent):void
        {
            // When user clicks the bar, set the volume
            volume = event.localX / 100;
            draw(  );
            dispatchEvent(new Event(Event.CHANGE));
        }
        
        private function draw(  ):void {
            // Draw a bar and the current volume position
            graphics.beginFill(0xcccccc);
            graphics.drawRect(0010216);
            graphics.endFill(  );
            
            graphics.beginFill(0x000000);
            graphics.drawRect(volume * 1000216);
        }
    }
}

        



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


Flash / Flex / ActionScript examples

 Navioo Graphics
» Controls