Creating a vertical Slider control in Flash using ActionScript 3.0

by Peter deHaan on March 5, 2009

in Slider

The following example shows how you can create a horizontal or vertical Slider control in Flash using ActionScript 3.0 by setting the Slider control’s direction property to one of the static constants in the fl.controls.SliderDirection class (SliderDirection.HORIZONTAL or SliderDirection.VERTICAL).

Full code after the jump.

// ActionScript 3.0
import fl.controls.ComboBox;
import fl.controls.Slider;
import fl.controls.SliderDirection;
import fl.data.DataProvider;
 
var dp:DataProvider = new DataProvider();
dp.addItem({label:SliderDirection.HORIZONTAL});
dp.addItem({label:SliderDirection.VERTICAL});
 
var comboBox:ComboBox = new ComboBox();
comboBox.dataProvider = dp;
comboBox.selectedIndex = 1;
comboBox.move(20, 20);
comboBox.addEventListener(Event.CHANGE, comboBox_change);
addChild(comboBox);
 
var slider:Slider = new Slider();
slider.direction = SliderDirection.VERTICAL;
slider.move(20, 50);
addChild(slider);
 
function comboBox_change(evt:Event):void {
    slider.direction = comboBox.selectedItem.label;
}

{ 1 comment… read it below or add one }

1 Anonymous 08.07.09 at 4:26 pm

I tried it and it doesn’t work.

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: Creating a custom context menu item in Flash using ActionScript 3.0

Next post: Adding tick marks to a Slider control in Flash using ActionScript 3.0