Reputation: 1
Now it´s 16 days that I am searching for a way to code in AS3.0. The idea is to have two sliders that work in opposition. Meaning that if for example the first one increments by 01 unit the second decrements by 01 unit and vice versa.
Many Thanks for any contributor
Upvotes: 0
Views: 377
Reputation: 1
A lots of Thanks for people that reacted to my Post. The code that solves the problem is the following. I am on my way to learn ActionScript 3.0.
import fl.controls.Slider;
import fl.events.SliderEvent;
var mySld01:Number;
var mySld02:Number;
//Sld01 slider 01 has a maxValue of 100 and minValue of 0 and value=0
//Sld02 slider02 has the same parameters except for value=100
sld01.addEventListener(SliderEvent.CHANGE, sld01Change);
function sld01Change(e:SliderEvent):void {
mySld01 = e.value;
sld02.value = 100 - mySld01;
trace(mySld01);
}
sld02.addEventListener(SliderEvent.CHANGE, sld02Change);
function sld02Change(e:SliderEvent):void {
mySld02 = e.value;
sld01.value = 100 - mySld02;
trace(mySld02);
}
Upvotes: 0
Reputation: 1153
I'd add listener on change event to each slider and let appropriate listener to adjust value of the next slider. You could also try listener on thumbDrag event, if you want to have "live sliding".
Upvotes: 1