Friday, April 6, 2007


How to add and removes thumbs:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="" layout="vertical">

public function add(event:MouseEvent):void {
slider.thumbCount++; // add new thumb

//! if you don't set the value of the new thumb all thumbs will reset
// thumbCount-1 is the last one added
// 5 is a number i randomly picked
public function remove(event:MouseEvent):void {
var index:int = 0; // the index of the thumb to be removed, indices are constant even with allowThumbOverlap="true"
slider.thumbCount--; // remove thumb
var values1:Array = slider.values; // get values of slider
values1.splice(index,1); // splice value at index out or the last one will be choped of by default
slider.values = values1; // set updated values
<mx:HSlider id="slider" thumbCount="2" allowThumbOverlap="true"/>
<mx:Button click="add(event)" label="add"/>
<mx:Button click="remove(event)" label="remove"/>


Anonymous said...

Hey I tried your removethumb thing with an index other than 0 and it didn't seem to work....I get the thumb removed from the current spot, but then get another one at the 0 spot...I did a print out and it seems that the pointer gets NaN'd, hslider still thinks it has 3 thumbs.

Fernando said...

Never was a typo on my part, works great!

"Flex", "ActionScript" and possibly "MXML" are probably trademarks of Adobe Systems Incorporated.
"Adobe" is a trademark of Adobe Systems Incorporated.
This site is in no way endorsed or sponsored by Adobe Systems Incorporated.
Content Copyright © 2007 Daniel Freiman.
Site Design Copyright by its copyright holder.
The Flex Non-Docs reserves the right to remove comments for any reason.
All ActionScript and MXML code (and ONLY ActionScript and MXML code) on this website is available under the MIT License.