Manually setting values on a ProgressBar control in Flash using ActionScript 3.0

by Peter deHaan on December 18, 2008

in ProgressBar

The following example shows how you can manually set an ActionScript 3.0 ProgressBar control’s value by setting the progress bar’s mode property to the static ProgressBarMode.MANUAL constant and calling the setProgress() method.

Full code after the jump.

// ActionScript 3.0
/* Requires:
 * - ProgressBar control in Library
 * - Slider control in Library
 */
import fl.controls.ProgressBar;
import fl.controls.ProgressBarMode;
import fl.controls.Slider;
import fl.events.SliderEvent;
 
var slider:Slider = new Slider();
slider.minimum = 0;
slider.maximum = 100;
slider.liveDragging = true;
slider.move(10, 10);
slider.addEventListener(SliderEvent.CHANGE, slider_change);
addChild(slider);
 
var progressBar:ProgressBar = new ProgressBar();
progressBar.mode = ProgressBarMode.MANUAL;
progressBar.setSize(300, 100);
progressBar.move(100, 100);
addChild(progressBar);
 
function slider_change(evt:SliderEvent):void {
    progressBar.setProgress(evt.value, slider.maximum);
}

{ 0 comments… add one now }

Leave a Comment

You can use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">

Previous post: Opening URLs in new browser windows using ActionScript 3.0 and ActionScript 2.0

Next post: Creating an indeterminate ProgressBar control in Flash using ActionScript 3.0