Using Components
Trademarks Add Life to the Web, Afterburner, Aftershock, Andromedia, Allaire, Animation PowerPack, Aria, Attain, Authorware, Authorware Star, Backstage, Bright Tiger, Clustercats, ColdFusion, Contribute, Design In Motion, Director, Dream Templates, Dreamweaver, Drumbeat 2000, EDJE, EJIPT, Extreme 3D, Fireworks, Flash, Flash Lite, Flex, Fontographer, FreeHand, Generator, HomeSite, JFusion, JRun, Kawa, Know Your Site, Knowledge Objects, Knowledge Stream, Knowledge Track, LikeMinds, Lingo, Live Effects, MacRec
CONTENTS INTRODUCTION: Getting Started with Components . ...................... 7 Intended audience . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . System requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . About the documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Typographical conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Deleting components from Flash documents. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50 Using code hints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50 Creating custom focus navigation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50 Managing component depth in a document . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51 Components in Live Preview . . . . . . . . . . . . . . . . . . . . . . . . . . .
Loader component . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 484 Media components (Flash Professional only) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 497 Menu component (Flash Professional only) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 538 MenuBar component (Flash Professional only) . . . . . . . . . . . . . . . . . . . . . . . . . . 574 NumericStepper component . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
APPENDIX: Collection Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 959 Defining a collection property . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 960 Simple collection example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 960 Defining the class for a collection item . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 962 Accessing collection information programmatically . . . . . . . .
INTRODUCTION Getting Started with Components Macromedia Flash MX 2004 and Macromedia Flash MX Professional 2004 are the professional standard authoring tools for producing high-impact web experiences. Components are the building blocks for the Rich Internet Applications that provide those experiences. A component is a movie clip with parameters that are set during authoring in Macromedia Flash, and with ActionScript methods, properties, and events that allow you to customize the component at runtime.
If you are less experienced with writing ActionScript, you can add components to a document, set their parameters in the Property inspector or Component inspector, and use the Behaviors panel to handle their events. For example, you could attach a Go To Web Page behavior to a Button component that opens a URL in a web browser when the button is clicked without writing any ActionScript code.
Terms used in this manual The following terms are used in this manual: at runtime When the code is running in Flash Player. while authoring While you are working in the Flash authoring environment. Additional resources For the latest information on Flash, plus advice from expert users, advanced topics, examples, tips, and other updates, see the Macromedia DevNet website at www.macromedia.com/devnet, which is updated regularly.
Introduction: Getting Started with Components
CHAPTER 1 About Components Components are movie clips with parameters that allow you to modify their appearance and behavior. A component can be a simple user interface control, such as a radio button or a check box, or it can contain content, such as a scroll pane; a component can also be non-visual, like the FocusManager that allows you to control which object receives focus in an application.
About version 2 component architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 What’s new in version 2 components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 About compiled clips and SWC files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 Accessibility and components. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
• • • • • • • RDBMSResolver component (Flash Professional only) Screen class (Flash Professional only) Slide class (Flash Professional only) Tree component (Flash Professional only) WebServiceConnector class (Flash Professional only) XMLConnector component (Flash Professional only) XUpdateResolver component (Flash Professional only) To verify installation of the Flash MX 2004 or Flash MX Professional 2004 components: 1. Start Flash. 2.
If you’ve added components, you’ll need to refresh the Components panel. To refresh the contents of the Components panel: • Select Reload from the Components panel menu. To remove a component from the Components panel: • Remove the MXP or FLA file from the Configuration folder. Benefits of using components Components enable the separation of coding and design. They also allow you to reuse code, either in components you create, or by downloading and installing components created by other developers.
Categories of components Components included with Flash MX 2004 and Flash MX Professional 2004 fall into the following five categories (the locations of their ActionScript source files roughly correspond to these categories as well and are listed in parentheses): • User interface components (mx.controls.*) User interface components allow you to interact with an application; for example, the RadioButton, CheckBox, and TextInput components are user interface controls. • Data components (mx.data.
Version 2 components are included in the Components panel as compiled clip (SWC) symbols. A compiled clip is a component movie clip whose code has been compiled. Compiled clips cannot be edited, but you can change their parameters in the Property inspector and Component inspector, just as you would with any component. For more information, see “About compiled clips and SWC files” on page 17. Version 2 components are written in ActionScript 2.0.
The Halo theme provides a ready-made, responsive, and flexible user interface for applications. Halo is the default theme that the version 2 components use. (See “About themes” on page 77.) Manager classes provide an easy way to handle focus and depth in a application. (See “Creating custom focus navigation” on page 50 and “Managing component depth in a document” on page 51.) The base classes UIObject and UIComponent provide core methods, properties, and events to components that extend them.
Accessibility and components A growing requirement for web content is that it should be accessible; that is, usable for people with a variety of disabilities. Visual content in Flash applications can be made accessible to the visually impaired with the use of screen reader software, which provides a spoken audio description of the contents of the screen. When a component is created, the author can write ActionScript that enables communication between the component and a screen reader.
CHAPTER 2 Creating an Application with Components (Flash Professional Only) Components in Flash are prebuilt elements that you can use when creating Flash applications, to add user interface controls, data connectivity, and other functionality. Components can save you work when you’re building an application, because you don’t have to create all the design and functionality from scratch.
You can modify the appearance and behavior of components by setting component parameters in the authoring environment, using the Parameters tab in either the Property inspector or the Component inspector. You can also control components during runtime using ActionScript. All components have ActionScript methods, properties, and events. For more information on authoring parameters, see “Setting component parameters” on page 47.
If you are experienced with building application architecture in Flash, you may want to skip the first section of the tutorial and read the second and third sections while referring to the finished FLA file of the sample application, to learn about the procedures used to bind the components and add event listeners for data integration. (To view the finished FLA file, see the next section.) All the ActionScript needed for creating the sample application is provided with this tutorial.
On the Checkout screen, click the Billing Information, Shipping Information, and Credit Card Information headers to view the form fields for each of these items. To place an order, you can add the appropriate information in each of these panes, and click Confirm at the bottom of the Credit Card Information pane. You can also click Back to return to the main screen. Close the SWF file when you finish examining the completed application.
• The WebService class is part of a set of web service classes, which provides a set of methods, events, and properties that enable you to connect to a web service. The WebService class is different from the WebServiceConnector component. (The WebServiceConnector component, like the XMLConnector component, enables you to connect to an external data source—in this case, a web service—by adding a component to an application and setting its parameters.
4. Make sure the Form layer is selected. In the Components panel (Window > Development Panels > Components), locate the ComboBox component in the UI Components folder. Drag an instance of ComboBox onto the Stage. Place it below the What Did You Do? text. In the Property inspector (Window > Properties), for the instance name enter problems_cb. Set Width to 400 pixels. Notice that the ComboBox component symbol is added to the library (Window > Library).
Create a movie clip with component instances to display product details In the application, a pop-up window appears when a user clicks on a product in the Gift Ideas section. The pop-up window contains component instances that display information for the product, including a text description, image, and price. To make this pop-up window, you’ll create a movie clip symbol and add instances of the Loader, TextArea, Label, NumericStepper, and Button components.
7. Drag an instance of the Label component from the UI Components folder in the Components panel onto the Stage. Place it below the Loader component. Set the X, Y coordinates to 5, 145. Enter price_lbl for the instance name. Click the Parameters tab in the Property inspector. For autoSize, select left. For html, select true. The Label component instance will display the price of the product and the price qualifier (the quantity of products indicated by the specified price, such as “each” or “one dozen.
Next, the code populates the TextArea and Label instances by using the description, price, and priceQualifier properties of the thisProduct object. These properties correspond to elements in the products.xml file that you linked to the products_xmlcon XMLConnector instance at the beginning of the tutorial. Later in the tutorial, you’ll bind the XMLConnector, DataSet, and DataGrid component instances together, and the elements in the XML file will populate the other two component instances.
Later in the tutorial, you’ll create movie clips to use as children in the Accordion instance, to display the Billing, Shipping, and Credit Card Information panes. 1. In the main Timeline for the application, move the playhead to Frame 10 (labeled Checkout). Make sure the Form layer is selected. 2. Insert a blank keyframe on Frame 10 in the Form layer (select the frame and select Insert > Timeline > Blank Keyframe). 3.
8. In the Create New Symbol dialog box, enter checkout1_sub_mc for Name and select Movie Clip for Behavior. 9. Click the Advanced button. Under Linkage, select Export for ActionScript, leave Export in First Frame selected, and click OK. A document window for the new symbol opens in symbol-editing mode. 10. Drag six instances of the Label component onto the Stage. Alternatively, you can drag one instance onto the Stage, and Control-drag (Windows) or Option-drag (Macintosh) it on the Stage to make copies.
14. In the Tools panel, select the Rectangle tool. Set the Stroke color to None and the Fill color to white. Click the Stroke Color control in the Tools panel and click the None button—the white swatch with a red line through it. Click the Fill Color control and click the white color swatch. 15. Drag to create a rectangle that extends beyond the bottom and right edges of the Label and TextInput instances.
2. Drag four instances of the Label component onto the Stage. Name and position the instances as follows: ■ ■ ■ ■ For the first instance, enter ccName_lbl for the instance name and set the X and Y coordinates to 5, 5. Click the Parameters tab and enter Name On Card for text. For the second instance, enter ccType_lbl for the instance name and set the X and Y coordinates to 5, 35. Click the Parameters tab and enter Card Type for text.
Specify a schema for the XML data source When you connect to an external XML data source with the XMLConnector component, you need to specify a schema—a schematic representation which identifies the structure of the XML document. The schema tells the XMLConnector component how to read the XML data source. The easiest way to specify a schema is to import a copy of the XML file that you’re going to connect to, and use that copy as a schema. 1. Launch your web browser and go to www.flash-mx.
8. On the Stage, select the products_ds instance. In the Bindings tab of the Component inspector, notice that the component’s data provider appears in the Binding List (the top pane of the Bindings tab). In the Binding Attributes pane, the Bound To parameter indicates that the products_ds instance is bound to the products_xmlcom instance, and the binding direction is In.
UI Components Controls package This package contains classes for the user interface control components, including ComboBox, DataGrid, Loader, TextInput, Label, NumericStepper, Button, and CheckBox. A package is a directory that contains class files and resides in a designated classpath directory. You can use a wild card to create references to all the classes in a package: for example, the syntax mx.controls.* creates references to all classes in the controls package.
Add an instance of the Cart class and initialize it The next code that you’ll add creates an instance of the custom Cart class and then initializes the instance. • In the Actions panel, add the following code: var myCart:Cart = new Cart(this); myCart.init(); This code uses the init() method of the Cart class to add a DataGrid instance to the Stage, define the columns, and position the DataGrid instance on the Stage.
Add columns to the Gift Ideas section Now you’re ready to add columns to the data grid in the Gift Ideas section of the application, for displaying product information and price. • In the Actions panel, add the following code to create, configure, and add a Name column and a Price column to the DataGrid instance: // define data grid columns and their default widths in the products_dg // DataGrid instance var name_dgc:DataGridColumn = new DataGridColumn("name"); name_dgc.headerText = "Name"; name_dgc.
}; // If you are unable to connect to the remote web service, display the // error messages in the Output panel. myProblems.onFault = function(error:Object) { trace("error:"); for (var prop in error) { trace(" "+prop+" -> "+error[prop]); } }; Load the external XML file listing product information Next you’ll add a line of code that causes the XMLConnector instance to load, parse, and bind the contents of the remote products.xml file.
Resetting the filtered property (setting it to false and then to true) at the beginning of the change() function ensures that the function will work properly if the user changes the What Did You Do? selection repeatedly. The filterFunc function checks whether a given item in the array of gifts falls within the severity the user selected in the combo box. If the gift is within the selected severity range, it is displayed in the DataGrid instance (which is bound to the DataSet instance).
Add an event listener to the Checkout button Now you’ll add code to display the Checkout screen when the user clicks the Checkout button. • In the Actions panel, add the following code: // when the Checkout button is clicked, go to the "checkout" frame label var checkoutBtnListener:Object = new Object(); checkoutBtnListener.click = function(evt:Object) { evt.target._parent.gotoAndStop("checkout"); }; checkout_button.
checkboxListener.click = function(evt:Object) { if (evt.target.selected) { thisChild2.shippingFirstName_ti.text = thisChild1.billingFirstName_ti.text; thisChild2.shippingLastName_ti.text = thisChild1.billingLastName_ti.text; thisChild2.shippingCountry_ti.text = thisChild1.billingCountry_ti.text; thisChild2.shippingProvince_ti.text = thisChild1.billingProvince_ti.text; thisChild2.shippingCity_ti.text = thisChild1.billingCity_ti.text; thisChild2.shippingPostal_ti.text = thisChild1.billingPostal_ti.
var response_lv:LoadVars = new LoadVars(); var checkout_lv:LoadVars = new LoadVars(); checkout_lv.billingFirstName = thisChild1.billingFirstName_ti.text; checkout_lv.billingLastName = thisChild1.billingLastName_ti.text; checkout_lv.billingCountry = thisChild1.billingCountry_ti.text; checkout_lv.billingProvince = thisChild1.billingProvince_ti.text; checkout_lv.billingCity = thisChild1.billingCity_ti.text; checkout_lv.billingPostal = thisChild1.billingPostal_ti.text; checkout_lv.
Chapter 2: Creating an Application with Components (Flash Professional Only)
CHAPTER 3 Working with Components In this chapter, you’ll use several Macromedia Flash (FLA) files and ActionScript class files to learn how to add components to a document and set their properties. This chapter also explains a few advanced topics such as using code hints, creating custom focus navigation, managing component depth, and upgrading version 1 components to version 2 architecture. The files used in this chapter are TipCalulator.fla and TipCalculator.swf.
The Components panel All components in the user-level configuration/Components directory are displayed in the Components panel. (For more information about this directory, see “Where component files are stored” on page 13.) To display the Components panel: • Select Window > Development Panels > Components. Components panel menu To display components that were installed after Flash started up: 1. Select Window > Development Panels > Components. 2. Select Reload from the Components panel menu.
3. If the component is a FLA (all installed version 2 components are SWC files) and if you have edited skins for another instance of the same component, or for a component that shares skins with the component you are adding, do one of the following: ■ ■ Select Don’t Replace Existing Items to preserve the edited skins and apply the edited skins to the new component. Select Replace Existing Items to replace all the skins with default skins.
Adding components at runtime with ActionScript Use the createClassObject() method (which most components inherit from the UIObject class) to add components to a Flash application dynamically. For example, you could add components that create a page layout based on user-set preferences (as on the home page of a web portal). Version 2 components that are installed with Flash MX 2004 reside in package directories. (For more information, see “Using packages” in Using ActionScript in Flash.
Alternatively, you can import the class package, as in this example: import mx.controls.CheckBox; createClassObject(CheckBox, "cb", 5, {label:"Check Me"}); For more information, see UIObject.createClassObject() on page 810 and Chapter 4, “Handling Component Events,” on page 55. Components in the Library panel When you add a component to a document, it is displayed as a compiled clip (SWC file) symbol in the Library panel.
You can set parameters for a component instance using the Component inspector or the Property inspector (it doesn’t matter which panel you use). To enter an instance name for a component in the Property inspector: 1. Select Window > Properties. 2. Select an instance of a component on the Stage. 3. Enter an instance name in the text field under the word Component.
Sizing components Use the Free Transform tool or the setSize() method to resize component instances. Resizing the Menu component on the Stage with the Free Transform tool You can call the setSize() method from any component instance (see UIObject.setSize() on page 823) to resize it. The following code resizes the Menu component to 200 pixels wide and 300 pixels high: myMenu.
Deleting components from Flash documents To delete a component’s instances from a Flash document, you must delete the component from the library by deleting the compiled clip icon. It isn’t enough to delete the component from the Stage. To delete a component from a document: 1. In the Library panel, select the compiled clip (SWC) symbol. 2. Click the Delete button at the bottom of the Library panel, or select Delete from the Library options menu. 3.
comment.tabIndex = 1; okButton.tabIndex = 2; You can also use the Accessibility panel to assign a tab index value. If nothing on the Stage has a tab index value, the Focus Manager uses the depth levels (z-order). The depth levels are set up primarily by the order in which components are dragged to the Stage; however, you can also use the Modify > Arrange > Bring to Front/Send to Back commands to determine the final z-order. To give focus to a component in an application, call focusManager.setFocus().
Components in Live Preview The Live Preview feature, enabled by default, lets you view components on the Stage as they will appear in the published Flash content; the components appear at their approximate size. The live preview reflects different parameters for different components. For information about which component parameters are reflected in the live preview, see each component entry in Chapter 6, “Components Dictionary,” on page 91.
Upgrading version 1 components to version 2 architecture The version 2 components were written to comply with several web standards (regarding events [www.w3.org/TR/DOM-Level-3-Events/events.html], styles, getter/setter policies, and so on) and are very different from their version 1 counterparts that were released with Macromedia Flash MX and in the DRKs that were released before Macromedia Flash MX 2004. Version 2 components have different APIs and were written in ActionScript 2.0.
Chapter 3: Working with Components
CHAPTER 4 Handling Component Events Every component has events that are broadcast when a user interacts with it (for example, the click and change events) or when something significant happens to the component (for example, the load event). To handle an event, you write ActionScript code that executes when the event occurs. Each component broadcasts its own set of events. This set includes the events of any class from which the component inherits.
The keyword this, used inside an on() handler attached to a component, refers to the component instance. For example, the following code, attached to the Button component instance myButton, sends “_level0.myButton” to the Output panel: on(click){ trace(this); } To use the on() event handler: 1. Open the file TipCalculator1.fla from Macromedia\Flash MX 2004\Samples\HelpExamples\TipCalculator. 2. On the Stage, select the TextInput component beside the “Enter subtotal” text. 3.
• To register a listener to a broadcaster, call the addEventListener() method from the broadcaster. Use the following syntax: componentInstance.addEventListener("eventName", listenerObjectORFunction); • You can register multiple listeners to one component instance. myButton.addEventListener("click", listener1); myButton.addEventListener("click", listener2); • You can register one listener to multiple component instances. myButton.addEventListener("click", listener1); myButton2.
// your code here }; Tip: The evtObj parameter is an object that is automatically generated when an event is triggered and passed to the callback function. The event object has properties that contain information about the event. For details, see “About the event object” on page 66. Finally, you call the addEventListener() method from the component instance that broadcasts the event.
8. In the Actions panel, enter the following code: var myButton:mx.controls.Button; var myText:mx.controls.TextInput; function click(evt){ myText.text = evt.target; } myButton.addEventListener("click", this); The target property of the event object, evt, is a reference to the instance broadcasting the event. This code displays the value of the target property in the TextInput component. To register a listener object in a class (AS) file: 1. Open the file TipCalculator.
function handleEvent(evt){ // check if the event was a click if (evt.type == "click"){ // do something if the event was click } else if (evt.type == "change"){ // do something else if the event was change } }; // // // // register the listener object to two different component instances because the function is defined on "this" object, the listener is this. instance.addEventListener("click", this); instance2.
4. Select Frame 1 in the Timeline. 5. Select Window > Development Panels > Actions. 6. In the Actions panel, enter the following code: // declare variables var myList:mx.controls.List; var myHandler:Function; // add items to the list myList.addItem("Bird"); myList.addItem("Dog"); myList.addItem("Fish"); myList.addItem("Cat"); myList.addItem("Ape"); myList.
As discussed earlier, you register a listener with a component instance by calling addEventListener(). This method takes two parameters: a string indicating the name of the event, and a reference to either an object or a function.
trace("this: " + this); trace("myGrid: " + myGrid); } } // register the myHandler function with myButton // when the button is clicked, myHandler executes function onLoad():Void{ myButton.addEventListener("click", myHandler); } } Delegating events You can import the Delegate class into your scripts or classes to delegate events to specific scopes and functions. Use the following syntax: import mx.utils.Delegate; compInstance.addEventListener("eventName", Delegate.
var myButton_btn:Button; function onLoad() { myCheckBox_chb.addEventListener("click", this); myButton_btn.addEventListener("click", this); } function click(eventObj:Object) { switch(eventObj.target) { case myButton_btn: // sends the broadcaster instance name // and the event type to the Output panel trace(eventObj.target + ": " + eventObj.type); break; case myCheckBox_chb: trace(eventObj.target + ": " + eventObj.type); break; } } } The following is the same class file (Cart.
Delegating the scope of a function The addEventListener() method requires two parameters: the name of an event and a reference to a listener. The listener can either be an object or a function. If you pass an object, the callback function assigned to the object is invoked in the scope of the object. However, if you pass a function, the function is invoked in the scope of the component instance that calls addEventListener(). (For more information, see “About scope in listeners” on page 61.
// from the chb_onClick function var i:Number = 10 function onLoad() { myCheckBox_chb.addEventListener("click", Delegate.create(this, chb_onClick)); } function chb_onClick(eventObj:Object) { // Sends 10 to the Output panel // because the function is scoped to // the Cart instance trace(i); } } About the event object The event object is an instance of the ActionScript Object class; it has the following properties that contain information about an event.
CHAPTER 5 Customizing Components You might want to change the appearance of components as you use them in different applications. There are three ways to accomplish this in Macromedia Flash MX 2004 and Macromedia Flash MX Professional 2004: • Use the setStyle() method of each component and style declaration to change the color and text formatting of a component. See “Using styles to customize component color and text” on page 67.
You can use styles to customize a component in the following ways: • Set styles on a component instance. You can change color and text properties of a single component instance. This is effective in some situations, but it can be time consuming if you need to set individual properties on all the components in a document. See “Setting styles on a component instance” on page 69. • Create custom style declarations and apply them to several component instances.
Setting styles on a component instance You can write ActionScript code to set and get style properties on any component instance. The UIObject.setStyle() and UIObject.getStyle() methods can be called directly from any component. The following syntax specifies a property and value for a component instance: instanceName.setStyle("propertyName", value); For example, the following code sets the accent colors on a Button instance called myButton that uses the Halo theme: myButton.
Custom style settings have priority over class, inherited, and global style settings. For a list of the styles that each component supports, see the component entries in Chapter 6, “Components Dictionary,” on page 91. To create a custom style declaration for a group of components: 1. Make sure the document contains at least one component instance. For more information, see “Adding components to Flash documents” on page 44. This example uses three button components with the instance names a, b, and c.
Another option in setting custom style declarations is you can assign the CSSStyleDeclaration instance directly to the component instance’s styleName property and bypass storing the declaration in _global.styles. To use this approach, modify the above procedure as follows: • Remove the ActionScript from steps 6 and 7 above. • Modify the ActionScript in step 9 to assign the CSSStyleDeclaration instance directly to the component instances: a.setStyle("styleName", styleObj); b.
The Style Manager tells Flash whether a style inherits its value. Additional styles can also be added at runtime as inheriting styles. For more information, see “StyleManager class” on page 721. Note: The CSS inherit value is not supported. Inherited styles take priority over global styles. The following example demonstrates how inheriting styles can be used with an Accordion component, which is available with Flash MX Professional.
Notice that the fontStyle setting on the Accordion component affects not only the Accordion text itself but also the text associated with the TextInput and Button components inside the Accordion component. Setting global styles The global style declaration is assigned to all Flash components built with version 2 of the Macromedia Component Architecture. The _global object has a style property (_global.style) that is an instance of CSSStyleDeclaration. This property acts as the global style declaration.
4. If the style is one of the inheriting styles, Flash looks through the parent hierarchy for an inherited value. 5. Flash looks for the style in the global style declaration. 6. If the property is still not defined, the property has the value undefined. About color style properties Color style properties behave differently than noncolor properties. All color properties have a name that ends in “Color”—for example, backgroundColor, disabledColor, and color.
You can use class style declarations and color names to easily control the colors of text and symbols on the screen. For example, if you want to provide a display configuration screen that looks like Microsoft Windows, you would define color names like ButtonText and WindowText and class style declarations like Button, CheckBox, and Window. Note: Some components provide style properties that are an array of colors, such as alternatingRowColors.
Easing class Description None Provides an equal movement from start to end with no effects, slowing, or speeding. This transition is also commonly referred to as a linear transition. Regular Provides for slower movement at one or both ends for a speeding-up effect, a slowing-down effect, or both. Strong Provides for much slower movement at one or both ends. This effect is similar to Regular but is more pronounced. Each of the classes in the mx.transitions.
About themes Themes are collections of styles and skins. The default theme for Flash MX 2004 and Flash MX Professional 2004 is called Halo (HaloTheme.fla). The Halo theme lets you provide a responsive, expressive experience for your users. Flash MX 2004 and Flash MX Professional 2004 include one additional theme, Sample (SampleTheme.fla). The Sample theme provides an example of how you can use more styles for customization. (The Halo theme does not use all styles included in the Sample theme.
4. Double-click any skin symbol you want to modify to open it in symbol-editing mode. The skins are located in the Flash UI Components 2/Themes/MMDefault/Component Assets folder (this example uses RadioButton Assets). 5. Modify the symbol or delete the graphics and create new graphics. You may need to select View > Zoom In to increase the magnification. When you edit a skin, you must maintain the registration point in order for the skin to be displayed correctly.
9. Modify all references to the source theme’s package to the new theme’s package. For example, change all occurrences of “halo” to “myTheme”. 10. Save the changed FocusRect class file. 11. Open the FLA file for your custom theme. This example uses MyTheme.fla. 12. Open the library (Window > Library) and locate the Defaults symbol. In this example, it’s in Flash UI Components 2/Themes/MMDefault/Defaults. 13. Edit the symbol properties for the Default symbol. 14. Change the AS 2.
3. Select File > Import > Open External Library, and select the FLA file of the theme you want to apply to your document. If you haven’t created a new theme, you can use the Sample theme. 4. In the theme’s Library panel, select Flash UI Components 2/Themes/MMDefault and drag the Assets folder of any components in your document to the ThemeApply.fla library. For example, drag the RadioButton Assets folder to the ThemeApply.fla library.
The AS file that defines each component class contains code that loads specific skins for the component. Each component skin corresponds to a skin property that is assigned to a skin symbol’s linkage identifier. For example, the pressed (down) state of the down arrow of the ScrollBar component has the skin property name downArrowDownName. The default value of the downArrowDownName property is "ScrollDownArrowDown", which is the linkage identifier of the skin symbol in the theme FLA file.
The procedure described below is very similar to creating and applying a new theme (see “About themes” on page 77). The primary difference is that this procedure describes copying symbols directly from the theme already in use to a single document and editing only a small number of all skins available. This is appropriate when your modifications are all in a single document and when you are modifying skins for only a few components.
Creating new component skins If you want to use a particular skin for one instance of a component, but another skin for another instance of the component, you must open a theme FLA file and create a new skin symbol. Components are designed to make it easy to use different skins for different instances. To create a new skin: 1. Select File > Open and open the theme FLA file that you want to use as a template. 2. Select File > Save As and select a unique name, such as MyTheme.fla. 3.
To link a skin to a style property: 1. If you already applied the Sample theme to a document, skip to step 5. 2. Select File > Import > Open External Library, and select the HaloTheme.fla file. This file is located in the application-level configuration folder. For the exact location on your operating system, see “About themes” on page 77. 3.
11. Drag an instance of the component to the Stage. For this example, drag two RadioButton components to the Stage, set one to selected, and use ActionScript to set both to disabled in order to see the changes. 12. Add ActionScript code to the document to set the new style property on the component instances or at the global level. For this example, set the property at the global level as follows: _global.style.setStyle("symbolBackgroundDisabledColor", 0xD9D9D9); 13. Select Control > Test Movie.
5. Select the RadioButton component on the Stage and open the Actions panel. 6. Attach the following code to the RadioButton instance: onClipEvent(initialize){ trueUpIcon = "MyRadioTrueUp"; } 7. Select Control > Test Movie. Applying new skins to a subcomponent In certain situations you may want to modify the skins of a subcomponent in a component, but the skin properties are not directly available (for example, there is no direct way to alter the skins of the scroll bar in a List component).
■ If you want to change a specific scroll bar in a document, enter the following code in the Actions panel on Frame 1 of the Timeline: import mx.controls.List import mx.controls.scrollClasses.ScrollBar var oldName = ScrollBar.prototype.downArrowDownName; ScrollBar.prototype.downArrowDownName = "MyScrollDownArrowDown"; createClassObject(List, "myList1", 0, {dataProvider: ["AL","AR","AZ", "CA","HI","ID", "KA","LA","MA"]}); myList1.redraw(true); ScrollBar.prototype.
The following example explains how to skin something that’s already on the Stage. This example skins only List scroll bars; any TextArea or ScrollPane scroll bars would not be skinned. To use #initclip to apply an edited skin to specific components in a document: 1. Follow the steps in “Editing component skins in a document” on page 81, but edit a scroll bar skin. For this example, edit the ScrollDownArrowDown skin and give it the new name MyScrollDownArrowDown. 2.
Changing skin properties in the prototype If a component does not directly support skin variables, you can subclass the component and replace its skins. For example, the ComboBox component doesn’t directly support skinning its drop-down list, because the ComboBox component uses a List component as its drop-down list. If a component is composed of subcomponents, the subcomponents are identified in the component’s entry in Chapter 6, “Components Dictionary.” To skin a subcomponent: 1.
13. Enter the following code: import mx.controls.ComboBox import mx.controls.scrollClasses.ScrollBar class MyComboBox extends ComboBox{ function getDropdown():Object{ var oldName = ScrollBar.prototype.downArrowDownName; ScrollBar.prototype.downArrowDownName = "MyScrollDownArrowDown"; var r = super.getDropdown(); ScrollBar.prototype.downArrowDownName = oldName; return r; } } 14. Select File > Save and save this file as MyComboBox.as. 15. Return to the file MyComboTest.fla. 16.
CHAPTER 6 Components Dictionary This reference chapter describes each component and its application programming interface (API). Each component description contains information about the following: • • • • • • • Keyboard interaction Live preview Accessibility Setting the component parameters Using the component in an application Customizing the component with styles and skins ActionScript methods, properties, and events Components are presented alphabetically.
Component Description CheckBox component Allows users to make a Boolean (true or false) choice. ComboBox component Allows users to select one option from a scrolling list of choices. This component can have an selectable text field at the top of the list that allows users to search the list. DataGrid component (Flash Professional only) Allows users to display and manipulate multiple columns of data.
Component Description DataProvider API The model for linear-access lists of data; it provides simple arraymanipulation capabilities that broadcast data changes. DataSet component (Flash Professional only) A building block for creating data-driven applications. RDBMSResolver component (Flash Professional only) Lets you save data back to any supported data source. This component translates the XML that can be received and parsed by a web service, JavaBean, servlet, or ASP page.
Screens Class Description Form class (Flash Professional Lets you manipulate form application screens at runtime. only) Screen class Base class for the Slide and Form classes. See Screen class (Flash Professional only). Slide class (Flash Professional only) Lets you manipulate slide presentation screens at runtime. Other listings in this chapter This chapter also describes several classes and APIs that don’t fall into the above categories of components. They are listed in the following table.
Item Description TreeDataProvider interface (Flash Professional only) Tree.dataProvider property. A set of properties and methods used to create XML for the UIComponent class Provides methods, properties, and events that allow components to share some common behavior. UIEventDispatcher class Allows components to emit certain events. This class is mixed in to the UIComponent class. UIObject class The base class for all version 2 components.
CHAPTER 6 Components Dictionary Accordion component (Flash Professional only) The Accordion component is a navigator that contains a sequence of children that it displays one at a time. The children must be objects that inherit from the UIObject class (which includes all components and screens built with version 2 of the Macromedia Component Architecture); most often, children are a subclass of the View class. This includes movie clips assigned to the class mx.core.View.
Using the Accordion component (Flash Professional only) You can use the Accordion component to present multipart forms. For example, a three-child accordion might present forms where the user fills out her shipping address, billing address, and payment information for an e-commerce transaction. Using an accordion instead of multiple web pages minimizes server traffic and allows the user to maintain a better sense of progress and context in an application.
5. Repeat steps 2-4 to create a screen named checkoutForm. 6. Create a new screen named accordionForm. 7. Drag an Accordion component from the Components panel to the accordionForm form, and name it myAccordion. 8. With myAccordion selected, in the Property inspector, do the following: ■ For the childSymbols property, enter addressForm, addressForm, and checkoutForm. These strings specify the names of the screens used to create the accordion’s children.
■ For the childNames property, enter shippingAddress, billingAddress, and checkout. These strings are the ActionScript names of the accordion’s children. ■ For the childLabels property, enter Shipping Address, Billing Address, and Checkout. These strings are the text labels on the accordion headers. ■ For the childIcons property, enter AddressIcon, AddressIcon, and CheckoutIcon. These strings specify the linkage identifiers of the movie clip symbols that are used as the icons on the accordion headers.
If the headers are too small to contain their label text, the labels are clipped. If the content area of an accordion is smaller than a child, the child is clipped. Using styles with the Accordion component You can set style properties to change the appearance of the border and background of an Accordion component. If the name of a style property ends in “Color”, it is a color style property and behaves differently than noncolor style properties.
Style Theme Description openDuration Both The duration, in milliseconds, of the transition animation. openEasing Both A reference to a tweening function that controls the animation. Defaults to sine in/out. For more information, see “Customizing component animations” on page 75. Using skins with the Accordion component The Accordion component uses skins to represent the visual states of its header buttons.
To create an ActionScript class to use as the skin and provide different states, the skin can read the borderStyle style property of the skin to determine the state.
clear(); lineStyle(0, 0, 100); beginFill(c, 100); drawRect(0, 0, __width, __height); endFill(); } // required for skins static function classConstruct():Boolean { UIObjectExtensions.Extensions(); _global.
To create movie clip symbols for Accordion header skins: 1. Create a new FLA file. 2. Create a new symbol by selecting Insert > New Symbol. 3. Set the name to RedAccordionHeaderSkin. 4. If the advanced view is not displayed, click the Advanced button. 5. Select Export for ActionScript. The identifier will be automatically filled out with RedAccordionHeaderSkin. 6. Leave the AS 2.0 Class text box blank. 7. Ensure that Export in First Frame is already selected, and click OK. 8.
Accordion class (Flash Professional only) Inheritance MovieClip > UIObject class > UIComponent class > View > Accordion ActionScript Class Name mx.containers.Accordion An Accordion component contains children that are displayed one at a time. Each child has a corresponding header button that is created when the child is created. A child must be an instance of UIObject. A movie clip symbol automatically becomes an instance of the UIObject class when it becomes a child of an accordion.
Method Description UIObject.getStyle() Gets the style property from the style declaration or object. UIObject.invalidate() Marks the object so it will be redrawn on the next frame interval. UIObject.move() Moves the object to the requested position. UIObject.redraw() Forces validation of the object so it is drawn in the current frame. UIObject.setSize() Resizes the object to the requested size. UIObject.setSkin() Sets a skin in the object. UIObject.
Property Description UIObject.scaleY A number indicating the scaling factor in the y direction of the object, relative to its parent. UIObject.top The position of the top edge of the object, relative to its parent. Read-only. UIObject.visible A Boolean value indicating whether the object is visible (true) or not (false). UIObject.width The width of the object, in pixels. Read-only. UIObject.x The left edge of the object, in pixels. Read-only. UIObject.y The top edge of the object, in pixels.
Events inherited from the UIComponent class The following table lists the events the Accordion class inherits from the UIComponent class. Event Description UIComponent.focusIn Broadcast when an object receives focus. UIComponent.focusOut Broadcast when an object loses focus. UIComponent.keyDown Broadcast when a key is pressed. UIComponent.keyUp Broadcast when a key is released. Accordion.change Availability Flash Player 6 (6.0 79.0). Edition Flash MX Professional 2004.
Example In the following example, a handler called myAccordionListener is defined and passed to the myAccordion.addEventListener() method as the second parameter. The event object is captured by the change handler in the eventObject parameter. When the change event is broadcast, a trace statement is sent to the Output panel. myAccordionListener = new Object(); myAccordionListener.change = function(){ trace("Changed to different view"); } myAccordion.
Example The following code creates an instance of the PaymentForm movie clip symbol named payment as the last child of myAccordion: var child = myAccordion.createChild("PaymentForm", "payment", {label: "Payment", Icon: "payIcon"}); child.cardType.text = "Visa"; child.cardNumber.text = "1234567887654321"; The following code creates a child that is an instance of the View class: var child = myAccordion.createChild(mx.core.View, "payment", {label: "Payment", Icon: "payIcon"}); child.cardType.
Description Method; creates a child for the accordion. The newly created child is added to the end of the list of children owned by the accordion. Use this method to place views inside the accordion. The created child is an instance of the class or movie clip symbol specified in the classOrSymbolName parameter. You can use the label and icon parameters to specify a text label and an icon for the associated accordion header for each child.
Returns Nothing. Description Method (inherited from View); destroys one of the accordion’s children. The child to be destroyed is specified by its index, which is passed to the method in the index parameter. Calling this method destroys the corresponding header as well. If the destroyed child is selected, a new selected child is chosen. If there is a next child, it is selected. If there is no next child, the previous child is selected. If there is no previous child, the selection is undefined.
Accordion.numChildren Availability Flash Player 6 (6.0 79.0). Edition Flash MX Professional 2004. Usage myAccordion.numChildren Description Property (inherited from View); indicates the number of children (of type UIObject) in an Accordion instance. Headers are not counted as children. Each accordion child is given an index number for its position. This index number is zero-based, so the first child is 0, the second child is 1, and so on. The code myAccordion.
The default value is myAccordion.getChildAt(0) if the accordion has children. If the accordion doesn’t have children, the default value is undefined. Example The following example retrieves the label of the selected child view: var selectedLabel = myAccordion.selectedChild.label; The following example sets the payment form to be the selected child view: myAccordion.selectedChild = myAccordion.payment; See also Accordion.selectedIndex Accordion.selectedIndex Availability Flash Player 6 (6.0 79.0).
Alert component (Flash Professional only) CHAPTER 6 Components Dictionary The Alert component lets you display a window that presents the user with a message and response buttons. The window has a title bar that you can fill with text, a message that you can customize, and buttons whose labels you can change. An Alert window can have any combination of Yes, No, OK, and Cancel buttons, and you can change the button labels by using the Alert.yesLabel, Alert.click, Alert.okLabel, and Alert.
3. In the Actions panel, enter the following code on Frame 1 of the Timeline to define an event handler for the click event: import mx.controls.Alert; myClickHandler = function (evt){ if (evt.detail == Alert.OK){ trace("start stock app"); // startStockApplication(); } } Alert.show("Launch Stock Application?", "Stock Price Alert", Alert.OK | Alert.CANCEL, this, myClickHandler, "stockIcon", Alert.OK); This code creates an Alert window with OK and Cancel buttons.
Style Theme Description border styles Both The Alert component uses a RectBorder instance as its border and responds to the styles defined on that class. See “RectBorder class” on page 647. The Alert component has a component-specific borderStyle setting of “alert” with the Halo theme and “outset” with the Sample theme. color Both The text color. The default value is 0x0B333C for the Halo theme and blank for the Sample theme. disabledColor Both The color for text when the component is disabled.
The following example demonstrates how to set the title of an Alert component to be italicized: import mx.controls.Alert; import mx.styles.CSSStyleDeclaration; var titleStyles = new CSSStyleDeclaration(); titleStyles.setStyle("fontWeight", "bold"); titleStyles.setStyle("fontStyle", "italic"); Alert.titleStyleDeclaration = titleStyles; Alert.show("Name is a required field", "Validation Error"); The default title style declarations set fontWeight to "bold".
4. If the advanced view is not displayed, click the Advanced button. 5. Select Export for ActionScript. 6. The identifier will be automatically filled out with TitleBackground. 7. Set the AS 2.0 class to mx.skins.SkinElement. SkinElement is a simple class that can be used for all skin elements that don’t provide their own ActionScript impelmentation. It provides movement and sizing functionality required by the version 2 component framework. 8. Ensure that Export in First Frame is already selected. 9.
To understand more about the Alert class, see “Window component” on page 878 and “PopUpManager class” on page 601. Method summary for the Alert class The following table lists the method of the Alert class. Method Description Alert.show() Creates an Alert window with optional parameters. Methods inherited from the UIObject class The following table lists the methods the Alert class inherits from the UIObject class. Method Description UIObject.
Property summary for the Alert class The following table lists properties of the Alert class. Property Description Alert.buttonHeight The height of each button, in pixels. The default value is 22. Alert.buttonWidth The width of each button, in pixels. The default value is 100. Alert.CANCEL A constant hexadecimal value indicating whether a Cancel button should be displayed in the Alert window. Alert.cancelLabel The label text for the Cancel button. Alert.click The label text for the No button.
Property Description UIObject.x The left edge of the object, in pixels. Read-only. UIObject.y The top edge of the object, in pixels. Read-only. Properties inherited from the UIComponent class The following table lists the properties the Alert class inherits from the UIComponent class. When calling these properties from the Alert object, use the form Alert.propertyName. Property Description UIComponent.enabled Indicates whether the component can receive focus and input. UIComponent.
Event Description UIObject.reveal Broadcast when an object’s state changes from invisible to visible. UIObject.unload Broadcast when the subobjects are being unloaded. Events inherited from the UIComponent class The following table lists the events the Alert class inherits from the UIComponent class. When calling these events from the Alert object, use the form Alert.eventName. Event Description UIComponent.focusIn Broadcast when an object receives focus. UIComponent.
Alert.buttonWidth Availability Flash Player 6 (6.0 79.0). Edition Flash MX Professional 2004. Usage Alert.buttonWidth Description Property (class); a class (static) property that changes the width of the buttons. The default value is 100. See also Alert.buttonHeight Alert.CANCEL Availability Flash Player 6 (6.0 79.0). Edition Flash MX Professional 2004. Usage Alert.CANCEL Description Property (constant); a property with the constant hexadecimal value 0x8.
Alert.cancelLabel Availability Flash Player 6 (6.0 79.0). Edition Flash MX Professional 2004. Usage Alert.cancelLabel Description Property (class); a class (static) property that indicates the label text on the Cancel button. Example The following example sets the Cancel button’s label to “cancellation”: Alert.cancelLabel = "cancellation"; Alert.click Availability Flash Player 6 (6.0 79.0). Edition Flash MX Professional 2004. Usage clickHandler = function(eventObject){ // insert code here } Alert.
Example In the following example, a handler called myClickHandler is defined and passed to the Alert.show() method as the fifth parameter. The event object is captured by myClickHandler in the evt parameter. The detail property of the event object is then used in a trace statement to send the name of the button that was clicked (Alert.OK or Alert.CANCEL) to the Output panel. import mx.controls.Alert; myClickHandler = function(evt){ if(evt.detail == Alert.OK){ trace(Alert.okLabel); }else if (evt.
Alert.noLabel Availability Flash Player 6 (6.0 79.0). Edition Flash MX Professional 2004. Usage Alert.noLabel Description Property (class); a class (static) property that indicates the label text on the No button. Example The following example sets the No button’s label to “nyet”: Alert.noLabel = "nyet"; Alert.OK Availability Flash Player 6 (6.0 79.0). Edition Flash MX Professional 2004. Usage Alert.OK Description Property (constant); a property with the constant hexadecimal value 0x4.
Alert.okLabel Availability Flash Player 6 (6.0 79.0). Edition Flash MX Professional 2004. Usage Alert.okLabel Description Property (class); a class (static) property that indicates the label text on the OK button. Example The following example sets the OK button’s label to “okay”: Alert.okLabel = "okay"; Alert.show() Availability Flash Player 6 (6.0 79.0). Edition Flash MX Professional 2004. Usage Alert.
clickHandler A handler for the click events broadcast when the buttons are clicked. In addition to the standard click event object properties, there is an additional detail property, which contains the flag value of the button that was clicked (Alert.OK, Alert.CANCEL, Alert.YES, Alert.NO). This handler can be a function or an object. For more information, see “Using listeners to handle events” on page 56.
Alert.YES Availability Flash Player 6 (6.0 79.0). Edition Flash MX Professional 2004. Usage Alert.YES Description Property (constant); a property with the constant hexadecimal value 0x1. This property can be used for the flags or defaultButton parameter of the Alert.show() method. When used as a value for the flags parameter, this property indicates that a Yes button should be displayed in the Alert window.
CHAPTER 6 Components Dictionary Button component The Button component is a resizable rectangular user interface button. You can add a custom icon to a button. You can also change the behavior of a button from push to toggle. A toggle button stays pressed when clicked and returns to its up state when clicked again. A button can be enabled or disabled in an application. In the disabled state, a button doesn’t receive mouse or keyboard input. An enabled button receives focus if you click it or tab to it.
Button parameters You can set the following authoring parameters for each Button component instance in the Property inspector or in the Component inspector: label sets the value of the text on the button; the default value is Button. icon adds a custom icon to the button. The value is the linkage identifier of a movie clip or graphic symbol in the library; there is no default value. toggle turns the button into a toggle switch.
Customizing the Button component You can transform a Button component horizontally and vertically while authoring and at runtime. While authoring, select the component on the Stage and use the Free Transform tool or any of the Modify > Transform commands. At runtime, use the setSize() method (see UIObject.setSize()) or any applicable properties and methods of the Button class (see “Button class” on page 139). Resizing the button does not change the size of the icon or label.
Style Theme Description embedFonts Both A Boolean value that indicates whether the font specified in fontFamily is an embedded font. This style must be set to true if fontFamily refers to an embedded font. Otherwise, the embedded font will not be used. If this style is set to true and fontFamily does not refer to an embedded font, no text will be displayed. The default value is false. fontFamily Both The font name for text. The default value is "_sans". fontSize Both The point size for the font.
If a button is enabled, it displays its over state when the pointer moves over it. The button receives input focus and displays its down state when it’s pressed. The button returns to its over state when the mouse is released. If the pointer moves off the button while the mouse is pressed, the button returns to its original state and it retains input focus. If the toggle parameter is set to true, the state of the button does not change until the mouse is released over it.
Property Description falseDisabledIconEmphasized The icon disabled state of an emphasized button. trueUpIconEmphasized The icon toggled state of an emphasized button. trueOverIconEmphasized The icon over-toggled state of an emphasized button. trueDownIconEmphasized The icon pressed-toggled state of an emphasized button. trueDisabledIconEmphasized The icon disabled-toggled state of an emphasized button.
To create an ActionScript customized Button skin: 1. Create a new ActionScript class file. For this example, name the file RedGreenBlueSkin.as. 2. Copy the following ActionScript to the file: import mx.skins.RectBorder; import mx.core.ext.
This class creates a square box based on the border style: a blue box for the false up, rollover, and disabled states; a green box for the normal pressed state; and a red box for the expanded child. It draws a hairline border in the normal case and a thick border if the button is emphasized. 3. Save the file. 4. Create a new FLA file. 5. Save the FLA file in the same folder as the AS file. 6. Create a new symbol by selecting Insert > New Symbol. 7. Set the name to ButtonSkin. 8.
12. Repeat steps 2-11 and create green and blue skins, named accordingly. 13. Click the Back button to return to the main Timeline. 14. Drag a Button component to the Stage. 15. Set the toggled property value to true to see all three skins. 16. Copy the following ActionScript code to the Actions panel with the Button instance selected.
Method summary for the Button class There are no methods exclusive to the Button class. Methods inherited from the UIObject class The following table lists the methods the Button class inherits from the UIObject class. When calling these methods from the Button object, use the form buttonInstance.methodName. Method Description UIObject.createClassObject() Creates an object on the specified class. UIObject.createObject() Creates a subobject on an object. UIObject.
Properties inherited from the SimpleButton class The following table lists the properties the Button class inherits from the SimpleButton class. When accessing these properties, use the form buttonInstance.propertyName. Property Description SimpleButton.emphasized Indicates whether a button has the look of a default push button. SimpleButton.emphasizedStyleDeclaration The style declaration when the emphasized property is set to true. SimpleButton.
Properties inherited from the UIComponent class The following table lists the properties the Button class inherits from the UIComponent class. When accessing these properties from the Button object, use the form buttonInstance.propertyName. Property Description UIComponent.enabled Indicates whether the component can receive focus and input. UIComponent.tabIndex A number indicating the tab order for a component in a document.
Button.icon Availability Flash Player 6 (6.0 79.0). Edition Flash MX 2004. Usage buttonInstance.icon Description Property; a string that specifies the linkage identifier of a symbol in the library to be used as an icon for a button instance. The icon can be a movie clip symbol or a graphic symbol with an upper left registration point. You must resize the button if the icon is too large to fit; neither the button nor the icon resizes automatically.
Description Property; specifies the text label for a button instance. By default, the label appears centered on the button. Calling this method overrides the label authoring parameter specified in the Property inspector or the Component inspector. The default value is "Button". Example The following code sets the label to “Remove from list”: buttonInstance.label = "Remove from list"; See also Button.labelPlacement Button.labelPlacement Availability Flash Player 6 (6.0 79.0). Edition Flash MX 2004.
CellRenderer API CHAPTER 6 Components Dictionary The CellRenderer API is a set of properties and methods that the list-based components (List, DataGrid, Tree, Menu, and ComboBox) use to manipulate and display custom cell content for each of their rows. This customized cell can contain a prebuilt component, such as a CheckBox component, or any class you create. Understanding the List class To use the CellRenderer API, you need an advanced understanding of the List class.
Because of this scrolling behavior, you cannot expect a cell to be used for only one value. Recycling of rows means that the cell renderer must know how to completely reset its state when it is set to a new value. For example, if your cell renderer creates an icon to display one item, it might need to remove that icon when another item is rendered with it.
Simple cell renderer example This section presents an example of a cell renderer that displays multiple lines of text in a cell. A cell renderer class must implement the following methods: • • CellRenderer.getPreferredHeight() CellRenderer.getPreferredWidth() This method is necessary only for Menu components; otherwise, comment it out of the code, as in the example. • CellRenderer.setSize() If a cell renderer class extends UIObject, implement size() instead. • CellRenderer.
var c = multiLineLabel = createLabel("multiLineLabel", 10); // links the style of the label to the // style of the grid c.styleName = listOwner; c.selectable = false; c.tabEnabled = false; c.background = false; c.border = false; c.multiline = true; c.wordWrap = true; } // // // // By extending UIComponent, you get setSize for free; however, UIComponent expects you to implement size(). Assume __width and __height are set for you now. You're going to expand the cell to fit the whole rowHeight.
Method Description CellRenderer.setSize() Sets the width and height of a cell. CellRenderer.setValue() Sets the content to be displayed in the cell. Methods provided by the CellRenderer API The List, DataGrid, Tree, and Menu components give the following methods to the cell when it is created within the component. You do not need to implement these methods. Method Description CellRenderer.
This method is provided by the List class; you do not have to implement it. Declare it in your cell renderer class as follows, and use it in the functions in your cell renderer: var getCellIndex:Function; Example This example edits a DataGrid component’s data provider from within a cell: var index = getCellIndex(); var colName = listOwner.getColumnAt(index.columnIndex).columnName; listOwner.dataProvider.editField(index.itemIndex, colName, someVal); CellRenderer.
Usage componentInstance.getPreferredHeight() Parameters None. Returns The correct height for the cell. Description Method; returns the preferred height of a cell. This is especially important for getting the right height of text within the cell. If you set this value higher than the rowHeight property of the component, cells will bleed above and below the rows. This method is not provided by the List class; you must implement it.
Returns A value (of type Number) that indicates the correct width of the cell. Description Method; the preferred width of a cell. If you specify a width greater than that of the component, the cell may be cut off. You need to implement this method only for the Menu component. Your cell will be sized to whatever the width of the row is, except in a menu, which must measure the text for the width of the row.
CellRenderer.owner Availability Flash Player 6 (6.0 79.0). Edition Flash MX 2004. Usage componentInstance.owner Description Property; a reference to the row that contains the cell. This method is provided by the List class; you do not have to implement it. Declare it in your cell renderer class and use it as a reference: var owner:MovieClip; // or UIObject, etc. CellRenderer.setSize() Availability Flash Player 6 (6.0 79.0). Edition Flash MX 2004. Usage componentInstance.
Example This example sizes an image in the cell to fit within the bounds specified by the list: function setSize(w:Number, h:Number):Void { image._width = w-2; image._height = h-2; image._x = image._y = 1; } This example is in a cell renderer class that extends UIComponent (which extends UIObject), so you must implement size() instead of setSize(), as follows: // // // // By extending UIComponent, you get setSize for free; however, UIComponent expects you to implement size().
Description Method; takes the values given and creates a representation of them in the cell. This resolves any difference between what was displayed in the cell and what needs to be displayed in the cell for the new item. (Remember that any cell could display many values during its time in the list.) This is the most important CellRenderer method, and you must implement it in every cell renderer.
if (myCheck.enabled!=itm.enabled){ myCheck.enabled = itm.enabled; } } If you want to enable the check box on the second row, you communicate through the data provider. Any change to the data provider (when made through a DataProvider method such as DataProvider.editField()) calls setValue() to refresh the display of the grid.
CheckBox component CHAPTER 6 Components Dictionary A check box is a square box that can be selected or deselected. When it is selected, a check mark appears in the box. You can add a text label to a check box and place it to the left, right, top, or bottom. A check box can be enabled or disabled in an application. If a check box is enabled and a user clicks it or its label, the check box receives input focus and displays its pressed appearance.
CheckBox parameters You can set the following authoring parameters for each CheckBox component instance in the Property inspector or in the Component inspector: label sets the value of the text on the check box; the default value is defaultValue. selected sets the initial value of the check box to checked (true) or unchecked (false). labelPlacement orients the label text on the check box. This parameter can be one of four values: left, right, top, or bottom; the default value is right.
Customizing the CheckBox component You can transform a CheckBox component horizontally and vertically while authoring and at runtime. While authoring, select the component on the Stage and use the Free Transform tool or any of the Modify > Transform commands. At runtime, use the setSize() method (UIObject.setSize()) or any applicable properties and methods of the CheckBox class. Resizing the check box does not change the size of the label or the check box icon; it only changes the size of the bounding box.
Style Theme Description textDecoration Both symbolBackgroundColor Sample The background color of the check box. The default value is 0xFFFFFF (white). symbolBackgroundDisabledColor Sample The background color of the check box when disabled. The default value is 0xEFEEEF (light gray). symbolBackgroundPressedColor Sample The background color of the check box when pressed. The default value is 0xFFFFFF (white). symbolColor Sample The color of the check mark. The default value is 0x000000 (black).
3. In the theme’s Library panel, expand the Flash UI Components 2/Themes/MMDefault folder and drag the CheckBox Assets folder to the library for your document. 4. Expand the CheckBox Assets/States folder in the library of your document. 5. Open the symbols you want to customize for editing. For example, open the CheckFalseDisabled symbol. 6. Customize the symbol as desired. For example, change the inner white square to a light gray. 7. Repeat steps 5-6 for all symbols you want to customize.
Methods inherited from the UIObject class The following table lists the methods the CheckBox class inherits from the UIObject class. When calling these methods from the CheckBox object, use the form checkBoxInstance.methodName. Method Description UIObject.createClassObject() Creates an object on the specified class. UIObject.createObject() Creates a subobject on an object. UIObject.destroyObject() Destroys a component instance. UIObject.
Properties inherited from the UIObject class The following table lists the properties the CheckBox class inherits from the UIObject class. When accessing these properties from the CheckBox object, use the form checkBoxInstance.propertyName. Property Description UIObject.bottom The position of the bottom edge of the object, relative to the bottom edge of its parent. Read-only. UIObject.height The height of the object, in pixels. Read-only. UIObject.left The left edge of the object, in pixels.
Properties inherited from the SimpleButton class The following table lists the properties the CheckBox class inherits from the SimpleButton class. When accessing these properties from the CheckBox object, use the form checkBoxInstance.propertyName. Property Description SimpleButton.emphasized Indicates whether a button has the appearance of a default push button. SimpleButton.emphasizedStyleDeclaration The style declaration when the emphasized property is set to true. SimpleButton.
Event Description UIObject.reveal Broadcast when an object’s state changes from invisible to visible. UIObject.unload Broadcast when the subobjects are being unloaded. Events inherited from the UIComponent class The following table lists the events the CheckBox class inherits from the UIComponent class. Event Description UIComponent.focusIn Broadcast when an object receives focus. UIComponent.focusOut Broadcast when an object loses focus. UIComponent.keyDown Broadcast when a key is pressed.
The first usage example uses an on() handler and must be attached directly to a CheckBox instance. The keyword this, used inside an on() handler attached to a component, refers to the component instance. For example, the following code, attached to the check box myCheckBox, sends “_level0.myCheckBox” to the Output panel: on(click){ trace(this); } The second usage example uses a dispatcher/listener event model.
CheckBox.label Availability Flash Player 6 (6.0 79.0). Edition Flash MX 2004. Usage checkBoxInstance.label Description Property; indicates the text label for the check box. By default, the label appears to the right of the check box. Setting this property overrides the label parameter specified in the Parameters tab of the Component Inspector panel. Example The following code sets the text that appears beside the CheckBox component and sends the value to the Output panel: checkBox.
• "left" The check box is pinned to the upper right corner of the bounding area. The label is set to the left of the check box. • "bottom" • "top" The label is set below the check box. The check box and label are centered horizontally and vertically. The label is placed below the check box. The check box and label are centered horizontally and vertically. You can change the bounding area of a component while authoring by using the Transform command or at runtime using the UIObject.
CHAPTER 6 Components Dictionary Collection interface (Flash Professional only) ActionScript Class Name mx.utils.Collection The collection class is distributed in the common classes library as a compiled clip symbol. To access this class, select Window > Other Panels > Common Libraries > Classes > UtilsClasses. The collection interface lets you programmatically manage a group of related items, called collection items.
Parameters item The object to be added to the collection. If item is null, it is not added to the collection. Returns A Boolean value of true if the collection was changed as a result of the operation. Description Method; adds a new item to the end of the collection. Example The following example calls addItem(): on (click) { import CompactDisc; var myColl:mx.utils.Collection; myColl = _parent.thisShelf.MyCompactDiscs; myCD = new CompactDisc(); myCD.Artist = "John Coltrane"; myCD.
Example The following example calls contains(): var myColl:mx.utils.Collection; myColl = _parent.thisShelf.MyCompactDiscs; var itr:mx.utils.Iterator = myColl.getIterator(); while (itr.hasNext()) { var cd:CompactDisc = CompactDisc(itr.next()); var title:String = cd.Title; var artist:String = cd.Artist; if(myColl.contains(cd)) { trace("myColl contains " + title); } else { trace("myColl does not contain " + title); } } Collection.clear() Availability Flash Player 7. Edition Flash MX Professional 2004.
Collection.getItemAt() Availability Flash Player 7. Edition Flash MX Professional 2004. Usage collection.getItemAt(index) Parameters A number that indicates the location of item within the collection. This is a zero-based index, so 0 retrieves the first item, 1 retrieves the second item, and so on. index Returns An object containing a reference to the specified collection item, or null if index is out of bounds. Description Method; returns an item within the collection by using its index.
Description Method; returns an iterator over the elements in the collection. There are no guarantees concerning the order in which the elements are returned (unless this collection is an instance of a class that provides a guarantee). Example The following example calls getIterator(): on (click) { var myColl:mx.utils.Collection; myColl = _parent.thisShelf.MyCompactDiscs; var itr:mx.utils.Iterator = myColl.getIterator(); while (itr.hasNext()) { var cd:CompactDisk = CompactDisc(itr.
Collection.isEmpty() Availability Flash Player 7. Edition Flash MX Professional 2004. Usage collection.isEmpty() Returns A Boolean value of true if the collection is empty. Description Method; indicates whether the collection is empty. Example The following example calls isEmpty(): on (click) { var myColl:mx.utils.Collection; myColl = _parent.thisShelf.MyCompactDiscs; if (myColl.isEmpty()) { trace("No CDs in the collection"); } } //... Collection.removeItem() Availability Flash Player 7.
Description Method; removes the specified item from the collection. Because Collection.removeItem() dynamically reduces the size of the collection, do not call this method while looping through an iterator. Example The following example calls removeItem(): var myColl:mx.utils.Collection; myColl = _parent.thisShelf.MyCompactDiscs; // get this from a text input box var removeArtist:String = _parent.tArtistToRemove.text; var removeSize:Number = 0; if (myColl.
ComboBox component CHAPTER 6 Components Dictionary A combo box allows a user to make a single selection from a drop-down list. A combo box can be static or editable. An editable combo box allows a user to enter text directly into a text field at the top of the list, as well as selecting an item from a drop-down list. If the drop-down list hits the bottom of the document, it opens up instead of down.
When the drop-down list of a combo box has focus, alphanumeric keystrokes move the selection up and down the drop-down list to the next item with the same first character. You can also use the following keys to control a drop-down list: Key Description Control+Up Arrow If the drop-down list is open, focus returns to the text box and the drop-down list closes in the stand-alone and browser versions of Flash Player. Down Arrow Moves the selection down one item.
Using the ComboBox component You can use a ComboBox component in any form or application that requires a single choice from a list. For example, you could provide a drop-down list of states in a customer address form. You can use an editable combo box for more complex scenarios. For example, in an application that provides driving directions, you could use an editable combo box for a user to enter her origin and destination addresses. The drop-down list would contain her previously entered addresses.
5. Select Frame 1 in the Timeline, open the Actions panel, and enter the following code: function change(evt){ trace(evt.target.selectedItem.label); } comboBox.addEventListener("change", this); The last line of code adds a change event handler to the ComboBox instance. For more information, see ComboBox.change. Customizing the ComboBox component You can transform a ComboBox component horizontally and vertically while authoring.
Style Theme Description border styles Both The Button subcomponent uses two RectBorder instances for its borders and responds to the styles defined on that class. See “RectBorder class” on page 647. In the Halo theme, the ComboBox component uses a custom rounded border for the collapsed portion of the ComboBox. The colors of this portion of the ComboBox can be modified only through skinning. See “Using skins with the ComboBox component” on page 181. color Both The text color.
Using skins with the ComboBox component The ComboBox component uses symbols in the library to represent the button states and has skin variables for the down arrow. These skins are located in the Flash UI Components 2/ Themes/MMDefault/ComboBox Assets/States folder of the HaloTheme.fla and SampleTheme.fla files. The information below describes these skins and provides steps for customizing them.
ComboBox class Inheritance MovieClip > UIObject class > UIComponent class > ComboBase > ComboBox ActionScript Class Name mx.controls.ComboBox The ComboBox component combines three separate subcomponents: Button, TextInput, and List. Most of the methods, properties, and events of each subcomponent are available directly from the ComboBox component and are listed in the summary tables for the ComboBox class. The drop-down list in a combo box is provided either as an array or as a data provider.
Method Description ComboBox.removeItemAt() Removes an item from the list at the specified location. ComboBox.replaceItemAt() Replaces the content of the item at the specified index. ComboBox.sortItems() Sorts the list using a compare function. ComboBox.sortItemsBy() Sorts the list using a field of each item. Methods inherited from the UIObject class The following table lists the methods the ComboBox class inherits from the UIObject class.
Property summary for the ComboBox class The following table lists properties of the ComboBox class. Property Description ComboBox.dataProvider The data model for the items in the list. ComboBox.dropdown Returns a reference to the List component contained by the combo box. ComboBox.dropdownWidth The width of the drop-down list, in pixels. ComboBox.editable Indicates whether a combo box is editable. ComboBox.labelField Indicates which data field to use as the label for the drop-down list.
Property Description UIObject.top The position of the top edge of the object, relative to its parent. Read-only. UIObject.visible A Boolean value indicating whether the object is visible (true) or not (false). UIObject.width The width of the object, in pixels. Read-only. UIObject.x The left edge of the object, in pixels. Read-only. UIObject.y The top edge of the object, in pixels. Read-only.
Event Description UIObject.resize Broadcast when an object has been resized. UIObject.reveal Broadcast when an object’s state changes from invisible to visible. UIObject.unload Broadcast when the subobjects are being unloaded. Events inherited from the UIComponent class The following table lists the events the ComboBox class inherits from the UIComponent class. Event Description UIComponent.focusIn Broadcast when an object receives focus. UIComponent.
ComboBox.addItemAt() Availability Flash Player 6 (6.0 79.0). Edition Flash MX 2004. Usage comboBoxInstance.addItemAt(index, label[, data]) comboBoxInstance.addItemAt(index, {label:label[, data:data]}) comboBoxInstance.addItemAt(index, obj); Parameters A number 0 or greater that indicates the position at which to insert the item (the index of the new item). index A string that indicates the label for the new item. label The data for the item; it can be of any data type. This parameter is optional.
Usage 2: listenerObject = new Object(); listenerObject.change = function(eventObject){ // your code here } comboBoxInstance.addEventListener("change", listenerObject) Description Event; broadcast to all registered listeners when the ComboBox.selectedIndex or ComboBox.selectedItem property changes as a result of user interaction. The first usage example uses an on() handler and must be attached directly to a ComboBox instance.
ComboBox.close() Availability Flash Player 6 (6.0 79.0). Edition Flash MX 2004. Usage myComboBox.close() Parameters None. Returns Nothing. Description Method; closes the drop-down list. Example The following example closes the drop-down list of the myBox combo box: myBox.close(); See also ComboBox.open() ComboBox.close Availability Flash Player 6 (6.0 79.0). Edition Flash MX 2004. Usage Usage 1: on(close){ // your code here } Usage 2: listenerObject = new Object(); listenerObject.
Description Event; broadcast to all registered listeners when the drop-down list of the combo box is fully retracted. The first usage example uses an on() handler and must be attached directly to a ComboBox instance. The keyword this, used in an on() handler attached to a component, refers to the component instance. For example, the following code, attached to the ComboBox instance myBox, sends “_level0.
Description Property; the data model for items viewed in a list. The value of this property can be an array or any object that implements the DataProvider API. The default value is []. The List component and the ComboBox component share the dataProvider property, and changes to this property are immediately available to both components. The List component, like other data-aware components, adds methods to the Array object’s prototype so that they conform to the DataProvider API (see DataProvider.
Description Property (read-only); returns a reference to the list contained by the combo box. The List subcomponent isn’t instantiated in the combo box until it needs to be displayed. However, when you access the dropdown property, the list is created. See also ComboBox.dropdownWidth ComboBox.dropdownWidth Availability Flash Player 6 (6.0 79.0). Edition Flash MX 2004. Usage myComboBox.dropdownWidth Description Property; the width limit of the drop-down list, in pixels.
Making a combo box editable clears the combo box text field. It also sets the selected index (and item) to undefined. To make a combo box editable and still retain the selected item, use the following code: var ix = myComboBox.selectedIndex; myComboBox.editable = true; // clears the text field myComboBox.selectedIndex = ix; // copies the label back into the text field Example The following code makes myComboBox editable: myComboBox.editable = true; ComboBox.enter Availability Flash Player 6 (6.0 79.0).
The second usage example uses a dispatcher/listener event model. A component instance (comboBoxInstance) dispatches an event (in this case, enter) and the event is handled by a function, also called a handler, on a listener object (listenerObject) that you create. You define a method with the same name as the event on the listener object; the method is called when the event is triggered. When the event is triggered, it automatically passes an event object (eventObject) to the listener object method.
Example The following code displays the item at index position 4: trace(myBox.getItemAt(4).label); ComboBox.itemRollOut Availability Flash Player 6 (6.0 79.0). Edition Flash MX 2004. Usage Usage 1: on(itemRollOut){ // your code here } Usage 2: listenerObject = new Object(); listenerObject.itemRollOut = function(eventObject){ // your code here } comboBoxInstance.
The second usage example uses a dispatcher/listener event model. A component instance (comboBoxInstance) dispatches an event (in this case, itemRollOut) and the event is handled by a function, also called a handler, on a listener object (listenerObject) that you create. You define a method with the same name as the event on the listener object; the method is called when the event is triggered. When the event is triggered, it automatically passes an event object (eventObject) to the listener object method.
Description Event; broadcast to all registered listeners when the mouse pointer rolls over drop-down list items. This is a List event that is broadcast from a combo box. For more information, see List.itemRollOver. The first usage example uses an on() handler and must be attached directly to a ComboBox instance. The keyword this, used in an on() handler attached to a component, refers to the component instance. For example, the following code, attached to the ComboBox instance myBox, sends “_level0.
Description Property; the name of the field in dataProvider array objects to use as the label field. This is a property of the List component that is available from a ComboBox component instance. For more information, see List.labelField. The default value is undefined. Example The following example sets the dataProvider property to an array of strings and sets the labelField property to indicate that the name field should be used as the label for the drop-down list: myComboBox.
See also List.labelField ComboBox.length Availability Flash Player 6 (6.0 79.0). Edition Flash MX 2004. Usage myComboBox.length Description Property (read-only); the length of the drop-down list. This is a property of the List component that is available from a ComboBox instance. For more information, see List.length. The default value is 0. Example The following example stores the value of length to a variable: dropdownItemCount = myBox.length; ComboBox.open() Availability Flash Player 6 (6.0 79.0).
See also ComboBox.close() ComboBox.open Availability Flash Player 6 (6.0 79.0). Edition Flash MX 2004. Usage Usage 1: on(open){ // your code here } Usage 2: listenerObject = new Object(); listenerObject.open = function(eventObject){ // your code here } comboBoxInstance.addEventListener("open", listenerObject) Description Event; broadcast to all registered listeners when the drop-down list is completely open.
Example The following example sends a message to the Output panel: function open(evt) { trace("The combo box has opened with text " + evt.target.text); } myBox.addEventListener("open", this); See also ComboBox.close, EventDispatcher.addEventListener() ComboBox.removeAll() Availability Flash Player 6 (6.0 79.0). Edition Flash MX 2004. Usage comboBoxInstance.removeAll() Parameters None. Returns Nothing. Description Method; removes all items in the list.
Usage listInstance.removeItemAt(index) Parameters A number that indicates the position of the item to remove. The index is zero-based. index Returns An object; the removed item (undefined if no item exists). Description Method; removes the item at the specified index position. The list indices after the index indicated by the index parameter collapse by one. This is a method of the List component that is available from an instance of the ComboBox component.
Description Method; replaces the content of the item at the specified index. This is a method of the List component that is available from the ComboBox component. Example The following example changes the third index position: myCombo.replaceItemAt(3, "new label"); See also ComboBox.removeAll(), ComboBox.removeItemAt() ComboBox.restrict Availability Flash Player 6 (6.0 79.0). Edition Flash MX 2004. Usage comboBoxInstance.
However, since this expression is surrounded by double quotation marks, the value 0-9-^\ is sent to the restrict interpreter, and the restrict interpreter doesn’t understand this value. Because you must enter this expression within double quotation marks, you must not only provide the expression for the restrict interpreter, but you must also escape the expression so that it will be read correctly by the Actions panel’s built-in interpreter for double quotation marks.
Example The following example specifies that the combo box should have 20 or fewer rows visible: myComboBox.rowCount = 20; ComboBox.scroll Availability Flash Player 6 (6.0 79.0). Edition Flash MX 2004. Usage Usage 1: on(scroll){ // your code here } Usage 2: listenerObject = new Object(); listenerObject.scroll = function(eventObject){ // your code here } comboBoxInstance.
The second usage example uses a dispatcher/listener event model. A component instance (comboBoxInstance) dispatches an event (in this case, scroll) and the event is handled by a function, also called a handler, on a listener object (listenerObject) that you create. You define a method with the same name as the event on the listener object; the method is called when the event is triggered. When the event is triggered, it automatically passes an event object (eventObject) to the listener object method.
See also ComboBox.selectedItem ComboBox.selectedItem Availability Flash Player 6 (6.0 79.0). Edition Flash MX 2004. Usage myComboBox.selectedItem Description Property; the value of the selected item in the drop-down list. If the combo box is editable, selectedItem returns undefined if the user enters any text in the text box. The property only has a value if you select an item from the drop-down list or set the value using ActionScript.
Parameters compareFunc A reference to a function that compares two items to determine their sort order. For details, see Array.sort() in Flash ActionScript Language Reference. This parameter is optional. optionsFlag Lets you perform multiple sorts of different types on a single array without having to replicate the entire array or re-sort it repeatedly. This parameter is optional. The following are possible values for optionsFlag: • • • Array.DESCENDING, • Array.
myComboBox.sortItems(upperCaseFunc, Array.DESCENDING); // The resulting sort order of myComboBox will be: // Venus // planet // Mercury // Earth ComboBox.sortItemsBy() Availability Flash Player 7. Edition Flash MX Professional 2004. Usage myComboBox.sortItemsBy(fieldName, order [optionsFlag]) Parameters A string that specifies the name of the field to use for sorting. This value is usually or "data".
Returns Nothing. Description Method; sorts the items in the combo box alphabetically or numerically, in the specified order, using the specified field name. If the fieldName items are a combination of text strings and integers, the integer items are listed first. The fieldName parameter is usually "label" or "data", but advanced programmers may specify any primitive value. If you want, you can use the optionsFlag parameter to specify a sorting style.
Usage myComboBox.text Description Property; the text of the text box. You can get and set this value for editable combo boxes. For static combo boxes, the value is read-only. Example The following example sets the current text value of an editable combo box: myComboBox.text = "California"; ComboBox.textField Availability Flash Player 6 (6.0 79.0). Edition Flash MX 2004. Usage myComboBox.
Description Property (read-only); if the combo box is editable, value returns the value of the text box. If the combo box is static, value returns the value of the drop-down list. The value of the drop-down list is the data field, or, if the data field doesn’t exist, the label field. Example The following example puts the data into the combo box by setting the dataProvider property. It then displays the value in the Output panel. Finally, it selects "California" and displays it in the text box. cb.
CHAPTER 6 Components Dictionary Data binding classes (Flash Professional only) The data binding classes provide the runtime functionality for the data binding feature in Flash MX Professional 2004. You can visually create and configure data bindings in the Flash authoring environment by using the Bindings tab in the Component inspector, or you can programmatically create and configure bindings by using the classes in the mx.data.binding package.
Class Description EndPoint class (Flash Professional only) Defines the source or destination of a binding. TypedValue class (Flash Professional only) Contains a data value and information about the value’s data type. Binding class (Flash Professional only) ActionScript Class Name mx.data.binding.Binding The Binding class defines an association between two endpoints, a source and a destination.
destination The destination endpoint of the binding. This parameter is nominally of type mx.data.binding.EndPoint, but can be any ActionScript object that has the required Endpoint fields. format An optional object that contains formatting information. The object must have the following properties: • • cls An ActionScript class that extends the class mx.data.binding.DataAccessor. An object whose properties provide optional settings for the formatter class specified by cls.
src.component = src_txt; src.property = "text"; src.event = "focusOut"; var dest= new EndPoint(); dest.component = text_dest; dest.property = "text"; new Binding(src, dest, {cls: mx.data.formatters.Custom, settings: {classname: "com.mycompany.SpecialFormatter"}}); Binding.execute() Availability Flash Player 6. Edition Flash MX Professional 2004. Usage myBinding.
CustomFormatter class (Flash Professional only) ActionScript Class Name mx.data.binding.CustomFormatter The CustomFormatter class defines two methods, format() and unformat(), that provide the ability to transform data values from a specific data type to String, and vice versa. By default, these methods do nothing; you must implement them in a subclass of mx.data.binding.CustomFormatter.
if (rawValue == numArray[i]) { returnValue = strArray[i]; break; } } return returnValue; } // convert a formatted value, return a raw value function unformat(formattedValue) { var returnValue; var strArray = new Array('one', 'two', 'three'); var numArray = new Array(1, 2, 3); returnValue = "invalid"; for (var i = 0; i
Method summary for the CustomFormatter class The following table lists the methods of the CustomFormatter class. Method Description CustomFormatter.format() Converts from a raw data type to a new object. CustomFormatter.unformat() Converts from a string, or other data type, to a raw data type. CustomFormatter.format() Availability Flash Player 6 (6.0 79.0). Edition Flash MX Professional 2004. Usage This method is called automatically; you don’t invoke it directly.
Returns An unformatted value. Description Method; converts from a string, or other data type, to the raw data type. This transformation should be the exact inverse transformation of CustomFormatter.format(). This method is not implemented by default. You must define it in your subclass of mx.data.binding.CustomFormatter. For more information, see “Sample custom formatter” on page 217. CustomValidator class (Flash Professional only) ActionScript Class Name mx.data.binding.
Method summary for the CustomValidator class The following table lists the methods of the CustomValidator class. Method Description CustomValidator.validate() Performs validation on data. CustomValidator.validationError() Reports validation errors. CustomValidator.validate() Availability Flash Player 6 (6.0 79.0). Edition Flash MX Professional 2004. Usage This method is called automatically; you don’t invoke it directly. Parameters value The data to be validated; it can be of any type.
To create and use a custom validator class: 1. In Flash MX Professional 2004, create a new ActionScript (AS) file. 2. Add the following code to the AS file: class OddNumbersOnly extends mx.data.binding.CustomValidator { public function validate(value) { // make sure the value is of type Number var n = Number(value); if (String(n) == "NaN") { this.validationError("'" + value + "' is not a number."); return; } // make sure the number is odd if (n % 2 == 0) { this.
18. Open the Timeline and select the first frame on Layer 1. 19. Open the Actions panel. 20. Add the following code to the Actions panel: function dataIsInvalid(evt) { if (evt.property == "text") { status.text = evt.messages; } } function dataIsValid(evt) { if (evt.property == "text") { status.text = "OK"; } } textLabel.addEventListener("valid", dataIsValid); textLabel.addEventListener("invalid", dataIsInvalid); 21. Save the FLA file as OddOnly.fla to the same folder that contains OddNumbersOnly.as. 22.
Each message you pass to validationError() is available in the messages property of the event object that was passed to the invalid event handler. Example See the Example section for CustomValidator.validate(). EndPoint class (Flash Professional only) ActionScript Class Name mx.data.binding.EndPoint The EndPoint class defines the source or destination of a binding.
Property summary for the EndPoint class The following table lists the properties of the EndPoint class. Method Description EndPoint.component A reference to a component instance. EndPoint.constant A constant value. EndPoint.event The name of an event, or array of event names, that the component will emit when the data changes. EndPoint.location The location of a data field within the property of the component instance. EndPoint.
Usage endPointObj.component Description Property; a reference to a component instance. Example This example assigns an instance of the List component (listBox1) as the component parameter of an EndPoint object. var sourceEndPoint = new mx.data.binding.EndPoint(); sourceEndPoint.component=listBox1; EndPoint.constant Availability Flash Player 6 (6.0 79.0). Edition Flash MX Professional 2004. Usage endPoint_src.constant Description Property; a constant value assigned to an EndPoint object.
Description Property; specifies the name of an event, or an array of event names, generated by the component when data assigned to the bound property changes. When the event occurs, the binding executes. The specified event only applies to components that are used as the source of a binding, or as the destination of a two-way binding. For more information about creating two-way bindings, see “Binding class (Flash Professional only)” on page 214.
If you specify an object as the location, the object must specify two properties: path and indices. The path property is an array of strings, as discussed above, except that one or more of the specified strings may be the special token "[n]". For each occurrence of this token in path, there must be a corresponding index item in indices. As the path is evaluated, the indices are used to index into arrays. The index item can be any EndPoint object.
Description Property; specifies a property name of the component instance specified by EndPoint.component that contains the bindable data. Note: EndPoint.component and EndPoint.property must combine to form a valid ActionScript object/ property combination. Example This example binds the text property of one TextInput component (text_1) to the same property in another TextInput component (text_2).
ComponentMixins.getField() Availability Flash Player 6 (6.0 79.0). Edition Flash MX Professional 2004. Usage componentInstance.getField(propertyName, [location]) Parameters propertyName A string that contains the name of a property of the specified component. An optional parameter that indicates the location of a field within the component property. This is useful if propertyName specifies a complex data structure and you are interested in a particular field of that structure.
ComponentMixins.initComponent() Availability Flash Player 6 (6.0 79.0). Edition Flash MX Professional 2004. Usage mx.data.binding.ComponentMixins.initComponent(componentInstance) Parameters componentInstance A reference to a component instance. Returns Nothing. Description Method (static); adds all the ComponentMixins methods to the component specified by componentInstance. This method is called automatically for all components involved in a data binding.
Example The following example executes all the bindings for which the DataSet component instance named user_data is the source EndPoint object: user_data.refreshDestinations(); ComponentMixins.refreshFromSources() Availability Flash Player 6 (6.0 79.0). Edition Flash MX Professional 2004. Usage componentInstance.refreshFromSources() Parameters None. Returns Nothing. Description Method; executes all bindings for which componentInstance is the destination EndPoint object.
Returns An array, or null. Description Method; determines if the data in propertyName is valid based on the property’s schema settings. The property’s schema settings are those specified on the Schema tab in the Component Inspector panel. The method returns null if the data is valid; otherwise, it returns an array of error messages as strings. Validation applies only to fields that have schema information available.
7. Add the following code to the Actions panel: // Add ComponentMixin methods to TextInput component. // Note that this step is only necessary if the component // isn’t already involved in a data binding, // either as the source or destination. mx.data.binding.ComponentMixins.initComponent(zipCode_txt); // Define event listener function for component: validateResults = function (eventObj) { var errors:Array = eventObj.target.
You can also use the methods of the DataType class to get or set fields in various data types. The DataType class automatically converts the raw data to the requested type, if possible. For example, in the code example above, the data that’s retrieved is converted to the String type, even if the raw data is a different type. The ComponentMixins.
DataType.encoder Availability Flash Player 6 (6.0 79.0). Edition Flash MX Professional 2004. Usage dataTypeObject.encoder Description Property; provides a reference to the encoder object associated with this field, if one exists. You can use this property to access any properties and methods defined by the specific encoder applied to the field in the Component inspector’s Schema tab. If no encoder was applied to the field in question, then this property returns undefined.
For more information about the formatters provided with Flash MX Professional 2004, see “Schema formatters” in Using Flash. Example This example assumes that the field being accessed is using the Number Formatter (mx.data.formatters.NumberFormatter) provided with Flash MX Professional 2004. This formatter contains a property named precision that specifies how many digits to display after the decimal point. This code sets the precision property to two decimal places for a field using this formatter.
Example This example attempts to get the value of a field (productInfo.available) in an XMLConnector component’s results property first as a number or, if that fails, as a string. import import var f: var b: mx.data.binding.DataType; mx.data.binding.TypedValue; DataType = myXmlConnector.getField("results", "productInfo.available"); TypedValue = f.getAnyTypedValue(["Number", "String"]); See also ComponentMixins.getField() DataType.getAsBoolean() Availability Flash Player 6 (6.0 79.0).
Parameters None. Returns A number. Description Method; fetches the current value of the field and converts it to Number form, if necessary. Example In this example, a field named propName that belongs to a component named myComponent is retrieved as a number, and assigned to a variable: var dataTypeObj:mx.data.binding.DataType = myComponent.getField("propName"); var propValue:Number = dataTypeObj.getAsNumber(); See also DataType.getAnyTypedValue() DataType.getAsString() Availability Flash Player 6 (6.
DataType.getTypedValue() Availability Flash Player 6 (6.0 79.0). Edition Flash MX Professional 2004. Usage dataTypeObject.getTypedValue(requestedType) Parameters requestedType A string containing the name of a data type, or null. Returns A TypedValue object (see “TypedValue class (Flash Professional only)” on page 244). Description Method; returns the value of the field in the specified form, if the field can provide its value in that form.
DataType.setAnyTypedValue() Availability Flash Player 6 (6.0 79.0). Edition Flash MX Professional 2004. Usage dataTypeObject.setAnyTypedValue(newTypedValue) Parameters A TypedValue object value to set in the field. For more information, see “TypedValue class (Flash Professional only)” on page 244. newTypedValue Returns An array of strings describing any errors that occurred while attempting to set the new value.
DataType.setAsBoolean() Availability Flash Player 6 (6.0 79.0). Edition Flash MX Professional 2004. Usage dataTypeObject.setAsBoolean(newBooleanValue) Parameters newBooleanValue A Boolean value. Returns Nothing. Description Method; sets the field to the new value, which is given as a Boolean value. The value is converted to, and stored as, the data type that is appropriate for this field. Example The following example sets a variable named bool to the Boolean value true.
Example The following example sets a variable named num to the Number value of 32. It then sets the value referenced by field to num. var num: Number = 32; field.setAsNumber (num); DataType.setAsString() Availability Flash Player 6 (6.0 79.0). Edition Flash MX Professional 2004. Usage dataTypeObject.setAsString(newStringValue) Parameters newStringValue A string. Returns Nothing. Description Method; sets the field to the new value, which is given as a string.
For more information about TypedValue objects, see “TypedValue class (Flash Professional only)” on page 244. Returns An array of strings describing any errors that occurred while attempting to set the new value. Errors can occur under any of the following conditions: • The data provided is not an acceptable type. • The data provided cannot be converted to the data type of this field (for example, "abc" cannot be converted to Number).
Property summary for the TypedValue class The following table lists the properties of the TypedValue class. Property Description TypedValue.type Contains the schema associated with the TypedValue object’s value. TypedValue.typeName Names the data type of the TypedValue object’s value. TypedValue.value Contains the data value of the TypedValue object. Constructor for the TypedValue class Availability Flash Player 6 (6.0 79.0). Usage new mx.data.binding.
TypedValue.typeName Availability Flash Player 6 (6.0 79.0). Edition Flash MX Professional 2004. Usage typedValueObject.typeName Description Property; contains the name of the data type of the TypedValue object’s value. Example This example displays Boolean in the Output panel: var t: TypedValue = new TypedValue (true, "Boolean", null); trace(t.typeName); TypedValue.value Availability Flash Player 6 (6.0 79.0). Edition Flash MX Professional 2004. Usage typedValueObject.
CHAPTER 6 Components Dictionary DataGrid component (Flash Professional only) The DataGrid component lets you create powerful data-enabled displays and applications. You can use the DataGrid component to instantiate a recordset (retrieved from a database query in Macromedia ColdFusion, Java, or .Net) using Macromedia Flash Remoting and display it in columns. You can also use data from a data set or from an array to fill a DataGrid component.
Key Description Left Arrow When a cell is being edited, the insertion point shifts one character to the left. If a cell is not editable, the Left Arrow key does nothing. Return/Enter/Shift+Enter When a cell is editable, the change is committed, and the insertion point is moved to the cell on the same column, next row (up or down, depending on the shift toggle). Shift+Tab/Tab Moves focus to the previous item.
• Lists perform worse as a function of their visible rows. Although lists can display 5000 records, they can’t render 5000 records at once. The more visible rows (specified by the rowCount property) you have on the Stage, the more work the list must to do to render. Limiting the number of visible rows, if at all possible, is the best solution. • Lists aren’t tables. DataGrid components are intended to provide an interface for many records.
The view consists of three main parts: • Row This is a view object responsible for rendering the items of the grid by laying out cells. Each row is laid out horizontally below the previous one. • Column Columns are fields that are displayed in the grid; the fields each correspond to the columnName property of each column. Each column is a view object (an instance of the DataGridColumn class) responsible for displaying each column—for example, width, color, size, and so on.
Creating an application with the DataGrid component To create an application with the DataGrid component, you must first determine where your data is coming from. The data for a grid can come from a recordset that is fed from a database query in Macromedia ColdFusion, Java, or .Net using Flash Remoting. Data can also come from a data set or an array. To pull the data into a grid, you set the DataGrid.dataProvider property to the recordset, data set, or array.
Using styles with the DataGrid component You can set style properties to change the appearance of a DataGrid component. The DataGrid component inherits styles from the List component. (See “Using styles with the List component” on page 453.) The DataGrid component also supports the following styles: Style Theme Description backgroundColor Both The background color, which can be set for the whole grid or for each column.
Style Theme Description hGridLines Both A Boolean value that indicates whether to show horizontal grid lines (true) or not (false). The default value is false. vGridLineColor Both The color of the vertical grid lines. The default value is 0x666666 (medium gray). hGridLineColor Both The color of the horizontal grid lines. The default value is 0x666666 (medium gray). Setting styles for an individual column Color and text styles can be set for the grid as a whole or for a column.
target.setStyle(style, source.getStyle(style)); } For more information about class-level styles, see “Setting styles for a component class” on page 71. Using skins with the DataGrid component The skins that the DataGrid component uses to represent its visual states are included in the subcomponents that constitute the data grid (scroll bars and RectBorder). For information about their skins, see “Using skins with the UIScrollBar component” on page 831 and “RectBorder class” on page 647.
Methods inherited from the UIObject class The following table lists the methods the DataGrid class inherits from the UIObject class. When calling these methods, use the form dataGridInstance.methodName. Method Description UIObject.createClassObject() Creates an object on the specified class. UIObject.createObject() Creates a subobject on an object. UIObject.destroyObject() Destroys a component instance. UIObject.
Method Description List.sortItems() Sorts the items in the list according to the specified compare function. List.sortItemsBy() Sorts the items in the list according to a specified property. Property summary for the DataGrid class The following table lists the properties of the DataGrid class. Property Description DataGrid.columnCount Read-only; the number of columns that are displayed. DataGrid.columnNames An array of field names within each item that are displayed as columns. DataGrid.
Property Description UIObject.scaleX A number indicating the scaling factor in the x direction of the object, relative to its parent. UIObject.scaleY A number indicating the scaling factor in the y direction of the object, relative to its parent. UIObject.top The position of the top edge of the object, relative to its parent. Read-only. UIObject.visible A Boolean value indicating whether the object is visible (true) or not (false). UIObject.width The width of the object, in pixels. Read-only.
Property Description List.maxHPosition The number of pixels the list can scroll to the right, when List.hScrollPolicy is set to "on". List.multipleSelection Indicates whether multiple selection is allowed in the list (true) or not (false). List.rowCount The number of rows that are at least partially visible in the list. List.rowHeight The pixel height of every row in the list. List.selectable Indicates whether the list is selectable (true) or not (false). List.
Event Description UIObject.move Broadcast when the object has moved. UIObject.resize Broadcast when an object has been resized. UIObject.reveal Broadcast when an object’s state changes from invisible to visible. UIObject.unload Broadcast when the subobjects are being unloaded. Events inherited from the UIComponent class The following table lists the events the DataGrid class inherits from the UIComponent class. Event Description UIComponent.focusIn Broadcast when an object receives focus.
Returns A reference to the DataGridColumn object that was added. Description Method; adds a new column to the end of the data grid. For more information, see “DataGridColumn class (Flash Professional only)” on page 278. Example The following code adds a new DataGridColumn object named Purple: import mx.controls.gridclasses.DataGridColumn; myGrid.addColumn(new DataGridColumn("Purple")); DataGrid.addColumnAt() Availability Flash Player 6 (6.0 79.0). Edition Flash MX Professional 2004. Usage myDataGrid.
DataGrid.addItem() Availability Flash Player 6 (6.0 79.0). Edition Flash MX Professional 2004. Usage myDataGrid.addItem(item) Parameters item An instance of an object to be added to the grid. Returns A reference to the instance that was added. Description Method; adds an item to the end of the grid (after the last item index). Note: This differs from the List.addItem() method in that an object is passed rather than a string.
Example The following example inserts an object instance to the grid at index position 4: var anObject= {name:"Jim!!", age:30}; myGrid.addItemAt(4, anObject); DataGrid.cellEdit Availability Flash Player 6 (6.0 79.0). Edition Flash MX Professional 2004. Usage listenerObject = new Object(); listenerObject.cellEdit = function(eventObject){ // insert your code here } myDataGridInstance.
var cell = "(" + event.columnIndex + ", " + event.itemIndex + ")"; trace("The value of the cell at " + cell + " has changed"); } myDataGrid.addEventListener("cellEdit", myDataGridListener); Note: The grid must be editable for the above code to work. DataGrid.cellFocusIn Availability Flash Player 6 (6.0 79.0). Edition Flash MX Professional 2004. Usage listenerObject = new Object(); listenerObject.cellFocusIn = function(eventObject){ // insert your code here } myDataGridInstance.
trace("The cell at " + cell + " has gained focus"); }; grid.addEventListener("cellFocusIn", myListener); Note: The grid must be editable for the above code to work. DataGrid.cellFocusOut Availability Flash Player 6 (6.0 79.0). Edition Flash MX Professional 2004. Usage listenerObject = new Object(); listenerObject.cellFocusOut = function(eventObject){ // insert your code here } myDataGridInstance.
trace("The cell at " + cell + " has lost focus"); }; grid.addEventListener("cellFocusOut", myListener); Note: The grid must be editable for the above code to work. DataGrid.cellPress Availability Flash Player 6 (6.0 79.0). Edition Flash MX Professional 2004. Usage listenerObject = new Object(); listenerObject.cellPress = function(eventObject){ // insert your code here } myDataGridInstance.
trace("The cell at " + cell + " has been clicked"); }; grid.addEventListener("cellPress", myListener); DataGrid.change Availability Flash Player 6 (6.0 79.0). Edition Flash MX Professional 2004. Usage listenerObject = new Object(); listenerObject.change = function(eventObject){ // insert your code here } myDataGridInstance.addEventListener("change", listenerObject) Description Event; broadcast to all registered listeners when an item has been selected.
DataGrid.columnCount Availability Flash Player 6 (6.0 79.0). Edition Flash MX Professional 2004. Usage myDataGrid.columnCount Description Property (read-only); the number of columns displayed. Example The following example gets the number of displayed columns in the DataGrid instance grid: var c = grid.columnCount; DataGrid.columnNames Availability Flash Player 6 (6.0 79.0). Edition Flash MX Professional 2004. Usage myDataGrid.
Usage listenerObject = new Object(); listenerObject.columnStretch = function(eventObject){ // insert your code here } myDataGridInstance.addEventListener("columnStretch", listenerObject) Description Event; broadcast to all registered listeners when a user resizes a column horizontally. Version 2 components use a dispatcher/listener event model.
The data grid adds methods to the prototype of the Array class so that each Array object conforms to the DataProvider API (see DataProvider.as in the Classes/mx/controls/listclasses folder). Any array that is in the same frame or screen as a data grid automatically has all the methods (addItem(), getItemAt(), and so on) needed for it to be the data model of a data grid, and can be used to broadcast data model changes to multiple components.
Caution: The DataGrid is not editable or sortable if it is bound directly to a WebServiceConnector component or an XMLConnector component. You must bind the DataGrid component to the DataSet component and bind the DataSet component to the WebServiceConnector component or XMLConnector component if you want the grid to be editable or sortable. For more information, see Chapter 14, “Data Integration (Flash Professional Only),” in Using Flash.
DataGrid.focusedCell Availability Flash Player 6 (6.0 79.0). Edition Flash MX Professional 2004. Usage myDataGrid.focusedCell Description Property; in editable mode only, an object instance that defines the cell that has focus. The object must have the fields columnIndex and itemIndex, which are both integers that indicate the index of the column and item of the cell. The origin is (0,0). The default value is undefined.
DataGrid.getColumnIndex() Availability Flash Player 6 (6.0 79.0). Edition Flash MX Professional 2004. Usage myDataGrid.getColumnIndex(columnName) Parameters columnName A string that is the name of a column. Returns A number that specifies the index of the column. Description Method; returns the index of the column specified by the columnName parameter. DataGrid.headerHeight Availability Flash Player 6 (6.0 79.0). Edition Flash MX Professional 2004. Usage myDataGrid.
Usage listenerObject = new Object(); listenerObject.headerRelease = function(eventObject){ // insert your code here } myDataGridInstance.addEventListener("headerRelease", listenerObject) Description Event; broadcast to all registered listeners when a column header has been released. You can use this event with the DataGridColumn.sortOnHeaderRelease property to prevent automatic sorting and to let you sort as you like. Version 2 components use a dispatcher/listener event model.
Description Property; specifies whether the data grid has a horizontal scroll bar. This property can have the value "on", "off", or "auto". The default value is "off". If hScrollPolicy is set to "off", columns scale proportionally to accommodate the finite width. Note: This differs from the List component, which cannot have hScrollPolicy set to "auto".
Usage myDataGrid.removeColumnAt(index) Parameters The index of the column to remove. index Returns A reference to the DataGridColumn object that was removed. Description Method; removes the DataGridColumn object at the specified index. Example The following example removes the DataGridColumn object at index 2 in myDataGrid: myDataGrid.removeColumnAt(2); DataGrid.replaceItemAt() Availability Flash Player 6 (6.0 79.0). Edition Flash MX Professional 2004. Usage myDataGrid.
DataGrid.resizableColumns Availability Flash Player 6 (6.0 79.0). Edition Flash MX Professional 2004. Usage myDataGrid.resizableColumns Description Property; a Boolean value that determines whether the columns of the grid can be stretched by the user (true) or not (false). This property must be true for individual columns to be resizable by the user. The default value is true. Example The following example prevents users from resizing columns: myDataGrid.resizableColumns = false; DataGrid.
Usage myDataGrid.showHeaders Description Property; a Boolean value that indicates whether the data grid displays the column headers (true) or not (false). Column headers are shaded to differentiate them from the other rows in a grid. Users can click column headers to sort the contents of the column if DataGrid.sortableColumns is set to true. The default value of showHeaders is true. Example The following example hides the column headers: myDataGrid.showHeaders = false; See also DataGrid.
DataGrid.spaceColumnsEqually() Availability Flash Player 6 (6.0 79.0). Edition Flash MX Professional 2004. Usage myDataGrid.spaceColumnsEqually() Parameters None. Returns Nothing. Description Method; respaces the columns equally. Example The following example respaces the columns of myGrid when any column header is pressed and released: myGrid.showHeaders = true myGrid.
• takes in the field names of the desired item fields and generates DataGridColumn objects, in order, for each field listed. This approach lets you select and order columns quickly with a minimal amount of configuration. This approach removes any previous column information. DataGrid.columnNames • The most flexible way to add columns is to prebuild them as DataGridColumn objects and add them to the data grid by using DataGrid.addColumn().
Parameters name A string that indicates the name of the DataGridColumn object. This parameter is the field of each item to display. Returns Nothing. Description Constructor; creates a DataGridColumn object. Use this constructor to create columns to add to a DataGrid component. After you create the DataGridColumn objects, you can add them to a data grid by calling DataGrid.addColumn(). Example The following example creates a DataGridColumn object called Location: import mx.controls.gridclasses.
Description Property (read-only); the name of the field associated with this column. The default value is the name called in the DataGridColumn constructor. Example The following example assigns the column name of the column at the third index position to the variable name: var name = myGrid.getColumnAt(3).columnName; See also Constructor for the DataGridColumn class DataGridColumn.editable Availability Flash Player 6 (6.0 79.0). Edition Flash MX Professional 2004. Usage myDataGrid.getColumnAt(index).
DataGridColumn.headerRenderer Availability Flash Player 6 (6.0 79.0). Edition Flash MX Professional 2004. Usage myDataGrid.getColumnAt(index).headerRenderer Description Property; a string that indicates a class name to be used to display the header of this column. Any class used for this property must implement the CellRenderer API (see “CellRenderer API” on page 145). The default value is undefined. Example The following example uses a linkage identifier to set a new header renderer: myGrid.
Usage myDataGrid.getColumnAt(index).labelFunction Description Property; specifies a function to determine which field (or field combination) of each item to display. This function receives one parameter, item, which is the item being rendered, and must return a string representing the text to display. This property can be used to create virtual columns that have no equivalent field in the item. Note: The specified function operates in a nondefined scope.
Description Property; a Boolean value that indicates whether a column can be sorted by a user (true) or not (false). The DataGrid.sortableColumns property must be set to true for this property to take effect. The default value is true. Caution: The DataGrid is not editable or sortable if it is bound directly to a WebServiceConnector component or an XMLConnector component.
DataGridColumn.width Availability Flash Player 6 (6.0 79.0). Edition Flash MX Professional 2004. Usage myDataGrid.getColumnAt(index).width Description Property; a number that indicates the width of the column, in pixels. The default value is 50. Example The following example makes a column half the default width: myGrid.getColumnAt(4).
CHAPTER 6 Components Dictionary DataHolder component (Flash Professional only) The DataHolder component is a repository for data and a means of generating events when that data has changed. Its main purpose is to hold data and act as a connector between other components that use data binding. Initially, the DataHolder component has a single bindable property named data. You can add more properties by using the Schema tab in the Component inspector.
Note: The DataHolder component is not meant to implement the same control over your data as the DataSet component. It does not manage or track data, nor does it have the ability to update data. It is a repository for holding data and generating events when that data has changed. Creating an application with the DataHolder component (Flash Professional only) In this example, you add an array property to a DataHolder component’s schema (an array) whose value is determined by ActionScript code that you write.
DataHolder class Inheritance MovieClip > DataHolder ActionScript class name mx.data.components.DataHolder The DataHolder component is a repository for data and a means of generating events when that data has changed. Its main purpose is to hold data and act as a connector between other components that use data binding. Initially, the DataHolder component has a single bindable property named data. You can add more properties by using the Schema tab in the Component inspector.
// Drag two Button components onto the Stage (addDate_btn and dumpDataHolder_btn), a TextInput (myDate_txt) and a DataHolder (myDataHolder). Add the following ActionScript to Frame 1: var dhListener:Object = {}; dhListener.click = function() { trace("dumping DataHolder"); trace(" "+myDataHolder.myDate); trace(""); }; var dateListener:Object = {}; dateListener.click = function() { myDataHolder.myDate = myDate_txt.text; trace("added value"); }; this.dumpDataHolder_btn.
CHAPTER 6 Components Dictionary DataProvider API ActionScript Class Name mx.controls.listclasses.DataProvider The DataProvider API is a set of methods and properties that a data source needs so that a listbased class can communicate with it. Arrays, recordsets, and data sets implement this API. You can create a DataProvider-compliant class by implementing all the methods and properties described in this section. A list-based component could then use that class as a data provider.
Method Description DataProvider.sortItems() Sorts the items in the data provider according to a compare function or sort options. DataProvider.sortItemsBy() Sorts the items in the data provider alphabetically or numerically, in the specified order, using the specified field name. Property summary for the DataProvider API The following table lists the properties of the DataProvider API. Property Description DataProvider.length The number of items in a data provider.
DataProvider.addItemAt() Availability Flash Player 6 (6.0 79.0). Edition Flash MX Professional 2004. Usage myDP.addItemAt(index, item) Parameters A number greater than or equal to 0. This number indicates the position at which to insert the item; it is the index of the new item. index item An object containing the data for the item. Returns Nothing. Description Method; adds a new item to the data provider at the specified index. Indices greater than the data provider’s length are ignored.
Returns Nothing. Description Method; changes one field of the data provider. This method triggers the modelChanged event with the event name updateField. Example The following code modifies the label field of the third item: myDP.editField(2, "label", "mynewData"); DataProvider.getEditingData() Availability Flash Player 6 (6.0 79.0). Edition Flash MX Professional 2004. Usage myDP.getEditingData(index, fieldName) Parameters A number greater than or equal to 0 and less than DataProvider.length.
Usage myDP.getItemAt(index) Parameters index A number greater than or equal to 0 and less than DataProvider.length. This number is the index of the item to retrieve. Returns A reference to the retrieved item; undefined if the index is out of range. Description Method; retrieves a reference to the item at a specified position. Example The following code displays the label of the fifth item: trace(myDP.getItemAt(4).label); DataProvider.getItemID() Availability Flash Player 6 (6.0 79.0).
DataProvider.length Availability Flash Player 6 (6.0 79.0). Edition Flash MX Professional 2004. Usage myDP.length Description Property (read-only); the number of items in the data provider. Example This example sends the number of items in the myArray data provider to the Output panel: trace(myArray.length); DataProvider.modelChanged Availability Flash Player 6 (6.0 79.0). Edition Flash MX Professional 2004. Usage listenerObject = new Object(); listenerObject.
■ removeItems A series of items has been deleted. ■ updateItems A series of items needs refreshing. ■ sort ■ updateField ■ updateColumn ■ The data has been sorted. filterModel A field in an item must be changed and needs refreshing. An entire field’s definition in the data provider needs refreshing. The model has been filtered, and the view needs refreshing (reset the scroll position). ■ • • schemaLoaded lastItem The field’s definition of the data provider has been declared.
Description Method; removes all items in the data provider. This method triggers the modelChanged event with the event name removeItems. Example This example removes all the items in the data provider: myDP.removeAll(); DataProvider.removeItemAt() Availability Flash Player 6 (6.0 79.0). Edition Flash MX Professional 2004. Usage myDP.removeItemAt(index) Parameters index A number greater than or equal to 0. This number is the index of the item to remove. Returns Nothing.
Parameters A number greater than or equal to 0. This number is the index of the item to change. index item An object that is the new item. Returns Nothing. Description Method; replaces the content of the item at the specified index. This method triggers the modelChanged event with the event name removeItems. Example This example replaces the item at index 3 with the item labeled “new label”: myDP.replaceItemAt(3, {label : "new label"}); DataProvider.sortItems() Availability Flash Player 7.
• Array.RETURNINDEXEDARRAY, which returns an integer index array that is the result of the sort. For example, the following array would return the second line of code and the array would remain unchanged: ["a", "d", "c", "b"] [0, 3, 2, 1] You can combine these options into one value. For example, the following code combines options 3 and 1: array.sort (Array.NUMERIC | Array.DESCENDING) Returns Nothing.
The following are possible values for optionsFlag: • • • Array.DESCENDING—sorts • Array.UNIQUESORT—if two objects in the array are identical or have identical sort fields, this method returns an error code (0) instead of a sorted array. • Array.RETURNINDEXEDARRAY—returns an integer highest to lowest. Array.CASEINSENSITIVE—sorts case-insensitively. Array.NUMERIC—sorts numerically if the two elements being compared are numbers.
CHAPTER 6 Components Dictionary DataSet component (Flash Professional only) The DataSet component lets you work with data as collections of objects that can be indexed, sorted, searched, filtered, and modified. The DataSet component functionality includes DataSetIterator, a set of methods for traversing and manipulating a data collection, and DeltaPacket, a set of interfaces and classes for working with updates to a data collection.
logChanges is a Boolean value that defaults to true. If this parameter is set to true, the data set logs all changes made to its data and any method calls made on the associated transfer objects. readOnly is a Boolean value that defaults to false. If this parameter is set to true, the data set cannot be modified. You can write ActionScript to control these and additional options for the DataSet component using its properties, methods, and events.
To create an application using the DataSet component: 1. In Flash MX Professional 2004, select File > New. In the Type column, select Flash Document and click OK. 2. Open the Components panel if it’s not already open. 3. Drag a DataSet component from the Components panel to the Stage. In the Property inspector, give it the instance name userData. 4. Drag a DataGrid component to the Stage and give it the instance name userGrid. 5.
17. Double-click the Bound To field in the Component inspector to open the Bound To dialog box. 18. In the Component Path field, select “DataSet ” from the Component Path column, and then select “selectedIndex : Number” from the Schema Location column. 19. Enter the following code in the Actions panel: nextBtn.addEventListener("click", nextBtnClick); function nextBtnClick(eventObj:Object):Void { userData.next(); } This code uses the DataSet.
Method Description DataSet.disableEvents() Stops sending DataSet events to listeners. DataSet.enableEvents() Resumes sending DataSet events to listeners. DataSet.find() Locates an item in the current view of the collection. DataSet.findFirst() Locates the first occurrence of an item in the current view of the collection. DataSet.findLast() Locates the last occurrence of an item in the current view of the collection. DataSet.first() Moves to the first item in the current view of the collection.
Property summary for the DataSet class The following table lists the properties of the DataSet class. Property Description DataSet.currentItem Returns the current item in the collection. DataSet.dataProvider Returns the data provider. DataSet.deltaPacket Returns changes made to the collection, or assigns changes to be made to the collection. DataSet.filtered Indicates whether items are filtered. DataSet.filterFunc User-defined function for filtering items in the collection. DataSet.
DataSet.addItem Availability Flash Player 7. Edition Flash MX Professional 2004. Usage on(addItem) { // insert your code here } listenerObject = new Object(); listenerObject.addItem = function (eventObj) { // insert your code here } dataSet.addEventListener("addItem", listenerObject) Description Event; generated just before a new record (transfer object) is inserted into this collection.
DataSet.addItem() Availability Flash Player 7. Edition Flash MX Professional 2004. Usage dataSet.addItem([obj]) Parameters obj An object to add to this collection. This parameter is optional. Returns A Boolean value: true if the item was added to the collection, false if it was not. Description Method; adds the specified record (transfer object) to the collection for management. The newly added item becomes the current item of the data set.
Parameters index A number greater than or equal to 0. This number indicates the position at which to insert the item; it is the index of the new item. item An object containing the data for the item. Returns A Boolean value indicating whether the item was added: true indicates that the item was added, and false indicates that the item already exists in the data set. Description Method; adds a new item to the data set at the specified index. Indices greater than the data provider’s length are ignored.
A DataSetError exception is thrown when DataSetIterator.Unique is specified as a sort option and the data being sorted is not unique, when the specified sort name has already been added, or when a property specified in the fieldList array does not exist in this data set. Returns Nothing. Description Method; creates a new ascending or descending sort for the current iterator based on the properties specified by the fieldList parameter.
Example In this example, a form named contactForm (not shown) is made visible once the items in the data set contact_ds have been assigned. contact_ds.addEventListener("afterLoaded", loadListener); loadListener = new Object(); loadListener.afterLoaded = function (eventObj) { if(eventObj.target == "contact_ds") { contactForm.visible = true; } } DataSet.applyUpdates() Availability Flash Player 7. Edition Flash MX Professional 2004. Usage dataSet.applyUpdates() Parameters None. Returns Nothing.
DataSet.calcFields Availability Flash Player 7. Edition Flash MX Professional 2004. Usage on(calcFields) { // insert your code here } listenerObject = new Object(); listenerObject.calcFields = function (eventObj) { // insert your code here } dataSet.addEventListener("calcFields", listenerObject) Description Event; generated when values of calculated fields for the current item in the collection need to be determined.
Description Method; returns true if the collection, or any item in the collection, has changes pending that have not yet been sent in a delta packet; otherwise, returns false. Example The following code enables a Save Changes button (not shown) if the DataSet collection, or any items with that collection, have had modifications made to them that haven’t been committed to a delta packet. if(data_ds.changesPending()) { saveChanges_btn.enabled = true; } DataSet.clear() Availability Flash Player 7.
DataSet.createItem() Availability Flash Player 7. Edition Flash MX Professional 2004. Usage dataSet.createItem([itemData]) Parameters itemData Data associated with the item. This parameter is optional. Returns The newly constructed item. Description Method; creates an item that isn’t associated with the collection. You can specify the class of object created by using the DataSet.itemClassName property. If no DataSet.
Usage dataSet.currentItem Description Property (read-only); returns the current item in the DataSet collection, or null if the collection is empty or if the current iterator’s view of the collection is empty. This property provides direct access to the item in the collection. Changes made by directly accessing this object are not tracked (in the DataSet.deltaPacket property), nor are any of the schema settings applied to any properties of this object.
Description Property; returns a delta packet that contains all of the change operations made to the dataSet collection and its items. This property is null until DataSet.applyUpdates() is called on dataSet. When DataSet.applyUpdates() is called, a transaction ID is assigned to the delta packet. This transaction ID is used to identify the delta packet on an update round trip from the server and back to the client.
DataSet.disableEvents() Availability Flash Player 7. Edition Flash MX Professional 2004. Usage dataSet.disableEvents() Returns Nothing. Description Method; disables events for the DataSet object. While events are disabled, no user interface controls (such as a DataGrid component) are updated when changes are made to items in the collection, or when the DataSet object is scrolled to another item in the collection. To reenable events, you must call DataSet.enableEvents().
Usage dataSet.enableEvents() Returns Nothing. Description Method; reenables events for the DataSet objects after events have been disabled by a call to DataSet.disableEvents(). To reenable events for the DataSet object, the enableEvents() method must be called an equal or greater number of times than disableEvents() was called. Example In this example, events are disabled before changes are made to items in the collection, so the DataSet object won’t try to refresh controls and impact performance.
Example In the following example, filtering is enabled on the DataSet object named employee_ds. Suppose that each record in the DataSet collection contains a field named empType. The following filter function returns true if the empType field in the current item is set to "management"; otherwise, it returns false. employee_ds.filtered = true; employee_ds.filterFunc = function(item:Object) { // filter out employees who are managers... return(item.empType != "management"); } See also DataSet.
return(item.empType != "management"); } See also DataSet.filtered DataSet.find() Availability Flash Player 7. Edition Flash MX Professional 2004. Usage dataSet.find(searchValues) Parameters searchValues An array that contains one or more field values to be found within the current sort. Returns Returns true if the values are found; otherwise, returns false. Description Method; searches the current view of the collection for an item with the field values specified by searchValues.
// Note that the order of the search fields matches those // specified in addSort(). if(studentData.find(["Bobby", 105])) { studentID = studentData.getItemId(); } // Now use locateByID() to position the current iterator // on the item in the collection whose ID matches studentID. if(studentID != null) { studentData.locateById(studentID); } See also DataSet.applyUpdates(), DataSet.getItemId(), DataSet.locateById() DataSet.findFirst() Availability Flash Player 7. Edition Flash MX Professional 2004.
Example This example searches for the first item in the current collection whose name and age fields contain "Bobby" and "13". If found, DataSet.getItemId() is used to get the unique identifier for the item in the collection, and DataSet.locateById() is used to position the current iterator on that item. var studentID:String = null; studentData.addSort("nameAndAge", ["name", "age"]); // Locate the first transfer object with the specified values.
Conversion of the data specified is based on the underlying field’s type. For example, if the search value specified is ["05-02-02"], the underlying date field is used to convert the value with the date’s setAsString() method. If the value specified is [new Date().getTime()], the date’s setAsNumber() method is used. Example This example searches for the last item in the current collection whose name and age fields contain "Bobby" and "13". If found, DataSet.
Example The following code positions the data set inventoryData at the first item in its collection, and then displays the value of the price property contained by that item using the DataSet.currentItem property. inventoryData.first(); trace("The price of the first item is:" + inventoryData.currentItem.price); See also DataSet.last() DataSet.getItemId() Availability Flash Player 7. Edition Flash MX Professional 2004. Usage dataSet.
Edition Flash MX Professional 2004. Usage dataSet.getIterator() Returns A ValueListIterator object. Description Method; returns a new iterator for this collection; this iterator is a clone of the current iterator in use, including its current position in the collection. This method is mainly for advanced users who want access to multiple, simultaneous views of the same collection. Example myIterator:ValueListIterator = myDataSet.getIterator(); myIterator.sortOn(["name"]); myIterator.
Edition Flash MX Professional 2004. Usage dataSet.hasNext() Returns A Boolean value. Description Method; returns false if the current iterator is at the end of its view of the collection; otherwise, returns true. Example This example iterates over all of the items in the current view of the collection (starting at its beginning) and performs a calculation on the price property of each item. myDataSet.first(); while(myDataSet.hasNext()) { var price = myDataSet.currentItem.price; price = price * 0.
myDataSet.last(); while(myDataSet.hasPrevious()) { var price = myDataSet.currentItem.price; price = price * 0.5; // Everything's 50% off! myDataSet.currentItem.price = price; myDataSet.previous(); } See also DataSet.currentItem, DataSet.skip(), DataSet.previous() DataSet.hasSort() Availability Flash Player 7. Edition Flash MX Professional 2004. Usage dataSet.hasSort(sortName) Parameters sortName A string that contains the name of a sort created with DataSet.addSort(). Returns A Boolean value.
DataSet.isEmpty() Availability Flash Player 7. Edition Flash MX Professional 2004. Usage dataSet.isEmpty() Returns A Boolean value. Description Method; returns true if the specified DataSet object doesn’t contain any items (that is, if dataSet.length == 0). Example The following code disables a Delete Record button (not shown) if the DataSet object it applies to is empty. if(userData.isEmpty()){ delete_btn.enabled = false; } See also DataSet.length DataSet.items Availability Flash Player 7.
DataSet.itemClassName Availability Flash Player 7. Edition Flash MX Professional 2004. Usage dataSet.itemClassName Description Property; a string indicating the name of the class that should be created when items are added to the collection. The class you specify must implement the TransferObject interface, shown below. interface mx.data.to.
Description Event; generated immediately after the current iterator has scrolled to a new item in the collection. The event object (eventObj) contains the following properties: The DataSet object that generated the event. target type The string "iteratorScrolled". scrolled A number that specifies how many items the iterator scrolled; positive values indicate that the iterator moved forward in the collection; negative values indicate that it moved backward in the collection.
See also DataSet.first() DataSet.length Availability Flash Player 7. Edition Flash MX Professional 2004. Usage dataSet.length Description Property (read-only); specifies the number of items in the current view of the collection. The viewable number of items is based on the current filter and range settings. Example The following example alerts users if they haven’t made enough entries in the data set, perhaps using an editable DataGrid component. if(myDataSet.
Returns Nothing. Description Method; loads all of the relevant data needed to restore this DataSet collection from a shared object. To save a DataSet collection to a shared object, use DataSet.saveToSharedObj(). The DataSet.loadFromSharedObject() method overwrites any data or pending changes that might exist in this DataSet collection. Note that the instance name of the DataSet collection is used to identify the data in the specified shared object.
Example This example uses DataSet.find() to search for an item in the current collection whose name and id fields contain the values "Bobby" and 105, respectively. If found, DataSet.getItemId() is used to get the unique identifier for that item, and DataSet.locateById() is used to position the current iterator at that item. var studentID:String = null; studentData.addSort("id", ["name","id"]); if(studentData.find(["Bobby", 105])) { studentID = studentData.getItemId(); studentData.
DataSet.modelChanged Availability Flash Player 7. Edition Flash MX Professional 2004. Description on(modelChanged) { // insert your code here } listenerObject = new Object(); listenerObject.modelChanged = function (eventObj) { // insert your code here } dataSet.
String value Description "updateField" A field in an item has been changed and needs refreshing. "updateItems" A series of items needs refreshing. Example In this example, a Delete Item button is disabled if the items have been removed from the collection and the target DataSet object has no more items. on(modelChanged) { delete_btn.enabled = ((eventObj.eventName == "removeItems") && (eventObj.target.isEmpty())); } See also DataSet.isEmpty() DataSet.newItem Availability Flash Player 7.
employee.name = "newGuy"; // property data happens to be XML employee.zip = employee.getPropertyData().firstChild.childNodes[1].attributes.zip; } employees_ds.addEventListener("newItem", newItemEvent); DataSet.next() Availability Flash Player 7. Edition Flash MX Professional 2004. Usage dataSet.next() Returns Nothing. Description Method; makes the next item in the current view of the collection the current item. Which items are in the current view depends on any current filter and range settings.
Returns Nothing. Description Method; makes the previous item in the current view of the collection the current item. Which items are in the current view depends on any current filter and range settings. This example loops over all the items in the current view of the collection, starting from the last item, and performs a calculation on a field in each item. myDataSet.last(); while(myDataSet.hasPrevious()) { var price = myDataSet.price; price = price * 0.5; // Everything's 50% off! myDataSet.
Usage dataSet.readOnly Description Property; a Boolean value that specifies whether this collection can be modified (false) or is read-only (true). Setting this property to true prevents updates to the collection. The default value is false. You can also set this property in the Property inspector. Example The following example makes the DataSet object named myDataSet read-only, and then attempts to change the value of a property that belongs to the current item in the collection.
DataSet.removeItem Availability Flash Player 7. Edition Flash MX Professional 2004. Usage on(removeItem) { // insert your code here } listenerObject = new Object(); listenerObject.removeItem = function (eventObj) { // insert your code here } dataSet.addEventListener("removeItem", listenerObject) Description Event; generated just before a new item is deleted from this collection.
DataSet.removeItem() Availability Flash Player 7. Edition Flash MX Professional 2004. Usage dataSet.removeItem([item]) Parameters item The item to be removed. This parameter is optional. Returns A Boolean value. Returns true if the item was successfully removed; otherwise, returns false. Description Method; removes the specified item from the collection, or removes the current item if the item parameter is omitted. This operation is logged to DataSet.deltaPacket if DataSet.logChanges is true.
Returns A Boolean value indicating whether the item was removed. Description Method; removes the item at the specified index. The indices after the removed index collapse by one. This method triggers the modelChanged event with the event name removeItems. In addition, it triggers the DataSet.removeItem event, which contains the result and item properties. The result property is used to determine if the item (referenced by the item property of the event) can be removed.
} myDataSet.removeRange(); myDataSet.removeSort("name_id"); See also DataSet.applyUpdates(), DataSet.hasNext(), DataSet.next(), DataSet.removeSort(), DataSet.setRange() DataSet.removeSort() Availability Flash Player 7. Edition Flash MX Professional 2004. Usage dataSet.removeSort(sortName) Parameters sortName A string that specifies the name of the sort to remove. Returns Nothing. Description Method; removes the specified sort from this DataSet object if the sort exists.
DataSet.resolveDelta Availability Flash Player 7. Edition Flash MX Professional 2004. Usage on(resolveDelta) { // insert your code here } listenerObject = new Object(); listenerObject.resolveDelta = function (eventObj) { // insert your code here } dataSet.addEventListener("resolveDelta", listenerObject) Description Event; broadcast when DataSet.
for (var i = 0; i0) { trace("The following problem occurred '"+msg+"' while performing a '"+ops[di.kind]+"' modification on/with '"+di.name+"' current server value ["+di.curValue+"], value sent ["+di.newValue+"] Please fix!"); } } } } DataSet.saveToSharedObj() Availability Flash Player 7. Edition Flash MX Professional 2004. Usage dataSet.
Example This example calls saveToSharedObj() in a try..catch block and displays an error if there is a problem saving the data to the shared object. try { myDataSet.saveToSharedObj("webapp/customerInfo"); } catch(e:DataSetError) { trace("Unable to create shared object”); } See also DataSet.loadFromSharedObj() DataSet.schema Availability Flash Player 7. Edition Flash MX Professional 2004. Usage dataSet.schema Description Property; provides the XML representation of the schema for this DataSet object.
Example The following example sets the schema of the data set myDataSet to a new XML object containing appropriately formatted XML: myDataSet.schema = new XML(" ..etc.. "); DataSet.selectedIndex Availability Flash Player 7. Edition Flash MX Professional 2004. Usage dataSet.selectedIndex Description Property; specifies the selected index in the collection. You can bind this property to the selected item in a DataGrid or List component, and vice versa.
Description Method; assigns the specified iterator to this DataSet object and makes it the current iterator. The specified iterator must come from a previous call to DataSet.getIterator() on the DataSet object to which it is being assigned; otherwise; a DataSetError exception is thrown. Example myIterator:ValueListIterator = myDataSet.getIterator(); myIterator.sortOn(["name"]); myDataSet.setIterator(myIterator); See also DataSet.getIterator() DataSet.setRange() Availability Flash Player 7.
See also DataSet.applyUpdates(), DataSet.hasNext(), DataSet.next(), DataSet.removeRange(), DataSet.removeSort() DataSet.skip() Availability Flash Player 7. Edition Flash MX Professional 2004. Usage dataSet.skip(offSet) Parameters offSet An integer specifying the number of records by which to move the iterator position. Returns Nothing. Description Method; moves the current iterator’s position forward or backward in the collection by the amount specified by offSet.
Parameters sortName order A string that contains the name of the sort to use. An integer value that indicates the sort order for the sort; the value must be or DataSetIterator.Descending. DataSetIterator.Ascending Returns Nothing. Description Method; switches the sort for the current iterator to the one specified by sortName, if it exists. If the specified sort does not exist, a DataSetError exception is thrown. To create a sort, use DataSet.applyUpdates(). Example This code uses DataSet.
CHAPTER 6 Components Dictionary DateChooser component (Flash Professional only) The DateChooser component is a calendar that allows users to select a date. It has buttons that allow users to scroll through months and click a date to select it. You can set parameters that indicate the month and day names, the first day of the week, and disabled dates, as well as highlighting the current date.
To create an application with the DateChooser component: 1. Double-click the DateChooser component in the Components panel to add it to the Stage. 2. In the Property inspector, enter the instance name flightCalendar. 3. In the Actions panel, enter the following code on Frame 1 of the Timeline to set the range of selectable dates: flightCalendar.
Style Theme Description headerColor Both The background color for the component heading. The default color is white. rollOverColor Both The background color of a rolled-over date. The default value is 0xE3FFD6 (bright green) with the Halo theme and 0xAAAAAA (light gray) with the Sample theme. selectionColor Both The background color of the selected date. The default value is 0xCDFFC1 (light green) with the Halo theme and 0xEEEEEE (very light gray) with the Sample theme.
The following example demonstrates how to set the month name and days of the week to a deep red color. _global.styles.HeaderDateText.setStyle("color", 0x660000); _global.styles.WeekDayStyle.setStyle("color", 0x660000); Using skins with the DateChooser component The DateChooser component uses skins to represent the forward and back month buttons and the today indicator.
6. Customize the symbol as desired. For example, change the tint of the arrow to red. 7. Repeat steps 5-6 for all symbols you want to customize. For example, change the tint of the forward arrow down symbol to match the back arrow. 8. Click the Back button to return to the main Timeline. 9. Drag a DateChooser component to the Stage. 10. Select Control > Test Movie. Note: The DateChooser Assets/States folder also has a Day Skins folder with a single skin element, cal_todayIndicator.
Methods inherited from the UIObject class The following table lists the methods the DateChooser class inherits from the UIObject class. When calling these methods from the DateChooser object, use the form dateChooserInstance.methodName. Method Description UIObject.createClassObject() Creates an object on the specified class. UIObject.createObject() Creates a subobject on an object. UIObject.destroyObject() Destroys a component instance. UIObject.
Property Description DateChooser.firstDayOfWeek A number indicating an element in the dayNames array to display in the first column of the date chooser. DateChooser.monthNames An array of strings indicating the month names. DateChooser.selectableRange A single selectable date or a range of selectable dates. DateChooser.selectedDate A Date object indicating the selected date. DateChooser.showToday A Boolean value indicating whether the current date is highlighted.
Event summary for the DateChooser class The following table lists the events that are exclusive to the DateChooser class. Event Description DateChooser.change Broadcast when a date is selected. DateChooser.scroll Broadcast when the month buttons are clicked. Events inherited from the UIObject class The following table lists the events the DateChooser class inherits from the UIObject class. Event Description UIObject.draw Broadcast when an object is about to draw its graphics. UIObject.
Usage 2: listenerObject = new Object(); listenerObject.change = function(eventObject){ ... } chooserInstance.addEventListener("change", listenerObject) Description Event; broadcast to all registered listeners when a date is selected. The first usage example uses an on() handler and must be attached directly to a DateChooser instance. The keyword this, used inside an on() handler attached to a component, refers to the component instance.
DateChooser.dayNames Availability Flash Player 6 (6.0 79.0). Edition Flash MX Professional 2004. Usage myDC.dayNames Description Property; an array containing the names of the days of the week. Sunday is the first day (at index position 0) and the rest of the day names follow in order. The default value is ["S", "M", "T", "W", "T", "F", "S"]. Example The following example changes the value of the fifth day of the week (Thursday) from “T” to “R”: myDC.dayNames[4] = "R"; DateChooser.
DateChooser.disabledRanges Availability Flash Player 6 (6.0 79.0). Edition Flash MX Professional 2004. Usage myDC.disabledRanges Description Property; disables a single day or a range of days. This property is an array of objects. Each object in the array must be either a Date object that specifies a single day to disable, or an object that contains either or both of the properties rangeStart and rangeEnd, each of whose value must be a Date object.
Description Property; a number indicating which month is displayed. The number indicates an element in the monthNames array, with 0 being the first month. The default value is the month of the current date. Example The following example sets the displayed month to December: myDC.displayedMonth = 11; See also DateChooser.displayedYear DateChooser.displayedYear Availability Flash Player 6 (6.0 79.0). Edition Flash MX Professional 2004. Usage myDC.
Description Property; a number indicating which day of the week (0-6, 0 being the first element of the dayNames array) is displayed in the first column of the DateChooser component. Changing this property changes the order of the day columns but has no effect on the order of the dayNames property. The default value is 0 (Sunday). Example The following example sets the first day of the week to Monday: myDC.firstDayOfWeek = 1; See also DateChooser.dayNames DateChooser.
... } Usage 2: listenerObject = new Object(); listenerObject.scroll = function(eventObject){ ... } myDC.addEventListener("scroll", listenerObject) Description Event; broadcast to all registered listeners when a month button is clicked. The first usage example uses an on() handler and must be attached directly to a DateChooser instance. The keyword this, used inside an on() handler attached to a component, refers to the component instance.
} myDC.addEventListener("scroll", form); DateChooser.selectableRange Availability Flash Player 6 (6.0 79.0). Edition Flash MX Professional 2004. Usage myDC.selectableRange Description Property; sets a single selectable date or a range of selectable dates. The user cannot scroll beyond the selectable range. The value of this property is an object that consists of two Date objects named rangeStart and rangeEnd. The rangeStart and rangeEnd properties designate the boundaries of the selectable date range.
DateChooser.selectedDate Availability Flash Player 6 (6.0 79.0). Edition Flash MX Professional 2004. Usage myDC.selectedDate Description Property; a Date object that indicates the selected date if that value falls within the value of the selectableRange property. The default value is undefined. You cannot set the selectedDate property within a disabled range, outside a selectable range, or on a day that has been disabled. If this property is set to one of these dates, the value is undefined.
CHAPTER 6 Components Dictionary DateField component (Flash Professional only) The DateField component is a nonselectable text field that displays the date with a calendar icon on its right side. If no date has been selected, the text field is blank and the month of today’s date is displayed in the date chooser. When a user clicks anywhere inside the bounding box of the date field, a date chooser pops up and displays the dates in the month of the selected date.
Creating an application with the DateField component The following procedure explains how to add a DateField component to an application while authoring. In this example, the DateField component allows a user to pick a date for an airline reservation system. All dates before today’s date must be disabled. Also, a 15-day range in December must be disabled to create a holiday black-out period. Also, some flights are not available on Mondays, so all Mondays must be disabled for those flights.
The DateField component supports the following styles: Style Theme Description themeColor Halo The glow color for the rollover and selected dates. Possible values are "haloGreen", "haloBlue", and "haloOrange". The default value is "haloGreen" backgroundColor Both The background color. The default value is 0xEFEBEF (light gray). borderColor Both The border color. The default value is 0x919999. The DateField component’s drop-down list uses a solid single-pixel line as its border.
The DateField component uses four categories of text to display the month name, the days of the week, today’s date, and regular dates. The text style properties set on the DateField component itself control the regular date text and the text displayed in the collapsed state, and provide defaults for the other text. To set text styles for specific categories of text, use the following classlevel style declarations. Declaration name Description HeaderDateText The month name.
5. Ensure that the DateFieldAssets symbol is selected for Export in First Frame. 6. Expand the DateField Assets/States folder in the library of your document. 7. Open the symbols you want to customize for editing. For example, open the openIconUp symbol. 8. Customize the symbol as desired. For example, draw a down arrow over the calendar image. 9. Repeat steps 7-8 for all symbols you want to customize. For example, draw a down arrow over all of the symbols. 10.
Methods inherited from the UIObject class The following table lists the methods the DateField class inherits from the UIObject class. When calling these methods from the DateField object, use the form dateFieldInstance.methodName. Method Description UIObject.createClassObject() Creates an object on the specified class. UIObject.createObject() Creates a subobject on an object. UIObject.destroyObject() Destroys a component instance. UIObject.
Property Description DateField.firstDayOfWeek A number indicating an element in the dayNames array to display in the first column of the DateField component. DateField.monthNames An array of strings indicating the month names. DateField.pullDown A reference to the DateChooser subcomponent. This property is read-only. DateField.selectableRange A single selectable date or a range of selectable dates. DateField.selectedDate A Date object indicating the selected date. DateField.
Properties inherited from the UIComponent class The following table lists the properties the DateField class inherits from the UIComponent class. When accessing these properties from the DateField object, use the form dateFieldInstance.propertyName. Property Description UIComponent.enabled Indicates whether the component can receive focus and input. UIComponent.tabIndex A number indicating the tab order for a component in a document.
DateField.change Availability Flash Player 6 (6.0 79.0). Edition Flash MX Professional 2004. Usage Usage 1: on(change){ ... } Usage 2: listenerObject = new Object(); listenerObject.change = function(eventObject){ ... } myDF.addEventListener("change", listenerObject) Description Event; broadcast to all registered listeners when a date is selected. The first usage example uses an on() handler and must be attached directly to a DateField instance.
Example This example, written on a frame of the Timeline, sends a message to the Output panel when a date field called myDF is changed. The first line of code creates a listener object called form. The second line defines a function for the change event on the listener object. Inside the function is a trace() statement that uses the event object that is automatically passed to the function, in this example eventObj, to generate a message.
Usage Usage 1: on(close){ ... } Usage 2: listenerObject = new Object(); listenerObject.close = function(eventObject){ ... } myDF.addEventListener("close", listenerObject) Description Event; broadcast to all registered listeners when the DateChooser subcomponent closes after a user clicks outside the icon or selects a date. The first usage example uses an on() handler and must be attached directly to a DateField instance.
form.close = function(eventObj){ trace("PullDown Closed" + eventObj.target.selectedDate); } myDF.addEventListener("close", form); DateField.dateFormatter Availability Flash Player 6 (6.0 79.0). Edition Flash MX Professional 2004. Usage myDF.dateFormatter Description Property; a function that formats the date to be displayed in the text field. The function must receive a Date object as parameter, and return a string in the format to be displayed.
DateField.disabledDays Availability Flash Player 6 (6.0 79.0). Edition Flash MX Professional 2004. Usage myDF.disabledDays Description Property; an array indicating the disabled days of the week. All the dates in a month that fall on the specified day are disabled. The elements of this array can have values between 0 (Sunday) and 6 (Saturday). The default value is [] (an empty array). Example The following example disables Sundays and Saturdays so that users can select only weekdays: myDF.
Example The following example defines an array with rangeStart and rangeEnd Date objects that disable the dates between May 7 and June 7: myDF.disabledRanges = [ {rangeStart: new Date(2003, 4, 7), rangeEnd: new Date(2003, 5, 7)}]; The following example disables all dates after November 7: myDF.disabledRanges = [ {rangeStart: new Date(2003, 10, 7)} ]; The following example disables all dates before October 7: myDF.
Usage myDF.displayedYear Description Property; a number indicating which year is displayed. The default value is the current year. Example The following example sets the displayed year to 2010: myDF.displayedYear = 2010; See also DateField.displayedMonth DateField.firstDayOfWeek Availability Flash Player 6 (6.0 79.0). Edition Flash MX Professional 2004. Usage myDF.
Description Property; an array of strings indicating the month names at the top of the DateField component. The default value is ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]. Example The following example sets the month names for the instance myDF: myDF.monthNames = ["Jan", "Feb","Mar","Apr", "May", "June","July", "Aug", "Sept","Oct", "Nov", "Dec"]; DateField.open() Availability Flash Player 6 (6.0 79.0).
... } Usage 2: listenerObject = new Object(); listenerObject.open = function(eventObject){ ... } myDF.addEventListener("open", listenerObject) Description Event; broadcast to all registered listeners when a DateChooser subcomponent opens after a user clicks on the icon. The first usage example uses an on() handler and must be attached directly to a DateField instance. The keyword this, used inside an on() handler attached to a component, refers to the component instance.
} myDF.addEventListener("open", form); DateField.pullDown Availability Flash Player 6 (6.0 79.0). Edition Flash MX Professional 2004. Usage myDF.pullDown Description Property (read-only); a reference to the DateChooser component contained by the DateField component. The DateChooser subcomponent is instantiated when a user clicks on the DateField component. However, if the pullDown property is referenced before the user clicks on the component, the DateChooser is instantiated and then hidden.
Description Event; broadcast to all registered listeners when a month button is clicked. The first usage example uses an on() handler and must be attached directly to a DateField instance. The keyword this, used inside an on() handler attached to a component, refers to the component instance. For example, the following code, attached to the date field myDF, sends “_level0.myDF” to the Output panel: on(scroll){ trace(this); } The second usage example uses a dispatcher/listener event model.
DateField.selectableRange Availability Flash Player 6 (6.0 79.0). Edition Flash MX Professional 2004. Usage myDF.selectableRange Description Property; sets a single selectable date or a range of selectable dates. The value of this property is an object that consists of two Date objects named rangeStart and rangeEnd. The rangeStart and rangeEnd properties designate the boundaries of the selectable date range. If only rangeStart is defined, all the dates after rangeStart are enabled.
DateField.selectedDate Availability Flash Player 6 (6.0 79.0). Edition Flash MX Professional 2004. Usage myDF.selectedDate Description Property; a Date object that indicates the selected date if that value falls within the value of the selectableRange property. The default value is undefined. Example The following example sets the selected date to June 7: myDF.selectedDate = new Date(2003, 5, 7); DateField.showToday Availability Flash Player 6 (6.0 79.0). Edition Flash MX Professional 2004.
CHAPTER 6 Components Dictionary Delegate class Inheritance Object > Delegate ActionScript Class Name mx.utils.Delegate The Delegate class lets you run a function in a specific scope. This class is provided so that you can dispatch the same event to two different functions (see “Delegating events to functions” on page 63), and so that you can call functions within the scope of the containing class. When you pass a function as a parameter to EventDispatcher.
See also EventDispatcher.
Delta interface (Flash Professional only) ActionScript Interface Name CHAPTER 6 Components Dictionary mx.data.components.datasetclasses.Delta The Delta interface provides access to the transfer object, collection, and transfer object-level changes. With this interface you can access the new and previous values in a transfer object. For example, if the delta packet was obtained from a data set, each delta would represent an added, edited, or deleted row.
Returns Nothing. Description Method; adds the specified DeltaItem instance. If the specified DeltaItem instance already exists, this method replaces it. Example The following example calls the addDeltaItem() method: //... var d:Delta = new DeltaImpl("ID1345678", curItem, DeltaPacketConsts.Added, "", false); d.addDeltaItem(new DeltaItem(DeltaItem.Property, "ID", {oldValue:15, newValue:16})); //... Delta.getChangeList() Availability Flash Player 7. Edition Flash MX Professional 2004. Usage delta.
} //... Delta.getDeltaPacket() Availability Flash Player 7. Edition Flash MX Professional 2004. Usage delta.getDeltaPacket() Parameters None. Returns The delta packet that contains this delta. Description Method; returns the delta packet that contains this delta. This method lets you write code that can handle delta packets generically at the delta level. Example The following example uses the getDeltaPacket() method to access the delta packet’s data source: while(dpCursor.
Description Method; returns a unique identifier for this item within the DeltaPacket collection. Use this ID in the source component for the delta packet to receive updates and make changes to items that the delta packet was generated from.
if (deltaObj.getOperation() != DeltaPacketConsts.Added) { oldValue = (chgItem != null ? (chgItem.oldValue != null ? encodeFieldValue(field.name, chgItem.oldValue) : __nullValue) : encodeFieldValue(field.name, deltaObj.getSource()[field.name])); newValue = (chgItem.newValue != null ? encodeFieldValue(field.name, chgItem.newValue) : __nullValue); result+= " oldValue=\"" + oldValue + "\""; result+= chgItem != null ? " newValue=\"" + newValue + "\"" : ""; result+= " key=\"" + isKey.
Delta.getOperation() Availability Flash Player 7. Edition Flash MX Professional 2004. Usage delta.getOperation() Parameters None. Returns A number; returns the operation that was performed on the item within the original collection. Description Method; returns the operation that was performed on this item within the original collection. Valid values for this are DeltaPacketConsts.Added, DeltaPacketConsts.Removed, and DeltaPacketConsts.Modified. You must either import mx.data.components.datasetclasses.
Parameters None. Returns The transfer object on which the changes were performed. Description Method; returns the transfer object on which the changes were performed. Example The following example calls the getSource() method: while(dpCursor.hasNext()) { dpDelta = Delta(dpCursor.next()); op=dpDelta.getOperation(); switch(op) { case mx.data.components.datasetclasses.DeltaPacketConsts.Modified: { // the original values are trace("Unmodified source is: "); var src = dpDelta.getDeltaPacket().
DeltaItem class (Flash Professional only) ActionScript Class Name CHAPTER 6 Components Dictionary mx.data.components.datasetclasses.DeltaItem The DeltaItem class provides information about an individual operation performed on a transfer object. It indicates whether a change was made directly to a property of the transfer object or whether the change was made by a method call. It also provides the original state of properties on a transfer object.
Usage deltaitem.argList Description Property (read-only); an array of values passed to the change method. This property applies only if the change’s kind is DeltaItem.Method. DeltaItem.curValue Availability Flash Player 7. Edition Flash MX Professional 2004. Usage deltaitem.curValue Description Property (read-only); an object containing the current property value on the server’s copy of the transfer object. This property applies only if the change’s kind is DeltaItem.
Usage deltaitem.kind Description Property; a number that indicates the type of change. Use the following constants to evaluate this property: • • DeltaItem.Property DeltaItem.Method The change was made to a property on the transfer object. The change was made through a method call on the transfer object. DeltaItem.message Availability Flash Player 7. Edition Flash MX Professional 2004. Usage deltaitem.
DeltaItem.newValue Availability Flash Player 7. Edition Flash MX Professional 2004. Usage deltaitem.newValue Description Property (read-only); an object containing the new value of the property. This property applies only if the change’s kind is DeltaItem.Property. DeltaItem.oldValue Availability Flash Player 7. Edition Flash MX Professional 2004. Usage deltaitem.oldValue Description Property (read-only); an object containing the old value of the property.
CHAPTER 6 Components Dictionary DeltaPacket interface (Flash Professional only) ActionScript Interface Name mx.data.components.datasetclasses.DeltaPacket The DeltaPacket interface is provided by the deltaPacket property of the DataSet component, which is part of the data management functionality in Flash MX Professional 2004. (For more information, see Chapter 14, “Data Integration (Flash Professional Only),” in Using Flash). Typically the delta packet is used internally by resolver components.
Usage deltaPacket.getConfigInfo(info) Parameters info Object; contains information specific to the implementation. Returns An object that contains information required for the specific DeltaPacket implementation. Description Method; returns configuration information that is specific to the implementation of the DeltaPacket interface. This method allows implementations of the DeltaPacket interface to access custom information. Example The following example calls the getConfigInfo() method: // ...
Example The following example uses the getIterator() method to access the iterator for the deltas in a delta packet and uses a while statement to loop through the deltas: var deltapkt:DeltaPacket = _parent.myDataSet.deltaPacket; trace("*** Test deltapacket. Trans ID is: " + deltapkt.getTransactionId() + " ***"); var OPS:Array = new Array("added", "removed", "modified"); var dpCursor:Iterator = deltapkt.getIterator(); var dpDelta:Delta; var op:Number; var changeMsg:String; while(dpCursor.
DeltaPacket.getTimestamp() Availability Flash Player 7. Edition Flash MX Professional 2004. Usage deltaPacket.getTimestamp() Parameters None. Returns A Date object containing the date and time at which the delta packet was created. Description Method; returns the date and time at which the delta packet was created. Example The following example calls the getTimestamp() method: // ... var deltapkt:DeltaPacket = _parent.myDataSet.deltaPacket; var dpTime:String = " Time: " + deltapkt.
Description Method; returns the transaction ID for the delta packet. This unique identifier is used to group a send/receive transaction for a delta packet. The data set uses this to determine if the delta packet is part of the same transaction it originated with the DataSet.applyUpdates() call. Example The following example calls the getTransactionId() method: // ... var deltapkt:DeltaPacket = _parent.myDataSet.deltaPacket; trace("*** Trans ID is: " + deltapkt.getTransactionId() + " ***"); // ...
CHAPTER 6 Components Dictionary DepthManager class ActionScript Class Name mx.managers.DepthManager The DepthManager class allows you manage the relative depth assignments of any component or movie clip, including _root. It also lets you manage reserved depths in a special highest-depth clip on _root for system-level services such as the cursor or tooltips. In general, the Depth Manager manages components automatically. You do not need to use its APIs unless you are an advanced Flash developer.
Property summary for the DepthManager class The following table lists the properties of the DepthManager class. Property Description DepthManager.kBottom A static property with the constant value 202. DepthManager.kCursor A static property with the constant value 101. This is the cursor depth. DepthManager.kNotopmost A static property with the constant value 204. DepthManager.kTooltip A static property with the constant value 102. This is the tooltip depth. DepthManager.
Example The following example creates a minuteHand instance of the MinuteSymbol movie clip and places it in front of the clock: import mx.managers.DepthManager; minuteHand = clock.createChildAtDepth("MinuteSymbol", DepthManager.kTop); DepthManager.createClassChildAtDepth() Availability Flash Player 6 (6.0 79.0). Edition Flash MX 2004. Usage movieClipInstance.createClassChildAtDepth(className, depthFlag[, initObj]) Parameters className A class name. This parameter is a of type Function.
DepthManager.createClassObjectAtDepth() Availability Flash Player 6 (6.0 79.0). Edition Flash MX 2004. Usage DepthManager.createClassObjectAtDepth(className, depthSpace[, initObj]) Parameters className A class name. This parameter is of type Function. depthSpace One of the following values: DepthManager.kCursor, DepthManager.kTooltip. All depth flags are static properties of the DepthManger class. You must either reference the DepthManager package (for example, mx.managers.DepthManager.
depthSpace One of the following values: DepthManager.kCursor, DepthManager.kTooltip. All depth flags are static properties of the DepthManger class. You must either reference the DepthManager package (for example, mx.managers.DepthManager.kCursor), or use the import statement to import the DepthManager package. initObj An optional initialization object. Returns A reference to the created object. The return type is MovieClip. Description Method; creates an object at the specified depth.
Description Property (static); a property with the constant value 101. This property is passed as a parameter in calls to DepthManager.createClassObjectAtDepth() and DepthManager.createObjectAtDepth() to request placement at cursor depth. DepthManager.kNotopmost Availability Flash Player 6 (6.0 79.0). Edition Flash MX Professional 2004. Usage DepthManager.kNotopmost Description Property (static); a property with the constant value 204. This property is passed as a parameter in calls to DepthManager.
Description Property (static); a property with the constant value 201. This property is passed as a parameter in calls to DepthManager.createClassChildAtDepth() and DepthManager.createChildAtDepth() to request placement on top of other content but below DepthManager.kTopmost content. DepthManager.kTopmost Availability Flash Player 6 (6.0 79.0). Edition Flash MX Professional 2004. Usage DepthManager.kTopmost Description Property (static); a property with the constant value 203.
DepthManager.setDepthBelow() Availability Flash Player 6 (6.0 79.0). Edition Flash MX 2004 and Flash MX Professional 2004. Usage movieClipInstance.setDepthBelow(instance) Parameters instance An instance name. This parameter is of type MovieClip. Returns Nothing. Description Method; sets the depth of a movie clip or component instance below the depth of the specified instance and moves other objects if necessary.
Example The following example sets the depth of the mc1 instance to a depth of 10: mc1.setDepthTo(10); For more information about depth and stacking order, see “Determining the next highest available depth” in Using ActionScript in Flash.
CHAPTER 6 Components Dictionary EventDispatcher class Events let your application know when the user has interacted with a component, and when important changes have occurred in the appearance or life cycle of a component—such as its creation, destruction, or resizing. The methods of the EventDispatcher class let you add and remove event listeners so that your code can react to events appropriately. For example, you use the EventDispatcher.
Method summary for the EventDispatcher class The following table lists the methods of the EventDispatcher class. Method Description EventDispatcher.addEventListener() Registers a listener with a component instance. EventDispatcher.dispatchEvent() Dispatches an event programmatically. EventDispatcher.removeEventListener() Removes an event listener from a component instance. EventDispatcher.addEventListener() Availability Flash Player 6 (6.0 79.0).
You can register multiple listeners to a single component instance, but you must use a separate call to addEventListener() for each listener. Also, you can register one listener to multiple component instances, but you must use a separate call to addEventListener() for each instance. For example, the following code defines one listener object and assigns it to two Button component instances, whose label properties are button1 and button2, respectively: lo = new Object(); lo.click = function(evt){ trace(evt.
Parameters eventObject A reference to an event object. The event object must have a type property that is a string indicating the name of the event. Generally, the event object also has a target property that is the name of the instance broadcasting the event. You can define other properties on the event object that will help a user capture information about the event when it is dispatched. Returns Nothing. Description Method; dispatches an event to any listener registered with an instance of the class.
FocusManager class CHAPTER 6 Components Dictionary You can use the Focus Manager to specify the order in which components receive focus when a user presses the Tab key to navigate in an application. You can also use the Focus Manager to set a button in your document that receives keyboard input when a user presses Enter (Windows) or Return (Macintosh). For example, when users fill out a form, they should be able to tab between fields and press Enter (Windows) or Return (Macintosh) to submit the form.
To create a button that receives focus when a user presses Enter (Windows) or Return (Macintosh), set the FocusManager.defaultPushButton property to the instance name of the desired button, as shown here: focusManager.defaultPushButton = okButton; Note: The Focus Manager is sensitive to when objects are placed on the Stage (the depth order of objects) and not their relative positions on the Stage. This is different from the way Flash Player handles tabbing.
If a Flash application is playing in a web browser, the application doesn’t have focus until a user clicks somewhere in the application. Also, once a user clicks in the Flash application, pressing Tab can cause focus to jump outside the Flash application.
Tip: In a class file that inherits from UIComponent, it is not good practice to refer to _root.focusManager. Every UIComponent instance inherits a getFocusManager() method, which returns a reference to the FocusManager instance responsible for controlling that component’s focus scheme. Method summary for the FocusManager class The following table lists the methods of the FocusManager class. Method Description FocusManager.getFocus() Returns a reference to the object that has focus. FocusManager.
Property summary for the FocusManager class The following table lists the properties of the FocusManager class. Property Description FocusManager.defaultPushButton The object that receives a click event when a user presses the Return or Enter key. FocusManager.defaultPushButtonEnabled Indicates whether keyboard handling for the default push button is turned on (true) or off (false). The default value is true. FocusManager.enabled Indicates whether tab handling is turned on (true) or off (false).
Properties inherited from the UIComponent class The following table lists the properties the FocusManager class inherits from the UIComponent class. Property Description UIComponent.enabled Indicates whether the component can receive focus and input. UIComponent.tabIndex A number indicating the tab order for a component in a document. Event summary for the FocusManager class There are no events exclusive to the FocusManager class.
Usage focusManager.defaultPushButton Description Property; specifies the default push button for an application. When the user presses Enter (Windows) or Return (Macintosh), the listeners of the default push button receive a click event. The default value is undefined and the data type of this property is object. The Focus Manager uses the emphasized style declaration of the SimpleButton class to visually indicate the current default push button.
Example The following code disables default push button handling: focusManager.defaultPushButtonEnabled = false; FocusManager.enabled Availability Flash Player 6 (6.0 79.0). Edition Flash MX 2004. Usage focusManager.enabled Description Property; a Boolean value that determines if tab handling is turned on (true) or not (false) for a particular group of focus objects. (For example, another pop-up window could have its own Focus Manager.
Example The following code sets the focus to myOKButton if the object that currently has focus is myInputText: if (focusManager.getFocus() == myInputText) { focusManager.setFocus(myOKButton); } See also FocusManager.setFocus() FocusManager.nextTabIndex Availability Flash Player 6 (6.0 79.0). Edition Flash MX 2004. Usage FocusManager.nextTabIndex Description Property; the next available tab index number. Use this property to dynamically set an object’s tabIndex property.
Returns Nothing. Description Method; sends a click event to listener objects registered to the default push button. Use this method to programmatically send a click event. Example The following code triggers the default push button click event and fills in the user name and password fields when a user selects the CheckBox instance chb (the check box would be labeled “Automatic Login”): name_txt.tabIndex = 1; password_txt.tabIndex = 2; chb.tabIndex = 3; submit_ib.tabIndex = 4; focusManager.
FocusManager.setFocus() Availability Flash Player 6 (6.0 79.0). Edition Flash MX 2004 and Flash MX Professional 2004. Usage focusManager.setFocus(object) Parameters object A reference to the object to receive focus. Returns Nothing. Description Method; sets focus to the specified object. If the object to which you want to set focus is not on the main Timeline, use the following code: _root.focusManager.setFocus(object); Example The following code sets focus to myOKButton: focusManager.
Form class (Flash Professional only) CHAPTER 6 Components Dictionary The Form class provides the runtime behavior of forms you create in the Screen Outline pane in Flash MX Professional 2004. For an overview of working with screens, see Chapter 12, “Working with Screens (Flash Professional Only),” in Using Flash. Using the Form class (Flash Professional only) Forms function as containers for graphic objects—user interface elements in an application, for example—as well as application states.
Form parameters You can set the following authoring parameters for each Form instance in the Property inspector or in the Component inspector: autoload indicates whether the content specified by the contentPath parameter should load automatically (true), or wait to load until the Loader.load() method is called (false). The default value is true. contentPath specifies the contents of the form.
Method Description UIObject.setSkin() Sets a skin in the object. UIObject.setStyle() Sets the style property on the style declaration or object. Methods inherited from the UIComponent class The following table lists the methods the Form class inherits from the UIComponent class. When calling these methods from the Form object, use the syntax formInstance.methodName. Method Description UIComponent.getFocus() Returns a reference to the object that has focus. UIComponent.
Property Description Form.parentForm Read-only; returns the root of the form tree, or subtree, that contains the form. Form.visible Specifies whether the form is visible when its parent form, slide, movie clip, or SWF file is visible. Properties inherited from the UIObject class The following table lists the properties the Form class inherits from the UIObject class. When accessing these properties from the Form object, use the syntax formInstance.propertyName. Property Description UIObject.
Properties inherited from the Loader class The following table lists the properties the Form class inherits from the Loader class. When accessing these properties from the Form object, use the syntax formInstance.propertyName. Property Description Loader.autoLoad A Boolean value that indicates whether the content loads automatically (true) or you must call Loader.load() (false). Loader.bytesLoaded A read-only property that indicates the number of bytes that have been loaded. Loader.
Events inherited from the UIObject class The following table lists the events the Form class inherits from the UIObject class. Event Description UIObject.draw Broadcast when an object is about to draw its graphics. UIObject.hide Broadcast when an object’s state changes from visible to invisible. UIObject.load Broadcast when subobjects are being created. UIObject.move Broadcast when the object has moved. UIObject.resize Broadcast when an object has been resized. UIObject.
Event Description Screen.mouseMove Broadcast when the mouse is moved while over a screen. Screen.mouseOut Broadcast when the mouse is moved from inside the screen to outside it. Screen.mouseOver Broadcast when the mouse is moved from outside this screen to inside it. Screen.mouseUp Broadcast when the mouse button was released over an object (shape or movie clip) directly owned by the screen. Screen.
Returns A Form object. Description Method; returns the child form of myForm whose index is childIndex. Example The following example displays in the Output panel the names of all the child Form objects belonging to the root Form object named application. for (var i:Number = 0; i < _root.application.numChildForms; i++) { var childForm:mx.screens.Form = _root.application.getChildForm(i); trace(childForm._name); } See also Form.numChildForms Form.indexInParentForm Availability Flash Player 6 (6.0 79.0).
Form.numChildForms Availability Flash Player 6 (6.0 79.0). Edition Flash MX Professional 2004. Usage myForm.numChildForms Description Property (read-only); the number of child forms contained by myForm that are derived directly from the class mx.screens.Form. This property does not include any slides that are contained by myForm; it contains only forms. Note: When using a custom ActionScript 2.0 class that extends mx.screens.Form, the form isn't counted in the numChildForms property.
Example if (myForm.parentIsForm) { trace("I have "+myForm._parent.numChildScreens+" sibling screens"); } else { trace("I am the root form and have no siblings"); } Form.parentForm Availability Flash Player 6 (6.0 79.0). Edition Flash MX Professional 2004. Usage myForm.parentForm Description Property (read-only): a reference to the form’s parent form.
Example In the following example, a reference to the root form of myForm is placed in a variable named root. If the value assigned to root refers to myForm, then myForm is at the top of its form tree. var root:mx.screens.Form = myForm.rootForm; if(rootForm == myForm) { trace("myForm is the top form in its tree"); } Form.visible Availability Flash Player 6 (6.0 79.0). Edition Flash MX Professional 2004. Usage myForm.
Iterator interface (Flash Professional only) ActionScript Class Name CHAPTER 6 Components Dictionary mx.utils.Iterator The Iterator interface lets you step through the objects that a collection contains. Method summary for the Iterator interface The following table lists the methods of the Iterator interface. Method Description Iterator.hasNext() Indicates whether the iterator has more items. Iterator.next() Returns the next item in the iteration. Iterator.hasNext() Availability Flash Player 7.
Iterator.next() Availability Flash Player 7. Edition Flash MX Professional 2004. Usage iterator.next() Returns An object that is the next item in the iterator. Description Method; returns an instance of the next item in the iterator. You must cast this instance to the correct type. Example The following example uses the next() method to access the next item in a collection: on (click) { var myColl:mx.utils.Collection; myColl = _parent.thisShelf.MyCompactDisks; var itr:mx.utils.Iterator = myColl.
Label component CHAPTER 6 Components Dictionary A label component is a single line of text. You can specify that a label be formatted with HTML. You can also control the alignment and size of a label. Label components don’t have borders, cannot be focused, and don’t broadcast any events. A live preview of each Label instance reflects changes made to parameters in the Property inspector or Component inspector during authoring.
Note: The Label component’s autoSize property is different from the built-in ActionScript TextField object’s autoSize property. You can write ActionScript to set additional options for Label instances using its methods, properties, and events. For more information, see “Label class” on page 445. Creating an application with the Label component The following procedure explains how to add a Label component to an application while authoring.
Style Theme Description fontSize Both The point size for the font. The default value is 10. fontStyle Both The font style: either "normal" or "italic". The default value is "normal". fontWeight Both The font weight: either "none" or "bold". The default value is "none". All components can also accept the value "normal" in place of "none" during a setStyle() call, but subsequent calls to getStyle() will return "none". textAlign Both The text alignment: either "left", "right", or "center".
Method Description UIObject.destroyObject() Destroys a component instance. UIObject.doLater() Calls a function when parameters have been set in the Property and Component inspectors. UIObject.getStyle() Gets the style property from the style declaration or object. UIObject.invalidate() Marks the object so it will be redrawn on the next frame interval. UIObject.move() Moves the object to the requested position. UIObject.
Property Description UIObject.visible A Boolean value indicating whether the object is visible (true) or not (false). UIObject.width The width of the object, in pixels. Read-only. UIObject.x The left edge of the object, in pixels. Read-only. UIObject.y The top edge of the object, in pixels. Read-only. Event summary for the Label class There are no events exclusive to the Label class.
• center The bottom side of the label resizes to fit the text. The horizontal center of the label stays anchored at its original horizontal center position. • right The left and bottom sides of the label resize to fit the text. The top and right sides don’t resize. Note: The Label component’s autoSize property is different from the built-in ActionScript TextField object’s autoSize property. Label.html Availability Flash Player 6 (6.0 79.0). Edition Flash MX 2004. Usage labelInstance.
Description Property; the text of a label. The default value is "Label". Example The following code sets the text property of the Label instance labelControl and sends the value to the Output panel: labelControl.text = "The Royal Nonesuch"; trace(labelControl.
CHAPTER 6 Components Dictionary List component The List component is a scrollable single- or multiple-selection list box. A list can also display graphics, including other components. You add the items displayed in the list by using the Values dialog box that appears when you click in the labels or data parameter fields. You can also use the List.addItem() and List.addItemAt() methods to add items to the list.
Using the List component You can set up a list so that users can make either single or multiple selections. For example, a user visiting an e-commerce website needs to select which item to buy. There are 30 items, and the user scrolls through a list and selects one by clicking it. You can also design a list that uses custom movie clips as rows so you can display more information to the user.
• Lists aren’t tables. For example, DataGrid components, which extend the List class, are intended to provide an interface for many records. They’re not designed to display complete information; they’re designed to display enough information so that users can drill down to see more. The message view in Microsoft Outlook is a prime example. You don't read the entire e-mail in the grid; the mail would be difficult to read and the client would perform terribly.
4. Select Frame 1 of the Timeline and, in the Actions panel, enter the following: myList.dataProvider = myDP; If you have defined a data provider named myDP, the list will fill with data. (For more information about data providers, see List.dataProvider.) 5. Select Control > Test Movie to see the list with its items. Customizing the List component You can transform a List component horizontally and vertically while authoring and at runtime.
Style Theme Description embedFonts Both A Boolean value that indicates whether the font specified in fontFamily is an embedded font. This style must be set to true if fontFamily refers to an embedded font. Otherwise, the embedded font will not be used. If this style is set to true and fontFamily does not refer to an embedded font, no text will be displayed. The default value is false. 454 fontFamily Both The font name for text. The default value is "_sans".
Style Theme Description selectionDisabledColor Both The background color of a selected row. The default value is a 0xDDDDDD (medium gray). Because the default value for this property is the same as the default for backgroundDisabledColor, the selection is not visible when the component is disabled unless one of these style properties is changed. selectionEasing Both A reference to the easing equation used to control the transition between selection states.
target.setStyle(style, source.getStyle(style)); } To provide styles for the List component but not for components that extend List (DataGrid and Tree), you must provide class-level style declarations for these subclasses. import mx.styles.CSSStyleDeclaration; if (_global.styles.DataGrid == undefined) { _global.styles.DataGrid = new CSSStyleDeclaration(); } _global.styles.DataGrid.setStyle("backgroundColor", 0xFFFFFF); if (_global.styles.Tree == undefined) { _global.styles.
To add a List component to the tab order of an application, set its tabIndex property (see UIComponent.tabIndex). The List component uses the Focus Manager to override the default Flash Player focus rectangle and draw a custom focus rectangle with rounded corners. For more information, see “Creating custom focus navigation” on page 50. Each component class has a version property, which is a class property. Class properties are available only on the class itself.
Method Description UIObject.redraw() Forces validation of the object so it is drawn in the current frame. UIObject.setSize() Resizes the object to the requested size. UIObject.setSkin() Sets a skin in the object. UIObject.setStyle() Sets the style property on the style declaration or object. Methods inherited from the UIComponent class The following table lists the methods the List class inherits from the UIComponent class. When calling these methods, use the form listInstance.methodName.
Property Description List.selectedItem The selected item in a single-selection list. This property is readonly. List.selectedItems The selected item objects in a multiple-selection list. This property is read-only. List.vPosition The topmost visible item of the list. List.vScrollPolicy Indicates whether the vertical scroll bar is displayed ("on"), not displayed ("off"), or displayed when needed ("auto").
Event summary for the List class The following table lists events that of the List class. Event Description List.change Broadcast whenever user interaction causes the selection to change. List.itemRollOut Broadcast when the pointer rolls over and then off of list items. List.itemRollOver Broadcast when the pointer rolls over list items. List.scroll Broadcast when a list is scrolled.
Usage listInstance.addItem(label[, data]) listInstance.addItem(itemObject) Parameters A string that indicates the label for the new item. label data The data for the item. This parameter is optional and can be of any data type. itemObject An item object that usually has label and data properties. Returns The index at which the item was added. Description Method; adds a new item to the end of the list.
data The data for the item. This parameter is optional and can be of any data type. itemObject An item object that usually has label and data properties. Returns The index at which the item was added. Description Method; adds a new item to the position specified by the index parameter. In the first usage example, an item object is always created with the specified label property, and, if specified, the data property. The second usage example adds the specified item object.
List.change Availability Flash Player 6 (6.0 79.0). Edition Flash MX 2004. Usage Usage 1: on(change){ // your code here } Usage 2: listenerObject = new Object(); listenerObject.change = function(eventObject){ // your code here } listInstance.addEventListener("change", listenerObject) Description Event; broadcast to all registered listeners when the selected index of the list changes as a result of user interaction.
Example The following example sends the instance name of the component that generated the change event to the Output panel: form.change = function(eventObj){ trace("Value changed to " + eventObj.target.value); } myList.addEventListener("change", form); See also EventDispatcher.addEventListener() List.dataProvider Availability Flash Player 6 (6.0 79.0). Edition Flash MX 2004. Usage listinstance.dataProvider Description Property; the data model for items viewed in a list.
This example creates a data provider array and assigns it to the dataProvider property, as in the following: myDP = new Array(); list.dataProvider = myDP; for (var i=0; i
Description Property; scrolls the list horizontally to the number of pixels specified. You can’t set hPosition unless the value of hScrollPolicy is "on" and the list has a maxHPosition that is greater than 0. Example The following example gets the horizontal scroll position of myList: var scrollPos = myList.hPosition; The following example sets the horizontal scroll position all the way to the left: myList.hPosition = 0; List.hScrollPolicy Availability Flash Player 6 (6.0 79.0). Edition Flash MX 2004.
Description Property; specifies the name of a field to be used as an icon identifier. If the field has a value of undefined, the default icon specified by the defaultIcon style is used. If the defaultIcon style is undefined, no icon is used. Example The following example sets the iconField property to the icon property of each item: list.iconField = "icon" See also List.iconFunction List.iconFunction Availability Flash Player 6 (6.0 79.0). Edition Flash MX 2004. Usage listInstance.
List.itemRollOut Availability Flash Player 6 (6.0 79.0). Edition Flash MX 2004. Usage Usage 1: on(itemRollOut){ // your code here } Usage 2: listenerObject = new Object(); listenerObject.itemRollOut = function(eventObject){ // your code here } listInstance.addEventListener("itemRollOut", listenerObject) Event object In addition to the standard properties of the event object, the itemRollOut event has an index property, which specifies the number of the item that was rolled out.
Example The following example sends a message to the Output panel that indicates which item index number has been rolled over: form.itemRollOut = function (eventObj) { trace("Item #" + eventObj.index + " has been rolled out."); } myList.addEventListener("itemRollOut", form); See also List.itemRollOver List.itemRollOver Availability Flash Player 6 (6.0 79.0). Edition Flash MX 2004. Usage Usage 1: on(itemRollOver){ // your code here } Usage 2: listenerObject = new Object(); listenerObject.
The second usage example uses a dispatcher/listener event model. A component instance (listInstance) dispatches an event (in this case, itemRollOver) and the event is handled by a function, also called a handler, on a listener object (listenerObject) that you create. You define a method with the same name as the event on the listener object; the method is called when the event is triggered. When the event is triggered, it automatically passes an event object (eventObject) to the listener object method.
List.labelFunction Availability Flash Player 6 (6.0 79.0). Edition Flash MX 2004. Usage listInstance.labelFunction Description Property; specifies a function that determines which field (or field combination) of each item to display. This function receives one parameter, item, which is the item being rendered, and must return a string representing the text to display. Example The following example makes the label display some formatted details of the items: list.
List.maxHPosition Availability Flash Player 6 (6.0 79.0). Edition Flash MX 2004. Usage listInstance.maxHPosition Description Property; specifies the number of pixels the list can scroll when List.hScrollPolicy is set to "on". The list doesn’t precisely measure the width of text that it contains. You must set maxHPosition to indicate the amount of scrolling that the list requires. The list does not scroll horizontally if this property is not set.
List.removeAll() Availability Flash Player 6 (6.0 79.0). Edition Flash MX 2004. Usage listInstance.removeAll() Parameters None. Returns Nothing. Description Method; removes all items in the list. Calling this method modifies the data provider of the List component. If the data provider is shared with other components, those components will update as well. Example The following code clears the list: myList.removeAll(); List.removeItemAt() Availability Flash Player 6 (6.0 79.0).
Calling this method modifies the data provider of the List component. If the data provider is shared with other components, those components will update as well. Example The following code removes the item at index position 3: myList.removeItemAt(3); List.replaceItemAt() Availability Flash Player 6 (6.0 79.0). Edition Flash MX 2004. Usage listInstance.replaceItemAt(index, label[, data]) listInstance.replaceItemAt(index, itemObject) Parameters index A number greater than 0 and less than List.
List.rowCount Availability Flash Player 6 (6.0 79.0). Edition Flash MX 2004. Usage listInstance.rowCount Description Property; the number of rows that are at least partially visible in the list. This is useful if you’ve scaled a list by pixel and need to count its rows. Conversely, setting the number of rows guarantees that an exact number of rows will be displayed, without a partial row at the bottom. The code myList.rowCount = num is equivalent to the code myList.setSize(myList.
Description Property; the height, in pixels, of every row in the list. The font settings do not make the rows grow to fit, so setting the rowHeight property is the best way to make sure items are fully displayed. The default value is 20. Example The following example sets each row to 30 pixels: myList.rowHeight = 30; List.scroll Availability Flash Player 6 (6.0 79.0). Edition Flash MX 2004. Usage Usage 1: on(scroll){ // your code here } Usage 2: listenerObject = new Object(); listenerObject.
The second usage example uses a dispatcher/listener event model. A component instance (listInstance) dispatches an event (in this case, scroll) and the event is handled by a function, also called a handler, on a listener object (listenerObject) that you create. You define a method with the same name as the event on the listener object; the method is called when the event is triggered. When the event is triggered, it automatically passes an event object (eventObject) to the listener object method.
Description Property; the selected index of a single-selection list. The value is undefined if nothing is selected; the value is equal to the last item selected if there are multiple selections. If you assign a value to selectedIndex, any current selection is cleared and the indicated item is selected. Using the selectedIndex property to change selection doesn’t dispatch a change event. To dispatch the change event, use the following code: myList.
List.selectedItem Availability Flash Player 6 (6.0 79.0). Edition Flash MX 2004. Usage listInstance.selectedItem Description Property (read-only); an item object in a single-selection list. (In a multiple-selection list with multiple items selected, selectedItem returns the item that was most recently selected.) If there is no selection, the value is undefined. Example This example displays the selected label: trace(myList.selectedItem.label); See also List.selectedIndex, List.selectedIndices, List.
List.setPropertiesAt() Availability Flash Player 6 (6.0 79.0). Edition Flash MX 2004. Usage listInstance.setPropertiesAt(index, styleObj) Parameters index A number greater than 0 or less than List.length indicating the index of the item to change. styleObj An object that enumerates the properties and values to set. Returns Nothing. Description Method; applies the specified properties to the specified item. The supported properties are icon and backgroundColor.
Description Method; sorts the items in the list by using the function specified in the compareFunc parameter. Example The following example sorts the items according to uppercase labels. Note that the a and b parameters that are passed to the function are items that have label and data properties. myList.sortItems(upperCaseFunc); function upperCaseFunc(a,b){ return a.label.toUpperCase() > b.label.toUpperCase(); } See also List.sortItemsBy() List.sortItemsBy() Availability Flash Player 6 (6.0 79.0).
• Array.RETURNINDEXEDARRAY, which returns an integer index array that is the result of the sort. For example, the following array would return the second line of code and the array would remain unchanged: ["a", "d", "c", "b"] [0, 3, 2, 1] You can combine these options into one value. For example, the following code combines options 3 and 1: array.sort (Array.NUMERIC | Array.DESCENDING) Returns Nothing.
Example The following example sets the position of the list to the first index item: myList.vPosition = 0; List.vScrollPolicy Availability Flash Player 6 (6.0 79.0). Edition Flash MX 2004. Usage listInstance.vScrollPolicy Description Property; a string that determines whether the list supports vertical scrolling. The value of this property can be "on", "off" or "auto". The value "auto" causes a scroll bar to appear when needed. Example The following example disables the scroll bar: myList.
Loader component CHAPTER 6 Components Dictionary The Loader component is a container that can display a SWF or JPEG file. You can scale the contents of the loader or resize the loader itself to accommodate the size of the contents. By default, the contents are scaled to fit the loader. You can also load content at runtime and monitor loading progress. A Loader component can’t receive focus. However, content loaded into the Loader component can accept focus and have its own focus interactions.
contentPath an absolute or relative URL indicating the file to load into the loader. A relative path must be relative to the SWF file loading the content. The URL must be in the same subdomain as the URL where the Flash content currently resides. For use in Flash Player or in test-movie mode, all SWF files must be stored in the same folder, and the filenames cannot include folder or disk drive specifications. The default value is undefined until the load starts.
Using skins with the Loader component The Loader component uses an instance of RectBorder for its border (see “RectBorder class” on page 647). Loader class Inheritance MovieClip > UIObject class > UIComponent class > View > Loader ActionScript Class Name mx.controls.Loader The properties of the Loader class let you set content to load and monitor its loading progress at runtime.
Method Description UIObject.setSkin() Sets a skin in the object. UIObject.setStyle() Sets the style property on the style declaration or object. Methods inherited from the UIComponent class The following table lists the methods the Loader class inherits from the UIComponent class. When calling these methods from the Loader object, use the form LoaderInstance.methodName. Method Description UIComponent.getFocus() Returns a reference to the object that has focus. UIComponent.
Property Description UIObject.right The position of the right edge of the object, relative to the right edge of its parent. Read-only. UIObject.scaleX A number indicating the scaling factor in the x direction of the object, relative to its parent. UIObject.scaleY A number indicating the scaling factor in the y direction of the object, relative to its parent. UIObject.top The position of the top edge of the object, relative to its parent. Read-only. UIObject.
Event Description UIObject.resize Broadcast when an object has been resized. UIObject.reveal Broadcast when an object’s state changes from invisible to visible. UIObject.unload Broadcast when the subobjects are being unloaded. Events inherited from the UIComponent class The following table lists the events the Loader class inherits from the UIComponent class. Event Description UIComponent.focusIn Broadcast when an object receives focus. UIComponent.
Description Property (read-only); the number of bytes of content that have been loaded. The default value is 0 until content begins loading. Example The following code creates a progress bar and a Loader component. It then creates a listener object with a progress event handler that shows the progress of the load. The listener is registered with the loader instance. createClassObject(mx.controls.ProgressBar, "pBar", 0); createClassObject(mx.controls.
// eventObj.target is the component that generated the progress event, // that is, the loader pBar.setProgress(loader.bytesLoaded, loader.bytesTotal); // show progress } loader.addEventListener("progress", loadListener); loader.content = "logo.swf"; See also Loader.bytesLoaded Loader.complete Availability Flash Player 6 (6.0 79.0). Edition Flash MX 2004. Usage Usage 1: on(complete){ ... } Usage 2: listenerObject = new Object(); listenerObject.complete = function(eventObject){ ... } loaderInstance.
The second usage example uses a dispatcher/listener event model. A component instance (loaderInstance) dispatches an event (in this case, complete) and the event is handled by a function, also called a handler, on a listener object (listenerObject) that you create. You define a method with the same name as the event on the listener object; the method is called when the event is triggered. When the event is triggered, it automatically passes an event object (eventObject) to the listener object method.
Loader.contentPath Availability Flash Player 6 (6.0 79.0). Edition Flash MX 2004. Usage loaderInstance.contentPath Description Property; a string that indicates an absolute or relative URL of the file to load into the loader. A relative path must be relative to the SWF file that loads the content. The URL must be in the same subdomain as the loading SWF file.
Example The following code creates a Loader instance and sets the autoload property to false so that the loader must wait for a call to load() to begin loading content. Next, the contentPath property is set, which indicates where to load content from. Then other tasks can be performed before the content is loaded with loader.load(). createClassObject(mx.controls.Loader, "loader", 0); loader.autoLoad = false; loader.contentPath = "logo.swf"; // Perform other tasks here and *then* start loading the file.
Loader.progress Availability Flash Player 6 (6.0 79.0). Edition Flash MX 2004. Usage Usage 1: on(progress){ ... } Usage 2: listenerObject = new Object(); listenerObject.progress = function(eventObject){ ... } loaderInstance.addEventListener("progress", listenerObject) Description Event; broadcast to all registered listeners while content is loading. This event occurs when the load is triggered by the autoload parameter or by a call to Loader.load().
Example The following code creates a Loader instance and then creates a listener object with an event handler for the progress event that sends a message to the Output panel telling what percent of the content has loaded: createClassObject(mx.controls.Loader, "loader", 0); loadListener = new Object(); loadListener.progress = function(eventObj){ // eventObj.target is the component that generated the progress event, // that is, the loader trace("logo.swf is " + loader.percentLoaded + "% loaded.
CHAPTER 6 Components Dictionary Media components (Flash Professional only) The streaming media components make it easy to incorporate streaming media into Flash presentations. These components let you present your media in a variety of ways. You can use the following three media components: • The MediaDisplay component lets media stream into your Flash content without a supporting user interface. You can use this component with video and audio data.
Target Navigation Description Slider controls of a given controller Move slider back and forth The playbar indicates the user’s position within the media; the playback slider moves horizontally (by default) to indicate the playback from beginning (left) to end (right). The slider moves from bottom to top when the controls are oriented vertically. As the slider moves from left to right, it highlights the previous display space to indicate that this content has been played back or selected.
• Cue point objects, along with their name, time, and player properties (see and Media.cuePoints). The name of the cue point is arbitrary; use a name that will have meaning when using listener and trace events. A cue point broadcasts a cuePoint event when the value of its time property is equal to that of the playhead location of the MediaPlayback or MediaDisplay component with which it is associated. The player property is a reference to the MediaPlayback instance with which it is associated.
For FLV files, when Media.autoSize is set to true, the media is displayed at its preferred size, regardless of the size of the component. This means that if the size of the MediaDisplay instance size is different from the size of the media, the media will either spill out of the instance boundaries or not fill the instance size. When Media.autoSize is set to false, Flash uses the instance size as much as possible, while honoring the aspect ratio. If both Media.autoSize and Media.
You can associate the MediaDisplay and MediaController components with each other by using the Media.associateDisplay() and Media.associateController() methods. These methods allow the MediaController instance to update its controls based on events broadcast from the MediaDisplay instance, and allow the MediaDisplay component to react to user settings in the MediaController. Understanding the MediaPlayback component The MediaPlayback contains the MediaController and MediaDisplay subcomponents.
7. Set the desired options for the Automatically Play, Use Preferred Media Size, and Respect Aspect Ratio check boxes. 8. Set the control placement to the desired side of the MediaPlayback component. 9. Add a cue point toward the end of the media; this cue point will be used with a listener to open a pop-up window that announces that the movie is on sale. Give the cue point the name cuePointName. Next, you’ll set the cue point time such that it is within a few seconds of the end of the clip. 10.
Using the MediaDisplay and MediaController components If you want a lot of control over the look and feel of your media display, you may want to use the MediaDisplay and MediaController components together. The following example creates a Flash application that displays your CD and DVD preview media. To create a Flash document that displays a CD or DVD preview: 1. In Flash, select File > New; then select Flash Document. 2.
Using the Component inspector with media components The Component inspector makes it easy to set media component parameters, properties, and so on. To use this panel, click the desired component on the Stage and, with the Property inspector open, click Launch Component Inspector. The Component inspector can be used for the following purposes: • To automatically play the media (see Media.activePlayControl and Media.autoPlay) • To keep or ignore the media’s aspect ratio (see Media.
To control a media component with a behavior, you use the Behaviors panel to apply the behavior to a given media component instance. You specify the event that will trigger the behavior (such as reaching a specified cue point), select a target object (the media components that will be affected by the behavior), and, if necessary, select settings for the behavior (such as the movie clip within the media to navigate to).
To use a Labeled Frame CuePoint Navigation behavior: 1. Place a MediaDisplay or MediaPlayback component instance on the Stage. 2. Select the desired frame that you want the media to navigate to and, using the Property inspector, enter the frame name myLabeledFrame. 3. Select your MediaDisplay or MediaPlayback instance. 4. In the Component inspector, click the Add (+) button and enter the cue point time in the format HH:MM:SS:mmm or HH:MM:SS:FF, and give the cue point the name myLabeledFrame.
MediaDisplay parameters Name Type Default value Description Automatically Play (Media.autoPlay) Boolean Selected Determines if the media plays as soon as it has loaded. Use Preferred Media Size (Media.autoSize) Boolean Selected Determines whether the media associated with the MediaDisplay instance conforms to the component size or simply uses its default size. FPS Integer 30 Indicates the number of frames per second. When the Milliseconds option is selected, this control is disabled.
Name Type Default value Description horizontal (Media.horizontal) Boolean true Determines whether the controller portion of the instance is vertically or horizontally oriented. A true value indicates that the component will have a horizontal orientation. enabled Boolean true Determines whether this control can be modified by the user. A true value indicates that the control can be modified. visible Boolean true Determines whether this control is viewable by the user.
Name Type Default value Description URL (Media.contentPath) String Undefined A string that holds the path and filename of the media to be played. Video Length (Media.totalTime) Undefined The total time needed to play the FLV media. This setting is required in order for the playbar to work correctly. Integer Creating applications with media components (Flash Professional only) Creating Flash content by using media components is quite simple and often requires only a few steps.
Media class (Flash Professional only) Inheritance MovieClip > UIObject class > UIComponent class > Media ActionScript Class Names mx.controls.MediaController, mx.controls.MediaDisplay, mx.controls.MediaPlayback Each component class has a version property, which is a class property. Class properties are available only for the class itself. The version property returns a string that indicates the version of the component. To access this property, use the following code: trace(mx.controls.MediaPlayback.
Property summary for the Media class The following table lists properties of the Media class. Property Components Description Media.activePlayControl MediaController Determines the component state when loaded at runtime. Media.aspectRatio MediaDisplay, MediaPlayback Determines if the component instance maintains its video aspect ratio. Media.autoPlay MediaDisplay, MediaPlayback Determines if the component instance immediately starts to buffer and play. Media.
Property Components Description Media.preferredWidth MediaDisplay, MediaPlayback The default value of the width of a FLV file. Media.totalTime MediaDisplay, MediaPlayback An integer that indicates the total length of the media, in seconds. Media.volume MediaDisplay, MediaPlayback An integer from 0 (minimum) to 100 (maximum) that represents the volume level. Event summary for the Media class The following table lists events of the Media class. Event Components Description Media.
Description Property; a string value that specifies the state the MediaController component should be in when it is loaded at runtime. A value of "play" indicates a play state; a value of "pause" indicates a paused state. Set this property and the autoPlay property such that both indicate the same state. The default value is "play". The button image displayed in the MediaController component is the opposite of the current play/pause state.
Description Method; adds a cue point object to a MediaPlayback or MediaDisplay instance. When the playhead time equals a cue point time, a cuePoint event is broadcast. Example The following code adds a cue point called Homerun to myMedia when the playhead time equals 16 seconds. myMedia.addCuePoint("Homerun", 16); See also Media.cuePoint, Media.cuePoints, Media.getCuePoint(), Media.removeAllCuePoints(), Media.removeCuePoint() Media.
Edition Flash MX Professional 2004. Usage myMedia.associateController(instanceName) Parameters instanceName A string that specifies the instance name of the MediaController component to associate. Returns Nothing. Description Method; associates a MediaDisplay instance with a MediaController instance. If associate a MediaController instance with a MediaDisplay instance by using Media.associateDisplay(), you do not need to use Media.associateController().
Description Method; associates a MediaController instance with a MediaDisplay instance. If you associate a MediaDisplay instance with a MediaController instance by using Media.associateController(), you do not need to use Media.associateDisplay(). Example The following code associates myMedia with myDisplay: myMedia.associateDisplay(myDisplay); See also Media.associateController() Media.autoPlay Applies to MediaDisplay, MediaPlayback Availability Flash Player 7. Edition Flash MX Professional 2004.
Media.autoSize Applies to MediaDisplay, MediaPlayback Availability Flash Player 7. Edition Flash MX Professional 2004. Usage myMedia.autoSize Description Property; a Boolean value that determines the size of the media-viewing portion of the MediaDisplay or MediaPlayback component. For the MediaDisplay component, the property behaves as follows: • If you set this property to true, Flash displays the media at its preferred size, regardless of the size of the component.
Media.backgroundStyle Applies to MediaController Availability Flash Player 7. Edition Flash MX Professional 2004. Usage myMedia.backgroundStyle Description Property; a Boolean value that indicates which background is drawn for the MediaController instance. A value of "default" indicates that the chrome background is drawn, and a value of "none" indicates that no chrome background is drawn. The default value is "default". This is not a style property and therefore is not affected by style settings.
// perform some function until playback ready for (PlaybackLoad < 150) { someFunction(); } Media.bytesTotal Applies to MediaDisplay, MediaPlayback Availability Flash Player 7. Edition Flash MX Professional 2004. Usage myMedia.bytesTotal Description Read-only property; the number of bytes to be loaded into the MediaPlayback or MediaDisplay component. The default value is undefined. Example The following example tells the user the size of the media to be streamed: myTextField.text = myMedia.
When the event is triggered, it automatically passes an event object (eventObject) to the handler. Each event object has properties that contain information about the event. You can use these properties to write code that handles the event. The Media.change event’s event object has two additional properties: A reference to the broadcasting object. target type The string "change", which indicates the type of event. For more information, see “EventDispatcher class” on page 415.
Example The following example opens a pop-up window when the user clicks Play: var myMediaListener = new Object() myMediaListener.click = function(){ PopUpManager.createPopup(_root, mx.containers.Window, false, {contentPath: movieSale}); } myMedia.addEventListener("click", myMediaListener); Media.complete Applies to MediaDisplay, MediaPlayback Availability Flash Player 7. Edition Flash MX Professional 2004. Usage listenerObject = new Object(); listenerObject.
Media.contentPath Applies to MediaDisplay, MediaPlayback Availability Flash Player 7. Edition Flash MX Professional 2004. Usage myMedia.contentPath Description Property; a string that holds the relative path and filename of the media to be streamed and/or played. Setting the contentPath property is equivalent to calling the Media.setMedia() method without specifying a mediaType parameter. When no mediaType parameter is set with Media.setMedia(), the default type is FLV.
The possible values for this property are as follows: • • • "on" specifies that the controls are always expanded. "off" specifies that the controls are always collapsed. "auto" (the default) specifies that the control remains in the collapsed state until the user moves the mouse over the hit area. The hit area matches the area in which the collapsed control is drawn. The control remains expanded until the mouse leaves the hit area. Note: The hit area expands and contracts with the controller.
Edition Flash MX Professional 2004. Usage listenerObject = new Object(); listenerObject.cuePoint = function(eventObject){ // insert your code here } myMedia.addEventListener("cuePoint", listenerObject) Description Event; notification that the playhead has reached the cue point. The Media.cuePoint event object has the following properties: name A string that indicates the name of the cue point. time A number, expressed in frames or seconds, that indicates when the cue point was reached.
Description Property; an array of cue point objects that have been assigned to a MediaPlayback or MediaDisplay instance. In the array, each cue point object can have a name, a time in seconds or frames, and a player property (which is the instance name of the component it is associated with). The default value is an empty array ([]). Example The following example deletes the third cue point if playing an action preview: if(myVariable == actionPreview) { myMedia.removeCuePoint(myMedia.
Media.displayNormal() Applies to MediaPlayback Availability Flash Player 7. Edition Flash MX Professional 2004. Usage myMedia.displayNormal() Parameters None. Returns Nothing. Description Method; sets the MediaPlayback instance back to its normal size after a Media.displayFull() method has been used. Example The following code returns a MediaPlayback component to its original size: myMedia.displayNormal(); See also Media.displayFull() Media.
Returns A cue point object. Description Method; returns a cue point object based on its cue point name. Example The following code retrieves a cue point named myCuePointName. myMedia.removeCuePoint(myMedia.getCuePoint("myCuePointName")); See also Media.addCuePoint(), Media.cuePoint, Media.cuePoints, Media.removeCuePoint() Media.horizontal Applies to MediaController Availability Flash Player 7. Edition Flash MX Professional 2004. Usage myMedia.
Edition Flash MX Professional 2004. Usage myMedia.mediaType Description Property; indicates the type of media (FLV or MP3) to be played. The default value is "FLV". See “Importing Macromedia Flash Video (FLV) files” in Using Flash. Example The following example determines the current media type being played: var currentMedia = myMedia.mediaType; See also Media.setMedia() Media.pause() Applies to MediaDisplay, MediaPlayback Availability Flash Player 7. Edition Flash MX Professional 2004.
Media.play() Applies to MediaDisplay, MediaPlayback Availability Flash Player 7. Edition Flash MX Professional 2004. Usage myMedia.play(startingPoint) Parameters A non-negative integer that indicates the starting point (in seconds) at which the media should begin playing. startingPoint Returns Nothing. Description Method; plays the media associated with the component instance at the given starting point. The default value is the current value of playheadTime.
} myMedia.addEventListener("playheadChange", listenerObject) Description Event; broadcast by the MediaController or MediaPlayback component when the user moves the playback slider or clicks the Go to Beginning or Go to End button. The Media.playheadChange event object has the following properties: A number that indicates the percentage of the media that has played. detail type The string "playheadChange".
Media.playing Applies to MediaDisplay, MediaPlayback, MediaController Availability Flash Player 7. Edition Flash MX Professional 2004. Usage myMedia.playing Description Property; returns a Boolean value that indicates whether the media is playing (true) or paused (false). This property is read-only for the MediaDisplay and MediaPlayback components, and read/write for the MediaController component. Example The following code determines if the media is playing or paused: if(myMedia.
Example The following example sizes a MediaPlayback instance according to the media it is playing and accounts for the pixel margin needed for the component instance: if(myPlayback.contentPath = !undefined){ var mediaHeight = myPlayback.preferredHeight; var mediaWidth = myPlayback.preferredWidth; myPlayback.setSize((mediaWidth + 20), (mediaHeight + 70)); } Media.preferredWidth Applies to MediaDisplay, MediaPlayback Availability Flash Player 7. Edition Flash MX Professional 2004. Usage myMedia.
Description Event; is generated continuously until media has completely downloaded. The Media.progress event object has the following properties: A reference to the MediaDisplay or MediaPlayback instance. target type The string "progress". Example The following example listens for progress: var myProgressListener = new Object(); myProgressListener.progress = function(){ // Make lightMovieClip blink while progress is occurring var lightVisible = lightMovieClip.visible; lightMovieClip.
Returns Nothing. Description Method; deletes all cue point objects associated with a component instance. Example The following code deletes all cue point objects: myMedia.removeAllCuePoints(); See also Media.addCuePoint(), Media.cuePoints, Media.removeCuePoint() Media.removeCuePoint() Applies to MediaDisplay, MediaPlayback Availability Flash Player 7. Edition Flash MX Professional 2004. Usage myMedia.
Media.setMedia() Applies to MediaDisplay, MediaPlayback Availability Flash Player 7. Edition Flash MX Professional 2004. Usage myMedia.setMedia(contentPath [, mediaType]) Parameters contentPath A string that indicates the URL of the media to be played. The default value is undefined. A string used to set the media type to either FLV or MP3. This parameter is optional. The default value is FLV. mediaType Returns Nothing.
Edition Flash MX Professional 2004. Usage myMedia.stop() Parameters None. Returns Nothing. Description Method; stops the playhead and moves it to position 0, which is the beginning of the media. Example The following code stops the playhead and moves it to position 0: myMedia.stop() Media.totalTime Applies to MediaDisplay, MediaPlayback Availability Flash Player 7. Edition Flash MX Professional 2004. Usage myMedia.totalTime Description Property; the total length of the media, in seconds.
Media.volume Applies to MediaDisplay, MediaPlayback Availability Flash Player 7. Edition Flash MX Professional 2004. Usage myMedia.volume Description Property; stores an integer that indicates the volume setting, which can range from 0 to 100. The default value is 75. Example The following example sets the maximum volume for media playback: myMedia.volume = 100; See also Media.volume, Media.pause() Media.volume Applies to MediaController, MediaPlayback Availability Flash Player 7.
Description Event; broadcast when the volume value is adjusted by the user. The Media.volume event object has the following properties: detail type An integer between 0 and 100 that represents the volume level. The string "volume". Example The following example informs the user that the volume is being adjusted: var myVolListener = new Object(); myVolListener.volume = function(){ mytextfield.text = "Volume adjusted!"; } myMedia.addEventListener("volume", myVolListener); See also Media.
CHAPTER 6 Components Dictionary Menu component (Flash Professional only) The Menu component lets a user select an item from a pop-up menu, much like the File or Edit menu of most software applications. A Menu component usually opens in an application when a user rolls over or clicks a button-like menu activator. You can also script a Menu component to open when a user presses a certain key. Menu components are always created dynamically at runtime.
radio The item’s selected attribute is set to true, and the previously selected item’s selected attribute in the radio group is set to false. The selection property of the corresponding radio group object is set to refer to the selected menu item. undefined and the parent of a hierarchical menu The visibility of the hierarchical menu is toggled.
Understanding the Menu component: view and data Conceptually, the Menu component consists of a data model and a view that displays the data. The Menu class provides the view and contains the visual configuration methods. The MenuDataProvider class adds methods to the global XML prototype object (much like the DataProvider API does to the Array object); these methods let you externally construct data providers and add them to multiple menu instances.
About menu item XML attributes The attributes of a menu item XML element determine what is displayed, how the menu item behaves, and how it is exposed to ActionScript. The following table describes the attributes of an XML menu item: Attribute name Type Default Description label String undefined The text that is displayed to represent a menu item. This attribute is required for all item types, except separator.
Normal menu items The Normal Item menu item doesn’t have a type attribute, which means that the type attribute defaults to normal. Normal items can be command activators or submenu activators, depending on whether they have nested subitems. Separator menu items A menu item whose type attribute is set to separator acts as a visual divider in a menu.
Radio button menu items Menu items whose type attribute is set to radio can be grouped together so that only one of the items can be selected at a time.
About initialization object properties (Flash Professional only) The initObject (initialization object) parameter is a fundamental concept in creating the layout for the Menu component. This parameter is an object with properties. Each property represents one of the possible the XML attributes of a menu item. (For a description of the properties allowed in the initObject parameter, see “About menu item XML attributes” on page 541.) The initObject parameter is used in the following methods: • • • • Menu.
Creating an application with the Menu component (Flash Professional only) In the following example, a developer is building an application and uses the Menu component to expose some of the commands that users can issue, such as Open, Close, and Save. To create an application with the Menu component: 1. Select File > New and create a Flash document. 2. Drag the Menu component from the Components panel to the Stage and delete it.
To use XML data from a server to create and populate a menu: 1. Select File > New and create a Flash document. 2. Drag the Menu component from the Components panel to the Stage and delete it. This adds the Menu component to the library without adding it to the application. Menus are created dynamically through ActionScript. 3. In the Actions panel, add the following code to the first frame to create a menu and add some items: var myMenu = mx.controls.Menu.
To use the MenuDataProvider class to create and populate a menu: 1. Select File > New and create a Flash document. 2. Drag the Menu component from the Components panel to the Stage and delete it. This adds the Menu component to the library without adding it to the application. Menus are created dynamically through ActionScript. 3. In the Actions panel, add the following code to the first frame to create a menu and add some items: // Create an XML object to act as a factory.
Using styles with the Menu component You can call the setStyle() method to change the style of the menu, its items, and its submenus.The Menu component supports the following styles: Style Theme Description themeColor Halo The base color scheme of a component. Possible values are "haloGreen", "haloBlue", and "haloOrange". The default value is "haloGreen". alternatingRowColors Both Specifies colors for rows in an alternating pattern.
Style Theme Description textDecoration Both The text decoration: either "none" or "underline". The default value is "none". textIndent Both A number indicating the text indent. The default value is 0. defaultIcon Both The name of the default icon to display on each row. The default value is undefined, which means no icon is displayed. popupDuration Both The duration of the transition as a menu opens. The value is specified in milliseconds; 0 indicates no transition. The default value is 150.
Setting styles for all Menu components in a document The Menu class inherits from the ScrollSelectList class. The default class-level style properties are defined on the ScrollSelectList class, which is shared by all List-based components. You can set new default style values on this class directly, and the new settings will be reflected in all affected components. _global.styles.ScrollSelectList.
5. Open the symbols you want to customize for editing. For example, open the MenuCheckEnabled symbol. 6. Customize the symbol as desired. For example, change the image to be an X instead of a check mark. 7. Repeat steps 6-7 for all symbols you want to customize. 8. Click the Back button to return to the main Timeline. 9. Drag a Menu component to the Stage and delete it. This adds the Menu component to the library and makes it available at runtime. 10.
Method Description Menu.indexOf() Returns the index of a given menu item. Menu.removeAll() Removes all items from a menu. Menu.removeMenuItem() Removes the specified menu item. Menu.removeMenuItemAt() Removes a menu item from a menu at a specified location. Menu.setMenuItemEnabled() Indicates whether a menu item is enabled (true) or not (false). Menu.setMenuItemSelected() Indicates whether a menu item is selected (true) or not (false). Menu.
Property summary for the Menu class The following table lists the property of the Menu class. Property Description Menu.dataProvider The data source for a menu. Properties inherited from the UIObject class The following table lists the properties the Menu class inherits from the UIObject class. When accessing these properties from the Menu object, use the form MenuInstance.propertyName. Property Description UIObject.
Event summary for the Menu class The following table lists events of the Menu class. Event Description Menu.change Broadcast when a user causes a change in a menu. Menu.menuHide Broadcast when a menu closes. Menu.menuShow Broadcast when a menu opens. Menu.rollOut Broadcast when the pointer rolls off an item. Menu.rollOver Broadcast when the pointer rolls over an item. Events inherited from the UIObject class The following table lists the events the Menu class inherits from the UIObject class.
Usage Usage 1: myMenu.addMenuItem(initObject) Usage 2: myMenu.addMenuItem(childMenuItem) Parameters An object containing properties that initialize a menu item’s attributes. See “About menu item XML attributes” on page 541. initObject childMenuItem An XML node object. Returns A reference to the added XML node. Description Method; Usage 1 adds a menu item at the end of the menu. The menu item is constructed from the values supplied in the initObject parameter.
Parameters index An integer indicating the index position (among the child nodes) at which the item is added. initObject An object containing properties that initialize a menu item’s attributes. See “About menu item XML attributes” on page 541. childMenuItem An XML node object. Returns A reference to the added XML node. Description Method; Usage 1 adds a menu item (child node) at the specified location in the menu. The menu item is constructed from the values supplied in the initObject parameter.
When the event is triggered, it automatically passes an event object (eventObject) to the handler. Each event object has properties that contain information about the event. You can use these properties to write code that handles the event. The Menu.change event’s event object has the following additional properties: • menuBar A reference to the MenuBar instance that is the parent of the target menu. When the target menu does not belong to a MenuBar instance, this value is undefined.
Description Method (static); instantiates a Menu instance, and optionally attaches it to the specified parent, with the specified MenuDataProvider as the data source for the menu items. If the parent parameter is omitted or null, the Menu is attached to the _root Timeline. If the mdp parameter is omitted or null, the menu does not have any items; you must call or setDataProvider() to populate the menu.
Description Property; the data source for items in a Menu component. Menu.dataProvider is an XML node object. Setting this property replaces the existing data source of the menu. The default value is undefined. Note: All XML or XMLNode instances are automatically given the methods and properties of the MenuDataProvider class when they are used with the Menu component. Example The following example imports an XML file and assigns it to the Menu.dataProvider property: var myMenuDP = new XML(); myMenuDP.
Menu.hide() Availability Flash Player 6 (6.0 79.0). Edition Flash MX Professional 2004. Usage myMenu.hide() Parameters None. Returns Nothing. Description Method; closes a menu. Example The following example retracts an extended menu: myMenu.hide(); See also Menu.show() Menu.indexOf() Availability Flash Player 6 (6.0 79.0). Edition Flash MX Professional 2004. Usage myMenu.indexOf(item) Parameters item A reference to an XML node that describes a menu item.
Example The following example adds a menu item to a parent item and then gets the item’s index within its parent: var myItem = myMenu.addMenuItem({label:"That item"}); var myIndex = myMenu.indexOf(myItem); Menu.menuHide Availability Flash Player 6 (6.0 79.0). Edition Flash MX Professional 2004. Usage listenerObject = new Object(); listenerObject.menuHide = function(eventObject){ // insert your code here } myMenu.
} myMenu.addEventListener("menuHide", form); See also Menu.menuShow Menu.menuShow Availability Flash Player 6 (6.0 79.0). Edition Flash MX Professional 2004. Usage listenerObject = new Object(); listenerObject.menuShow = function(eventObject){ // insert your code here } myMenu.addEventListener("menuShow", listenerObject) Description Event; broadcast to all registered listeners whenever a menu opens. All parent nodes open menus to show their children.
} myMenu.addEventListener("menuShow", form); See also Menu.menuHide Menu.removeAll() Availability Flash Player 6 (6.0 79.0). Edition Flash MX Professional 2004. Usage myMenu.removeAll() Parameters None. Returns Nothing. Description Method; removes all items and refreshes the menu. Example The following example removes all nodes from the menu: myMenu.removeAll(); Menu.removeMenuItem() Availability Flash Player 6 (6.0 79.0). Edition Flash MX Professional 2004. Usage myMenuItem.
Example The following example removes the menu item referenced by the variable theItem: theItem.removeMenuItem(); Menu.removeMenuItemAt() Availability Flash Player 6 (6.0 79.0). Edition Flash MX Professional 2004. Usage myMenu.removeMenuItemAt(index) Parameters index The index of the menu item to remove. Returns A reference to the returned menu item (XML node). This value is undefined if there is no item in that position.
Version 2 components use a dispatcher-listener event model. When a Menu component broadcasts a rollOut event, the event is handled by a function (also called a handler) that is attached to a listener object (listenerObject) that you create. You call the addEventListener() method and pass it the name of the handler as a parameter. When the event is triggered, it automatically passes an event object (eventObject) to the handler. Each event object has properties that contain information about the event.
When the event is triggered, it automatically passes an event object (eventObject) to the handler. Each event object has properties that contain information about the event. You can use these properties to write code that handles the event. The Menu.rollOver event’s event object has one additional property: menuItem, which is a reference to the menu item (XML node) that the pointer rolled over. For more information, see “EventDispatcher class” on page 415.
See also Menu.setMenuItemSelected() Menu.setMenuItemSelected() Availability Flash Player 6 (6.0 79.0). Edition Flash MX Professional 2004. Usage myMenu.setMenuItemSelected(item, select) Parameters item An XML node. The target menu item’s node in the data provider. select A Boolean value indicating whether the item is selected (true) or not (false). If the item is a check box, its check mark is visible or not visible.
Parameters x The x coordinate. y The y coordinate. Returns Nothing. Description Method; opens a menu at a specific location. The menu is automatically resized so that all of its top-level items are visible, and the upper left corner is placed at the specified location in the coordinate system provided by the component’s parent. If the x and y parameters are omitted, the menu is shown at its previous location.
Method summary for the MenuDataProvider class The following table lists the methods of the MenuDataProvider class. Method Description MenuDataProvider.addMenuItem() Adds a child item. MenuDataProvider.addMenuItemAt() Adds a child item at a specified location. MenuDataProvider.getMenuItemAt() Gets a reference to a menu item at a specified location. MenuDataProvider.indexOf() Returns the index of a specified menu item. MenuDataProvider.removeMenuItem() Removes a menu item. MenuDataProvider.
Example The following example adds a new node to a specified node in the menu: var item0 = myMenuDP.getMenuItemAt(0); item0.addMenuItem("Inbox", { label:"Item 1", icon:"radioItemIcon", type:"radio", selected:false, enabled:true, instanceName:"radioItem1", groupName:"myRadioGroup" } ); MenuDataProvider.addMenuItemAt() Availability Flash Player 6 (6.0 79.0). Edition Flash MX Professional 2004. Usage Usage 1: myMenuDataProvider.addMenuItemAt(index, initObject) Usage 2: myMenuDataProvider.
MenuDataProvider.getMenuItemAt() Availability Flash Player 6 (6.0 79.0). Edition Flash MX Professional 2004. Usage myMenuDataProvider.getMenuItemAt(index) Parameters An integer indicating the position of the menu. index Returns A reference to the specified XML node. Description Method; returns a reference to the specified child menu item of the current menu item. Any node or menu item in a MenuDataProvider instance can call the methods of the MenuDataProvider class.
Description Method; returns the index of the specified menu item in this parent menu item. Any node or menu item in a MenuDataProvider instance can call the methods of the MenuDataProvider class. Example The following example adds a menu item to a parent item and gets the item’s index: var myMenuItem = myParentMenuItem.addMenuItem({label:"That item"}); var myIndex = myParentMenuItem.indexOf(myItem); MenuDataProvider.removeMenuItem() Availability Flash Player 6 (6.0 79.0).
Parameters index The index of the menu item. Returns A reference to the removed menu item. This value is undefined if there is no item in that position. Description Method; removes the child item of the menu item specified by the index parameter. If there is no menu item at that index, calling this method has no effect. Any node or menu item in a MenuDataProvider instance can call the methods of the MenuDataProvider class. Example The following example removes the fourth item: myMenuDataProvider.
CHAPTER 6 Components Dictionary MenuBar component (Flash Professional only) The MenuBar component lets you create a horizontal menu bar with pop-up menus and commands, just like the menu bars that contain File and Edit menus in common software applications. The MenuBar component complements the Menu component by providing a clickable interface to show and hide menus that behave as a group for mouse and keyboard interactivity. The MenuBar component lets you create an application menu in a few steps.
Using the MenuBar component (Flash Professional only) You can use the MenuBar component to add a set of menus (for example, File, Edit, Special, Window) to the top edge of an application. MenuBar parameters You can set the following authoring parameter for each MenuBar component instance in the Property inspector or in the Component inspector: Labels An array that adds menu activators with the specified labels to the MenuBar component. The default value is [] (an empty array).
This code creates a listener object, listen, that uses the event object, evt, to catch menu item selections. Note: You must call the addEventListener() method to register the listener with the menu instance, not with the menu bar instance. 7. Select Control > Test Movie to test the MenuBar component. Customizing the MenuBar component (Flash Professional only) This component sizes itself according to the activator labels that are supplied through the property or the methods of the MenuBar class.
Using skins with the MenuBar component The MenuBar component uses three skins to represent its background, uses a movie clip symbol for highlighting individual items, and contains a Menu component as the pop-up which itself is skinnable. The MenuBar skins are described below. For information on skinning the Menu component, see “Using skins with the Menu component” on page 550. The MenuBar component supports the following skin properties.
MenuBar class (Flash Professional only) Inheritance MovieClip > UIObject class > UIComponent class > MenuBar ActionScript Class Name mx.controls.MenuBar The methods and properties of the MenuBar class let you create a horizontal menu bar with popup menus and commands. These methods and properties complement those of the Menu class by allowing you to create a clickable interface to show and hide menus that behave as a group for mouse and keyboard interactivity.
Methods inherited from the UIComponent class The following table lists the methods the MenuBar class inherits from the UIComponent class. When calling these methods from the MenuBar object, use the form MenuBar.methodName. Method Description UIComponent.getFocus() Returns a reference to the object that has focus. UIComponent.setFocus() Sets focus to the component instance. Property summary for the MenuBar class The following table lists properties of the MenuBar class. Property Description MenuBar.
Properties inherited from the UIComponent class The following table lists the properties the MenuBar class inherits from the UIComponent class. When calling these properties from the MenuBar object, use the form MenuBar.propertyName. Property Description UIComponent.enabled Indicates whether the component can receive focus and input. UIComponent.tabIndex A number indicating the tab order for a component in a document.
Events inherited from the UIComponent class The following table lists the events the MenuBar class inherits from the UIComponent class. When calling these events from the MenuBar object, use the form MenuBar.eventName. Event Description UIComponent.focusIn Broadcast when an object receives focus. UIComponent.focusOut Broadcast when an object loses focus. UIComponent.keyDown Broadcast when a key is pressed. UIComponent.keyUp Broadcast when a key is released. MenuBar.
myMenu = myMenuBar.addMenu("File"); myMenu.addMenuItem({label:"New", instanceName:"newInstance"}); myMenu.addMenuItem({label:"Open", instanceName:"openInstance"}) Usage 2: The following example adds a Font menu with the menu items Bold and Italic that are defined in the MenuDataProvider instance myMenuDP2: var myMenuDP2 = new XML(); myMenuDP2.addMenuItem({type:"check", label:"Bold", instanceName:"check1"}); myMenuDP2.addMenuItem({type:"check", label:"Italic", instanceName:"check2"}); menu = myMenuBar.
Usage 2: The following example adds an Edit menu with the menu items Undo, Redo, Cut, and Copy, which are defined in the MenuDataProvider instance myMenuDP: var myMenuDP = new XML(); myMenuDP.addMenuItem({label:"Undo", instanceName:"undoInst"}); myMenuDP.addMenuItem({label:"Redo", instanceName:"redoInst"}); myMenuDP.addMenuItem({type:"separator"}); myMenuDP.addMenuItem({label:"Cut", instanceName:"cutInst"}); myMenuDP.addMenuItem({label:"Copy", instanceName:"copyInst"}); myMenuBar.
MenuBar.getMenuAt() Availability Flash Player 6 (6.0 79.0). Edition Flash MX Professional 2004. Usage myMenuBar.getMenuAt(index) Parameters index An integer indicating the position of the menu. Returns A reference to the menu at the specified index. This value is undefined if there is no menu at that position. Description Method; returns a reference to the menu at the specified index. Example Because getMenuAt() returns an instance, it is possible to add items to a menu at the specified index.
Description Method; returns a Boolean value that indicates whether this menu can be chosen (true) or not (false). Example The following example calls the method on the menu in the first position of myMenuBar: myMenuBar.getMenuEnabledAt(0); MenuBar.labelField Availability Flash Player 6 (6.0 79.0). Edition Flash MX Professional 2004. Usage myMenuBar.labelField Description Property; a string that determines which attribute of each XML node to use as the label text of the menu.
Example The following example of a label function builds and returns a custom label from the node attributes: myMenuBar.labelFunction = function(node){ var a = node.attributes; return "The Price for " + a.name + " is " + a.price; }; MenuBar.removeMenuAt() Availability Flash Player 6 (6.0 79.0). Edition Flash MX Professional 2004. Usage myMenuBar.removeMenuAt(index) Parameters index The index of the menu to be removed from the menu bar.
boolean A Boolean value indicating whether the menu item at the specified index is enabled (true) or not (false). Returns Nothing. Description Method; enables the menu at the specified index. If there is no menu at that index, calling this method has no effect. Example The following example enables the item at index 3 in the MenuBar object myMenuBar: myMenuBar.
NumericStepper component CHAPTER 6 Components Dictionary The NumericStepper component allows a user to step through an ordered set of numbers. The component consists of a number in a text box displayed beside small up and down arrow buttons. When a user presses the buttons, the number is raised or lowered incrementally according to the unit specified in the stepSize parameter, until the user releases the buttons or until the maximum or minimum value is reached.
NumericStepper parameters You can set the following authoring parameters for each NumericStepper instance in the Property inspector or in the Component inspector: value sets the value displayed in the text area of the stepper. The default value is 0. minimum sets the minimum value that can be displayed in the stepper. The default value is 0. maximum sets the maximum value that can be displayed in the stepper. The default value is 10.
Customizing the NumericStepper component You can transform a NumericStepper component horizontally and vertically while authoring and at runtime. While authoring, select the component on the Stage and use the Free Transform tool or any of the Modify > Transform commands. At runtime, use the setSize() method (see UIObject.setSize()) or any applicable properties and methods of the NumericStepper class. (See “NumericStepper class” on page 592.
Style Theme Description textDecoration Both The text decoration: either "none" or "underline". The default value is "none". repeatDelay Both The number of milliseconds of delay between when a user first presses a button and when the action begins to repeat. The default value is 500 (half a second). repeatInterval Both The number of milliseconds between automatic clicks when a user holds the mouse button down on a button. The default value is 35. symbolColor Sample The color of the arrows.
To create movie clip symbols for NumericStepper skins: 1. Create a new FLA file. 2. Select File > Import > Open External Library, and select the HaloTheme.fla file. This file is located in the application-level configuration folder. For the exact location on your operating system, see “About themes” on page 77. 3. In the theme’s Library panel, expand the Flash UI Components 2/Themes/MMDefault folder and drag the Stepper Assets folder to the library for your document. 4.
Each component class has a version property, which is a class property. Class properties are available only on the class itself. The version property returns a string that indicates the version of the component. To access this property, use the following code: trace(mx.controls.NumericStepper.version); Note: The code trace(myNumericStepperInstance.version); returns undefined. Method summary for the NumericStepper class There are no methods exclusive to the NumericStepper class.
Property summary for the NumericStepper class The following table lists properties of the NumericStepper class. Property Description NumericStepper.maximum A number indicating the maximum range value. NumericStepper.minimum A number indicating the minimum range value. NumericStepper.nextValue A number indicating the next sequential value. This property is read-only. NumericStepper.previousValue A number indicating the previous sequential value. This property is read-only. NumericStepper.
Properties inherited from the UIComponent class The following table lists the properties the NumericStepper class inherits from the UIComponent class. When calling these properties from the NumericStepper object, use the form NumericStepper.propertyName. Property Description UIComponent.enabled Indicates whether the component can receive focus and input. UIComponent.tabIndex A number indicating the tab order for a component in a document.
NumericStepper.change Availability Flash Player 6 (6.0 79.0). Edition Flash MX 2004. Usage Usage 1: on(click){ ... } Usage 2: listenerObject = new Object(); listenerObject.change = function(eventObject){ ... } stepperInstance.addEventListener("change", listenerObject) Description Event; broadcast to all registered listeners when the value of the stepper is changed. The first usage example uses an on() handler and must be attached directly to a NumericStepper instance.
Example This example, written on a frame of the Timeline, sends a message to the Output panel when a stepper called myNumericStepper is changed. The first line of code creates a listener object called form. The second line defines a function for the change event on the listener object. Inside the function is a trace() statement that uses the event object that is automatically passed to the function, in this example eventObj, to generate a message.
Usage stepperInstance.minimum Description Property; the minimum range value of the stepper. This property can contain a number of up to three decimal places. The default value is 0. Example The following example sets the minimum value of the stepper range to 100: myStepper.minimum = 100; See also NumericStepper.maximum NumericStepper.nextValue Availability Flash Player 6 (6.0 79.0). Edition Flash MX 2004. Usage stepperInstance.nextValue Description Property (read-only); the next sequential value.
Usage stepperInstance.previousValue Description Property (read-only); the previous sequential value. This property can contain a number of up to three decimal places. Example The following example sets the stepSize property to 1 and the starting value to 4, which would make the value of nextValue 3: myStepper.stepSize = 1; myStepper.value = 4; trace(myStepper.previousValue); See also NumericStepper.nextValue NumericStepper.stepSize Availability Flash Player 6 (6.0 79.0). Edition Flash MX 2004.
Usage stepperInstance.value Description Property; the current value displayed in the text area of the stepper. The value is not assigned if it does not correspond to the stepper’s range and step increment as defined in the stepSize property. This property can contain a number of up to three decimal places. Example The following example sets the current value of the stepper to 10 and sends the value to the Output panel: myStepper.value = 10; trace(myStepper.
CHAPTER 6 Components Dictionary PopUpManager class ActionScript Class Name mx.managers.PopUpManager The PopUpManager class lets you create overlapping windows that can be modal or nonmodal. (A modal window doesn’t allow interaction with other windows while it’s active.) You use the methods of this class to create and destroy pop-up windows. Method summary for the PopUpManager class The following table lists the methods of the PopUpManager class. Method Description PopUpManager.
Example The following code creates a modal window when the button is clicked: lo = new Object(); lo.click = function(){ mx.managers.PopUpManager.createPopUp(_root, mx.containers.Window, true); } button.addEventListener("click", lo); PopUpManager.deletePopUp() Availability Flash Player 6 (6.0 79.0). Edition Flash MX 2004 and Flash MX Professional 2004 Usage windowInstance.deletePopUp(); Parameters None. Returns Nothing. Description Method; deletes a pop-up window and removes the modal state.
ProgressBar component CHAPTER 6 Components Dictionary The ProgressBar component displays the progress of loading content. The loading process can be determinate or indeterminate. A determinate progress bar is a linear representation of a task’s progress over time and is used when the amount of content to load is known. An indeterminate progress bar is used when the amount of content to load is unknown. You can add a label to display the progress of the loading content.
labelPlacement indicates the position of the label in relation to the progress bar. This parameter can be one of the following values: top, bottom, left, right, center. The default value is bottom. conversion is a number by which to divide the %1 and %2 values in the label string before they are displayed. The default value is 1. You can write ActionScript to control these and additional options for the ProgressBar component using its properties, methods, and events.
To create an application with the ProgressBar component in polled mode: 1. Drag a ProgressBar component from the Components panel to the Stage. 2. In the Property inspector, do the following: ■ Enter the instance name pBar. ■ Select Polled for the mode parameter. ■ Enter loader for the source parameter. 3.
A ProgressBar component supports the following styles: Style Theme Description themeColor Halo The base color scheme of a component. Possible values are "haloGreen", "haloBlue", and "haloOrange". The default value is "haloGreen". color Both The text color. The default value is 0x0B333C for the Halo theme and blank for the Sample theme. disabledColor Both The color for text when the component is disabled. The default color is 0x848384 (dark gray).
A ProgressBar component supports the following skin properties: Property Description progTrackMiddleName The expandable middle of the track. The default value is ProgTrackMiddle. progTrackLeftName The fixed-size left cap. The default value is ProgTrackLeft. progTrackRightName The fixed-size right cap. The default value is ProgTrackRight. progBarMiddleName The expandable middle bar graphic. The default value is ProgBarMiddle. progBarLeftName The fixed-size left bar cap.
Each component class has a version property, which is a class property. Class properties are available only on the class itself. The version property returns a string that indicates the version of the component. To access this property, use the following code: trace(mx.controls.ProgressBar.version); Note: The code trace(myProgressBarInstance.version); returns undefined. Method summary for the ProgressBar class The following table lists the method of the ProgressBar class. Method Description ProgressBar.
Property Description ProgressBar.indeterminate Indicates whether the size of the loading source is unknown. ProgressBar.label The text that accompanies the progress bar. ProgressBar.labelPlacement The location of the label in relation to the progress bar. ProgressBar.maximum The maximum value of the progress bar in manual mode. ProgressBar.minimum The minimum value of the progress bar in manual mode. ProgressBar.mode The mode in which the progress bar loads content. ProgressBar.
Event summary for the ProgressBar class The following table lists events of the ProgressBar class. Event Description ProgressBar.complete Triggered when loading is complete. ProgressBar.progress Triggered as content loads in manual or polled mode. Events inherited from the UIObject class The following table lists the events the ProgressBar class inherits from the UIObject class. When calling these events from the ProgressBar object, use the form ProgressBar.eventName. Event Description UIObject.
Event object In addition to the standard event object properties, there are two additional properties defined for the ProgressBar.complete event: current (the loaded value equals total), and total (the total value). Description Event; broadcast to all registered listeners when the loading progress has completed. The first usage example uses an on() handler and must be attached directly to a ProgressBar instance.
ProgressBar.conversion Availability Flash Player 6 (6.0 79.0). Edition Flash MX 2004. Usage pBarInstance.conversion Description Property; a number that sets a conversion value for the incoming values. It divides the current and total values, floors them, and displays the converted value in the label property. The default value is 1. Note: The floor is the closest integer value that is less than or equal to the specified value. For example, the number 4.6 becomes 4.
Usage pBarInstance.indeterminate Description Property; a Boolean value that indicates whether the progress bar has a striped fill and a loading source of unknown size (true), or a solid fill and a loading source of a known size (false). For example, you might use this property if you are loading a large data set into a SWF file and do not know the size of the data you are loading. Example The following code creates a determinate progress bar with a solid fill that moves from left to right.
Description Property; text that indicates the loading progress. This property is a string in the format "%1 out of %2 loaded (%3%%)". In this string, %1 is a placeholder for the current bytes loaded, %2 is a placeholder for the total bytes loaded, and %3 is a placeholder for the percentage of content loaded. (The characters %% allow Flash to display a single % character.) If a value for %2 is unknown, it is replaced by ??. If a value is undefined, the label doesn’t display.
Usage pBarInstance.maximum Description Property; the largest value for the progress bar when the ProgressBar.mode property is set to "manual". Example The following code sets the maximum property to the total frames of a Flash application that’s loading: pBar.maximum = _totalframes; See also ProgressBar.minimum, ProgressBar.mode ProgressBar.minimum Availability Flash Player 6 (6.0 79.0). Edition Flash MX 2004. Usage pBarInstance.
Description Property; the mode in which the progress bar loads content. This value can be "event", "polled", or "manual". Event mode and polled mode are the most common modes. In event mode, the source property specifies loading content that emits progress and complete events; you should use a Loader object in this mode. In polled mode, the source property specifies loading content (such as a MovieClip object) that exposes getBytesLoaded() and getsBytesTotal() methods.
Description Property (read-only); tells what percentage of the content has been loaded. This value is floored. (The floor is the closest integer value that is less than or equal to the specified value. For example, the number 7.8 becomes 7.) The following formula is used to calculate the percentage: 100*(value-minimum)/(maximum-minimum) Example The following code sends the value of the percentComplete property to the Output panel: trace("percent complete = " + pBar.percentComplete); ProgressBar.
The second usage example uses a dispatcher/listener event model. A component instance (pBarInstance) dispatches an event (in this case, progress) and the event is handled by a function, also called a handler, on a listener object (listenerObject) that you create. You define a method with the same name as the event on the listener object; the method is called when the event is triggered. When the event is triggered, it automatically passes an event object (eventObject) to the listener object method.
Returns A number indicating the amount of progress that has been made. Description Method; sets the state of the progress bar to reflect the amount of progress made when the ProgressBar.mode property is set to "manual". You can call this method to make the bar reflect the state of a process other than loading. For example, you might want to explicitly set the progress bar to zero progress.
ProgressBar.value Availability Flash Player 6 (6.0 79.0). Edition Flash MX 2004. Usage pBarInstance.value Description Property (read-only); indicates the amount of progress that has been made. This property is a number between the value of ProgressBar.minimum and ProgressBar.maximum. The default value is 0.
RadioButton component CHAPTER 6 Components Dictionary The RadioButton component lets you force a user to make a single choice within a set of choices. This component must be used in a group of at least two RadioButton instances. Only one member of the group can be selected at any given time. Selecting one radio button in a group deselects the currently selected radio button in the group. You set the groupName parameter to indicate which group a radio button belongs to.
RadioButton parameters You can set the following authoring parameters for each RadioButton component instance in the Property inspector or in the Component inspector: label sets the value of the text on the button; the default value is Radio Button. data is the value associated with the radio button. There is no default value. groupName is the group name of the radio button. The default value is radioGroup. selected sets the initial value of the radio button to selected (true) or unselected (false).
Customizing the RadioButton component You can transform a RadioButton component horizontally and vertically while authoring and at runtime. While authoring, select the component on the Stage and use the Free Transform tool or any of the Modify > Transform commands. At runtime, use the setSize() method (see UIObject.setSize()). The bounding box of a RadioButton component is invisible and also designates the hit area for the component.
Style Theme Description symbolBackgroundColor Sample The background color of the radio button. The default value is 0xFFFFFF (white). symbolBackgroundDisabledColor Sample The background color of the radio button when disabled. The default value is 0xEFEEEF (light gray). symbolBackgroundPressedColor Sample The background color of the radio button when pressed. The default value is 0xFFFFFF (white). symbolColor Sample The color of the dot in the radio button. The default value is 0x000000 (black).
To create movie clip symbols for RadioButton skins: 1. Create a new FLA file. 2. Select File > Import > Open External Library, and select the HaloTheme.fla file. This file is located in the application-level configuration folder. For the exact location on your operating system, see “About themes” on page 77. 3. In the theme’s Library panel, expand the Flash UI Components 2/Themes/MMDefault folder and drag the RadioButton Assets folder to the library for your document. 4.
Note: The code trace(myRadioButtonInstance.version); returns undefined. Method summary for the RadioButton class There are no methods exclusive to the RadioButton class. Methods inherited from the UIObject class The following table lists the methods the RadioButton class inherits from the UIObject class. When calling these methods from the RadioButton object, use the form RadioButtonInstance.methodName. Method Description UIObject.createClassObject() Creates an object on the specified class. UIObject.
Property Description RadioButton.label The text that appears next to a radio button. RadioButton.labelPlacement The orientation of the label text in relation to a radio button or radio button group. RadioButton.selected Selects the radio button, and deselects the previously selected radio button. This property can be used with a RadioButton instance or a RadioButtonGroup instance. RadioButton.selectedData Selects the radio button with the specified data value in a radio button group. RadioButton.
Properties inherited from the UIComponent class The following table lists the properties the RadioButton class inherits from the UIComponent class. When accessing these properties from the RadioButton object, use the form RadioButtonInstance.propertyName. Property Description UIComponent.enabled Indicates whether the component can receive focus and input. UIComponent.tabIndex A number indicating the tab order for a component in a document.
Events inherited from the UIObject class The following table lists the events the RadioButton class inherits from the UIObject class. Event Description UIObject.draw Broadcast when an object is about to draw its graphics. UIObject.hide Broadcast when an object’s state changes from visible to invisible. UIObject.load Broadcast when subobjects are being created. UIObject.move Broadcast when the object has moved. UIObject.resize Broadcast when an object has been resized. UIObject.
Usage 2: listenerObject = new Object(); listenerObject.click = function(eventObject){ ... } radioButtonGroup.addEventListener("click", listenerObject) Description Event; broadcast to all registered listeners when the mouse is clicked (pressed and released) over the radio button or if the radio button is selected by means of the arrow keys. The event is also broadcast if the Spacebar or arrow keys are pressed when a radio button group has focus, but none of the radio buttons in the group are selected.
} radioGroup.addEventListener("click", form); The following code also sends a message to the Output panel when radioButtonInstance is clicked. The on() handler must be attached directly to radioButtonInstance. on(click){ trace("radio button component was clicked"); } RadioButton.data Availability Flash Player 6 (6.0 79.0). Edition Flash MX 2004. Usage radioButtonInstance.data Description Property; specifies the data to associate with a RadioButton instance.
Example The following example sets the group name of a radio button instance to colorChoice and then changes the group name to sizeChoice. To test this example, place a radio button on the Stage, name the instance name myRadioButton, and enter the following code on Frame 1: myRadioButton.groupName = "colorChoice"; trace(myRadioButton.groupName); colorChoice.groupName = "sizeChoice"; trace(colorChoice.groupName); RadioButton.label Availability Flash Player 6 (6.0 79.0). Edition Flash MX 2004.
The following are the four possible values: • "right" The radio button is pinned to the upper left corner of the bounding area. The label is placed to the right of the radio button. • "left" The radio button is pinned to the upper right corner of the bounding area. The label is placed to the left of the radio button. • "bottom" • "top" The label is placed below the radio button. The radio button and label grouping are centered horizontally and vertically.
Usage radioButtonGroup.selectedData Description Property; selects the radio button with the specified data value and deselects the previously selected radio button. If the data property is not specified for a selected instance, the label value of the selected instance is selected and returned. The selectedData property can be of any data type. Example The following example selects the radio button with the value "#FF00FF" from the radio group colorGroup and sends the value to the Output panel: colorGroup.
RadioButtonGroup component CHAPTER 6 Components Dictionary For information about the RadioButtonGroup class, see RadioButton component.
CHAPTER 6 Components Dictionary RDBMSResolver component (Flash Professional only) Resolver components are used with the DataSet component (part of the data management functionality in the Flash data architecture) to save changes to an external data source. Resolvers include both the RDBMSResolver component and the XUpdateResolver component. Resolvers take a delta packet (returned by DataSet.deltaPacket) and convert it to an update packet in a format appropriate to the type of resolver.
• The default value. This setting uses the old value of the key fields. This implies an “optimistic concurrency” model, which most database systems today employ, and guarantees that you are modifying the same record that you retrieved from the database. Your changes overwrites any other user’s changes to the same data. umUsingKey NullValue is a string representing a null field value. You can customize this parameter to prevent it from being confused with an empty string ("") or another valid value.
Common workflow for the RDBMSResolver component The following steps describe the typical workflow for the RDBMSResolver component. To use an RDBMSResolver component: 1. Add two instances of the WebServiceConnector component and one instance of the DataSet and RDBMSResolver components to your application, and give them instance names. 2. Select the first WebServiceConnector component.
Property summary for the RDBMSResolver component The following table lists properties of the RDBMSResolver class. Property Description RDBMSResolver.deltaPacket The DataSet object’s deltaPacket property should be bound to this property so that when DataSet.applyUpdates() is called, the binding will copy it across and the resolver will create the update packet. RDBMSResolver.
Parameters fieldName String; provides the name of the field that this information object describes. String; provides the name of the table that owns this field. If this name is the same as the RDBMSResolver instance’s tableName property, you can leave this parameter blank (""). ownerName isKey Boolean; indicates whether this field is a key field. Returns Nothing. Description Method; adds a new item to the XML fieldInfo collection in the update packet.
Property Description type String; the name of the event. updatePacket XML object; the XML object about to be applied. Returns Nothing. Description Property; a property of type deltaPacket. It receives a delta packet to be translated into an update packet, and outputs a delta packet from any server results placed in the updateResults property. This event handler provides a way for you to make custom modifications to the XML before sending the updated data to a connector.
Messages in the updateResults property are treated as errors. This means that a delta with messages is added to the delta packet again so it can be re-sent the next time the delta packet is sent to the server. You must write code to handle deltas that have messages so that the messages are presented to the user and the deltas can be modified before being added to the next delta packet. RDBMSResolver.fieldInfo Availability Flash Player 7. Edition Flash MX Professional 2004. Usage resolveData.
RDBMSResolver.reconcileResults Availability Flash Player 7. Edition Flash MX Professional 2004. Usage resolveData.reconcileResults(eventObject) Parameters Resolver event object; describes the event object used to compare two update packets. This event object should contain the following properties: eventObject Property Description target Object; the resolver broadcasting this event. type String; the name of the event. Returns Nothing.
Edition This method is not currently available; for more information, see Flash MX 2004 release notes. Usage resolveData.reconcileUpdates(eventObject) Parameters eventObject Resolver event object; describes the customizations to the XML packet before the update is sent through the connector to the database. This event object should contain the following properties: Property Description target Object; the resolver broadcasting this event. type String; the name of the event. Returns None.
Usage resolveData.tableName Description Property; a string that represents the table name in the XML for the database table to be updated. This property also determines which fields to send in the update packet. To make this determination, the RDBMSResolver component compares the value of this property with the value provided for the fieldInfo.ownerName property. If a field has no entry in the fieldInfo collection property, the field is placed in the update packet.
RDBMSResolver.updatePacket Availability Flash Player 7. Edition Flash MX Professional 2004. Usage resolveData.updatePacket Description Property; property of type XML, containing an XML packet used to bind to a connector property that transmits the translated update packet of changes back to the server so the source of the data can be updated. This is an XML document containing the packet of DataSet changes. RDBMSResolver.updateResults Availability Flash Player 7. Edition Flash MX Professional 2004.
CHAPTER 6 Components Dictionary RectBorder class The RectBorder class is used as the border of most components. A separate implementation of this class is provided by each theme, which has its own set of border styles and properties that it supports. You interact with the RectBorder class primarily by setting styles on other components.
Creating a custom RectBorder implementation The RectBorder class is used as a border skin in most version 2 components. The default implementations in both the Halo and Sample themes use ActionScript to draw the border. A custom implementation must use ActionScript to register itself as the RectBorder implementation and provide sizing functionality, but can use either ActionScript or graphic elements to represent the visuals.
// all of these borders have the same size edges, one pixel var offset:Number = 1; function init(Void):Void { super.init(); } function drawBorder(Void):Void { // the graphics are on the symbol's Timeline, // so all you need to do here is size the border _width = __width; _height = __height; } // register ourselves as the RectBorder for all components to use static function classConstruct():Boolean { UIObjectExtensions.Extensions(); _global.styles.rectBorderClass = RectBorder; _global.
14. Ensure that the graphics are flush against the upper left corner with x and y coordinates set to (0,0). Your custom drawBorder implementation will set the width and height according to the component requirements. 15. Click Back to return to the main Timeline. 16. Drag several components that use RectBorder to the Stage. For example, drag a List, TextArea, and TextInput component to the Stage. 17. Select Control > Test Movie.
CHAPTER 6 Components Dictionary Screen class (Flash Professional only) The Screen class is the base class for screens you create in the Screen Outline pane in Flash MX Professional 2004. Screens are high-level containers for creating applications and presentations. For an overview of working with screens, see Chapter 12, “Working with Screens (Flash Professional Only),” in Using Flash. The Screen class has two primary subclasses: Slide and Form.
For example, suppose you have a slide presentation in which three people are each contributing a single section. You could ask each presenter to create a separate slide presentation (SWF file). You would then create a “master slide presentation” that contains three placeholder slides, one for each slide presentation being created by the presenters. For each placeholder slide, you could point its contentPath property to one of the SWF files.
Referencing loaded screens with ActionScript The Loader class creates an internal movie clip named contentNode into which it loads the SWF or JPEG file specified by the contentPath property. This movie clip, in effect, adds an extra screen node between the “placeholder” slide (that you created in the “master” presentation above) and the first slide in the loaded slide presentation.
The methods, properties, and events of the Screen class allow you to create and manipulate screens at runtime. Method summary for the Screen class The following table lists the method of the Screen class. Method Description Screen.getChildScreen() Returns the child screen of this screen at a particular index. Methods inherited from the UIObject class The following table lists the methods the Screen class inherits from the UIObject class.
Methods inherited from the Loader class The following table lists the method the Screen class inherits from the Loader class. When calling this method from the Screen object, use the form ScreenInstance.methodName. Method Description Loader.load() Loads the content specified by the contentPath property. Property summary for the Screen class The following table lists properties of the Screen class. Property Description Screen.
Property Description UIObject.visible A Boolean value indicating whether the object is visible (true) or not (false). UIObject.width The width of the object, in pixels. Read-only. UIObject.x The left edge of the object, in pixels. Read-only. UIObject.y The top edge of the object, in pixels. Read-only. Properties inherited from the UIComponent class The following table lists the properties the Screen class inherits from the UIComponent class.
Event summary for the Screen class The following table lists events of the Screen class. Event Description Screen.allTransitionsInDone Broadcast when all “in” transitions applied to a screen have finished. Screen.allTransitionsOutDone Broadcast when all “out” transitions applied to a screen have finished. Screen.mouseDown Broadcast when the mouse button was pressed over an object (shape or movie clip) directly owned by the screen. Screen.
Event Description UIComponent.keyDown Broadcast when a key is pressed. UIComponent.keyUp Broadcast when a key is released. Events inherited from the Loader class The following table lists the events the Screen class inherits from the Loader class. Event Description Loader.complete Triggered when the content finished loading. Loader.progress Triggered while content is loading. Screen.allTransitionsInDone Availability Flash Player 6 (6.0 79.0). Edition Flash MX Professional 2004.
Screen.allTransitionsOutDone Availability Flash Player 6 (6.0 79.0). Edition Flash MX Professional 2004. Usage on(allTransitionsOutDone) { // your code here } listenerObject = new Object(); listenerObject.allTransitionsOutDone = function(eventObject){ // insert your code here } screenObj.addEventListener("allTransitionsOutDone", listenerObject) Description Event; broadcast when all “out” transitions applied to the screen have finished.
screen2 subscreen1_2 If myUIButton has focus, the leafmost screen containing the focus is subscreen1_1, which is what currentFocusedScreen would return. In this case, presentation, screen1, and subscreen1_1 all contain the focus but the one that is “closest” (in the screen hierarchy) to the leaves of the tree (that is, farthest away from the root) is subscreen1_1. Example The following example displays the name of the currently focused screen in the Output panel. var currentFocus:mx.screens.Screen = mx.
Screen.indexInParent Availability Flash Player 6 (6.0 79.0). Edition Flash MX Professional 2004. Usage myScreen.indexInParent Description Property (read-only); contains the zero-based index of myScreen in its parent’s list of child screens. Example The following example displays the relative position of the screen myScreen in its parent screen’s list of child screens. var numChildren:Number = myScreen._parent.numChildScreens; var myIndex:Number = myScreen.
Example The following code displays the name of the screen that captured the mouse event in the Output panel. on(mouseDown) { trace("Mouse down event on: " + eventObj.target._name); } Screen.mouseDownSomewhere Availability Flash Player 6 (6.0 79.0). Edition Flash MX Professional 2004. Usage on(mouseDownSomewhere) { // your code here } listenerObject = new Object(); listenerObject.mouseDownSomewhere = function(eventObject){ // insert your code here } screenObj.
Description Event; broadcast when the mouse moves while over the screen. This event is sent only when the mouse is over the bounding box of this screen. When the event is triggered, it automatically passes an event object (eventObj) to the handler. Each event object has properties that contain information about the event. You can use these properties to write code that handles the event. For more information, see “EventDispatcher class” on page 415.
// your code here } listenerObject = new Object(); listenerObject.mouseOver = function(eventObject){ // insert your code here } screenObj.addEventListener("mouseOver", listenerObject) Description Event; broadcast when the mouse moves from outside the screen’s bounding box to inside its bounding box. When the event is triggered, it automatically passes an event object (eventObj) to the handler. Each event object has properties that contain information about the event.
Screen.mouseUpSomewhere Availability Flash Player 6 (6.0 79.0). Edition Flash MX Professional 2004. Usage on(mouseUpSomewhere) { // your code here } listenerObject = new Object(); listenerObject.mouseUpSomewhere = function(eventObject){ // insert your code here } screenObj.addEventListener("mouseUpSomewhere", listenerObject) Description Event; broadcast when the mouse button is released, but not necessarily over the specified screen.
See also Screen.getChildScreen() Screen.parentIsScreen Availability Flash Player 6 (6.0 79.0). Edition Flash MX Professional 2004. Usage myScreen.parentIsScreen Description Property (read-only): returns a Boolean value indicating whether the specified screen’s parent object is also a screen (true) or not (false). If this property is false, myScreen is at the root of its screen hierarchy. Example The following code determines if the parent object of the screen myScreen is also a screen. If myScreen.
Example The following example displays the name of the screen that contains the screen myScreen. var myParent:mx.screens.Screen = myScreen.rootScreen; Screen.rootScreen Availability Flash Player 6 (6.0 79.0). Edition Flash MX Professional 2004. Usage myScreen.rootScreen Description Property (read-only); returns the screen at the top of the screen hierarchy that contains myScreen. Example The following example displays the name of the root screen that contains the screen myScreen. var myRoot:mx.
ScrollPane component CHAPTER 6 Components Dictionary The ScrollPane component displays movie clips, JPEG files, and SWF files in a scrollable area. By using a scroll pane, you can limit the amount of screen area occupied by these media types. The scroll pane can display content that is loaded from a local disk or from the Internet. You can set this content while authoring and at runtime by using ActionScript. Once the scroll pane has focus, if its content has valid tab stops, those markers receive focus.
contentPath indicates the content to load into the scroll pane. This value can be a relative path to a local SWF or JPEG file, or a relative or absolute path to a file on the Internet. It can also be the linkage identifier of a movie clip symbol in the library that is set to Export for ActionScript. hLineScrollSize indicates the number of units a horizontal scroll bar moves each time an arrow button is clicked. The default value is 5.
The first block of code is a scroll event handler on the myScrollPane instance that displays the value of the vPosition property in a TextField instance called txtPosition. The second block of code creates an event handler for the complete event that sends a message to the Output panel. Customizing the ScrollPane component You can transform a ScrollPane component horizontally and vertically while authoring and at runtime.
Using skins with the ScrollPane component The ScrollPane component uses an instance of RectBorder for its border and scroll bars for scroll assets. For more information about skinning these visual elements, see “RectBorder class” on page 647 and “Using skins with the UIScrollBar component” on page 831. ScrollPane class Inheritance MovieClip > UIObject class > UIComponent class > View > ScrollView > ScrollPane ActionScript Class Name mx.containers.
Methods inherited from the UIObject class The following table lists the methods the ScrollPane class inherits from the UIObject class. When calling these methods from the ScrollPane object, use the form ScrollPaneInstance.methodName. Method Description UIObject.createClassObject() Creates an object on the specified class. UIObject.createObject() Creates a subobject on an object. UIObject.destroyObject() Destroys a component instance. UIObject.
Method Description ScrollPane.hPosition The horizontal pixel position of the scroll pane’s horizontal scroll bar. ScrollPane.hScrollPolicy The status of the horizontal scroll bar. It can be always on ("on"), always off ("off"), or on when needed ("auto"). The default value is "auto". ScrollPane.scrollDrag Indicates whether scrolling occurs (true) or not (false) when a user drags on content within the scroll pane. The default value is false. ScrollPane.
Properties inherited from the UIComponent class The following table lists the properties the ScrollPane class inherits from the UIComponent class. When accessing these properties from the ScrollPane object, use the form ScrollPaneInstance.propertyName. Property Description UIComponent.enabled Indicates whether the component can receive focus and input. UIComponent.tabIndex A number indicating the tab order for a component in a document.
ScrollPane.complete Availability Flash Player 6 (6.0 79.0). Edition Flash MX 2004. Usage Usage 1: on(complete){ ... } Usage 2: listenerObject = new Object(); listenerObject.complete = function(eventObject){ ... } scrollPaneInstance.addEventListener("complete", listenerObject) Description Event; broadcast to all registered listeners when the content has finished loading. The first usage example uses an on() handler and must be attached directly to a ScrollPane instance.
Example The following example creates a listener object with a complete event handler for the scrollPane instance: form.complete = function(eventObj){ // insert code to handle the event } scrollPane.addEventListener("complete",form); ScrollPane.content Availability Flash Player 6 (6.0 79.0). Edition Flash MX 2004. Usage scrollPaneInstance.content Description Property (read-only); a reference to the content of the scroll pane. The value is undefined until the load begins.
If you load content using a relative URL, the loaded content must be relative to the location of the SWF file that contains the scroll pane. For example, an application using a ScrollPane component that resides in the directory /scrollpane/nav/example.swf could load contents from the directory /scrollpane/content/flash/logo.swf by using the following contentPath property: "../content/flash/logo.
loadListener.progress = function(eventObj){ // eventObj.target is the component that generated the change event var bytesLoaded = scrollPane.getBytesLoaded(); var bytesTotal = scrollPane.getBytesTotal(); var percentComplete = Math.floor(bytesLoaded/bytesTotal); if (percentComplete < 5) // loading begins { trace(" Starting loading contents from Internet"); } else if(percentComplete = 50) // 50% complete { trace(" 50% contents downloaded "); } } scrollPane.
Usage scrollPaneInstance.hLineScrollSize Description Property; the number of pixels to move the content when an arrow in the horizontal scroll bar is clicked. The default value is 5. Example This example increases the horizontal scroll unit to 10: scrollPane.hLineScrollSize = 10; ScrollPane.hPageScrollSize Availability Flash Player 6 (6.0 79.0). Edition Flash MX 2004. Usage scrollPaneInstance.
Example This example positions the scroll bar at pixel 20: scrollPane.hPosition = 20; ScrollPane.hScrollPolicy Availability Flash Player 6 (6.0 79.0). Edition Flash MX 2004. Usage scrollPaneInstance.hScrollPolicy Description Property; determines whether the horizontal scroll bar is always present ("on"), is never present ("off"), or appears automatically according to the size of the image ("auto"). The default value is "auto". Example The following code turns scroll bars on all the time: scrollPane.
Description Event; broadcast to all registered listeners while content is loading. The progress event is not always broadcast; the complete event may be broadcast without any progress events being dispatched. This can happen especially if the loaded content is a local file. Your application triggers the progress event when the content starts loading by setting the value of the contentPath property. The first usage example uses an on() handler and must be attached directly to a ScrollPane instance.
ScrollPane.refreshPane() Availability Flash Player 6 (6.0 79.0). Edition Flash MX 2004. Usage scrollPaneInstance.refreshPane() Parameters None. Returns Nothing. Description Method; refreshes the scroll pane after content is loaded. This method reloads the content. You could use this method if, for example, you’ve loaded a form into a scroll pane and an input property (for example, a text field) has been changed by ActionScript.
Event object In addition to the standard event object properties, there are two additional properties defined for the scroll event: a type property whose value is "scroll", and a direction property whose value can be "vertical" or "horizontal". In addition to the standard event object properties, there are two additional properties defined for the ProgressBar.progress event: current (the loaded value equals total), and total (the total value).
ScrollPane.scrollDrag Availability Flash Player 6 (6.0 79.0). Edition Flash MX 2004. Usage scrollPaneInstance.scrollDrag Description Property; a Boolean value that indicates whether scrolling occurs (true) or not (false) when a user drags within the scroll pane. The default value is false. Example This example causes the content to scroll when the user drags within the scroll pane: scrollPane.scrollDrag = true; ScrollPane.vLineScrollSize Availability Flash Player 6 (6.0 79.0). Edition Flash MX 2004.
Usage scrollPaneInstance.vPageScrollSize Description Property; the number of pixels to move the content in the display area when the user clicks the track in a vertical scroll bar. The default value is 20. Example This code causes the content in the display area to move 30 pixels when the vertical scroll track is clicked: scrollPane.vPageScrollSize = 30; ScrollPane.vPosition Availability Flash Player 6 (6.0 79.0). Edition Flash MX 2004. Usage scrollPaneInstance.
CHAPTER 6 Components Dictionary SimpleButton class Inheritance MovieClip > UIObject class > UIComponent class > SimpleButton ActionScript Class Name mx.controls.
Property summary for the SimpleButton class The following table lists properties of the SimpleButton class. Property Description SimpleButton.emphasized Indicates whether a button has the appearance of a default push button. SimpleButton.emphasizedStyleDeclaration The style declaration when the emphasized property is set to true. SimpleButton.selected A Boolean value indicating whether the button is selected (true) or not (false). The default value is false. SimpleButton.
Properties inherited from the UIComponent class The following table lists the properties the SimpleButton class inherits from the UIComponent class. When accessing these properties from the SimpleButton object, use the form buttonInstance.propertyName. Property Description UIComponent.enabled Indicates whether the component can receive focus and input. UIComponent.tabIndex A number indicating the tab order for a component in a document.
SimpleButton.click Availability Flash Player 6 (6.0 79.0). Edition Flash MX 2004. Usage Usage 1: on(click){ ... } Usage 2: listenerObject = new Object(); listenerObject.click = function(eventObject){ ... } buttonInstance.addEventListener("click", listenerObject) Description Event; broadcast to all registered listeners when the mouse is clicked (released) over the button or if the button has focus and the Spacebar is pressed.
The second usage example uses a dispatcher/listener event model. A component instance (buttonInstance) dispatches an event (in this case, click) and the event is handled by a function, also called a handler, on a listener object (listenerObject) that you create. You define a method with the same name as the event on the listener object; the method is called when the event occurs. When the event occurs, it automatically passes an event object (eventObject) to the listener object method.
Description Property; indicates whether the button is in an emphasized state (true) or not (false). The emphasized state is equivalent to the appearance of a default push button. In general, use the FocusManager.defaultPushButton property instead of setting the emphasized property directly. The default value is false. If you aren’t using FocusManager.defaultPushButton, you might just want to set a button to the emphasized state, or use the emphasized state to change text from one color to another.
Usage buttonInstance.selected Description Property; a Boolean value that indicates whether the button is selected (true) or not (false). The default value is false. SimpleButton.toggle Availability Flash Player 6 (6.0 79.0). Edition Flash MX 2004. Usage buttonInstance.toggle Description Property; a Boolean value that indicates whether the button acts as a toggle switch (true) or not (false). The default value is false.
Slide class (Flash Professional only) CHAPTER 6 Components Dictionary The Slide class corresponds to a node in a hierarchical slide presentation. In Flash MX Professional 2004, you can create slide presentations using the Screen Outline pane. For an overview of working with screens, see Chapter 12, “Working with Screens (Flash Professional Only),” in Using Flash.
You can also use the built-in behaviors that are available in the Behaviors panel to control slide presentations. For more information, see “Adding controls to screens using behaviors (Flash Professional only)” in Using Flash. Slide parameters You can set the following authoring parameters for each slide in the Property inspector or in the Component inspector: autoKeyNav determines how, or if, the slide responds to the default keyboard navigation. For more information, see Slide.autoKeyNav.
6. Select the Presentation slide and open the Components panel. 7. Drag a Button component from the Components panel to the bottom of the Stage. 8. In the Property inspector, type Next Slide for the Button component’s Label property. 9. In the Actions panel, type the following code: on(click) { _parent.currentSlide.gotoNextSlide(); } 10. Test the SWF file (Control > Test Movie) and click the Next Slide button to advance to the next slide.
Method Description UIObject.invalidate() Marks the object so it will be redrawn on the next frame interval. UIObject.move() Moves the object to the requested position. UIObject.redraw() Forces validation of the object so it is drawn in the current frame. UIObject.setSize() Resizes the object to the requested size. UIObject.setSkin() Sets a skin in the object. UIObject.setStyle() Sets the style property on the style declaration or object.
Property Description Slide.currentSlide Read-only; returns the currently active slide. Slide.defaultKeydownHandler Callback handler that overrides the default keyboard navigation (Left and Right Arrow keys). Slide.firstSlide Read-only; returns the slide’s first child slide that has no children. Slide.indexInParentSlide Read-only; returns the slide’s index (zero-based) in its parent’s list of subslides. Slide.lastSlide Read-only; returns the slide’s last child slide that has no children. Slide.
Property Description UIObject.visible A Boolean value indicating whether the object is visible (true) or not (false). UIObject.width The width of the object, in pixels. Read-only. UIObject.x The left edge of the object, in pixels. Read-only. UIObject.y The top edge of the object, in pixels. Read-only. Properties inherited from the UIComponent class The following table lists the properties the Slide class inherits from the UIComponent class.
Properties inherited from the Screen class The following table lists the properties the Slide class inherits from the Screen class. When accessing these properties from the Slide object, use the form SlideInstance.propertyName. Property Description Screen.currentFocusedScreen Read-only; returns the screen that contains the global current focus. Screen.indexInParent Read-only; returns the screen’s index (zero-based) in its parent screen’s list of child screens. Screen.
Events inherited from the UIComponent class The following table lists the events the Slide class inherits from the UIComponent class. Event Description UIComponent.focusIn Broadcast when an object receives focus. UIComponent.focusOut Broadcast when an object loses focus. UIComponent.keyDown Broadcast when a key is pressed. UIComponent.keyUp Broadcast when a key is released. Events inherited from the Loader class The following table lists the events the Slide class inherits from the Loader class.
Slide.autoKeyNav Availability Flash Player 6 (6.0 79.0). Edition Flash MX Professional 2004. Usage mySlide.autoKeyNav Description Property; determines whether the slide uses default keyboard handling to navigate to the next/ previous slide when mySlide has focus. This property accepts the string values "true", "false", and "inherit". You can override this default keyboard handling behavior by using the Slide.defaultKeydownHandler property.
Description Property (read-only); returns the immediate child of mySlide that contains the currently active slide; returns null if no child slide contained by mySlide has the current focus. Example Consider the following screen outline: Presentation Slide_1 Bullet1_1 SubBullet1_1_1 Bullet1_2 SubBullet1_2_1 Slide_2 Assuming that SubBullet1_1_1 is the current slide, then the following statements are all true: Presentation.currentChildSlide == Slide_1; Slide_1.
Slide.currentSlide Availability Flash Player 6 (6.0 79.0). Edition Flash MX Professional 2004. Usage mySlide.currentSlide Description Property (read-only); returns the currently active slide. This is always a “leaf ” slide—that is, a slide that contains no child slides. Example The following code, attached to a button on the root presentation slide, advances the slide presentation to the next slide each time the button is clicked.
• shiftKey A Boolean value indicating if the Shift key is currently being pressed (true) or not (false). • A Boolean value indicating if the Control key is currently being pressed (true) or not (false). ctrlKey Returns Nothing. Description Callback handler; lets you override the default keyboard navigation with a custom keyboard handler that you create.
Description Property (read-only); returns the first child slide of mySlide that has no child slides. Example In the hierarchy of slides shown below, the following statements are both true: Presentation.Intro.firstSlide == Intro_bullet_1_1; Presentation.Intro_bullet_1.firstSlide == Intro_bullet_1-1; Slide.getChildSlide() Availability Flash Player 6 (6.0 79.0). Edition Flash MX Professional 2004. Usage mySlide.
Example The following code causes the Output panel to display the names of all the child slides of the root presentation slide. var numSlides = _root.Presentation.numChildSlides; for(var slideIndex=0; slideIndex < numSlides; slideIndex++) { var childSlide = _root.Presentation.getChildSlide(slideIndex); trace(childSlide._name); } See also Slide.numChildSlides Slide.gotoFirstSlide() Availability Flash Player 6 (6.0 79.0). Edition Flash MX Professional 2004. Usage mySlide.gotoFirstSlide() Parameters None.
This method call would navigate to the slide named Intro_bullet_2_1: Presentation.Intro.Intro_bullet_2.gotoFirstSlide(); See also Slide.firstSlide, Slide.revealChild Slide.gotoLastSlide() Availability Flash Player 6 (6.0 79.0). Edition Flash MX Professional 2004. Usage mySlide.gotoLastSlide() Parameters None. Returns Nothing. Description Method; navigates to the last leaf slide in the tree of child slides beneath mySlide.
Example In the slide hierarchy illustrated below, the following method calls would navigate to the slide named Intro_bullet_1_2: Presentation.Intro.gotoLastSlide(); Presentation.Intro.Intro_bullet_1.gotoLastSlide(); These method calls would navigate to the slide named Intro_bullet_2_1: Presentation.gotoLastSlide(); Presentation.Intro.gotoLastSlide(); See also Slide.gotoSlide(), Slide.lastSlide Slide.gotoNextSlide() Availability Flash Player 6 (6.0 79.0). Edition Flash MX Professional 2004.
Description Method; navigates to the next slide in the slide presentation. As control passes from one slide to the next, the outgoing slide is hidden and the incoming slide is revealed. If the outgoing and incoming slides are in different slide subtrees, then all ancestor slides, starting with the outgoing slide and up to the common ancestor of the incoming and outgoing slides, are hidden and receive a hide event.
Also, still assuming that the current slide is Intro_bullet_1_1, calling Results.gotoNextSlide() would have no effect, because Results does not contain the current slide (that is, Results.currentSlide is null). See also Slide.currentSlide, Slide.gotoPreviousSlide(), Slide.nextSlide Slide.gotoPreviousSlide() Availability Flash Player 6 (6.0 79.0). Edition Flash MX Professional 2004. Usage mySlide.gotoPreviousSlide() Parameters None. Returns A Boolean value, or null.
Example Suppose that, in the following slide hierarchy, the slide named Intro_bullet_1_2 is the current slide being viewed (that is, _root.Presentation.currentSlide._name == Intro_bullet_1_2). In this case, calling Intro_bullet_1_2.gotoPreviousSlide() would navigate to which is the previous sibling slide of Intro_bullet_1_2. Intro_bullet_1_1, However, calling Intro_bullet_2.
Usage mySlide.gotoSlide(newSlide) Parameters newSlide The slide to navigate to. Returns A Boolean value indicating if the navigation succeeded (true) or not (false). Description Method; navigates to the slide specified by newSlide. For the navigation to succeed, the following must be true: • The current slide must be a child slide of mySlide.
on(click) { _parent.gotoSlide(_parent.currentSlide.nextSlide); } This is equivalent to the following code, which uses the Slide.gotoNextSlide() method: on(click) { _parent.currentSlide.gotoNextSlide(); } See also Slide.currentSlide, Slide.gotoNextSlide() Slide.hideChild Availability Flash Player 6 (6.0 79.0). Edition Flash MX Professional 2004. Usage on(hideChild) { // your code here } Description Event; broadcast each time a child of a slide changes from visible to invisible.
Slide.indexInParentSlide Availability Flash Player 6 (6.0 79.0). Edition Flash MX Professional 2004. Usage mySlide.indexInParent Description Property (read-only); returns the zero-based index of mySlide in its parent’s list of child slides. Example The following code uses the indexInParentSlide and Slide.numChildSlides properties to display the index of the current slide being viewed and the total number of slides contained by its parent slide.
Intro_bullet_1.lastSlide._name == Intro_bullet_1_2; Results.lastSlide._name = Results_bullet_1; Slide.nextSlide Availability Flash Player 6 (6.0 79.0). Edition Flash MX Professional 2004. Usage mySlide.nextSlide Description Property (read-only); returns the slide you would reach if you called mySlide.gotoNextSlide(), but does not actually navigate to that slide.
nextButton.label = "End of this slide presentation."; } See also Slide.gotoNextSlide(), Slide.previousSlide Slide.numChildSlides Availability Flash Player 6 (6.0 79.0). Edition Flash MX Professional 2004. Usage mySlide.numChildSlides Description Property (read-only); returns the number of child slides that mySlide contains. A slide can contain either forms or other slides; if mySlide contains both slides and forms, this property only returns the number of slides, and does not count forms.
Description Property; determines whether child slides of mySlide remain visible when navigating from one child slide to the next. When this property is true, the previous slide remains visible when control passes to its next sibling slide; when this property is false, the previous slide is invisible when control passes to its next sibling slide.
If mySlide is the root slide in a presentation, this property returns false, because the presentation slide’s parent is the main Timeline (_level0), not a slide. This property also returns false if a form is the parent of mySlide. Example The following code determines whether the parent object of the slide mySlide is itself a slide. If mySlide.parentIsSlide is true, the number of mySlide’s sibling slides is displayed in the Output panel.
Description Property (read-only); returns the slide you would reach if you called mySlide.gotoPreviousSlide(), but does not actually navigate to that slide. For example, you can use this property to display the name of the previous slide in a presentation and let users select whether they want to navigate to that slide. Example In this example, the label of a Button component named previousButton displays the name of the previous slide in the presentation.
See also Slide.hideChild Slide.rootSlide Availability Flash Player 6 (6.0 79.0). Edition Flash MX Professional 2004. Usage mySlide.rootSlide Description Property (read-only); returns the root slide of the slide tree, or slide subtree, that contains mySlide. Example Suppose you have a movie clip on a slide that, when clicked, goes to the first slide in the presentation. To accomplish this, you would attach the following code to the movie clip: on(press) { _parent.rootSlide.
CHAPTER 6 Components Dictionary StyleManager class ActionScript Class Name mx.styles.StyleManager The StyleManager class keeps track of known inheriting styles and colors. You only need to use this class if you are creating components and want to add a new inheriting style or color. To determine which styles are inheriting, see the W3C web site at www.w3.org/Style/CSS/. Method summary for the StyleManager class The following table lists methods of the StyleManager class.
StyleManager.registerColorStyle() Availability Flash Player 6 (6.0 79.0). Edition Flash MX 2004. Usage StyleManager.registerColorStyle(colorStyle) Parameters A string indicating the name of the color (for example, "highlightColor", and so on). colorStyle "shadowColor", "disabledColor", Returns Nothing. Description Method; adds a new color style to the Style Manager. Example The following example registers "highlightColor" as a color style: StyleManager.
When a style’s value is not inherited, you can set its style only on an instance, not on a custom or global style sheet. A style that doesn’t inherit its value is set on the class style sheet, and therefore, setting it on a custom or global style sheet does not work. Example The following example registers newProp1 as an inheriting style: StyleManager.
CHAPTER 6 Components Dictionary SystemManager class ActionScript Class Name mx.managers.SystemManager The SystemManager class works automatically with the FocusManager class to handle which toplevel window is activated in an application that contains version 2 components. It also provides a screen property that allows components to access Stage coordinates. Property summary for the SystemManager class The following table lists the property of the SystemManager class. Property Description SystemManager.
TextArea component CHAPTER 6 Components Dictionary The TextArea component wraps the native ActionScript TextField object. You can use styles to customize the TextArea component; when an instance is disabled, its contents display in a color represented by the disabledColor style. A TextArea component can also be formatted with HTML, or as a password field that disguises the text. See “Applying a style sheet to a TextArea component” in Using ActionScript in Flash.
editable indicates whether the TextArea component is editable (true) or not (false). The default value is true. wordWrap indicates whether the text wraps (true) or not (false). The default value is true. You can write ActionScript to control these and additional options for the TextArea component using its properties, methods, and events. For more information, see “TextArea class” on page 728.
Using styles with the TextArea component The TextArea component supports one set of component styles for all text in the field. However, you can also display HTML that is compatible with Flash Player HTML rendering. To display HTML text, set TextArea.html to true. The TextArea component has its backgroundColor and borderStyle style properties defined on a class style declaration.
Style Theme Description textAlign Both The text alignment: either "left", "right", or "center". The default value is "left". textIndent Both A number indicating the text indent. The default value is 0. textDecoration Both The text decoration: either "none" or "underline". The default value is "none". The TextArea and TextInput components use exactly the same styles and are often used in the same manner. Thus, by default they share the same class-level style declaration.
Each component class has a version property, which is a class property. Class properties are available only on the class itself. The version property returns a string that indicates the version of the component. To access this property, use the following code: trace(mx.controls.TextArea.version); Note: The code trace(myTextAreaInstance.version); returns undefined. Method summary for the TextArea class There are no methods exclusive to the TextArea class.
Property summary for the TextArea class The following table lists properties of the TextArea class. Property Description TextArea.editable A Boolean value indicating whether the field is editable (true) or not (false). TextArea.hPosition Defines the horizontal position of the text in the field. TextArea.hScrollPolicy Indicates whether the horizontal scroll bar is always on ("on"), is never on ("off"), or turns on when needed ("auto"). TextArea.
Property Description UIObject.scaleY A number indicating the scaling factor in the y direction of the object, relative to its parent. UIObject.top The position of the top edge of the object, relative to its parent. Read-only. UIObject.visible A Boolean value indicating whether the object is visible (true) or not (false). UIObject.width The width of the object, in pixels. Read-only. UIObject.x The left edge of the object, in pixels. Read-only. UIObject.y The top edge of the object, in pixels.
Events inherited from the UIComponent class The following table lists the events the TextArea class inherits from the UIComponent class. Event Description UIComponent.focusIn Broadcast when an object receives focus. UIComponent.focusOut Broadcast when an object loses focus. UIComponent.keyDown Broadcast when a key is pressed. UIComponent.keyUp Broadcast when a key is released. TextArea.change Availability Flash Player 6 (6.0 79.0). Edition Flash MX 2004. Usage Usage 1: on(change){ ...
The second usage example uses a dispatcher/listener event model. A component instance (textAreaInstance) dispatches an event (in this case, change) and the event is handled by a function, also called a handler, on a listener object (listenerObject) that you create. You define a method with the same name as the event on the listener object; the method is called when the event is triggered. When the event is triggered, it automatically passes an event object (eventObject) to the listener object method.
Description Property; a Boolean value that indicates whether the component is editable (true) or not (false). The default value is true. TextArea.hPosition Availability Flash Player 6 (6.0 79.0). Edition Flash MX 2004. Usage textAreaInstance.hPosition Description Property; defines the horizontal position of the text in the field. The default value is 0. Example The following code displays the leftmost characters in the field: myTextArea.hPosition = 0; TextArea.
TextArea.html Availability Flash Player 6 (6.0 79.0). Edition Flash MX 2004. Usage textAreaInstance.html Description Property; a Boolean value that indicates whether the text field is formatted with HTML (true) or not (false). If the html property is true, the text field is an HTML text field. If html is false, the text field is a non-HTML text field. The default value is false.
TextArea.maxChars Availability Flash Player 6 (6.0 79.0). Edition Flash MX 2004. Usage textAreaInstance.maxChars Description Property; the maximum number of characters that the text field can contain. A script may insert more text than the maxChars property allows; the property indicates only how much text a user can enter. If the value of this property is null, there is no limit to the amount of text a user can enter. The default value is null.
TextArea.maxVPosition Availability Flash Player 6 (6.0 79.0). Edition Flash MX 2004. Usage textAreaInstance.maxVPosition Description Property (read-only); indicates the maximum value of TextArea.vPosition. The default value is 0. Example The following code causes the text to scroll to the bottom of the component: myTextArea.vPosition = myTextArea.maxVPosition; See also TextArea.hPosition TextArea.password Availability Flash Player 6 (6.0 79.0). Edition Flash MX 2004. Usage textAreaInstance.
TextArea.restrict Availability Flash Player 6 (6.0 79.0). Edition Flash MX 2004. Usage textAreaInstance.restrict Description Property; indicates the set of characters that users can enter in the text field. The default value is undefined. If this property is null, users can enter any character. If this property is an empty string, no characters can be entered. If this property is a string of characters, users can enter only characters in the string; the string is scanned from left to right.
The style sheet associated with a TextArea component may be changed at any time. If the style sheet in use is changed, the TextArea component is redrawn with the new style sheet. The style sheet may be set to null or undefined to remove the style sheet. If the style sheet in use is removed, the TextArea component is redrawn without a style sheet. The formatting done by a style sheet is not retained if the style sheet is removed.
Usage textAreaInstance.text Description Property; the text contents of a TextArea component. The default value is "" (an empty string). Example The following code places a string in the myTextArea instance, and then traces that string to the Output panel: myTextArea.text = "The Royal Nonesuch"; trace(myTextArea.text); // traces "The Royal Nonesuch" TextArea.vPosition Availability Flash Player 6 (6.0 79.0). Edition Flash MX 2004. Usage textAreaInstance.
Example The following code turns vertical scroll bars off all the time: text.vScrollPolicy = "off"; TextArea.wordWrap Availability Flash Player 6 (6.0 79.0). Edition Flash MX 2004. Usage textAreaInstance.wordWrap Description Property; a Boolean value that indicates whether the text wraps (true) or not (false). The default value is true.
TextInput component CHAPTER 6 Components Dictionary The TextInput component is a single-line text component that is a wrapper for the native ActionScript TextField object. You can use styles to customize the TextInput component; when an instance is disabled, its contents appear in a color represented by the disabledColor style. A TextInput component can also be formatted with HTML, or as a password field that disguises the text. A TextInput component can be enabled or disabled in an application.
You can write ActionScript to control these and additional options for the TextInput component using its properties, methods, and events. For more information, see “TextInput class” on page 745. Creating an application with the TextInput component The following procedure explains how to add a TextInput component to an application while authoring. In this example, the component is a password field with an event listener that determines if the proper number of characters has been entered.
Using styles with the TextInput component The TextInput component has its backgroundColor and borderStyle style properties defined on a class style declaration. Class styles override global styles; therefore, if you want to set the backgroundColor and borderStyle style properties, you must create a different custom style declaration or define it on the instance. A TextInput component supports the following styles: Style Theme Description The background color. The default color is white.
The TextArea and TextInput components both use the same styles and are often used in the same manner. Thus, by default they share the same class-level style declaration. For example, the following code sets a style on the TextArea declaration but it affects both TextArea and TextInput components. _global.styles.TextArea.setStyle("disabledColor", 0xBBBBFF); To separate the components and provide class-level styles for one and not the other, create a new style declaration. import mx.styles.
Method summary for the TextInput class There are no methods exclusive to the TextInput class. Methods inherited from the UIObject class The following table lists the methods the TextInput class inherits from the UIObject class. When calling these methods from the TextInput object, use the form TextInputInstance.methodName. Method Description UIObject.createClassObject() Creates an object on the specified class. UIObject.createObject() Creates a subobject on an object. UIObject.
Property Description TextInput.length The number of characters in a TextInput component. This property is read-only. TextInput.maxChars The maximum number of characters that a user can enter in the text field. TextInput.maxHPosition The maximum possible value for TextField.hPosition. This property is read-only. TextInput.password A Boolean value that indicates whether the text field is a password field that hides the entered characters. TextInput.
Properties inherited from the UIComponent class The following table lists the properties the TextInput class inherits from the UIComponent class. When accessing these properties from the TextInput object, use the form TextInputInstance.propertyName. Property Description UIComponent.enabled Indicates whether the component can receive focus and input. UIComponent.tabIndex A number indicating the tab order for a component in a document.
TextInput.change Availability Flash Player 6 (6.0 79.0). Edition Flash MX 2004. Usage Usage 1: on(change){ ... } Usage 2: listenerObject = new Object(); listenerObject.change = function(eventObject){ ... } textInputInstance.addEventListener("change", listenerObject) Description Event; notifies listeners that text has changed. This event is broadcast after the text has changed.
Example This example sets a flag in the application that indicates if contents in the TextInput field have changed: form.change = function(eventObj){ // note: eventObj.target refers to the component that generated the change // event, i.e., the TextInput component. myFormChanged.visible = true; // set a change indicator if the contents changed; } myInput.addEventListener("change", form); See also EventDispatcher.addEventListener() TextInput.editable Availability Flash Player 6 (6.0 79.0).
} textInputInstance.addEventListener("enter", listenerObject) Description Event; notifies listeners that the Enter key has been pressed. The first usage example uses an on() handler and must be attached directly to a TextInput instance. The keyword this, used inside an on() handler attached to a component, refers to the component instance. For example, the following code, attached to the instance myTextInput, sends “_level0.
Usage textInputInstance.hPosition Description Property; defines the horizontal position of the text in the field. The default value is 0. Example The following code displays the leftmost character in the field: myTextInput.hPosition = 0; TextInput.length Availability Flash Player 6 (6.0 79.0). Edition Flash MX 2004. Usage inputInstance.length Description Property (read-only); a number that indicates the number of characters in a TextInput component.
Example The following example limits the number of characters a user can enter to 255: myTextInput.maxChars = 255; TextInput.maxHPosition Availability Flash Player 6 (6.0 79.0). Edition Flash MX 2004. Usage textInputInstance.maxHPosition Description Property (read-only); indicates the maximum value of TextInput.hPosition. The default value is 0. Example The following code scrolls to the far right: myTextInput.hPosition = myTextInput.maxHPosition; TextInput.password Availability Flash Player 6 (6.
TextInput.restrict Availability Flash Player 6 (6.0 79.0). Edition Flash MX 2004. Usage textInputInstance.restrict Description Property; indicates the set of characters that a user can enter in the text field. The default value is undefined. If this property is null or an empty string (""), a user can enter any character. If this property is a string of characters, the user can enter only characters in the string; the string is scanned from left to right. You can specify a range by using a dash (-).
The restrict property restricts only user interaction; a script may put any text into the text field. This property does not synchronize with the Embed Font Outlines check boxes in the Property inspector. Example In the following example, the first line of code limits the text field to uppercase letters, numbers, and spaces. The second line of code allows all characters except lowercase letters. my_txt.restrict = "A-Z 0-9"; my_txt.
CHAPTER 6 Components Dictionary TransferObject interface ActionScript Class Name mx.data.to.TransferObject The TransferObject interface defines a set of methods that items managed by the DataSet component must implement. The DataSet.itemClassName property specifies the name of the transfer object class that is instantiated each time a new item is needed. You can also specify this property for a selected DataSet component using the Property inspector.
Example The following function returns a copy of this transfer object with all of the properties set to the same values as the original: class itemClass implements mx.data.to.TransferObject { function clone():Object { var copy:itemClass = new itemClass(); for (var p in this) { copy[p]= this[p]; } return(copy); } } TransferObject.getPropertyData() Availability Flash Player 7. Edition Flash MX Professional 2004. Usage class itemClass implements mx.data.to.
TransferObject.setPropertyData() Availability Flash Player 7. Edition Flash MX 2004. Usage class yourClass implements TransferObject { function setPropertyData(propData) { // your code here } } Parameters propData An object that contains the data assigned to this transfer object. Returns Nothing. Description Method; sets the data for this transfer object. The propData parameter is an object whose fields contain the data assigned by the DataSet component to this transfer object.
Tree component (Flash Professional only) CHAPTER 6 Components Dictionary The Tree component allows a user to view hierarchical data. The tree appears in a box like the List component, but each item in a tree is called a node and can be either a leaf or a branch. By default, a leaf is represented by a text label beside a file icon, and a branch is represented by a text label beside a folder icon with an expander arrow (disclosure triangle) that a user can open to expose children.
The Tree component comprises two sets of APIs: the Tree class and the TreeDataProvider interface. The Tree class contains the visual configuration methods and properties. The TreeDataProvider interface lets you construct XML and add it to multiple tree instances. A TreeDataProvider object broadcasts changes to any trees that use it. In addition, any XML or XMLNode object that exists on the same frame as a tree or a menu is automatically given the TreeDataProvider methods and properties.
When a Tree displays a node, it uses the label attribute of the node by default as the text label. If any other attributes exist, they become additional properties of the node’s attributes within the tree. The actual root node is interpreted as the Tree component itself. This means that the first child (in the previous example, ), is rendered as the root node in the tree view. This means that a tree can have multiple root folders.
You cannot enter data parameters in the Property inspector or in the Component inspector for the Tree component as you can with other components. For more information, see “Using the Tree component (Flash Professional only)” on page 759 and “Creating an application with the Tree component” on page 762. Creating an application with the Tree component The following procedures show how to use a Tree component to display mailboxes in an e-mail application.
var node = menuTree.selectedItem; // If this is a branch, expand/collapse it if (menuTree.getIsBranch(node)) { menuTree.setIsOpen(node, !menuTree.getIsOpen(node), true); } // If this is a hyperlink, jump to it var url = node.attributes.url; if (url) { getURL(url, "_top"); } // Clear any selection menuTree.selectedNode = null; } } function onMenuLoaded() { menuTree.dataProvider = menuXML.firstChild; menuTree.addEventListener("change", this); } } This ActionScript sets up styles for the tree.
}; myTree.addEventListener("change", treeListener); This code creates an XML object called myTreeDP and calls the XML.load() method to load an XML data source. The code then defines an onLoad event handler that sets the dataProvider property of the myTree instance to the new XML object when the XML loads. For more information about the XML object, see its entry in Flash ActionScript Language Reference. 5. Create a new file called treeXML.xml in a text editor. 6.
This code creates an XML object called myTreeDP. Any XML object on the same frame as a Tree component automatically receives all the properties and methods of the TreeDataProvider interface. The second line of code creates a single root node called Local Folders. For detailed information about the rest of the code, see the comments (lines preceded with //) throughout the code. 5. Select Control > Test Movie. In the SWF file, you can see the XML structure displayed in the tree.
To use a well-formed string to create XML in Flash while authoring: 1. In Flash, select File > New and select Flash Document. 2. Drag an instance of the Tree component onto the Stage. 3. Select the Tree instance. In the Property inspector, enter the instance name myTree. 4. In the Actions panel on Frame 1, enter the following code: var myTreeDP:XML = new XML(""); myTree.
Style Theme Description border styles Both The Tree component uses a RectBorder instance as its border and responds to the styles defined on that class. See “RectBorder class” on page 647. The default border style is "inset". color Both The text color. disabledColor Both The color for text when the component is disabled. The default color is 0x848384 (dark gray). embedFonts Both A Boolean value that indicates whether the font specified in fontFamily is an embedded font.
Style Theme Description folderOpenIcon Both The icon displayed for an open folder node in a Tree component if no node-specific icon is set. The default value is "TreeFolderOpen", which is a yellow open file folder image. indentation Both The number of pixels to indent each row of a Tree component. The default value is 17. openDuration Both The duration, in milliseconds, of the expand and collapse animations. The default value is 250.
Style Theme Description textRollOverColor Both The color of text when the pointer rolls over it. The default value is 0x2B333C (dark gray). This style is important when you set rollOverColor, because the two must complement each other so that text is easily viewable during a rollover. textSelectedColor Both The color of text in the selected row. The default value is 0x005F33 (dark gray).
Tree class (Flash Professional only) Inheritance MovieClip > UIObject class > UIComponent class > View > ScrollView > ScrollSelectList > List component > Tree ActionScript Class Name mx.controls.Tree The methods, properties, and events of the Tree class allow you to manage and manipulate Tree objects. Method summary for the Tree class The following table lists methods of the Tree class. Method Description Tree.addTreeNode() Adds a node to a Tree instance. Tree.
Method Description UIObject.getStyle() Gets the style property from the style declaration or object. UIObject.invalidate() Marks the object so it will be redrawn on the next frame interval. UIObject.move() Moves the object to the requested position. UIObject.redraw() Forces validation of the object so it is drawn in the current frame. UIObject.setSize() Resizes the object to the requested size. UIObject.setSkin() Sets a skin in the object. UIObject.
Property summary for the Tree class The following table lists properties of the Tree class. Property Description Tree.dataProvider Specifies an XML data source. Tree.firstVisibleNode Specifies the first node at the top of the display. Tree.selectedNode Specifies the selected node in a Tree instance. Tree.selectedNodes Specifies the selected nodes in a Tree instance.
Properties inherited from the List class The following table lists the properties the Tree class inherits from the List class. When accessing these properties from the Tree object, use the form TreeInstance.propertyName. Property Description List.cellRenderer Assigns the class or symbol to use to display each row of the list. List.dataProvider The source of the list items. List.hPosition The horizontal position of the list. List.
Events inherited from the UIObject class The following table lists the events the Tree class inherits from the UIObject class. Event Description UIObject.draw Broadcast when an object is about to draw its graphics. UIObject.hide Broadcast when an object’s state changes from visible to invisible. UIObject.load Broadcast when subobjects are being created. UIObject.move Broadcast when the object has moved. UIObject.resize Broadcast when an object has been resized. UIObject.
Usage Usage 1: myTree.addTreeNode(label [, data]) Usage 2: myTree.addTreeNode(child) Parameters A string that displays the node, or an object with a label field (or whatever label field name is specified by the labelField property). label data An object of any type that is associated with the node. This parameter is optional. child Any XMLNode object. Returns The added XML node. Description Method; adds a child node to the tree.
Parameters The zero-based index position (among the child nodes) at which the node should be index added. A string that displays the node. label data An object of any type that is associated with the node. This parameter is optional. child Any XMLNode object. Returns The added XML node. Description Method; adds a node at the specified location in the tree.
Example The following example imports an XML file and assigns it to the myTree instance of the Tree component: myTreeDP = new XML(); myTreeDP.ignoreWhite = true; myTreeDP.load("http://myServer.myDomain.com/source.xml"); myTreeDP.onLoad = function(){ myTree.dataProvider = myTreeDP; } Note: Most XML files contain white space. To make Flash ignore white space, you must set the XML.ignoreWhite property to true. Tree.firstVisibleNode Availability Flash Player 6 (6.0 79.0). Edition Flash MX Professional 2004.
Parameters node An XMLNode object. Returns The index of the specified node, or undefined if the node is not currently displayed. Description Method; returns the display index of the node specified in the node parameter. The display index indicates the item’s position in the list of items that are visible in the tree window. For example, any children of a closed node are not in the display index. The list of display indices starts with 0 and proceeds through the visible items regardless of parent.
Tree.getIsOpen() Availability Flash Player 6 (6.0 79.0). Edition Flash MX Professional 2004. Usage myTree.getIsOpen(node) Parameters node An XMLNode object. Returns A Boolean value that indicates whether the tree is open (true) or closed (false). Description Method; indicates whether the specified node is open or closed. Note: Display indices change every time nodes open and close. Example The following code assigns the state of the node to a variable: var open = myTree.getIsOpen(myTree.
The display index is an array of items that can be viewed in the tree window. For example, any children of a closed node are not in the display index. The display index starts with 0 and proceeds through the visible items regardless of parent. In other words, the display index is the row number, starting with 0, of the displayed rows. Note: Display indices change every time nodes open and close. Example The following code gets a reference to the XML node that is the second row displayed in myTree: myTree.
} myTreeInstance.addEventListener("nodeClose", listenerObject) Description Event; broadcast to all registered listeners when the nodes of a Tree component are closed by a user. Version 2 components use a dispatcher/listener event model. The Tree component broadcasts a nodeClose event when one of its nodes is clicked closed; the event is handled by a function, also called a handler, that is attached to a listener object (listenerObject) that you create.
Version 2 components use a dispatcher/listener event model. The Tree component dispatches a nodeOpen event when a node is clicked open by a user; the event is handled by a function, also called a handler, that is attached to a listener object (listenerObject) that you create. You call the addEventListener() method and pass it the name of the handler as a parameter. When the event is triggered, it automatically passes an event object (eventObject) to the handler.
Tree.removeAll() Availability Flash Player 6 (6.0 79.0). Edition Flash MX Professional 2004. Usage myTree.removeAll() Parameters None. Returns Nothing. Description Method; removes all nodes and refreshes the tree. Example The following code empties myTree: myTree.removeAll(); Tree.removeTreeNodeAt() Availability Flash Player 6 (6.0 79.0). Edition Flash MX Professional 2004. Usage myTree.removeTreeNodeAt(index) Parameters The index number of a tree child.
Example The following code removes the fourth child of the root of the tree myTree: myTree.removeTreeNodeAt(3); Tree.selectedNode Availability Flash Player 6 (6.0 79.0). Edition Flash MX Professional 2004. Usage myTree.selectedNode Description Property; specifies the selected node in a tree instance. Example The following example specifies the first child node in myTree: myTree.selectedNode = myTree.getTreeNodeAt(0); See also Tree.selectedNodes Tree.selectedNodes Availability Flash Player 6 (6.0 79.
Tree.setIcon() Availability Flash Player 6 (6.0 79.0). Edition Flash MX Professional 2004. Usage myTree.setIcon(node, linkID [, linkID2]) Parameters node An XML node. linkID The linkage identifier of a symbol to be used as an icon beside the node. This parameter is used for leaf nodes and for the closed state of branch nodes. linkID2 For a branch node, the linkage identifier of a symbol to be used as an icon that represents the open state of the node. This parameter is optional. Returns Nothing.
Returns Nothing. Description Method; specifies whether the node has a folder icon and expander arrow and either has children or can have children. A node is automatically set as a branch when it has children; you only need to call setIsBranch() when you want to create an empty folder. You may want to create branches that don’t yet have children if, for example, you only want child nodes to load when a user opens a folder. Calling setIsBranch() refreshes any views.
CHAPTER 6 Components Dictionary TreeDataProvider interface (Flash Professional only) The TreeDataProvider interface is a set of properties and methods and does not need to be instantiated to be used. If a Tree class is packaged in a SWF file, all XML instances in the SWF file contain the TreeDataProvider interface. All nodes in a tree are XML objects that contain the TreeDataProvider interface. It’s best to use the TreeDataProvider methods to create XML for the Tree.
TreeDataProvider.addTreeNode() Availability Flash Player 6 (6.0 79.0). Edition Flash MX Professional 2004. Usage Usage 1: someNode.addTreeNode(label, data) Usage 2: someNode.addTreeNode(child) Parameters label data child A string that displays the node. An object of any type that is associated with the node. Any XMLNode object. Returns The added XML node. Description Method; adds a child node at the root of the tree.
TreeDataProvider.addTreeNodeAt() Availability Flash Player 6 (6.0 79.0). Edition Flash MX Professional 2004. Usage Usage 1: someNode.addTreeNodeAt(index, label, data) Usage 2: someNode.addTreeNodeAt(index, child) Parameters An integer that indicates the index position (among the child nodes) at which the node should be added. index label data child A string that displays the node. An object of any type that is associated with the node. Any XMLNode object. Returns The added XML node.
TreeDataProvider.attributes.data Availability Flash Player 6 (6.0 79.0). Edition Flash MX Professional 2004. Usage someNode.attributes.data Description Property; specifies the data to associate with the node. This adds the value as an attribute in the XMLNode object. Setting this property does not refresh any tree displays. This property can be of any data type. Example The following code locates the node to adjust and sets its data property: var myTreeNode = myTreeDP.firstChild.firstChild; myTreeNode.
TreeDataProvider.getTreeNodeAt() Availability Flash Player 6 (6.0 79.0). Edition Flash MX Professional 2004. Usage someNode.getTreeNodeAt(index) Parameters index An integer representing the position of the child node in the current node. Returns The specified node. Description Method; returns the specified child node of the node. Example The following code locates a node and then retrieves the second child of myTreeNode: var myTreeNode = myTreeDP.firstChild.firstChild; myTreeNode.
Example The following code removes a node: myTreeDP.firstChild.removeTreeNode(); TreeDataProvider.removeTreeNodeAt() Availability Flash Player 6 (6.0 79.0). Edition Flash MX Professional 2004. Usage someNode.removeTreeNodeAt(index) Parameters index An integer indicating the position of the node to be removed. Returns The removed XML node, or undefined if an error occurs.
CHAPTER 6 Components Dictionary UIComponent class The UIComponent class does not represent a visual component; it contains methods, properties, and events that allow Macromedia components to share some common behavior. All version 2 components extend UIComponent.
Method Description UIObject.doLater() Calls a function when parameters have been set in the Property and Component inspectors. UIObject.getStyle() Gets the style property from the style declaration or object. UIObject.invalidate() Marks the object so it will be redrawn on the next frame interval. UIObject.move() Moves the object to the requested position. UIObject.redraw() Forces validation of the object so it is drawn in the current frame. UIObject.
Property Description UIObject.x The left edge of the object, in pixels. Read-only. UIObject.y The top edge of the object, in pixels. Read-only. Event summary for the UIComponent class The following table lists events of the UIComponent class. Event Description UIComponent.focusIn Broadcast when an object receives focus. UIComponent.focusOut Broadcast when an object loses focus. UIComponent.keyDown Broadcast when a key is pressed. UIComponent.keyUp Broadcast when a key is released.
Example The following example sets the enabled property of a CheckBox component to false: checkBoxInstance.enabled = false; UIComponent.focusIn Availability Flash Player 6 (6.0 79.0). Edition Flash MX 2004. Usage Usage 1: on(focusIn){ ... } Usage 2: listenerObject = new Object(); listenerObject.focusIn = function(eventObject){ ... } componentInstance.addEventListener("focusIn", listenerObject) Description Event; notifies listeners that the object has received keyboard focus.
Example The following code disables a Button component, btn, while a user types in the TextInput component, txt, and enables the button when the user click on it: var txt:mx.controls.TextInput; var btn:mx.controls.Button; var txtListener:Object = new Object(); txtListener.focusOut = function() { _root.btn.enabled = true; } txt.addEventListener("focusOut", txtListener); var txtListener2:Object = new Object(); txtListener2.focusIn = function() { _root.btn.enabled = false; } txt.
The second usage example uses a dispatcher/listener event model. A component instance (componentInstance) dispatches an event (in this case, focusOut) and the event is handled by a function, also called a handler, on a listener object (listenerObject) that you create. You define a method with the same name as the event on the listener object; the method is called when the event is triggered. When the event is triggered, it automatically passes an event object (eventObject) to the listener object method.
Returns A reference to the object that currently has focus. Description Method; returns a reference to the object that has keyboard focus. Example The following code returns a reference to the object that has focus and assigns it to the tmp variable: var tmp = checkbox.getFocus(); UIComponent.keyDown Availability Flash Player 6 (6.0 79.0). Edition Flash MX 2004. Usage on(keyDown){ ... } listenerObject = new Object(); listenerObject.keyDown = function(eventObject){ ... } componentInstance.
Example The following code makes an icon blink when a key is pressed: formListener.handleEvent = function(eventObj) { form.icon.visible = !form.icon.visible; } form.addEventListener("keyDown", formListener); UIComponent.keyUp Availability Flash Player 6 (6.0 79.0). Edition Flash MX 2004. Usage on(keyUp){ ... } listenerObject = new Object(); listenerObject.keyUp = function(eventObject){ ... } componentInstance.
{ form.icon.visible = !form.icon.visible; } form.addEventListener("keyUp", formListener); UIComponent.setFocus() Availability Flash Player 6 (6.0 79.0). Edition Flash MX 2004. Usage componentInstance.setFocus(); Parameters None. Returns Nothing. Description Method; sets the focus to this component instance. The instance with focus receives all keyboard input. Example The following code gives focus to the checkbox instance: checkbox.setFocus(); UIComponent.tabIndex Availability Flash Player 6 (6.
CHAPTER 6 Components Dictionary UIEventDispatcher class ActionScript Class Name Inheritance mx.events.UIEventDispatcher EventDispatcher class > UIEventDispatcher The UIEventDispatcher class is mixed in to the UIComponent class and allows components to emit certain events. If you want an object that doesn’t inherit from UIComponent to dispatch certain events, you can use UIEventDispatcher. Method summary for the UIEventDispatcher class The following table lists the method of the UIEventDispatcher class.
UIEventDispatcher.keyDown Availability Flash Player 6 (6.0 79.0). Edition Flash MX Professional 2004. Usage listenerObject = new Object(); listenerObject.keyDown = function(eventObject){ // insert your code here } componentInstance.addEventListener("keyDown", listenerObject) Description Event; broadcast to all registered listeners when a key is pressed and the Flash application has focus. When the event is triggered, it automatically passes an event object (eventObject) to the handler.
UIEventDispatcher.load Availability Flash Player 6 (6.0 79.0). Edition Flash MX Professional 2004. Usage listenerObject = new Object(); listenerObject.load = function(eventObject){ // insert your code here } componentInstance.addEventListener("load", listenerObject) Description Event; broadcast to all registered listeners when a component is loaded into Flash Player. When the event is triggered, it automatically passes an event object (eventObject) to the handler.
UIEventDispatcher.mouseOut Availability Flash Player 6 (6.0 79.0). Edition Flash MX Professional 2004. Usage listenerObject = new Object(); listenerObject.mouseOut = function(eventObject){ // insert your code here } componentInstance.addEventListener("mouseOut", listenerObject) Description Event; broadcast to all registered listeners when a Flash application has focus and the mouse is moved off a component instance.
UIEventDispatcher.mouseUp Availability Flash Player 6 (6.0 79.0). Edition Flash MX Professional 2004. Usage listenerObject = new Object(); listenerObject.mouseUp = function(eventObject){ // insert your code here } componentInstance.addEventListener("mouseUp", listenerObject) Description Event; broadcast to all registered listeners when a Flash application has focus and the mouse is pressed and released. When the event is triggered, it automatically passes an event object (eventObject) to the handler.
UIEventDispatcher.unload Availability Flash Player 6 (6.0 79.0). Edition Flash MX Professional 2004. Usage listenerObject = new Object(); listenerObject.unload = function(eventObject){ // insert your code here } componentInstance.addEventListener("unload", listenerObject) Description Event; broadcast to all registered listeners when a component is unloaded from Flash Player. When the event is triggered, it automatically passes an event object (eventObject) to the handler.
CHAPTER 6 Components Dictionary UIObject class Inheritance MovieClip > UIObject ActionScript Class Name mx.core.UIObject UIObject is the base class for all version 2 components; it is not a visual component. The UIObject class wraps the ActionScript MovieClip object and contains functions and properties that allow version 2 components to share some common behavior. Wrapping the MovieClip class allows Macromedia to add new events and extend functionality in the future without breaking content.
Method Description UIObject.setSkin() Sets a skin in the object. UIObject.setStyle() Sets the style property on the style declaration or object. Property summary for the UIObject class The following table lists properties of the UIObject class. Property Description UIObject.bottom The position of the bottom edge of the object, relative to the bottom edge of its parent. Read-only. UIObject.height The height of the object, in pixels. Read-only. UIObject.
UIObject.bottom Availability Flash Player 6 (6.0 79.0). Edition Flash MX 2004. Usage componentInstance.bottom Description Property (read-only); a number indicating the bottom position of the object, in pixels, relative to its parent’s bottom. To set this property, call UIObject.move(). Example This example moves the check box so it aligns under the bottom edge of the list box: myCheckbox.move(myCheckbox.x, form.height - listbox.bottom); UIObject.createClassObject() Availability Flash Player 6 (6.0 79.
Example The following code imports the assets of the Button component and then makes a subobject of the Button component. import mx.controls.Button; createClassObject(Button,"button2",5,{label:"Test Button"}); The following example creates a CheckBox object: import mx.controls.CheckBox; form.createClassObject(CheckBox, "cb", 0, {label:"Check this"}); You can also specify the class package name using the following syntax: createClassObject(mx.controls.Button,"button2",5,{label:"Test Button"}); UIObject.
UIObject.destroyObject() Availability Flash Player 6 (6.0 79.0). Edition Flash MX 2004. Usage componentInstance.destroyObject(instanceName) Parameters instanceName A string indicating the instance name of the object to be destroyed. Returns Nothing. Description Method; destroys a component instance. UIObject.doLater() Availability Flash Player 6 (6.0 79.0). Edition Flash MX 2004. Usage componentInstance.
Although properties that are set in a class or a frame script are available immediately, most properties assigned in the Property inspector or Component inspector are not set until the next frame within the component itself. Although any approach that delays access of the property will resolve this problem, the simplest and most direct solution is to use the doLater() method. Example The following example shows how the doLater() method is used: // doLater() is called from the component instance myCheckBox.
The second usage example uses a dispatcher/listener event model. A component instance (componentInstance) dispatches an event (in this case, draw) and the event is handled by a function, also called a handler, on a listener object (listenerObject) that you create. You define a method with the same name as the event on the listener object; the method is called when the event is triggered. When the event is triggered, it automatically passes an event object (eventObject) to the listener object method.
Example The following code sets the ib instance’s fontWeight style property to bold if the cb instance’s fontWeight style property is bold: if (cb.getStyle("fontWeight") == "bold") { ib.setStyle("fontWeight", "bold"); }; UIObject.height Availability Flash Player 6 (6.0 79.0). Edition Flash MX 2004. Usage componentInstance.height Description Property (read-only); a number indicating the height of the object, in pixels. To change the height property, call UIObject.setSize().
Example The following handler displays a message in the Output panel when the object it’s attached to becomes invisible. on(hide) { trace("I’ve become invisible."); } See also UIObject.reveal UIObject.invalidate() Availability Flash Player 6 (6.0 79.0). Edition Flash MX 2004. Usage componentInstance.invalidate() Parameters None. Returns Nothing. Description Method; marks the object so it will be redrawn on the next frame interval.
UIObject.left Availability Flash Player 6 (6.0 79.0). Edition Flash MX 2004. Usage componentInstance.left Description Property (read-only); a number indicating the left edge of the object, in pixels, relative to its parent. To set this property, call UIObject.move(). UIObject.load Availability Flash Player 6 (6.0 79.0). Edition Flash MX 2004. Usage Usage 1: on(load){ ... } Usage 2: listenerObject = new Object(); listenerObject.load = function(eventObject){ ... } componentInstance.
The second usage example uses a dispatcher/listener event model. A component instance (componentInstance) dispatches an event (in this case, load) and the event is handled by a function, also called a handler, on a listener object (listenerObject) that you create. You define a method with the same name as the event on the listener object; the method is called when the event is triggered. When the event is triggered, it automatically passes an event object (eventObject) to the listener object method.
The second usage example uses a dispatcher/listener event model. A component instance (componentInstance) dispatches an event (in this case, move) and the event is handled by a function, also called a handler, on a listener object (listenerObject) that you create. You define a method with the same name as the event on the listener object; the method is called when the event is triggered. When the event is triggered, it automatically passes an event object (eventObject) to the listener object method.
UIObject.redraw() Availability Flash Player 6 (6.0 79.0). Edition Flash MX 2004. Usage componentInstance.redraw(always) Parameters A Boolean value. If true, the method draws the object, even if invalidate() wasn’t called. If false, the method draws the object only if invalidate() was called. always Returns Nothing. Description Method; forces validation of the object so that it is drawn in the current frame.
Description Event; notifies listeners that an object has been resized. The first usage example uses an on() handler and must be attached directly to a component instance. The second usage example uses a dispatcher/listener event model. A component instance (componentInstance) dispatches an event (in this case, resize) and the event is handled by a function, also called a handler, on a listener object (listenerObject) that you create.
Example The following handler displays a message in the Output panel when the object it’s attached to becomes visible. on(reveal) { trace("I’ve become visible."); } See also UIObject.hide UIObject.right Availability Flash Player 6 (6.0 79.0). Edition Flash MX 2004. Usage componentInstance.right Description Property (read-only); a number indicating the right edge of the object, in pixels, relative to its parent’s right edge. To set this property, call UIObject.move().
Example The following example makes the check box twice as wide and sets the tmp variable to the horizontal scale factor: checkbox.scaleX = 200; var tmp = checkbox.scaleX; UIObject.scaleY Availability Flash Player 6 (6.0 79.0). Edition Flash MX 2004. Usage componentInstance.scaleY Description Property; a number indicating the scaling factor in the y direction of the object, relative to its parent.
Description Method; resizes the object to the requested size. You should pass only integral values to UIObject.setSize(), or the component may appear fuzzy. This method (like all methods and properties of UIObject) is available from any component instance. When you call this method on a ComboBox instance, the combo box is resized and the rowHeight property of the contained list is also changed. Example This example resizes the pBar component instance to 100 pixels wide and 100 pixels high: pBar.
var themeShape:String = "circle_skin" function Shape(){ } function init(Void):Void{ super.init(); } function createChildren():Void{ setSkin(1, themeShape); super.createChildren(); } } UIObject.setStyle() Availability Flash Player 6 (6.0 79.0). Edition Flash MX 2004. Usage componentInstance.setStyle(propertyName, value) Parameters propertyName "borderStyle", value A string indicating the name of the style property (for example, "fontWeight", and so on). The value of the property.
UIObject.top Availability Flash Player 6 (6.0 79.0). Edition Flash MX 2004. Usage componentInstance.top Description Property (read-only); a number indicating the top edge of the object, in pixels, relative to its parent. To set this property, call UIObject.move(). UIObject.unload Availability Flash Player 6 (6.0 79.0). Edition Flash MX 2004. Usage Usage 1: on(unload){ ... } Usage 2: listenerObject = new Object(); listenerObject.unload = function(eventObject){ ... } componentInstance.
The second usage example uses a dispatcher/listener event model. A component instance (componentInstance) dispatches an event (in this case, unload) and the event is handled by a function, also called a handler, on a listener object (listenerObject) that you create. You define a method with the same name as the event on the listener object; the method is called when the event is triggered. When the event is triggered, it automatically passes an event object (eventObject) to the listener object method.
Description Property (read-only); a number indicating the width of the object, in pixels. To change the width, call UIObject.setSize(). Example The following example makes the check box wider: myCheckbox.setSize(myCheckbox.width + 10, myCheckbox.height); UIObject.x Availability Flash Player 6 (6.0 79.0). Edition Flash MX 2004. Usage componentInstance.x Description Property (read-only); a number indicating the left edge of the object, in pixels. To set this property, call UIObject.move().
UIScrollBar component CHAPTER 6 Components Dictionary The UIScrollBar component allows you to add a scroll bar to a text field. You can add a scroll bar to a text field while authoring, or at runtime with ActionScript. The UIScrollBar component functions like any other scroll bar. It contains arrow buttons at either end and a scroll track and scroll box (thumb) in between. It can be attached to any edge of a text field and used both vertically and horizontally.
3. Verify that object snapping is turned on (View > Snapping > Snap to Objects). 4. Drag a UIScrollBar instance from the Components panel onto the text input field near the side you want to attach it to. The component must overlap with the text field when you release the mouse in order for it to be properly bound to the field. The _targetInstanceName property of the component is automatically populated with the text field instance name in the Property and Component inspectors. 5.
Note, however, that with the Halo theme, the width of a vertically oriented scroll bar must be 16 pixels, and the height of a horizontally oriented scroll bar must also be 16 pixels. These dimensions are determined strictly by the current theme used with the scroll bar. Only the dimension of a scroll bar that corresponds to its length can be changed. You can customize the appearance of a UIScrollBar instance by using styles and skins.
Property Description scrollTrackName The symbol used for the scroll bar’s track (background). The default value is ScrollTrack. scrollTrackOverName The symbol used for the scroll track (background) when rolled over. The default value is undefined. scrollTrackDownName The symbol used for the scroll track (background) when pressed. The default value is undefined. thumbTopName The top and left caps of the scroll box (thumb). The default value is ScrollThumbTopUp.
UIScrollBar class Inheritance MovieClip > UIObject class > UIComponent class > ScrollBar > UIScrollBar ActionScript Class Name mx.controls.UIScrollBar The properties of the UIScrollBar class let you adjust the scroll position and the amount of scrolling that occurs when the user clicks the scroll arrows or the scroll track. Unlike most other components, events are broadcast when the mouse button is pressed and continue broadcasting until the button is released.
Method Description UIObject.setSkin() Sets a skin in the object. UIObject.setStyle() Sets the style property on the style declaration or object. Methods inherited from the UIComponent class The following table lists the methods the UIScrollBar class inherits from the UIComponent class. When calling these methods from the UIScrollBar object, use the form UIScrollBarInstance.methodName. Method Description UIComponent.getFocus() Returns a reference to the object that has focus. UIComponent.
Property Description UIObject.scaleY A number indicating the scaling factor in the y direction of the object, relative to its parent. UIObject.top The position of the top edge of the object, relative to its parent. Read-only. UIObject.visible A Boolean value indicating whether the object is visible (true) or not (false). UIObject.width The width of the object, in pixels. Read-only. UIObject.x The left edge of the object, in pixels. Read-only. UIObject.y The top edge of the object, in pixels.
Event Description UIObject.reveal Broadcast when an object’s state changes from invisible to visible. UIObject.unload Broadcast when the subobjects are being unloaded. Events inherited from the UIComponent class The following table lists the events the UIScrollBar class inherits from the UIComponent class. Event Description UIComponent.focusIn Broadcast when an object receives focus. UIComponent.focusOut Broadcast when an object loses focus. UIComponent.keyDown Broadcast when a key is pressed.
Description Property; gets or sets the number of lines or pixels scrolled when the user clicks the arrow buttons of the UIScrollBar component. If the scroll bar is oriented vertically, the value is a number of lines. If the scroll bar is oriented horizontally, the value is a number of pixels. The default value is 1. Example The following example sets the scroll bar to scroll two lines of text each time the user clicks one of the scroll arrows: myScrollBar.lineScrollSize = 2; UIScrollBar.
Usage Usage 1: on(scroll){ ... } Usage 2: listenerObject = new Object(); listenerObject.scroll = function(eventObject){ ... } UIScrollBarInstance.addEventListener("scroll", listenerObject) Description Event; broadcast to all registered listeners when the mouse is clicked (released) over the scroll bar. The UIScrollBar.scrollPosition property and the scroll bar’s onscreen image are updated before this event is broadcast.
Example The following code implements Usage 1. The code is attached to the UIScrollBar component instance and sends a message to the Output panel when the user clicks the scroll bar. The on() handler must be attached directly to the UIScrollBar instance.
Example The following example scrolls the text field to the beginning of the text it contains: myScrollBar.scrollPosition = 0; The following example scrolls the text field to the end of the text it contains: myScrollBar.scrollPosition = myTextField.maxscroll - 1; UIScrollBar.setScrollProperties() Availability Flash Player 6 (6.0 79.0). Edition Flash MX 2004. Usage scrollBarInstance.setScrollProperties(pageSize, minPos, maxPos) Parameters The number of items that can be viewed in the display area.
UIScrollBar.setScrollTarget() Availability Flash Player 6 (6.0 79.0). Edition Flash MX 2004. Usage scrollBarInstance.setScrollTarget(textInstance) Parameters textInstance The text field to assign to the scroll bar. Description Method; assigns a UIScrollBar component to a text field instance. If you need to associate a text field and a UIScrollBar component at runtime, use this method. Example The following example assigns the UIScrollBar instance named myScrollBar to the text field instance named txt.
CHAPTER 6 Components Dictionary Web service classes (Flash Professional only) The web service classes, which are found in the mx.services package, let you access web services that use Simple Object Access Protocol (SOAP). This API is not the same as the WebServiceConnector component API. The web service API is a set of classes that can you use only in ActionScript code, and is common to various Macromedia products.
Callback summary for the Log object The following table lists the callback of the Log object. Callback Description Log.onLog() Called by Flash Player when a log message is sent to a log file. Constructor for the Log class Availability Flash Player 6 (6.0 79.0). Edition Flash MX Professional 2004. Usage myWebSrvcLog = new Log([logLevel] [, logName]); Parameters logLevel A level to indicate the category of information you want to record in the log. Three log levels are available: • Log.
As the web services code executes and messages are sent to the Log object, the onLog() function of your Log object is called. This is the only place to put code that displays the log messages if you want to see them in real time.
mytrace("Log Event:\r myWebSrvcLog.message="+message+); } PendingCall class (Flash Professional only) ActionScript Class Name mx.services.PendingCall The PendingCall class is part of the mx.services package and is used with the WebService class. For an overview of the classes in the mx.services package, see “Web service classes (Flash Professional only)” on page 842.
Method Description PendingCall.getOutputValue() Retrieves the output value according to the specified index. PendingCall.getOutputValues() Retrieves an array of all the output values. Property summary for the PendingCall object The following table lists properties of the PendingCall class. Property Description PendingCall.myCall The SOAPCall operation descriptor for the PendingCall operation. PendingCall.request The SOAP request in raw XML format. PendingCall.
Description Function; gets an additional output parameter of the SOAPParameter object, which contains the value and the XML element. SOAP RPC calls may return multiple output parameters. The first (or only) return value is always delivered in the result parameter of the onResult callback function, but to get access to the other return values, you must use functions such as getOutputParameter() and getOutputValue().
Description Function; gets any output parameter as a SOAPParameter object, which contains the value and the XML element. SOAP RPC calls may return multiple output parameters. The first (or only) return value is always delivered in the result parameter of the onResult callback function, but to get access to the other return values, you must use functions such as getOutputParameterByName(). This function returns the output parameter with the name localName.
Description Function; gets additional output parameters of the SOAPParameter object, which contains the values and the XML elements. SOAP RPC calls may return multiple output parameters. The first (or only) return value is always delivered in the result parameter of the onResult callback function, but to get access to the other return values, you must use functions such as getOutputParameters() and getOutputValues(). See also PendingCall.getOutputParameterByName(), PendingCall.
See also PendingCall.getOutputParameterByName(),PendingCall.getOutputParameter(), PendingCall.getOutputParameters(), PendingCall.getOutputValues() PendingCall.getOutputValues() Availability Flash Player 6 (6.0 79.0). Edition Flash MX Professional 2004. Usage myPendingCall.getOutputValues() Parameters None. Returns An array of all output parameters’ decoded values. Description Function; gets the decoded ActionScript value of all output parameters. SOAP RPC calls can return multiple output parameters.
Example The following onResult callback traces the name of the SOAPCall operation. callback.onResult = function(result) { // Check my operation name trace("My operation name is " + this.myCall.name); } PendingCall.onFault Availability Flash Player 6 (6.0 79.0). Edition Flash MX Professional 2004. Usage myPendingCallObj.onFault = function(fault) { // your code here } Parameters Decoded ActionScript object version of the SOAPFault object with properties.
This is a good place to put code that handles any faults, for example, by telling the user that the server isn’t available or to contact technical support, if appropriate. Example The following example handles errors returned from the web service method. // handles any error returned from the use of a web service method myPendingCallObj = myWebService.methodName(params) myPendingCallObj.onFault = function(fault) { // catches the SOAP fault DebugOutputField.text = fault.
Example The following example handles results returned from the web service method. // handles results returned from the use of a web service method myPendingCallObj = myWebService.methodName(params) myPendingCallObj.onResult = function(result) { // catch the result and handle it for this application ResultOutputField.text = result; } See also PendingCall.response PendingCall.request Availability Flash Player 6 (6.0 79.0). Edition Flash MX Professional 2004. Usage rawXML = myPendingCallback.
SOAPCall class (Flash Professional only) ActionScript Class Name mx.services.SOAPCall The SOAPCall class is part of the mx.services package and is an advanced class to be used with the WebService class (see “WebService class (Flash Professional only)” on page 856). For an overview of the classes in the mx.data.services package, see “Web service classes (Flash Professional only)” on page 842. The SOAPCall object is not constructed by you.
Description Property; the number of concurrent requests. Possible values are listed in the table below: Value Description SOAPCall.MULTIPLE_CONCURRENCY Allows multiple active calls. SOAPCall.SINGLE_CONCURRENCY Allows only one call at a time by causing a fault after one is active. SOAPCall.LAST_CONCURRENCY Allows only one call by cancelling previous ones. SOAPCall.doDecoding Availability Flash Player 6 (6.0 79.0). Edition Flash MX Professional 2004. Usage SOAPCall.
WebService class (Flash Professional only) ActionScript Class Name mx.services.WebService The WebService class is part of the mx.services package and is used with the Log, PendingCall, and SOAPCall classes. For an overview of the classes in the mx.services package, see “Web service classes (Flash Professional only)” on page 842. Note: The WebService class is not the same as the WebServiceConnector class.
Method summary for the WebService object The following table lists methods of the WebService object. Method Description WebService.getCall() Gets the SOAPCall object for a given operation. WebService.myMethodName() Invokes a specific web service operation defined by the WSDL. Callback summary for the WebService object The following table lists the callbacks of the WebService object. Callback Description WebService.onFault Called when an error occurs during WSDL parsing. WebService.
XML schema type ActionScript binding byte Number unsignedLong Number unsignedShort Number unsignedInt Number unsignedByte Number float Number double Number Date and Time Simple types XML schema type ActionScript binding date Date object datetime Date object duration Date object gDay Date object gMonth Date object gMonthDay Date object gYear Date object gYearMonth Date object time Date object Name and String Simple types XML schema type ActionScript binding string Actio
Object types XML schema type ActionScript binding Any XML object Complex Type ActionScript object composed of properties of any supported type Array ActionScript array composed of any supported object or type Supported XML schema object elements The following schema description illustrates the supported XML schema object elements: schema complexType complexContent restriction sequence | simpleContent restriction element complexType | simpleType WebService security (Flash Professional only) The meth
Usage myWebServiceObject = new WebService(wsdlURI [, logObject]); Parameters wsdlURI The URI of the web service WSDL file. logObject An optional parameter specifying the name of the Log object for this web service. If this parameter is used, the Log object must be created first. For more information, see “Log class (Flash Professional only)” on page 842. Returns Nothing. Description Constructor function; creates a WebService object.
{ OutputField.text = result } MyPendingCallObject.onFault = function(fault) { DebugField.text = fault.faultCode + "," + fault.faultstring; // add code to handle any faults, for example, by telling the // user that the server isn’t available or to contact technical // support } WebService.getCall() Availability Flash Player 6 (6.0 79.0). Edition Flash MX Professional 2004.
Usage callbackObj = myWebServiceObject.myMethodName(param1, ... paramN); Parameters param1, ... paramN Various parameters, depending on the web service method that is called. Returns A PendingCall object to which you can attach a function for handling results and errors on the invocation. For more information, see “PendingCall class (Flash Professional only)” on page 845. The callback invoked when the response comes back from the WebService method is PendingCall.onResult or PendingCall.onFault.
Parameters Decoded ActionScript object version of the error with properties. If the error information came from a server in the form of XML, then the SOAPFault object will be the decoded ActionScript version of that XML. fault The type of error object returned to WebService.onFault methods is a SOAPFault object. This object is not constructed directly by you, but returned as the result of a failure. This object is an ActionScript mapping of the SOAPFault XML type.
Usage myService.onLoad = function(wsdlDocument) { // your code here } Parameters wsdlDocument The WSDL XML document. Returns Nothing. Description Callback function; called by Flash Player when the WebService object has successfully loaded and parsed its WSDL file. If operations are invoked in an application before this callback function is called, they are queued internally and not actually transmitted until the WSDL has loaded.
CHAPTER 6 Components Dictionary WebServiceConnector component (Flash Professional only) The WebServiceConnector component lets you access remote methods exposed by a server using the industry-standard Simple Object Access Protocol (SOAP). A web service method may accept parameters and return a result. Using the Flash MX Professional 2004 authoring tool and the WebServiceConnector component you can inspect, access, and bind data between a remote web service and your Flash application.
WSDLURL (String type) is the URL of the WSDL file that defines the web service operation. When you set this URL during authoring, the WSDL file is immediately fetched and parsed. The resulting parameters and results information can be seen in the Schema tab of the Component inspector. The service description is also added to the Web Service panel. For example, see www.flash-mx.com/mm/tips/tips.cfc?wsdl.
Method summary for the WebServiceConnector class The following table lists the method of the WebServiceConnector class. Method Description WebServiceConnector.trigger() Initiates a call to a web service. Property summary for the WebServiceConnector class The following table lists properties of the WebServiceConnector class. Property Description WebServiceConnector.multipleSimultaneousAllowed Indicates whether multiple calls can take place at the same time. WebServiceConnector.
WebServiceConnector.multipleSimultaneousAllowed Availability Flash Player 6 (6.0 79.0). Edition Flash MX Professional 2004. Usage componentInstance.multipleSimultaneousAllowed Description Property; indicates whether multiple calls can (true) or cannot (false) take place at the same time. If this property is false, the WebServiceConnector.trigger() method performs a call if another call is already in progress. A status event is emitted, with the code CallAlreadyInProgress.
Example This example returns data from a remote web service and traces a tip and how long the service takes to return the data to the SWF file. Drag a WebServiceConnector component into your library, and enter the following code on Frame 1 of the Timeline: import mx.data.components.WebServiceConnector; var startTime:Number; var wscListener:Object = new Object(); wscListener.result = function(evt:Object) { var resultTimeMS:Number = getTimer()-startTime; trace("result loaded in "+resultTimeMS+" ms.
Example The following example sets the params property for a web service component named wsc: wsc.params = [param_txt.text]; WebServiceConnector.result Availability Flash Player 6 (6.0 79.0). Edition Flash MX Professional 2004. Usage componentInstance.addEventListener("result", myListenerObject) Description Event; broadcast when a call to a web service completes successfully.
WebServiceConnector.results Availability Flash Player 6 (6.0 79.0). Edition Flash MX Professional 2004. Usage componentInstance.results Description Property; identifies data that was received from the server as a result of a trigger() operation. Each WebServiceConnector component defines how this data is fetched, and what the valid types are. This data appears when the RPC operation has successfully completed, as signaled by the result event.
Example The following example defines a function sendFunction for the send event and assigns the function to the addEventListener event handler: var sendFunction = function (sendEnv) { sendEnv.target.params = [newParam_txt.text]; }; wsc.addEventListener("send", sendFunction); WebServiceConnector.status Availability Flash Player 6 (6.0 79.0). Edition Flash MX Professional 2004. Usage componentInstance.
Here are the possible web service faults: faultcode faultstring detail Timeout Timeout while calling method xxx MustUnderstand No callback for header xxx Server.Connection Unable to connect to endpoint: xxx VersionMismatch Request implements version: xxx Response implements version yyy Client.
faultcode faultstring Unknown.Call.Failure WebService invocation failed for unknown reasons Client.Disconnected Could not load imported schema detail Unable to load schema; if currently online, please verify the URI and/or format of the schema at (XXXX) Example The following example defines a function statusFunction for the status event and assigns the function to the addEventListener event handler: var statusFunction = function (stat) { trace(stat.code); trace(stat.data.faultcode); trace(stat.
case 'StatusChange' : break; default : trace("Error: "+error.code); break; } }; var wsConn:WebServiceConnector = new WebServiceConnector(); wsConn.addEventListener("result", res); wsConn.addEventListener("status", stat); wsConn.WSDLURL = "http://www.flash-mx.com/mm/tips/tips.cfc?wsdl"; wsConn.operation = "getTipByProduct"; // wsConn.params = ["Flash"]; wsConn.suppressInvalidCalls = true; wsConn.trigger(); To display a tip instead of an error, uncomment the line wsConn.params = ["Flash"];.
The trigger() method performs the following steps: 1. If any data is bound to the params property, the method executes all the bindings to ensure that up-to-date data is available. This also causes data validation to occur. 2. If the data is not valid and suppressInvalidCalls is set to true, the operation is discontinued. 3. If the operation continues, the send event is emitted. 4. The actual remote call is initiated using the connection method indicated (for example, HTTP).
var res:Function = function (evt:Object) { trace(evt.target.results); }; var wsConn:WebServiceConnector = new WebServiceConnector(); wsConn.addEventListener("result", res); wsConn.WSDLURL = "http://www.flash-mx.com/mm/tips/tips.cfc?wsdl"; wsConn.operation = "getTipByProduct"; wsConn.params = ["Flash"]; wsConn.suppressInvalidCalls = true; wsConn.
Window component CHAPTER 6 Components Dictionary A Window component displays the contents of a movie clip inside a window with a title bar, a border, and an optional close button. A Window component can be modal or nonmodal. A modal window prevents mouse and keyboard input from going to other components outside the window. The Window component also supports dragging; a user can click the title bar and drag the window and its contents to another location. Dragging the borders doesn’t resize the window.
title indicates the title of the window. closeButton indicates whether a close button is displayed (true) or not (false). Clicking the close button broadcasts a click event, but doesn’t close the window. You must write a handler that calls Window.deletePopUp() to explicitly close the window. For more information about the click event, see Window.click. Note: If a window was created by means other than the PopUp Manager, you can’t close it.
This handler calls PopUpManager.createPopUp() to instantiate a Window component with the title bar “Change Password”; the window displays the contents of the PasswordForm movie clip when the button is clicked. To close the window when the OK or Cancel button is clicked, you must write another handler. Customizing the Window component You can transform a Window component horizontally and vertically while authoring and at runtime.
Style Theme Description fontWeight Both The font weight: either "none" or "bold". The default value is "none". All components can also accept the value "normal" in place of "none" during a setStyle() call, but subsequent calls to getStyle() will return "none". textAlign Both The text alignment: either "left", "right", or "center". The default value is "left". textDecoration Both The text decoration: either "none" or "underline". The default value is "none".
Property Description skinCloseDisabled The close button in its disabled state. The default value is CloseButtonDisabled. skinCloseOver The close button in its over state. The default value is CloseButtonOver. The following example demonstrates how to create a new movie clip symbol to use as the title background. To set the title of an Window component to a custom movie clip symbol: 1. Create a new FLA file. 2. Create a new symbol by selecting Insert > New Symbol. 3. Set the name to TitleBackground.
The best way to instantiate a window is to call PopUpManager.createPopUp(). This method creates a window that can be modal (overlapping and disabling existing objects in an application) or nonmodal. For example, the following code creates a modal Window instance (the last parameter indicates modality): var newWindow = PopUpManager.createPopUp(this, Window, true); Flash simulates modality by creating a large transparent window underneath the Window component.
Method Description UIObject.destroyObject() Destroys a component instance. UIObject.doLater() Calls a function when parameters have been set in the Property and Component inspectors. UIObject.getStyle() Gets the style property from the style declaration or object. UIObject.invalidate() Marks the object so it will be redrawn on the next frame interval. UIObject.move() Moves the object to the requested position. UIObject.
Properties inherited from the UIObject class The following table lists the properties the Window class inherits from the UIObject class. When accessing these properties from the Window object, use the form WindowInstance.propertyName. Property Description UIObject.bottom The position of the bottom edge of the object, relative to the bottom edge of its parent. Read-only. UIObject.height The height of the object, in pixels. Read-only. UIObject.left The left edge of the object, in pixels. Read-only.
Event Description Window.complete Broadcast when a window is created. Window.mouseDownOutside Broadcast when the mouse is clicked (released) outside the modal window. Events inherited from the UIObject class The following table lists the events the Window class inherits from the UIObject class. Event Description UIObject.draw Broadcast when an object is about to draw its graphics. UIObject.hide Broadcast when an object’s state changes from visible to invisible. UIObject.
Usage 2: listenerObject = new Object(); listenerObject.click = function(eventObject){ ... } windowInstance.addEventListener("click", listenerObject) Description Event; broadcast to all registered listeners when the mouse is clicked (released) over the close button. The first usage example uses an on() handler and must be attached directly to a Window instance. The keyword this, used inside an on() handler attached to a component, refers to the component instance.
Window.closeButton Availability Flash Player 6 (6.0 79.0). Edition Flash MX 2004. Usage windowInstance.closeButton Description Property; a Boolean value that indicates whether the title bar should have a close button (true) or not (false). This property must be set in the initObject parameter of the PopUpManager.createPopUp() method. The default value is false. Clicking the close button broadcasts a click event, but doesn’t close the window. You must write a handler that calls Window.
A component instance (windowInstance) dispatches an event (in this case, complete) and the event is handled by a function, also called a handler, on a listener object (listenerObject) that you create. You define a method with the same name as the event on the listener object; the method is called when the event is triggered. When the event is triggered, it automatically passes an event object (eventObject) to the listener object method.
Example The following code sets the value of the text property within the content inside the Window component: myLoginWindow.content.password.text = "secret"; Window.contentPath Availability Flash Player 6 (6.0 79.0). Edition Flash MX 2004. Usage windowInstance.contentPath Description Property; sets the name of the content to display in the window. This value can be the linkage identifier of a movie clip in the library, or the absolute or relative URL of a SWF or JPEG file to load.
Example The following code creates a modal window, then creates a listener that deletes the window when the close button is clicked: import mx.managers.PopUpManager; import mx.containers.Window; var myTW:MovieClip = PopUpManager.createPopUp(_root, Window, true, {closeButton:true, title:"Test"}); var twListener:Object = new Object(); twListener.click = function(evt:Object){ evt.target.deletePopUp(); } myTW.
The second usage example uses a dispatcher/listener event model. A component instance (windowInstance) dispatches an event (in this case, mouseDownOutside) and the event is handled by a function, also called a handler, on a listener object (listenerObject) that you create. You define a method with the same name as the event on the listener object; the method is called when the event is triggered.
Window.titleStyleDeclaration Availability Flash Player 6 (6.0 79.0). Edition Flash MX 2004. Usage windowInstance.titleStyleDeclaration Description Property; a string indicating the style declaration that formats the title bar of a window. The default value is undefined, which indicates bold, white text. Example With a Window component in the library, use the following ActionScript to format the style of the window’s title bar.
CHAPTER 6 Components Dictionary XMLConnector component (Flash Professional only) The XMLConnector component lets you read or write XML documents using HTTP GET or POST operations. It acts as a connector between other components and external XML data sources. The XMLConnector component communicates with components in your application using either ActionScript code or data binding features in the Flash authoring environment.
Common workflow for the XMLConnector component The following procedure outlines the typical workflow for the XMLConnector component. To use an XMLConnector component: 1. Add an instance of the XMLConnector component to your application and give it an instance name. 2. Use the Parameters tab of the Component inspector to enter the URL for the external XML data source that you want to access. 3. Use the Schema tab of the Component inspector to specify a schema for the XML document.
Property summary for the XMLConnector class The following table lists properties of the XMLConnector class. Property Description XMLConnector.direction Indicates whether data is being sent, received, or both. XMLConnector.ignorewhite Indicates whether text nodes containing only white space are discarded during the parsing process. XMLConnector.multipleSimultaneousAllowed Indicates whether multiple calls can take place at the same time. XMLConnector.
Description Property; indicates whether data is being sent, received, or both. The values are the following: • send XML data for the params property is sent by HTTP POST method to the URL for the XML document. Any data that is returned is ignored. The results property is not set to anything, and there is no result event. Note: The params and results properties and the result event are inherited from the RPC component API. • • No params data is sent to the URL.
Usage componentInstance.multipleSimultaneousAllowed Description Property; indicates whether multiple calls can take place at the same time. If this property is false, the XMLConnector.trigger() method performs a call if another call is already in progress. A status event is emitted, with the code CallAlreadyInProgress. If this property is true, the call takes place. When multiple calls are simultaneously in progress, there is no guarantee that they will complete in the order in which they were triggered.
XMLConnector.params Availability Flash Player 6 (6.0 79.0). Edition Flash MX Professional 2004. Usage componentInstance.params Description Property; specifies data that will be sent to the server when the next trigger() operation is executed. Each RPC component defines how this data is used, and what the valid types are. Example The following example defines name and city parameters for myXMLConnector: myXMLConnector.
XMLConnector.results Availability Flash Player 6 (6.0 79.0). Edition Flash MX Professional 2004. Usage componentInstance.results Description Property; identifies data that was received from the server as a result of a trigger() operation. Each RPC component defines how this data is fetched, and what the valid types are. This data appears when the RPC operation has successfully completed, as signaled by the result event. It is available until the component is unloaded, or until the next RPC operation.
You can retrieve or modify the actual parameter values by using the params property. Example The following example defines a function sendFunction for the send event and assigns the function to the addEventListener event handler: var sendFunction = function (sendEnv) { sendEnv.target.params = [newParam_txt.text]; }; xcon.addEventListener("send", sendFunction); XMLConnector.status Availability Flash Player 6 (6.0 79.0). Edition Flash MX Professional 2004. Usage componentInstance.
The following are the faults that can occur with the status event: FaultCode FaultString Notes XMLConnector.Not.XML params is not an XML object The params value must be an ActionScript XML object. XMLConnector.Parse.Error params had XML parsing error NN. The status property of the params XML object had a nonzero value NN. To see the possible errors NN, see XML.status in Flash ActionScript Language Reference. XMLConnector.No.Data.
XMLConnector.suppressInvalidCalls Availability Flash Player 6 (6.0 79.0). Edition Flash MX Professional 2004. Usage componentInstance.suppressInvalidCalls Description Property; indicates whether to suppress a call if parameters are invalid. If this property is true, the trigger() method does not perform a call if the bound parameters fail the validation. A status event is emitted, with the code InvalidParams. If this property is false, the call takes place, using the invalid data as required.
XMLConnector.trigger() Availability Flash Player 6 (6.0 79.0). Edition Flash MX Professional 2004. Usage componentInstance.trigger() Description Method; initiates a remote procedure call. Each RPC component defines exactly what this involves. If the operation is successful, the results of the operation appear in the RPC component’s results property. The trigger() method performs the following steps: 1.
This code specifies the URL of the XML file and sets multipleSimultaneousAllowed to false. It triggers the XMLConnector instance three times, which causes the event listener's status method to display the error code CallAlreadyInProgress two times in the Output panel. The first attempt is successfully sent from Flash to the server. When the first trigger successfully receives a result, the result event is broadcast and the XML packet you receive is displayed in the Output panel. XMLConnector.
This code specifies the URL of the XML file and sets multipleSimultaneousAllowed to false. It triggers the XMLConnector instance three times, which causes the event listener’s status() method to display the error code CallAlreadyInProgress two times in the Output panel. The first attempt is successfully sent from Flash to the server. When the first trigger successfully receives a result, the result event is broadcast and the XML packet you receive is displayed in the Output panel.
CHAPTER 6 Components Dictionary XUpdateResolver component (Flash Professional only) Resolver components are used with the DataSet component (part of the data management functionality in the Flash data architecture) to save changes to an external data source. Resolvers take a DataSet.deltaPacket object and convert it to an update packet in a format appropriate to the type of resolver. The update packet can then be transmitted to the external data source by one of the connector components.
XUpdateResolver component parameter The XUpdateResolver component has one authoring parameter, the Boolean includeDeltaPacketInfo parameter. When this parameter is set to true, the update packet includes additional information that can be used by an external data source to generate results that can be sent back to your application. This information includes a unique transaction and operation ID that is used internally by the data set.
6. Use the Bindings tab of the Component inspector to bind data elements (DataSet fields) to the visual components in your application. 7. Select the Schema tab of the XUpdateResolver component. With the deltaPacket component property selected, use the Schema Attributes pane to set the encoder property to the DataSetDeltaToXUpdateDelta encoder. 8. Select Encoder Options and enter the rowNodeKey value that uniquely identifies the row node within the XML file.
Property summary for the XUpdateResolver class The following table lists properties of the XUpdateResolver class. Property Description XUpdateResolver.deltaPacket Contains a description of the changes to the DataSet component. The DataSet component’s deltaPacket property should be bound to this property so that when DataSet.applyUpdates() is called, the binding will copy it across and the resolver will create the XUpdate packet. XUpdateResolver.
Parameters eventObject Resolver event object; describes the customizations to the XML packet before the update is sent through the connector to the database. This event object should contain the following properties: Property Description target Object; the resolver generating this event. type String; the name of the event. updatePacket XML object; the XML object that is about to be applied. Returns None.
Messages in the updateResults property are treated as errors. This means that a delta with messages is added to the delta packet again so it can be re-sent the next time the delta packet is sent to the server. You must write code that handles deltas that have messages so that the messages are presented to the user and the deltas can be modified before being added to the next delta packet.
Returns None. Description Event; called by the resolver component to compare two packets. Use this callback to insert any code after the results have been received from the server and immediately before the transmission, through data binding, of the delta packet that contains operation results. This is a good place to put code that handles messages from the server.
XUpdateResolver.xupdatePacket Availability Flash Player 7. Edition Flash MX Professional 2004. Usage resolveData.xupdatePacket Description Property; property of type xml that contains the XUpdate translation of the changes to the DataSet component. Bind this property to the connector component’s property that transmits the translated update packet of changes back to the DataSet component.
CHAPTER 7 Creating Components This chapter describes how to create your own component and package it for deployment. The version 2 architecture has simplified the component development process in several ways. For more information, see “What’s new in version 2 components” on page 916. This chapter contains the following sections: Component source files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 915 What’s new in version 2 components . . . . . .
What’s new in version 2 components The current version (version 2) of the Macromedia Component Architecture is very different from the Macromedia Flash MX version (version 1). The following list provides an overview of some of the changes that affect component developers: New base classes provide a new component hierarchy. In version 1 components, the base class was FUIComponent. In version 2, the base classes are the UIObject class and UIComponent class. See “Selecting a parent class” on page 924.
Overview of component structure A component is comprised of a Flash (FLA) file and an ActionScript (AS) file. There are other files (for example, an icon and a .swd debugging file) that you can optionally create and package with your component, but all components require a FLA and an ActionScript file. When you’ve finished developing your component, you export it as a SWC file.
Building your first component In this section, you will build a Dial component. The completed component files, Dial.fla, Dial.as, Dial.swf, and DialAssets.fla are located in the examples folder on your hard disk: • Macromedia/Flash MX 2004/Samples/HelpExamples/DialComponent The Dial component is a potentiometer. A user can click on the needle and drag it to change its position. The API for the Dial has one property, value, that you can use to get and set the position of the needle.
11. Choose File > Import > Open External Library and choose the StandardComponents.fla file from the FirstRun/ComponentFLA folder. Dial extends the UIComponent base class; therefore, you must drag an instance of the UIComponent class into the Dial document. Note: For information about folder locations, see “Configuration folders installed with Flash” in Using Flash. 12.
Creating the Dial class file The following is the ActionScript class for the Dial component. Please read the comments in the code for a description of each section. To create this file, you can create a new ActionScript file in the Flash IDE, or use any other text editor. Save the file as Dial.as in the same folder as the Dial.fla file. // Import the package so you can reference // the class directly. import mx.core.
size(); } // The draw method is invoked after the component has // been invalidated, by someone calling invalidate(). // This is better than redrawing from within the set function // for value, because if there are other properties, it's // better to batch up the changes into one redraw, rather // than doing them all individually. This approach leads // to more efficiency and better centralization of code. function draw():Void { super.draw(); dial.needle.
} // When the dial is pressed, the dragging flag is set. // The mouse events are assigned callback functions. function beginDrag() { dragging = true; onMouseMove = mouseMoveHandler; onMouseUp = mouseUpHandler; } // Remove the mouse events when the drag is complete, // and clear the flag.
To test the Dial component: 1. In the Dial.fla file, choose the Dial component in the library and choose Convert to Compiled Clip from the Library options menu. A compiled clip is added to the library with the name Dial SWF. Note: If you’ve already created a compiled clip (for example, if this is the second or third time you’re testing), a Resolve Library Conflict dialog box appears. Choose Replace Existing Items to add the new version to the document. 2. Drag Dial SWF to the Stage on the main Timeline.
To export the Dial component: 1. In the Dial.fla file, choose the Dial component in the library and select Export to SWC from the Library options menu. 2. Choose a location to save the SWC file. If you save it to the Components folder in the user-level configuration folder, you can reload the Components panel without restarting Flash and the component appears in the panel. Note: For information about folder locations, see “Configuration folders installed with Flash” in Using Flash.
The following table briefly describes the version 2 base classes: Base class Extends mx.core.UIObject MovieClip UIObject is the base class for all graphical objects. It can have shape, draw itself, and be invisible. UIObject provides the following functionality: • Editing styles • Event handling • Resizing by scaling mx.core.UIComponent UIObject Description UIComponent is the base class for all components.
Extending other version 2 classes To make component construction easier, you can extend any class; you are not required to extend the UIObject or UIComponent class directly. If you extend any other version 2 component’s class (except the Media components), you extend UIObject and UIComponent by default. Any component class listed in the Component dictionary can be extended to create a new component class.
Creating a component movie clip To create a component, you must create a movie clip symbol and link it to the component’s class file. The movie clip has two frames and two layers. The first layer is an Actions layer and has a stop() action on Frame 1. The second layer is an Assets layer with two keyframes. Frame 1 contains a bounding box or any graphics that serve as placeholders for the final art. Frame 2 contains all other assets, including graphics and base classes, used by the component.
Editing the movie clip After you create the new symbol and define the linkages for it, you can define the component’s assets in the symbol’s Timeline. A component’s symbol should have two layers. This section describes what layers to insert and what to add to those layers. To edit the movie clip: 1. Rename Layer 1 Actions and select Frame 1. 2. Open the Actions panel and add a stop() function, as follows: stop(); Do not add any graphical assets to this frame. 3. Add a Layer named Assets. 4.
6. If you are extending an existing component, place an instance of that component and any other base classes in Frame 2 of the Assets layer. To do this, select the symbol from the Components panel and drag it onto the Stage. If you are extending a base class, open StandardComponents.fla from the FirstRun/ComponentFLA folder and drag the class from the library to the Stage. Note: When you drag UIComponent to the component library, the folder hierarchy in the library is changed.
3. Use other options in the Component Definition dialog box, if desired: ■ Click the Plus (+) button to define parameters. This is optional. The best practice is to use the metadata Inspectable tag in the component’s class file to specify parameters. When an ActionScript 2.0 class is not specified, define the parameters for the component here. ■ Specify a custom UI. This is a SWF file that plays in the Component inspector. You can embed it in the component FLA file or browse to an external SWF.
This example contains a minimal set of imports, methods, and declarations for a component, MyComponent, that inherits from the UIComponent class. The MyComponents.as file is saved in the myPackage folder. [Event("eventName")] // Import packages. import mx.core.UIObject; // Declare the class and extend from the parent class. class mypackage.MyComponent extends UIObject { // Identify the symbol name that this class is bound to. static var symbolName:String = "mypackage.
Overview of a component class file The following procedure is an overview of the creation of an ActionScript file for a component. Some steps may be optional, depending on the type of component you create. To write a component class file: 1. (Optional) Import classes. (See “Importing classes” on page 933). This allows you to refer to classes without writing out the package (for example, Button instead of mx.controls.Button). 2.
Importing classes You can import class files so that you don’t have to write fully qualified class names throughout your code. This can make code more concise and easier to read. To import a class, use the import statement at the top of the class file, as in the following: import mx.core.UIObject; import mx.core.ScrollView; import mx.core.ext.UIObjectExtensions; class MyComponent extends UIComponent{ You can also use the wildcard character (*) to import all the classes in a given package.
The following table describes these variables: Variable Type Description symbolName String The name of the ActionScript class (for example, ComboBox). This name must match the symbol’s Linkage Identifier. This variable must be static. symbolOwner Object The fully qualified class name (for example, mypackage.MyComponent). Do not use quotation marks around the symbolOwner value, because is is an Object data type. This name must match the AS 2.0 class in the Linkage Properties dialog box.
Using getter/setter methods to define parameters The simplest way to define a component parameter is to add a public member variable that is Inspectable: [Inspectable(defaultValue="strawberry")] public var flavorStr:String; However, if code that employs a component modifies the flavorStr property, the component typically must perform an action to update itself in response to the property change.
Metadata is associated with a class declaration or an individual data field. If the value of an attribute is of type String, you must enclose that attribute in quotation marks. Metadata statements are bound to the next line of the ActionScript file. When defining a component property, add the metadata tag on the line before the property declaration. The only exception is the Event metadata tag.
About the Inspectable tag You use the Inspectable tag to specify the user-editable (inspectable) parameters that appear in the Component inspector and Property inspector. This lets you maintain the inspectable properties and the underlying ActionScript code in the same place. To see the component properties, drag an instance of the component onto the Stage and select the Parameters tab of the Component inspector. Collection parameters are also inspectable.
The following table describes the attributes of the Inspectable tag: Attribute Type Description defaultValue String or Number (Optional) A default value for the inspectable property. enumeration String (Optional) Specifies a comma-delimited list of legal values for the property. listOffset Number (Optional) Added for backward compatibility with Flash MX components. Used as the default index into a List value. name String (Optional) A display name for the property. For example, Font Width.
The InspectableList tag must immediately precede the class definition because it applies to the entire class. The following example allows the flavorStr and colorStr properties to be displayed in the Property inspector, but excludes other inspectable properties from the Parent class: [InspectableList("flavorStr","colorStr")] class BlackDot extends DotParent { [Inspectable(defaultValue="strawberry")] public var flavorStr:String; [Inspectable(defaultValue="blue")] public var colorStr:String; ...
Use the Bindable tag before a property in an ActionScript class to make the property appear in the Bindings tab in the Component inspector. You can declare a property by using var or getter/ setter methods. If a property has both a getter and a setter method, you only need to apply the Bindable tag to one. The Bindable tag has the following syntax: [Bindable "readonly"|"writeonly",type="datatype"] Both attributes are optional.
About the ChangeEvent tag The ChangeEvent tag tells data binding that the component will generate an event any time the value of a specific property changes. In response to the event, data binding executes any binding that has that property as a source. The component only generates the event if you write appropriate ActionScript code in the component. The event should be included in the list of Event metadata declared by the class. You can declare a property by using var or getter/setter methods.
About the Collection tag Use the Collection tag to describe an array of objects that can be modified as a collection of items in the Values dialog box while authoring. The type of the objects is identified by the collectionItem attribute. A collection property contains a series of collection items that you define in a separate class. This class is either mx.utils.CollectionImpl or a subclass of it.
Attribute Type Description collectionItem String (Required) Specifies the class of the collection items to be stored within the collection. This class includes its own inspectable properties that are exposed through metadata. identifier String (Required) Specifies the name of an inspectable property within the collection item class that Flash MX uses as the default identifier when the user adds a new collection item through the Values dialog box.
[Inspectable(defaultValue="default text")] function set text(t:String) } You can use any of the following types for parameters: • • • • • • • • Array Object List String Number Boolean Font Name Color Note: The JellyBean class is a theoretical example. To see an actual example, look at the Button.as class file that installs with Flash MX 2004 in the First Run/Classes/mx/controls directory.
If your component extends UIComponent or UIObject, Flash automatically calls init(), createChildren(), and size() methods and you can leave your constructor function empty, as shown here: class MyComponent extends UIComponent{ ... // this is the constructor function function MyComponent(){ } } All version 2 components should define an init() function that is called after the constructor has been called. You should place the initialization code in the component’s init() function.
The init() method is called from UIObject’s constructor, so the flow of control climbs up the chain of constructors until it reaches UIObject. UIObject’s constructor calls the init() method that is defined on lowest subclass. Each implementation of init() should call super.init() so that its base class can finish initializing. If you implement an init() method and you don’t call super.init(), the ()init method is not called on any of the base classes, so they might never be in a usable state.
if (mode_mc == undefined) createClassObject(SimpleButton, "mode_mc", 1, { falseUpSkin: modeUpSkinName, falseOverSkin: modeOverSkinName, falseDownSkin: modeDownSkinName }); mode_mc.addEventListener("click", this); size() invalidate() } Defining the draw() method You can write code in the draw() method to create or modify visual elements of a component. In other words, in the draw() method, a component draws itself to match its state variables.
About invalidation Macromedia recommends that a component not update itself immediately in most cases, but that it instead should save a copy of the new property value, set a flag indicating what is changed, and call the invalidate() method. (This method indicates that just the visuals for the object have changed, but size and position of subobjects have not changed. This method calls the draw() method.) You must call an invalidation method at least once during the instantiation of your component.
The description of each event in the Flash MX 2004 documentation lists the event properties that are optional and required. For example, the ScrollBar.scroll event takes a detail property in addition to the type and target properties. For more information, see the event descriptions in Chapter 6, “Components Dictionary,” on page 91. Common events The following table lists the common events that are broadcast by various classes.
About assigning skins A user interface (UI) component is composed entirely of attached movie clips. This means that all assets for a UI component can be external to the UI component movie clip, so they can be used by other components. For example, if your component needs check box functionality, you can reuse the existing CheckBox component assets. The CheckBox component uses a separate movie clip to represent each of its states (FalseUp, FalseDown, Disabled, Selected, and so on).
Registering skins to styles The following example creates a component called Shape. This component displays a shape that is one of two skins: a circle or a square. The skins are registered to the themeColor style. To register a skin to a style: 1. Create a new ActionScript file and copy the following code into it: import mx.core.
10. Select the Shape movie clip in the library, select Component Definition from the Library options menu, and enter the AS 2.0 class Shape. 11. Test the movie clip with the Shape component on the Stage. To change the theme color, set the style on the instance. The following code changes the color of a Shape component with the instance name shape to red: shape.setStyle("themeColor",0xff0000); 12. Draw a square on the Stage and convert it to a movie clip.
symbolDisabledColor: true, themeColor:true, todayIndicatorColor: true, shadowCapColor:true, borderCapColor:true, focusColor:true, shapeColor:true }; Register the new style name to the circle and square skins on Frame 1 of each skin movie clip, as follows: mx.skins.ColoredSkinElement.setColorStyle(this, "shapeColor"); The color can be changed with the new style name by setting the style on the instance, as shown here: shape.
The following table describes the contents of a SWC file: File Description catalog.xml (Required) Lists the contents of the component package and its individual components, and serves as a directory to the other files in the SWC file. ActionScript (AS) files If you create the component with Flash MX Professional 2004, the source code is one or more ActionScript files that contain a class declaration for the component. The compiler uses the source code for type checking when a component is extended.
Exporting a SWC for a completed component You can export components as SWC files that contain all the ActionScript, SWF files, and other optional files needed to use the component. To export a SWC file for a completed component: 1. Select the component movie clip in the Flash library. 2. Select Export SWC File from the Library options menu. 3. Save the SWC file.
Adding an icon You can add an icon that represents your component in the Components panel of the Flash authoring environment. To add an icon for your component: 1. Create a new image. The image must measure 18 pixels square, and you must save it in PNG format. It must be 8bit with alpha transparency, and the upper left pixel must be transparent to support masking. 2. Add the following definition to your component’s ActionScript class file before the class definition: [IconFile("component_name.png")] 3.
• When defining the symbol, do not select the Export in First Frame option unless absolutely necessary. Flash loads the component just before it is used in your Flash application, so if you select this option, Flash preloads the component in the first frame of its parent. The reason you typically do not preload the component in the first frame is for considerations on the web: the component loads before your preloader begins, defeating the purpose of the preloader.
Chapter 7: Creating Components
APPENDIX Collection Properties This appendix explains how to create a collection property in a component. The Collection class is a helper class used to manage a group of zero or more related objects, called collection items. If you define a property of your component as a collection and make it available to users through the Component inspector, they can add, delete, and modify collection items in the Values dialog box while authoring.
This appendix contains the following sections: Defining a collection property . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 960 Simple collection example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 960 Defining the class for a collection item. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 962 Accessing collection information programmatically . . . . . . . . . . . .
class MyShelf extends mx.core.UIObject { // required variables for all classes static var symbolName:String = "MyShelf"; static var symbolOwner:Object = Object(MyShelf); var className:String = "MyShelf"; // the Collection metadata tag and attributes [Collection(variable="myCompactDiscs",name="My Compact Discs",collectionClass="mx.utils.CollectionImpl", collectionItem="CompactDisc", identifier="Title")] // get and set methods for the collection public function get MyCompactDiscs():mx.utils.
5. Choose Window > Other Panels > Common Libraries > Classes, and drag UtilClasses to the library of MyShelf.fla. 6. In the MyShelf symbol’s Timeline, name one layer Assets. Create another layer and name it Actions. 7. Place a stop() function on Frame 1 of the Actions layer. 8. Select Frame 2 of the Assets layer and select Insert > Timeline > Keyframe. 9. Open StandardComponents.
Accessing collection information programmatically Flash provides programmatic access to collection data through the Collection and Iterator interfaces. The Collection interface lets you add, modify, and remove items in a collection. The Iterator interface allows you to loop through the items in a collection.
Accessing collection items at runtime in a Flash application If a Flash application uses a component that has a collection property, you can access the collection property at runtime. This example adds several items to a collection property using the Values dialog and displays them at runtime using the Collection and Iterator APIs. To access collection items at runtime: 1. Open the MyShelf.fla file that you created earlier. See “Simple collection example” on page 960.
Of these files, your code typically uses the Collection and Iterator interfaces, which marks them as dependent classes. Flash automatically includes dependent files in the SWC file and output SWF file. However, the collection implementation class (mx.utils.CollectionImpl) and component-specific collection item class are not automatically included in the SWC file.
Appendix: Collection Properties
INDEX A accessibility 18 Accordion component creating an application with 97 customizing 99 events 107 inheritance 105 methods 105 package 105 parameters 97 properties 106 using skins with 101 using styles with 100 using with movie clips (tutorial) 27 ActionScript class files activators 574 Alert component 115 creating an application with 115 customizing 116 events 122 inheritance 119 methods 120 package 119 parameters 115 properties 121 using skins with 118 using styles with 116 application architecture,
class style sheets 67 classes Accordion 105 Alert 119 and component inheritance 16 Binding 214 Button 139 CheckBox 161 ComboBox 182 ComponentMixins 229 creating references to (tutorial) 33 creating.
compiled clips about 17 in Library panel 47 component categories data 92 managers 93 media 93 other 94 screens 94 UI components 91 component class file.
TypedValue class 244 using at runtime 213 data binding, with XML file (tutorial) 31 data components 92 data grids. See DataGrid component data integration with components (tutorial) 22 data models DataGrid component 249 Menu component 540 data sets.
dispatcher 56 dispatching events 948 documentation guide to terminology 9 overview 8 draw() method, defining 947 E element (PendingCall.onFault) 851 element (WebService.onFault) 863 EndPoint class about 224 methods 225 event listeners.
parameters 443 properties 446 tutorial 28 using styles 444 library adding instances to 23 compiled clips in 47 Library panel 47 StandardComponents 928 linkage identifiers for skins 81 List component 450 creating an application 452 customizing 453 design 145 events 460 inheritance 456 methods 457 package 456 parameters 452 properties 458 using skins 456 using styles 453 listeners 56 functions 60 objects 57 scope 61 using with component instances (tutorial) 26 using with components (tutorial) 37 Live Preview
parameters 575 properties 579 using skins 577 using styles 576 MenuDataProvider class 568 events 569 methods 569 metadata 935 Collection tag 942 Event tag 939 Inspectable tag 937 tags, list of 936 movie clips, component instances in (tutorial) 25 MovieClip class, extending 926 multipleSimultaneousAllowed parameter 865 N NumericStepper component 588 creating an application 589 customizing 590 events 595 methods 593 parameters 589 properties 594 using skins 591 using styles 590 O on() 55 onFault 863 operation
separator 542 SimpleButton class 686 events 688 methods 686 properties 687 size() method, defining 947 skin properties changing in the prototype 89 setting 81 skinning 80 skins applying 85 applying to subcomponents 86 creating components 950 editing 83 linkage identifiers 81 See also individual component names Slide class 693 events 699 example 694 inheritance 695 methods 695 package 695 parameters 694 properties 696 SOAPCall class 854 properties 854 SOAPFault 863 StandardComponents library 928 style declar
themes 77 applying 79 creating 77 tip text, adding 956 TransferObject interface about 756 methods 756 Tree component 759 creating an application 762 customizing 766 events 773 inheritance 770 methods 771 package 770 parameters 761 properties 772 using skins 769 using styles 766 XML formatting 760 TreeDataProvider interface 787 methods 787 properties 787 TypedValue class about 244 properties 245 types.
Window component 878 creating an application 879 customizing 880 events 885 inheritance 882 methods 883 package 882 parameters 878 properties 884 using skins 881 using styles 880 WSDLURL parameter 866 X XML attributes of menu item 541 formatting for the Tree component 760 schema types 857 XMLConnector component 894 binding to DataSet (tutorial) 31 common workflow 895 events 896 loading an external XML file (tutorial) 37 methods 895 parameters 894 properties 896 schemas and 894 specifying schema (tutorial) 3