I am adding a slider to a titlebar as following:
private var hs:HSlider;
hs = new HSlider(); hs.minimum = 1; hs.maximum = 10; hs.width = 100; hs.height = 15; hs.tickInterval = 1; hs.snapInterval = 1; hs.allowTrackClick = true; hs.setStyle("fontSize", "8"); hs.labels = [1,2,3,4,5,6,7,8,9,10]; hs.setStyle("labelOffset", "-10"); hs.addEventListener("change", setHistoryNumberOfYears) titleBar.addChild(hs); hs.value = 5; titleBar.validateNow();
It works fine. Then I am trying either to hide it or completely remove:
Alert.show(String(titleBar.getChildIndex(hs))); titleBar.removeChildAt(4); titleBar.validateNow();
Alert will show 4, but the slider is still staying there.
Any idea what I might be doing wrong?
Here is what helped but I can't explain why. The slider will disappear by setting its property visible to false only if I set it to false in the first palce:
hs.visible = false; titleBar.addChild(hs); hs.value = 5; titleBar.validateNow();