Paket | spark.components |
Klass | public class ToggleButton |
Arv | ToggleButton ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Underklasser | AXMToggleButton, ButtonBarButton |
Språkversion: | ActionScript 3.0 |
Produktversion: | Flex 4 |
Körningsmiljöversioner: | Flash Player 10, AIR 1.5 |
![]() | Because this component does not define a skin for the mobile theme, Adobe recommends that you not use it in a mobile application. Alternatively, you can define your own mobile skin for the component. For more information, see Basics of mobile skinning. |
The ToggleButton component defines a toggle button. Clicking the button toggles it between the up and an down states. If you click the button while it is in the up state, it toggles to the down state. You must click the button again to toggle it back to the up state.
You can get or set this state programmatically
by using the selected
property.
To use this component in a list-based component, such as a List or DataGrid, create an item renderer. For information about creating an item renderer, see Custom Spark item renderers.
The ToggleButton control has the following default characteristics:
Characteristic | Description |
---|---|
Default size | Wide enough to display the text label of the control |
Minimum size | 21 pixels wide and 21 pixels high |
Maximum size | 10000 pixels wide and 10000 pixels high |
Default skin class | spark.skins.spark.ToggleButtonSkin |
![expanded expanded](../../images/expanded.gif)
The <s:ToggleButton>
tag inherits all of the tag
attributes of its superclass and adds no tag attributes:
<s:ToggleButton/>
MXML-standardegenskaplabel
Fler exempel
Relaterade API-element
Metod | Definieras med | ||
---|---|---|---|
Constructor. | ToggleButton | ||
![]() | addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void
Registrerar ett händelseavlyssnarobjekt för ett EventDispatcher-objekt så att avlyssnaren får meddelanden om händelser. | EventDispatcher | |
![]() |
Adds a non-visual style client to this component instance. | UIComponent | |
![]() |
Anger om säkerhetsrestriktionerna kan göra att visningsobjekt utelämnas från listan som returneras när metoden DisplayObjectContainer.getObjectsUnderPoint() anropas med den angivna punkten. | DisplayObjectContainer | |
![]() |
Queues a function to be called later. | UIComponent | |
![]() |
Deletes a style property from this component instance. | UIComponent | |
![]() |
Avgör om det angivna visningsobjektet är underordnat DisplayObjectContainer-instansen eller själva instansen. | DisplayObjectContainer | |
![]() |
Converts a Point object from content coordinates to global coordinates. | UIComponent | |
![]() |
Converts a Point object from content to local coordinates. | UIComponent | |
![]() |
Returns a set of properties that identify the child within
this container. | UIComponent | |
![]() |
Returns a set of properties that identify the child within
this container. | UIComponent | |
![]() |
Creates an id reference to this IUIComponent object
on its parent document object. | UIComponent | |
![]() |
Deletes the id reference to this IUIComponent object
on its parent document object. | UIComponent | |
![]() |
Returns a UITextFormat object corresponding to the text styles
for this UIComponent. | UIComponent | |
![]() | [åsidosätt]
Dispatches an event into the event flow. | UIComponent | |
![]() |
Shows or hides the focus indicator around this component. | UIComponent | |
![]() | drawRoundRect(x:Number, y:Number, w:Number, h:Number, r:Object = null, c:Object = null, alpha:Object = null, rot:Object = null, gradient:String = null, ratios:Array = null, hole:Object = null):void
Programmatically draws a rectangle into this skin's Graphics object. | UIComponent | |
![]() |
Called by the effect instance when it stops playing on the component. | UIComponent | |
![]() |
Called by the effect instance when it starts playing on the component. | UIComponent | |
![]() |
Ends all currently playing effects on the component. | UIComponent | |
![]() |
Executes all the bindings for which the UIComponent object is the destination. | UIComponent | |
![]() |
Called after printing is complete. | UIComponent | |
![]() |
Provides the automation object at the specified index. | UIComponent | |
![]() |
Provides the automation object list . | UIComponent | |
![]() |
Returnerar en rektangel som definierar visningsområdets område i relation till targetCoordinateSpace-objektets koordinatsystem. | DisplayObject | |
![]() |
Returns the x coordinate of the element's bounds at the specified element size. | UIComponent | |
![]() |
Returns the y coordinate of the element's bounds at the specified element size. | UIComponent | |
![]() |
Returnerar det underordnade visningsobjektet som har ett visst namn. | DisplayObjectContainer | |
![]() |
Finds the type selectors for this UIComponent instance. | UIComponent | |
![]() |
Returns a layout constraint value, which is the same as
getting the constraint style for this component. | UIComponent | |
![]() |
A convenience method for determining whether to use the
explicit or measured height
| UIComponent | |
![]() |
A convenience method for determining whether to use the
explicit or measured width
| UIComponent | |
![]() |
Gets the object that currently has focus. | UIComponent | |
![]() |
Returns the element's layout height. | UIComponent | |
![]() |
Returns the element's layout width. | UIComponent | |
![]() |
Returns the x coordinate that the element uses to draw on screen. | UIComponent | |
![]() |
Returns the y coordinate that the element uses to draw on screen. | UIComponent | |
![]() |
Returns the transform matrix that is used to calculate the component's
layout relative to its siblings. | UIComponent | |
![]() |
Returns the layout transform Matrix3D for this element. | UIComponent | |
![]() |
Returns the element's maximum height. | UIComponent | |
![]() |
Returns the element's maximum width. | UIComponent | |
![]() |
Returns the element's minimum height. | UIComponent | |
![]() |
Returns the element's minimum width. | UIComponent | |
![]() |
Returnerar en array med objekt som ligger under den angivna punkten och är underordnade (eller indirekt underordnade) den här DisplayObjectContainer-instansen. | DisplayObjectContainer | |
![]() |
Returns the element's preferred height. | UIComponent | |
![]() |
Returns the element's preferred width. | UIComponent | |
![]() |
Returnerar en rektangel som definierar visningsområdets gräns, baserat på koordinatsystemet som definieras av targetCoordinateSpace-parametern, exklusive eventuella linjer i former. | DisplayObject | |
![]() |
Returns the item in the dataProvider that was used
by the specified Repeater to produce this Repeater, or
null if this Repeater isn't repeated. | UIComponent | |
![]() |
Gets a style property that has been set anywhere in this
component's style lookup chain. | UIComponent | |
![]() |
Converts a Point object from global to content coordinates. | UIComponent | |
![]() |
Konverterar punktobjektet från scenens (globala) koordinater till visningsobjektets (lokala) koordinater. | DisplayObject | |
![]() |
Konverterar en tvådimensionell punkt från scenens (globala) koordinater till ett tredimensionellt visningsobjekts (lokala) koordinater. | DisplayObject | |
![]() |
Returns true if currentCSSState is not null. | UIComponent | |
![]() |
Kontrollerar om EventDispatcher-objektet har några avlyssnare registrerade för en viss typ av händelse. | EventDispatcher | |
![]() |
Anger om det finns en egenskap angiven för ett objekt. | Object | |
![]() |
Determines whether the specified state has been defined on this
UIComponent. | UIComponent | |
![]() |
Utvärderar begränsningsramen för visningsobjektet för att kontrollera om den överlappar eller korsar begränsningsramen för obj-visningsobjektet. | DisplayObject | |
![]() |
Utvärderar visningsobjektet för att avgöra om det överlappar eller korsar den punkt som anges av x- och y-parametrarna. | DisplayObject | |
![]() |
Returns a box Matrix which can be passed to the
drawRoundRect() method
as the rot parameter when drawing a horizontal gradient. | UIComponent | |
![]() |
Initializes the internal structure of this component. | UIComponent | |
![]() |
Initializes various properties which keep track of repeated instances
of this component. | UIComponent | |
![]() |
Marks a component so that its updateDisplayList()
method gets called during a later screen update. | UIComponent | |
![]() |
Called by a component's items to indicate that their depth
property has changed. | UIComponent | |
![]() |
An element must call this method when its layoutDirection changes or
when its parent's layoutDirection changes. | UIComponent | |
![]() |
Marks a component so that its commitProperties()
method gets called during a later screen update. | UIComponent | |
![]() |
Marks a component so that its measure()
method gets called during a later screen update. | UIComponent | |
![]() |
Marks the component so that the new state of the skin is set
during a later screen update. | SkinnableComponent | |
![]() |
Anger om en instans av klassen Object finns i prototypkedjan för objektet som anges som parameter. | Object | |
![]() |
Konverterar en tredimensionell punkt för det tredimensionella visningsobjektets (lokala) koordinater till en tvådimensionell punkt i scenens (globala) koordinater. | DisplayObject | |
![]() |
Converts a Point object from local to content coordinates. | UIComponent | |
![]() |
Konverterar punktobjektet från visningsobjektets (lokala) koordinater till scenens (globala) koordinater. | DisplayObject | |
![]() |
Returns true if cssState matches currentCSSState. | UIComponent | |
![]() |
Determines whether this instance is the same as, or is a subclass of,
the given type. | UIComponent | |
![]() |
Measures the specified HTML text, which can contain HTML tags such
as <font> and <b>,
assuming that it is displayed
in a single-line UITextField using a UITextFormat
determined by the styles of this UIComponent. | UIComponent | |
![]() |
Measures the specified text, assuming that it is displayed
in a single-line UITextField (or UIFTETextField) using a UITextFormat
determined by the styles of this UIComponent. | UIComponent | |
![]() |
Moves the component to a specified position within its parent. | UIComponent | |
![]() |
Propagates style changes to the children. | UIComponent | |
![]() |
Returns true if the chain of owner properties
points from child to this UIComponent. | UIComponent | |
![]() |
Called by Flex when a UIComponent object is added to or removed from a parent. | UIComponent | |
![]() |
Prepares an IFlexDisplayObject for printing. | UIComponent | |
![]() |
Anger om den angivna egenskapen finns och är uppräkningsbar. | Object | |
![]() |
Builds or rebuilds the CSS style cache for this component
and, if the recursive parameter is true,
for all descendants of this component as well. | UIComponent | |
![]() |
For each effect event, registers the EffectManager
as one of the event listeners. | UIComponent | |
![]() |
Tar bort alla child-DisplayObject-instanser från listan med underordnade för DisplayObjectContainer-instansen. | DisplayObjectContainer | |
![]() |
Tar bort en avlyssnare från EventDispatcher-objektet. | EventDispatcher | |
![]() |
Removes a non-visual style client from this component instance. | UIComponent | |
![]() |
Replays the specified event. | UIComponent | |
![]() |
Visar ett virtuellt tangentbord. | InteractiveObject | |
![]() |
Resolves a child by using the id provided. | UIComponent | |
![]() | [statisk]
Resumes the background processing of methods
queued by callLater(), after a call to
suspendBackgroundProcessing(). | UIComponent | |
![]() |
Sizes the object. | UIComponent | |
![]() |
Sets a layout constraint value, which is the same as
setting the constraint style for this component. | UIComponent | |
![]() |
Set the current state. | UIComponent | |
![]() |
Sets the focus to this component. | UIComponent | |
![]() |
Sets the coordinates that the element uses to draw on screen. | UIComponent | |
![]() |
Sets the layout size of the element. | UIComponent | |
![]() |
Sets the transform Matrix that is used to calculate the component's layout
size and position relative to its siblings. | UIComponent | |
![]() |
Sets the transform Matrix3D that is used to calculate the component's layout
size and position relative to its siblings. | UIComponent | |
![]() |
Anger tillgänglighet för en dynamisk egenskap för slingåtgärder. | Object | |
![]() |
Sets a style property on this component instance. | UIComponent | |
![]() |
Called when the visible property changes. | UIComponent | |
![]() |
Gör att användaren kan dra angiven sprite. | Sprite | |
![]() |
Låter användaren dra angiven sprite på en beröringsaktiverad enhet. | Sprite | |
![]() |
Stoppar rekursivt tidslinjekörning av alla filmklipp vars rot är detta objekt. | DisplayObjectContainer | |
![]() |
Avslutar metoden startDrag(). | Sprite | |
![]() |
Avslutar metoden startTouchDrag(), som används med beröringsaktiverade enheter. | Sprite | |
![]() |
Detects changes to style properties. | UIComponent | |
![]() |
Flex calls the stylesInitialized() method when
the styles for a component are first initialized. | UIComponent | |
![]() | [statisk]
Blocks the background processing of methods
queued by callLater(),
until resumeBackgroundProcessing() is called. | UIComponent | |
![]() |
Returnerar det här objektets strängrepresentation, formaterad i enlighet med språkspecifika konventioner. | Object | |
![]() | [åsidosätt]
Returns a string indicating the location of this object
within the hierarchy of DisplayObjects in the Application. | FlexSprite | |
![]() | transformAround(transformCenter:Vector3D, scale:Vector3D = null, rotation:Vector3D = null, translation:Vector3D = null, postLayoutScale:Vector3D = null, postLayoutRotation:Vector3D = null, postLayoutTranslation:Vector3D = null, invalidateLayout:Boolean = true):void
A utility method to update the rotation, scale, and translation of the
transform while keeping a particular point, specified in the component's
own coordinate space, fixed in the parent's coordinate space. | UIComponent | |
![]() |
A utility method to transform a point specified in the local
coordinates of this object to its location in the object's parent's
coordinates. | UIComponent | |
![]() |
Validates the position and size of children and draws other
visuals. | UIComponent | |
![]() |
Validate and update the properties and layout of this object
and redraw it, if necessary. | UIComponent | |
![]() |
Used by layout logic to validate the properties of a component
by calling the commitProperties() method. | UIComponent | |
![]() |
Validates the measured size of the component
If the LayoutManager.invalidateSize() method is called with
this ILayoutManagerClient, then the validateSize() method
is called when it's time to do measurements. | UIComponent | |
![]() |
Handles both the valid and invalid events from a
validator assigned to this component. | UIComponent | |
![]() |
Returnerar det angivna objektets primitiva värde. | Object | |
![]() |
Returns a box Matrix which can be passed to drawRoundRect()
as the rot parameter when drawing a vertical gradient. | UIComponent | |
![]() |
Kontrollerar om en händelseavlyssnare är registrerad för det här EventDispatcher-objektet eller något av dess överordnade objekt för den angivna händelsetypen. | EventDispatcher |
Format är antingen allmänna eller kopplade till ett visst tema. Om formatet är allmänt kan det användas med alla teman. Om ett format är kopplat till ett visst tema kan det bara användas om programmet använder just det temat.
Den här komponenten använder skal som består av skaldelar. Ställ inte in skaldelar direkt. Komponentens skal anger skaldelarna.
Implementera ett skal som definierar följande lägen om du vill använda ett skal för komponenten. Trots att alla skallägen måste implementeras kan ett skalläge vara tomt. Ett tomt skalläge innebär att inga ändringar görs i standardskalläget.
ToggleButton | () | Konstruktor |
public function ToggleButton()
Språkversion: | ActionScript 3.0 |
Produktversion: | Flex 4 |
Körningsmiljöversioner: | Flash Player 10, AIR 1.5 |
Constructor.
<?xml version="1.0"?> <!-- Simple example to demonstrate the Spark ToggleButton control --> <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx"> <fx:Script> <![CDATA[ // Event handler function to print a message // describing the Spark ToggleButton selected state. // Toggle the fontWeight of the Label between bold and normal private function printMessage(evt:Event):void { if (evt.target.selected){ message.text += "fontWeight: bold" + "\n"; lbl.setStyle("fontWeight", "bold"); togBtn.label = "Bold"; } else{ message.text += "fontWeight: normal" + "\n"; lbl.setStyle("fontWeight", "normal"); togBtn.label = "Normal"; } } ]]> </fx:Script> <s:Panel title="Spark ToggleButton Control Example" width="75%" height="75%" horizontalCenter="0" verticalCenter="0"> <s:VGroup left="10" right="10" top="10" bottom="10"> <s:ToggleButton id="togBtn" label="Normal" click="printMessage(event);" /> <s:Label id="lbl" text="Label" /> <s:TextArea id="message" height="100%" width="100%" color="#0000FF" /> </s:VGroup> </s:Panel> </s:Application>
Tue Jun 12 2018, 01:40 PM Z