Skip to content
Dec 22 / Peter deHaan

Setting the volume on an FLVPlayback component in Flash using ActionScript 3.0

The following example shows how you can set the volume level on a Flash ActionScript 3.0 FLVPlayback control by setting the volume property.

Full code after the jump.

// ActionScript 3.0
/* Requires:
 * - Button component in Flash library
 * - Slider component in Flash library
 * - FLVPlayback component in Flash library
 */
import fl.controls.Button;
import fl.controls.Slider;
import fl.events.SliderEvent;
import fl.video.FLVPlayback;
 
var button:Button = new Button();
button.label = "Play";
button.addEventListener(MouseEvent.CLICK, button_click);
button.move(10, 10);
addChild(button);
 
var slider:Slider = new Slider();
slider.minimum = 0.0;
slider.maximum = 1.0;
slider.value = 1.0;
slider.tickInterval = 0.1;
slider.snapInterval = 0.01;
slider.liveDragging = true;
slider.addEventListener(SliderEvent.CHANGE, slider_change);
slider.move(120, 20);
addChild(slider);
 
var flvPlayback:FLVPlayback = new FLVPlayback();
flvPlayback.autoPlay = false;
flvPlayback.source = "http://www.helpexamples.com/flash/video/cuepoints.flv";
flvPlayback.x = 10;
flvPlayback.y = 40;
addChild(flvPlayback);
 
function button_click(evt:Event):void {
    flvPlayback.stop();
    flvPlayback.seek(0);
    flvPlayback.play();
}
 
function slider_change(evt:SliderEvent):void {
    flvPlayback.volume = evt.value;
}

2 Comments

leave a comment
  1. silky / Feb 1 2010

    Do you have any FLV sample for this As3?

  2. Peter deHaan / Feb 1 2010

    @silky,

    You can download the FLV from http://helpexamples.com/flash/video/cuepoints.flv

    Peter

Leave a Comment