0
votes

I'm trying to set a custom skin using the built-in AS3 slider component in Flash CS4. I have the following code, but setting myslider.width and myslider.height does not seem to have any effect. The slider is still displayed at the default width and height, and my custom sliderTrackSkin is being scaled down.

import fl.controls.Slider;
import fl.controls.SliderDirection;
import fl.events.SliderEvent;

var myslider:Slider = new Slider();
myslider.direction = SliderDirection.VERTICAL;
myslider.width = 43;
myslider.height = 110;
myslider.minimum = 1;
myslider.maximum = 90;
myslider.value = 30;
myslider.snapInterval = 1;
myslider.liveDragging = true;
myslider.addEventListener(SliderEvent.CHANGE, slider_change);
myslider.move(640, 60);
myslider.setStyle("thumbUpSkin", thumb1);
myslider.setStyle("thumbDownSkin", thumb1);
myslider.setStyle("thumbOverSkin", thumb1);
myslider.setStyle("sliderTrackSkin", slidertrack1);
addChild(myslider);

I would appreciate any advice. Thanks.

2

2 Answers

1
votes

It turns out the myslider.width and myslider.height were taking effect on the parent, but the thumb and track of the slider component were not being resized. I had to manually resize the thumb and track like this:

var mysliderthumb = Sprite(myslider.getChildAt(1));
mysliderthumb.height = 34;
mysliderthumb.width = 15;

var myslidertrack = Sprite(myslider.getChildAt(0));
myslidertrack.height = 15;
myslidertrack.width = 100;

Furthermore because I had myslider.direction = SliderDirection.VERTICAL, the thumb and track were being rotated 90 degrees so I had to flip the width and height accordingly.

0
votes

Try to call myslider.validateNow() method after all properties are set and skin is applied.