| Package | qnx.ui.buttons |
| Class | public class SegmentedControl |
| Inheritance | SegmentedControl UIComponent flash.display.MovieClip |
| Implements | ISizeable, IDataViewer |
SegmentedControl instance with three buttons:
You can skin the SegmentedControl component by defining the
background skin and the button skins for the segmented control.
See also
| Property | Defined By | ||
|---|---|---|---|
![]() | containment : String
Gets or sets a property that determines how a component is contained within a parent container. | UIComponent | |
| dataProvider : IDataProvider
Gets or sets the DataProvider object used by the segmented control. | SegmentedControl | ||
| selectedIndex : int
Gets or sets the currently selected index. | SegmentedControl | ||
| selectedItem : Object
Gets or sets the currently selected item. | SegmentedControl | ||
![]() | size : Number
Gets or sets the size for this component (as a percentage of the
container's size, or in pixels). | UIComponent | |
![]() | sizeMode : String
Gets or sets the size mode for this component. | UIComponent | |
![]() | sizeUnit : String
Gets or sets the unit of measure for the size property. | UIComponent | |
| Method | Defined By | ||
|---|---|---|---|
Creates a new SegmentedControl instance. | SegmentedControl | ||
addItem(item:Object):void
Appends an item to the DataProvider. | SegmentedControl | ||
addItemAt(item:Object, index:int):void
Adds an item to the DataProvider at a given index. | SegmentedControl | ||
addItemsAt(items:Array, index:int):void
Adds items in the DataProvider at a given index, given an Array of items. | SegmentedControl | ||
![]() | destroy():void
Call this method when you want to have your object collected by the garbage collector. | UIComponent | |
![]() | drawNow():void
Calls the draw() method. | UIComponent | |
getItemAt(index:int):Object
Gets the data object from the DataProvider at a given index. | SegmentedControl | ||
![]() | invalidate(property:String, invalidateNow:Boolean = false):void
Marks the property as invalid and the draw() method is called on the next frame or the next render, whichever comes first. | UIComponent | |
removeAll():void
Removes all items from the DataProvider. | SegmentedControl | ||
removeItem(item:Object):void
Removes an item from the DataProvider. | SegmentedControl | ||
removeItemAt(index:int):void
Removes an item from the DataProvider at a given index. | SegmentedControl | ||
replaceItem(newObject:Object, oldObject:Object):void
Replaces an item with a new item. | SegmentedControl | ||
replaceItemAt(item:Object, index:int):void
Replaces the data at a given index. | SegmentedControl | ||
setBackgroundSkin(skin:Object):void
Sets the background skin for the segmented control, given a DisplayObject object to represent the
background skin. | SegmentedControl | ||
setButtonSkin(skin:Object):void
Sets the button skin for the buttons in the segmented control. | SegmentedControl | ||
setButtonWidthAtIndex(buttonWidth:int = 100, index:int = 0):void
Sets the button width of an item at the specified index. | SegmentedControl | ||
![]() | setPosition(x:Number, y:Number):void
Sets the x and y position of the component. | UIComponent | |
![]() | setSize(w:Number, h:Number):void
Sets the width and height of the component. | UIComponent | |
updateItem(value:Object, oldObject:Object):void
Updates an item with a new item at the same position in the DataProvider. | SegmentedControl | ||
updateItemAt(value:Object, index:int):void
Updates the item at the specified index with a new item. | SegmentedControl | ||
updateItemsAt(items:Array, index:int):void
Updates items in the DataProvider at a given index, given an Array of items. | SegmentedControl | ||
| Event | Summary | Defined By | ||
|---|---|---|---|---|
| Dispatches a change event when the selection of the control changes. | SegmentedControl | |||
| dataProvider | property |
dataProvider:IDataProvider
Gets or sets the DataProvider object used by the segmented control. The DataProvider must be of type IDataProvider.
public function get dataProvider():IDataProvider public function set dataProvider(value:IDataProvider):voidSee also
| selectedIndex | property |
selectedIndex:intGets or sets the currently selected index.
mySegment.selectedIndex = 2;
The default value is -1.
public function get selectedIndex():int public function set selectedIndex(value:int):void| selectedItem | property |
selectedItem:ObjectGets or sets the currently selected item.
public function get selectedItem():Object public function set selectedItem(value:Object):void| SegmentedControl | () | Constructor |
public function SegmentedControl()
Creates a new SegmentedControl instance.
| addItem | () | method |
public function addItem(item:Object):void
Appends an item to the DataProvider.
The following example adds an object with the label Friday to the right-end of the SegmentedControl:
mySegment.addItem({label: "Friday" })
Adding or removing an item fires a DataProvider event, which causes the columns to be cleared and redrawn.
Parameters
item:Object — The object to add to the DataProvider.
|
| addItemAt | () | method |
public function addItemAt(item:Object, index:int):void
Adds an item to the DataProvider at a given index.
In the following example, an object with the label Thursday is added to the penultimate position in the SegmentedControl:
mySegment.addItemAt({label: "Thursday" }, mySegment.dataProvider.length -1)
Adding or removing an item from the SegmentedControl dispatches a DataProvider event, which causes the columns to be cleared and redrawn.
Parameters
item:Object — The item to add.
| |
index:int — The index at which to add the item.
|
| addItemsAt | () | method |
public function addItemsAt(items:Array, index:int):void
Adds items in the DataProvider at a given index, given an Array of items.
Adding or removing an item fires a DataProvider event, which causes the columns to be cleared and redrawn.
Parameters
items:Array — The index at which to add the item.
| |
index:int |
| getItemAt | () | method |
public function getItemAt(index:int):Object
Gets the data object from the DataProvider at a given index.
Adding or removing an item fires a DataProvider event, which causes the columns to be cleared and redrawn.
Parameters
index:int — The index at which to return the item.
|
Object |
| removeAll | () | method |
public function removeAll():void
Removes all items from the DataProvider.
Adding or removing an item fires a DataProvider event, which causes the columns to be cleared and redrawn.
| removeItem | () | method |
public function removeItem(item:Object):void
Removes an item from the DataProvider.
Adding or removing an item fires a DataProvider event, which causes the columns to be cleared and redrawn.
Parameters
item:Object — The item to remove.
|
ArgumentError — Thrown if the item could not be found.
|
| removeItemAt | () | method |
public function removeItemAt(index:int):void
Removes an item from the DataProvider at a given index.
Adding or removing an item fires a dDataProvider event, which causes the columns to be cleared and redrawn.
Parameters
index:int — The index location at which to remove the item.
|
| replaceItem | () | method |
public function replaceItem(newObject:Object, oldObject:Object):voidReplaces an item with a new item.
Parameters
newObject:Object — The new item.
| |
oldObject:Object — The current item to replace.
|
RangeError — Thrown if the specified index is less than 0, or greater than or equal to the length of the DataProvider.
|
See also
| replaceItemAt | () | method |
public function replaceItemAt(item:Object, index:int):voidReplaces the data at a given index.
Adding or removing an item fires a data provider event, which causes the columns to be cleared and redrawn.
Parameters
item:Object — The new item to add.
| |
index:int — The index at which to add the itemm.
|
| setBackgroundSkin | () | method |
public function setBackgroundSkin(skin:Object):void
Sets the background skin for the segmented control, given a DisplayObject object to represent the
background skin.
The following code listing sets the background skin to the default skin for the dark color scheme:
mySegment.setBackgroundSkin(SegmentedControlSkinBlack);
Parameters
skin:Object — The skin to use for the background of the segmented control.
|
See also
| setButtonSkin | () | method |
public function setButtonSkin(skin:Object):voidSets the button skin for the buttons in the segmented control.
You can pass in a qualified class name String, or the actual class.
In either instance the class that is used must implement the ISkin interface.
Note: Do not pass in an instance of a skin class. This may cause unexpected behavior.
The following code listing sets the button skin to the default skin for the dark color scheme:
mySegment.setButtonSkin(RoundedButtonSkinBlack);
Parameters
skin:Object — The button skin.
|
See also
| setButtonWidthAtIndex | () | method |
public function setButtonWidthAtIndex(buttonWidth:int = 100, index:int = 0):voidSets the button width of an item at the specified index.
The following listing sets the width of the second button to 200 pixels.
mySegment.setButtonWidthAtIndex(200, 1);
This operation will override the current width and height of this control, other button widths will not be changed.
Parameters
buttonWidth:int (default = 100) — The new width to set. The default is 100 (pixels).
| |
index:int (default = 0) — The index of the button to set. The default is 0.
|
| updateItem | () | method |
public function updateItem(value:Object, oldObject:Object):void
Updates an item with a new item at the same position in the DataProvider.
Parameters
value:Object — The new item.
| |
oldObject:Object — The current item to replace.
|
RangeError — Thrown if the specified index is less than 0, or greater than or equal to the length of the DataProvider.
|
See also
| updateItemAt | () | method |
public function updateItemAt(value:Object, index:int):voidUpdates the item at the specified index with a new item.
Parameters
value:Object — The new item.
| |
index:int — The index of the item to replace.
|
RangeError — Thrown if the specified index is less than 0, or greater than or equal to the length of the DataProvider.
|
See also
| updateItemsAt | () | method |
public function updateItemsAt(items:Array, index:int):void
Updates items in the DataProvider at a given index, given an Array of items.
Updating an item fires a DataProvider event, which causes the columns to be cleared and redrawn.
Parameters
items:Array — The index at which to update the items.
| |
index:int |
| change | Event |
flash.events.Eventflash.events.Event.CHANGEDispatches a change event when the selection of the control changes.
The following example creates a SegmentedControl instance.
package
{
import flash.display.Sprite;
import qnx.ui.buttons.SegmentedControl;
import qnx.ui.data.DataProvider;
[SWF(height="600", width="1024",
frameRate="30", backgroundColor="#FFFFFF")]
public class SegmentedControlExample extends Sprite
{
public function SegmentedControlExample()
{
initializeUI();
}
private function initializeUI():void
{
// create an array for the segmented control with objects
//that have label properties
var buttonArray:Array=[];
buttonArray.push({label:"AM"});
buttonArray.push({label:"FM"});
buttonArray.push({label:"HD"});
// create a segemented control
var mySegment:SegmentedControl = new SegmentedControl();
mySegment.x = 200;
mySegment.y = 200;
mySegment.width = 200;
mySegment.height = 50;
// set the data provider
mySegment.dataProvider = new DataProvider(buttonArray);
// set the selected index to be the 3rd item in the dataProvider
mySegment.selectedIndex = 2;
// add the control to the disply list
this.addChild(mySegment);
}
}
}