MACROMEDIA FLASH MX 2004-USING COMPONENTS Use Manual
MACROMEDIA FLASH MX 2004-USING COMPONENTS Use Manual

MACROMEDIA FLASH MX 2004-USING COMPONENTS Use Manual

Using components
Hide thumbs Also See for FLASH MX 2004-USING COMPONENTS:
Table of Contents

Advertisement

Quick Links

Using Components

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the FLASH MX 2004-USING COMPONENTS and is the answer not in the manual?

Questions and answers

Summary of Contents for MACROMEDIA FLASH MX 2004-USING COMPONENTS

  • Page 1 Using Components...
  • Page 2 Open Sesame!, Roundtrip, Roundtrip HTML, Shockwave, Sitespring, SoundEdit, Titlemaker, UltraDev, Web Design 101, what the web can be, and Xtra are either registered trademarks or trademarks of Macromedia, Inc. and may be registered in the United States or in other jurisdictions including internationally. Other product names, logos, designs, titles, words, or phrases mentioned within this publication may be trademarks, service marks, or trade names of Macromedia, Inc.
  • Page 3: Table Of Contents

    CONTENTS INTRODUCTION: Getting Started with Components ..... . . 7 Intended audience ..........7 System requirements .
  • Page 4 Deleting components from Flash documents......50 Using code hints ..........50 Creating custom focus navigation .
  • Page 5 Loader component ..........484 Media components (Flash Professional only) .
  • Page 6 APPENDIX: Collection Properties ........959 Defining a collection property .
  • Page 7: Introduction: Getting Started With Components

    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.
  • Page 8: System Requirements

    Chapter 3, “Working with Components,” on page System requirements Macromedia components do not have any system requirements in addition to Flash MX 2004 or Flash MX Professional 2004. Any SWF file that uses version 2 components must be viewed with Flash Player 6 (6.0.79.0) or later.
  • Page 9: Terms Used In This Manual

    For detailed information on ActionScript terms, syntax, and usage, see Using ActionScript in Flash and Flash ActionScript Language Reference. For an introduction to using components, see the Macromedia On Demand Seminar, Flash MX 2004 Family: Using UI Components at www.macromedia.com/macromedia/events/online/ ondemand/index.html.
  • Page 10 Introduction: Getting Started with Components...
  • Page 11: Chapter 1: About Components

    Components are built on version 2 of the Macromedia Component Architecture, which allows you to easily and quickly build robust applications with a consistent appearance and behavior.
  • Page 12: Installing Components

    Accessibility and components..........18 Installing components A set of Macromedia components is already installed when you launch Flash MX 2004 or Flash MX Professional 2004 for the first time. You can view them in the Components panel.
  • Page 13: Where Component Files Are Stored

    Select Window > Development Panels > Components to open the Components panel if it isn’t already open. Select UI Components to expand the tree and view the installed components. You can also download components from the Macromedia Exchange at www.macromedia.com/ exchange. To install components downloaded from the Exchange, download and install the Macromedia Extension Manager at www.macromedia.com/exchange/em_download/...
  • Page 14: Benefits Of Using Components

    Developers can encapsulate frequently used functionality into components and designers can customize the look and behavior of components by changing parameters in the Property inspector or the Component inspector. Members of the Flash community can use the Macromedia Exchange at www.macromedia.com/ go/exchange to exchange components.
  • Page 15: Categories Of Components

    1 components to version 2 architecture” on page Note: Flash MX UI components have been updated to work with Flash Player 7. These updated components are still based on version 1 architecture. You can download them from the Macromedia Flash Exchange at www.macromedia.com/cfusion/exchange/...
  • Page 16: What's New In Version 2 Components

    RadioButton class whose package name is mx.controls. For more information about packages, see “Using packages” in Using ActionScript in Flash. Most UI components built with version 2 of the Macromedia Component Architecture are subclasses of the UIObject and UIComponent classes and inherit all properties, methods, and events from those classes.
  • Page 17: About Compiled Clips And Swc Files

    Components included with Flash MX 2004 or Flash MX Professional 2004 are not FLA files— they are compiled clips that have been packaged into SWC files. SWC is the Macromedia file format for distributing components; it contains a compiled clip, the component’s ActionScript class file, and other files that describe the component.
  • Page 18: Accessibility And Components

    Flash, the developer uses the Accessibility panel to configure each component instance. Most components built by Macromedia are designed for accessibility. To find out whether a component is accessible, see its entry in Chapter 6, “Components Dictionary,” on page 91.
  • Page 19: Chapter 2: Creating An Application With Components (Flash Professional Only)

    This tutorial shows how to build a Flash application using components available in Macromedia Flash MX Professional 2004, including a variety of user interface and data connectivity components.
  • Page 20: About This Tutorial

    The components included with Flash MX 2004 and Flash MX Professional 2004 are SWC files (the Macromedia file format for components). A SWC file contains a compiled clip of the component, as well as an icon that appears in the Components panel, and other assets to create component functionality.
  • Page 21: View The Application

    In Windows: boot drive\Program Files\Macromedia\Flash MX 2004\Samples\ HelpExamples\components_application • On the Macintosh: Macintosh HD/Applications/Macromedia Flash MX 2004/Samples/ HelpExamples/components_application To see how the application works, first click the arrow control in the What Did You Do? section. Select from a list of blunders you might have committed (ranging in severity from Forgot to Water Your Plants to Burned Your House Down).
  • Page 22: About Data Integration In The Sample Application

    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.
  • Page 23: Build The Application Architecture

    • 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.) The sample application uses the WebService class rather than the...
  • Page 24 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 >...
  • Page 25 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.
  • Page 26 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 , select .
  • Page 27 Next, the code populates the TextArea and Label instances by using the description price properties of the object. These properties correspond to priceQualifier thisProduct 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.
  • Page 28 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. In the main Timeline for the application, move the playhead to Frame 10 (labeled Checkout). Make sure the Form layer is selected.
  • Page 29 In the Create New Symbol dialog box, enter checkout1_sub_mc for Name and select Movie Clip for Behavior. 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. Drag six instances of the Label component onto the Stage.
  • Page 30 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. Drag to create a rectangle that extends beyond the bottom and right edges of the Label and TextInput instances.
  • Page 31: Bind Components To Display Product Information From An External Source

    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 text For the second instance, enter ccType_lbl for the instance name and set the X and Y...
  • Page 32 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.
  • Page 33: Add Actionscript To The Main Timeline

    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.
  • Page 34 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 creates references to all classes in the controls mx.controls.*...
  • Page 35 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();...
  • Page 36 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...
  • Page 37 // 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.
  • Page 38 Resetting the property (setting it to and then to ) at the beginning of the filtered false true function ensures that the function will work properly if the user changes the What Did change() You Do? selection repeatedly. function checks whether a given item in the array of gifts falls within the filterFunc severity the user selected in the combo box.
  • Page 39 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();...
  • Page 40 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.text; thisChild2.sameAsBilling_ch.addEventListener("click", checkboxListener); The first two lines of code are similar to the code for creating the Billing Information child: you create an instance of the movie clip symbol, with the instance name checkout2_mc...
  • Page 41: Test The Application

    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.shippingFirstName = thisChild2.shippingFirstName_ti.text; checkout_lv.shippingLastName = thisChild2.shippingLastName_ti.text; checkout_lv.shippingCountry = thisChild2.shippingCountry_ti.text; checkout_lv.shippingProvince = thisChild2.shippingProvince_ti.text; checkout_lv.shippingCity = thisChild2.shippingCity_ti.text;...
  • Page 42 Chapter 2: Creating an Application with Components (Flash Professional Only)
  • Page 43: Chapter 3: Working With Components

    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.
  • Page 44: The Components Panel

    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: Select Window >...
  • Page 45 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.
  • Page 46 Adding components at runtime with ActionScript Use the method (which most components inherit from the UIObject createClassObject() 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).
  • Page 47: Components In The Library Panel

    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 on page 810 Chapter 4, UIObject.createClassObject() “Handling Component Events,” on page 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.
  • Page 48 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: Select Window > Properties. Select an instance of a component on the Stage. Enter an instance name in the text field under the word Component.
  • Page 49: Sizing Components

    Sizing components Use the Free Transform tool or the method to resize component instances. setSize() Resizing the Menu component on the Stage with the Free Transform tool You can call the method from any component instance (see setSize() UIObject.setSize() on page 823) to resize it.
  • Page 50: Deleting Components From Flash Documents

    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: In the Library panel, select the compiled clip (SWC) symbol.
  • Page 51: Managing Component Depth In A Document

    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 >...
  • Page 52: Components In Live Preview

    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,”...
  • Page 53: 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.
  • Page 54 Chapter 3: Working with Components...
  • Page 55: Chapter 4: Handling Component Events

    Chapter 6, “Components Dictionary,” on page This chapter uses several versions of a simple Macromedia Flash application, TipCalculator, to teach you how to handle component events. The FLA and SWF files are installed with Flash MX 2004 version 7.2 to the Macromedia/Flash MX 2004/Samples/HelpExamples/TipCalculator...
  • Page 56: Using Listeners To Handle Events

    To use the on() event handler: Open the file TipCalculator1.fla from Macromedia\Flash MX 2004\Samples\HelpExamples\TipCalculator. On the Stage, select the TextInput component beside the “Enter subtotal” text. Open the Actions panel, if it isn’t already open. Look at the following code assigned to the subtotal_ti TextInput component: on(change){ this._parent.calculate();...
  • Page 57 • To register a listener to a broadcaster, call the method from the addEventListener() 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);...
  • Page 58 // your code here Tip: The parameter is an object that is automatically generated when an event is triggered and evtObj passed to the callback function. The event object has properties that contain information about the event. For details, see “About the event object”...
  • Page 59 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); property of the event object, , is a reference to the instance broadcasting the target event. This code displays the value of the property in the TextInput component.
  • Page 60 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"...
  • Page 61 Select Frame 1 in the Timeline. Select Window > Development Panels > Actions. 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.addItem("Monkey"); // define myHandler function function myHandler(eventObj:Object){ // use the eventObj parameter...
  • Page 62 As discussed earlier, you register a listener with a component instance by calling . This method takes two parameters: a string indicating the name of the addEventListener() event, and a reference to either an object or a function. The following table lists the scope of each parameter type: Listener type Scope...
  • Page 63: Delegating Events

    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.
  • Page 64 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 + ": "...
  • Page 65 Delegating the scope of a function method requires two parameters: the name of an event and a reference addEventListener() 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 .
  • Page 66: About The Event Object

    // 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;...
  • Page 67: Chapter 5: Customizing Components

    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...
  • Page 68 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.
  • Page 69 Setting styles on a component instance You can write ActionScript code to set and get style properties on any component instance. methods can be called directly from UIObject.setStyle() UIObject.getStyle() any component. The following syntax specifies a property and value for a component instance: instanceName.setStyle("propertyName", value);...
  • Page 70 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 To create a custom style declaration for a group of components: Make sure the document contains at least one component instance.
  • Page 71 Another option in setting custom style declarations is you can assign the CSSStyleDeclaration instance directly to the component instance’s property and bypass storing the styleName declaration in . To use this approach, modify the above procedure as follows: _global.styles • Remove the ActionScript from steps 6 and 7 above.
  • Page 72 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 value is not supported. inherit 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.
  • Page 73 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 property style ) that is an instance of CSSStyleDeclaration. This property acts as the global _global.style...
  • Page 74 If the style is one of the inheriting styles, Flash looks through the parent hierarchy for an inherited value. Flash looks for the style in the global style declaration. 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.
  • Page 75 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.
  • Page 76 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. Provides for slower movement at one or both ends for a speeding-up Regular effect, a slowing-down effect, or both.
  • Page 77: About Themes

    (The Halo theme does not use all styles included in the Sample theme.) The theme files are located in the following folders in a default installation: • Windows: \Program Files\Macromedia\Flash MX 2004\language\ Configuration\ComponentFLA\ •...
  • Page 78 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). Modify the symbol or delete the graphics and create new graphics. You may need to select View >...
  • Page 79 Modify all references to the source theme’s package to the new theme’s package. For example, change all occurrences of “halo” to “myTheme”. Save the changed FocusRect class file. Open the FLA file for your custom theme. This example uses MyTheme.fla. Open the library (Window >...
  • Page 80: About Skinning Components

    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. 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.
  • Page 81 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 .
  • Page 82 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.
  • Page 83 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.
  • Page 84 To link a skin to a style property: If you already applied the Sample theme to a document, skip to step 5. 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”...
  • Page 85 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. Add ActionScript code to the document to set the new style property on the component instances or at the global level.
  • Page 86 Select the RadioButton component on the Stage and open the Actions panel. Attach the following code to the RadioButton instance: onClipEvent(initialize){ trueUpIcon = "MyRadioTrueUp"; 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).
  • Page 87 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"]});...
  • Page 88 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: Follow the steps in “Editing component skins in a document”...
  • Page 89 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.”...
  • Page 90 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; Select File > Save and save this file as MyComboBox.as. Return to the file MyComboTest.fla.
  • Page 91: Chapter 6: Components Dictionary

    Other listings in this chapter ..........94 Types of components The following tables list the different components, arranged by category, in version 2 of the Macromedia Component Architecture. User interface (UI) components Component...
  • Page 92 (Flash Professional only) DateField component (Flash An nonselectable text field with a calendar icon. When a user clicks Professional only) inside the component’s bounding box, Macromedia Flash displays a DateChooser component. Label component A non-editable, single-line text field. List component Allows users to select one or more options from a scrolling list.
  • Page 93 Component Description DataProvider API The model for linear-access lists of data; it provides simple array- manipulation capabilities that broadcast data changes. DataSet component (Flash A building block for creating data-driven applications. Professional only) RDBMSResolver component Lets you save data back to any supported data source. This (Flash Professional only) component translates the XML that can be received and parsed by a web service, JavaBean, servlet, or ASP page.
  • Page 94: Other Listings In This Chapter

    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 Lets you manipulate slide presentation screens at runtime. only) Other listings in this chapter This chapter also describes several classes and APIs that don’t fall into the above categories of...
  • Page 95 Item Description TreeDataProvider interface A set of properties and methods used to create XML for the (Flash Professional only) property. Tree.dataProvider 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.
  • Page 96: Accordion Component (Flash Professional Only)

    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.
  • Page 97 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.
  • Page 98 Repeat steps 2-4 to create a screen named checkoutForm. Create a new screen named accordionForm. Drag an Accordion component from the Components panel to the accordionForm form, and name it myAccordion. With myAccordion selected, in the Property inspector, do the following: For the childSymbols property, enter addressForm, addressForm, and checkoutForm.
  • Page 99 property, enter shippingAddress, billingAddress, and checkout. For the childNames These strings are the ActionScript names of the accordion’s children. For the property, enter Shipping Address, Billing Address, and Checkout. childLabels These strings are the text labels on the accordion headers. For the property, enter AddressIcon, AddressIcon, and CheckoutIcon.
  • Page 100 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.
  • Page 101 Style Theme Description openDuration Both The duration, in milliseconds, of the transition animation. Both A reference to a tweening function that controls the animation. openEasing Defaults to sine in/out. For more information, see “Customizing component animations” on page Using skins with the Accordion component The Accordion component uses skins to represent the visual states of its header buttons.
  • Page 102 To create an ActionScript class to use as the skin and provide different states, the skin can read the style property of the skin to determine the state. The following table shows the borderStyle border style that is set for each skin: Property Border style falseUpSkin...
  • Page 103 clear(); lineStyle(0, 0, 100); beginFill(c, 100); drawRect(0, 0, __width, __height); endFill(); // required for skins static function classConstruct():Boolean UIObjectExtensions.Extensions(); _global.skinRegistry["AccordionHeaderSkin"] = true; return true; static var classConstructed:Boolean = classConstruct(); static var UIObjectExtensionsDependency = UIObjectExtensions; This class creates a square box based on the border style: a blue box for the false up, rollover, and disabled states;...
  • Page 104 To create movie clip symbols for Accordion header skins: Create a new FLA file. Create a new symbol by selecting Insert > New Symbol. Set the name to RedAccordionHeaderSkin If the advanced view is not displayed, click the Advanced button. Select Export for ActionScript.
  • Page 105 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.
  • Page 106 Method Description Gets the style property from the style declaration or object. UIObject.getStyle() Marks the object so it will be redrawn on the next frame interval. UIObject.invalidate() Moves the object to the requested position. UIObject.move() Forces validation of the object so it is drawn in the current frame. UIObject.redraw() Resizes the object to the requested size.
  • Page 107 Property Description A number indicating the scaling factor in the y direction of the UIObject.scaleY object, relative to its parent. The position of the top edge of the object, relative to its parent. UIObject.top Read-only. A Boolean value indicating whether the object is visible ( ) or UIObject.visible true...
  • Page 108 Events inherited from the UIComponent class The following table lists the events the Accordion class inherits from the UIComponent class. Event Description Broadcast when an object receives focus. UIComponent.focusIn Broadcast when an object loses focus. UIComponent.focusOut Broadcast when a key is pressed. UIComponent.keyDown Broadcast when a key is released.
  • Page 109 Example In the following example, a handler called is defined and passed to the myAccordionListener method as the second parameter. The event object is myAccordion.addEventListener() captured by the handler in the parameter. When the event is change eventObject change broadcast, a statement is sent to the Output panel.
  • Page 110 Example The following code creates an instance of the movie clip symbol named PaymentForm payment 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"});...
  • Page 111 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.
  • Page 112 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 parameter. Calling index this method destroys the corresponding header as well. If the destroyed child is selected, a new selected child is chosen.
  • Page 113 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.
  • Page 114 The default value is if the accordion has children. If the accordion myAccordion.getChildAt(0) 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;...
  • Page 115: Alert Component (Flash Professional Only)

    CHAPTER 6 Components Dictionary Alert component (Flash Professional only) 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.
  • Page 116 In the Actions panel, enter the following code on Frame 1 of the Timeline to define an event handler for the event: click 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);...
  • Page 117 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 “ ”...
  • Page 118 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 .
  • Page 119 If the advanced view is not displayed, click the Advanced button. Select Export for ActionScript. The identifier will be automatically filled out with TitleBackground 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.
  • Page 120 To understand more about the Alert class, see “Window component” on page 878 “PopUpManager class” on page 601. Method summary for the Alert class The following table lists the method of the Alert class. Method Description Creates an Alert window with optional parameters. Alert.show() Methods inherited from the UIObject class The following table lists the methods the Alert class inherits from the UIObject class.
  • Page 121 Property summary for the Alert class The following table lists properties of the Alert class. Property Description The height of each button, in pixels. The default value is 22. Alert.buttonHeight The width of each button, in pixels. The default value is 100. Alert.buttonWidth A constant hexadecimal value indicating whether a Cancel Alert.CANCEL...
  • Page 122 Property Description The left edge of the object, in pixels. Read-only. UIObject.x The top edge of the object, in pixels. Read-only. UIObject.y 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...
  • Page 123 Event Description Broadcast when an object’s state changes from invisible to visible. UIObject.reveal Broadcast when the subobjects are being unloaded. UIObject.unload 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...
  • Page 124 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.
  • Page 125 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";...
  • Page 126 Example In the following example, a handler called is defined and passed to the myClickHandler method as the fifth parameter. The event object is captured by Alert.show() myClickHandler in the parameter. The property of the event object is then used in a statement detail trace...
  • Page 127 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";...
  • Page 128 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";...
  • Page 129 A handler for the events broadcast when the buttons are clicked. In clickHandler click addition to the standard click event object properties, there is an additional property, detail which contains the flag value of the button that was clicked ( Alert.OK Alert.CANCEL ).
  • Page 130 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 parameter of the method. When used as a flags defaultButton Alert.show()
  • Page 131: Button Component

    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.
  • Page 132 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;...
  • Page 133 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 method (see setSize() ) or any applicable properties and methods of the Button class (see...
  • Page 134 Style Theme Description embedFonts Both A Boolean value that indicates whether the font specified in is an embedded font. This style must be set to fontFamily refers to an embedded font. Otherwise, the true fontFamily embedded font will not be used. If this style is set to true does not refer to an embedded font, no text will be fontFamily...
  • Page 135 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.
  • Page 136 Property Description falseDisabledIconEmphasized The icon disabled state of an emphasized button. The icon toggled state of an emphasized button. trueUpIconEmphasized The icon over-toggled state of an emphasized button. trueOverIconEmphasized trueDownIconEmphasized The icon pressed-toggled state of an emphasized button. trueDisabledIconEmphasized The icon disabled-toggled state of an emphasized button. The default value for all skin properties ending in “Skin”...
  • Page 137 To create an ActionScript customized Button skin: Create a new ActionScript class file. For this example, name the file RedGreenBlueSkin.as. Copy the following ActionScript to the file: import mx.skins.RectBorder; import mx.core.ext.UIObjectExtensions; class RedGreenBlueSkin extends RectBorder static var symbolName:String = "RedGreenBlueSkin"; static var symbolOwner:Object = RedGreenBlueSkin;...
  • Page 138 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.
  • Page 139 Repeat steps 2-11 and create green and blue skins, named accordingly. Click the Back button to return to the main Timeline. Drag a Button component to the Stage. Set the property value to to see all three skins. toggled true Copy the following ActionScript code to the Actions panel with the Button instance selected.
  • Page 140 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...
  • Page 141 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 Indicates whether a button has the look of a default SimpleButton.emphasized push button.
  • Page 142 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 Indicates whether the component can receive focus and input. UIComponent.enabled A number indicating the tab order for a component in a document.
  • Page 143 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.
  • Page 144 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"...
  • Page 145: Cellrenderer Api

    CHAPTER 6 Components Dictionary CellRenderer API 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.
  • Page 146 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.
  • Page 147 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.
  • Page 148 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;...
  • Page 149 Method Description Sets the width and height of a cell. CellRenderer.setSize() Sets the content to be displayed in the cell. CellRenderer.setValue() 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.
  • Page 150 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();...
  • Page 151 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 property of the rowHeight component, cells will bleed above and below the rows.
  • Page 152 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.
  • Page 153 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;...
  • Page 154 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 instead of , as follows:...
  • Page 155 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.
  • Page 156 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 ) calls to refresh the display of the grid. This code DataProvider.editField() setValue() would be written in the Flash application, either on a frame, on an object, or in another class file...
  • Page 157: Checkbox Component

    CHAPTER 6 Components Dictionary CheckBox component 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.
  • Page 158 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 ( ) or unchecked ( true...
  • Page 159 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 method setSize() ) or any applicable properties and methods of the...
  • Page 160 Style Theme Description textDecoration Both The text decoration: either . The "none" "underline" default value is "none" Sample The background color of the check box. The default symbolBackgroundColor value is 0xFFFFFF (white). Sample The background color of the check box when symbolBackgroundDisabledColor disabled.
  • Page 161 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. Expand the CheckBox Assets/States folder in the library of your document. Open the symbols you want to customize for editing. For example, open the CheckFalseDisabled symbol.
  • Page 162 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 Creates an object on the specified class. UIObject.createClassObject() Creates a subobject on an object.
  • Page 163 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 The position of the bottom edge of the object, relative to the UIObject.bottom bottom edge of its parent.
  • Page 164 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 Indicates whether a button has the appearance of a SimpleButton.emphasized default push button.
  • Page 165 Event Description Broadcast when an object’s state changes from invisible to visible. UIObject.reveal Broadcast when the subobjects are being unloaded. UIObject.unload Events inherited from the UIComponent class The following table lists the events the CheckBox class inherits from the UIComponent class. Event Description Broadcast when an object receives focus.
  • Page 166 The first usage example uses an handler and must be attached directly to a CheckBox on() instance. The keyword , used inside an handler attached to a component, refers to the this on() component instance. For example, the following code, attached to the check box myCheckBox sends “_level0.myCheckBox”...
  • Page 167 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.
  • Page 168 • The check box is pinned to the upper right corner of the bounding area. The label is "left" set to the left of the check box. • The label is set below the check box. The check box and label are centered "bottom"...
  • Page 169: Collection Interface (Flash Professional Only)

    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.
  • Page 170 Parameters The object to be added to the collection. If , it is not added to the collection. item item null Returns A Boolean value of if the collection was changed as a result of the operation. true Description Method; adds a new item to the end of the collection. Example The following example calls addItem()
  • Page 171 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.
  • Page 172 Collection.getItemAt() Availability Flash Player 7. Edition Flash MX Professional 2004. Usage collection.getItemAt(index) Parameters A number that indicates the location of within the collection. This is a zero-based index item index, so 0 retrieves the first item, 1 retrieves the second item, and so on. Returns An object containing a reference to the specified collection item, or is out of...
  • Page 173 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;...
  • Page 174 Collection.isEmpty() Availability Flash Player 7. Edition Flash MX Professional 2004. Usage collection.isEmpty() Returns A Boolean value of if the collection is empty. true Description Method; indicates whether the collection is empty. Example The following example calls isEmpty() on (click) { var myColl:mx.utils.Collection;...
  • Page 175 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;...
  • Page 176: Combobox Component

    CHAPTER 6 Components Dictionary ComboBox component 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.
  • Page 177 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: Description Control+Up If the drop-down list is open, focus returns to the text box and the drop-down list...
  • Page 178 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.
  • Page 179 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 event handler to the instance. For more change ComboBox information, see ComboBox.change Customizing the ComboBox component You can transform a ComboBox component horizontally and vertically while authoring.
  • Page 180 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.
  • Page 181 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.
  • Page 182 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.
  • Page 183 Method Description Removes an item from the list at the specified location. ComboBox.removeItemAt() Replaces the content of the item at the specified index. ComboBox.replaceItemAt() Sorts the list using a compare function. ComboBox.sortItems() Sorts the list using a field of each item. ComboBox.sortItemsBy() Methods inherited from the UIObject class The following table lists the methods the ComboBox class inherits from the UIObject class.
  • Page 184 Property summary for the ComboBox class The following table lists properties of the ComboBox class. Property Description The data model for the items in the list. ComboBox.dataProvider Returns a reference to the List component contained by the ComboBox.dropdown combo box. The width of the drop-down list, in pixels.
  • Page 185 Property Description The position of the top edge of the object, relative to its parent. UIObject.top Read-only. A Boolean value indicating whether the object is visible ( ) or UIObject.visible true not ( false The width of the object, in pixels. Read-only. UIObject.width The left edge of the object, in pixels.
  • Page 186 Event Description Broadcast when an object has been resized. UIObject.resize Broadcast when an object’s state changes from invisible to visible. UIObject.reveal Broadcast when the subobjects are being unloaded. UIObject.unload Events inherited from the UIComponent class The following table lists the events the ComboBox class inherits from the UIComponent class. Event Description Broadcast when an object receives focus.
  • Page 187 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 index of the new item). A string that indicates the label for the new item.
  • Page 188 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 property changes as a result of user interaction. ComboBox.selectedItem The first usage example uses an handler and must be attached directly to a ComboBox on() instance.
  • Page 189 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 combo box: myBox myBox.close(); See also ComboBox.open() ComboBox.close Availability Flash Player 6 (6.0 79.0).
  • Page 190 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 handler and must be attached directly to a ComboBox on() instance. The keyword , used in an handler attached to a component, refers to the this on()
  • Page 191 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 property, and changes to dataProvider this property are immediately available to both components.
  • Page 192 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 property, the list is created. dropdown See also ComboBox.dropdownWidth ComboBox.dropdownWidth...
  • Page 193 Making a combo box editable clears the combo box text field. It also sets the selected index (and item) to . To make a combo box editable and still retain the selected item, use the undefined following code: var ix = myComboBox.selectedIndex; myComboBox.editable = true;...
  • Page 194 The second usage example uses a dispatcher/listener event model. A component instance ) dispatches an event (in this case, ) and the event is handled by a comboBoxInstance enter function, also called a handler, on a listener object ( ) that you create. You define listenerObject a method with the same name as the event on the listener object;...
  • Page 195 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.addEventListener("itemRollOut", listenerObject) Event object...
  • Page 196 The second usage example uses a dispatcher/listener event model. A component instance ) dispatches an event (in this case, ) and the event is handled by comboBoxInstance itemRollOut a function, also called a handler, on a listener object ( ) that you create. You listenerObject define a method with the same name as the event on the listener object;...
  • Page 197 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 handler and must be attached directly to a ComboBox on() instance.
  • Page 198 Description Property; the name of the field in array objects to use as the label field. This is a dataProvider 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...
  • Page 199 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 .
  • Page 200 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. The first usage example uses an handler and must be attached directly to a ComboBox on()
  • Page 201 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...
  • Page 202 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 parameter collapse by one.
  • Page 203 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...
  • Page 204 However, since this expression is surrounded by double quotation marks, the value is sent 0-9-^\ 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.
  • Page 205 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();...
  • Page 206 The second usage example uses a dispatcher/listener event model. A component instance ) dispatches an event (in this case, ) and the event is handled by a comboBoxInstance scroll function, also called a handler, on a listener object ( ) that you create. You define listenerObject a method with the same name as the event on the listener object;...
  • Page 207 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, returns if the user enters any text in the selectedItem undefined text box.
  • Page 208 Parameters A reference to a function that compares two items to determine their sort order. compareFunc For details, see in Flash ActionScript Language Reference. This parameter Array.sort() is optional. Lets you perform multiple sorts of different types on a single array without optionsFlag having to replicate the entire array or re-sort it repeatedly.
  • Page 209 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 fieldName "label"...
  • Page 210 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 items are a combination of text strings and fieldName integers, the integer items are listed first. The parameter is usually fieldName "label"...
  • Page 211 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 value of an editable combo box: text myComboBox.text = "California";...
  • Page 212 Description Property (read-only); if the combo box is editable, returns the value of the text box. If the value combo box is static, returns the value of the drop-down list. The value of the drop-down value list is the field, or, if the field doesn’t exist, the field.
  • Page 213: Data Binding Classes (Flash Professional Only)

    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.
  • Page 214 Class Description EndPoint class (Flash Defines the source or destination of a binding. Professional only) TypedValue class (Flash Contains a data value and information about the value’s data type. Professional only) 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.
  • Page 215 The destination endpoint of the binding. This parameter is nominally of type destination , but can be any ActionScript object that has the required Endpoint mx.data.binding.EndPoint fields. An optional object that contains formatting information. The object must have the format following properties: •...
  • Page 216 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.execute([reverse]) Parameters A Boolean value that specifies whether the binding should also be executed from the reverse destination to the source (...
  • Page 217 CustomFormatter class (Flash Professional only) ActionScript Class Name mx.data.binding.CustomFormatter The CustomFormatter class defines two methods, , that provide the format() unformat() 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.
  • Page 218 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";...
  • Page 219 Method summary for the CustomFormatter class The following table lists the methods of the CustomFormatter class. Method Description Converts from a raw data type to a new object. CustomFormatter.format() Converts from a string, or other data type, to a raw data CustomFormatter.unformat() type.
  • Page 220 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.
  • Page 221 Method summary for the CustomValidator class The following table lists the methods of the CustomValidator class. Method Description Performs validation on data. CustomValidator.validate() Reports validation errors. CustomValidator.validationError() CustomValidator.validate() Availability Flash Player 6 (6.0 79.0). Edition Flash MX Professional 2004. Usage This method is called automatically;...
  • Page 222 To create and use a custom validator class: In Flash MX Professional 2004, create a new ActionScript (AS) file. 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);...
  • Page 223 Open the Timeline and select the first frame on Layer 1. Open the Actions panel. 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";...
  • Page 224 Each message you pass to is available in the property of the event validationError() messages object that was passed to the event handler. invalid 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.
  • Page 225 Property summary for the EndPoint class The following table lists the properties of the EndPoint class. Method Description A reference to a component instance. EndPoint.component A constant value. EndPoint.constant The name of an event, or array of event names, that the component will EndPoint.event emit when the data changes.
  • Page 226 Usage endPointObj.component Description Property; a reference to a component instance. Example This example assigns an instance of the List component ( ) as the component parameter listBox1 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.
  • Page 227 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.
  • Page 228 If you specify an object as the location, the object must specify two properties: path indices property is an array of strings, as discussed above, except that one or more of the path specified strings may be the special token .
  • Page 229 Description Property; specifies a property name of the component instance specified by that contains the bindable data. EndPoint.component Note: must combine to form a valid ActionScript object/ EndPoint.component EndPoint.property property combination. Example This example binds the property of one TextInput component ( ) to the same text text_1...
  • Page 230 ComponentMixins.getField() Availability Flash Player 6 (6.0 79.0). Edition Flash MX Professional 2004. Usage componentInstance.getField(propertyName, [location]) Parameters A string that contains the name of a property of the specified component. propertyName An optional parameter that indicates the location of a field within the component location property.
  • Page 231 ComponentMixins.initComponent() Availability Flash Player 6 (6.0 79.0). Edition Flash MX Professional 2004. Usage mx.data.binding.ComponentMixins.initComponent(componentInstance) Parameters A reference to a component instance. componentInstance Returns Nothing. Description Method (static); adds all the ComponentMixins methods to the component specified by . This method is called automatically for all components involved in a data componentInstance binding.
  • Page 232 Example The following example executes all the bindings for which the DataSet component instance named is the source EndPoint object: user_data 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;...
  • Page 233 Returns An array, or null Description Method; determines if the data in is valid based on the property’s schema settings. propertyName The property’s schema settings are those specified on the Schema tab in the Component Inspector panel. The method returns if the data is valid;...
  • Page 234 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);...
  • Page 235 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.
  • Page 236 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.
  • Page 237 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 that specifies how many digits to display after precision...
  • Page 238 Example This example attempts to get the value of a field ( ) in an productInfo.available XMLConnector component’s property first as a number or, if that fails, as a string. results import mx.data.binding.DataType; import mx.data.binding.TypedValue; var f: DataType = myXmlConnector.getField("results", "productInfo.available"); var b: TypedValue = f.getAnyTypedValue(["Number", "String"]);...
  • Page 239 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 that belongs to a component named propName myComponent retrieved as a number, and assigned to a variable: var dataTypeObj:mx.data.binding.DataType = myComponent.getField("propName");...
  • Page 240 DataType.getTypedValue() Availability Flash Player 6 (6.0 79.0). Edition Flash MX Professional 2004. Usage dataTypeObject.getTypedValue(requestedType) Parameters A string containing the name of a data type, or requestedType null Returns A TypedValue object (see “TypedValue class (Flash Professional only)” on page 244). Description Method;...
  • Page 241 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 newTypedValue “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: •...
  • Page 242 DataType.setAsBoolean() Availability Flash Player 6 (6.0 79.0). Edition Flash MX Professional 2004. Usage dataTypeObject.setAsBoolean(newBooleanValue) Parameters A Boolean value. newBooleanValue 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.
  • Page 243 Example The following example sets a variable named to the Number value of 32. It then sets the value referenced by field 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...
  • Page 244 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: •...
  • Page 245 Property summary for the TypedValue class The following table lists the properties of the TypedValue class. Property Description Contains the schema associated with the TypedValue object’s value. TypedValue.type Names the data type of the TypedValue object’s value. TypedValue.typeName Contains the data value of the TypedValue object. TypedValue.value Constructor for the TypedValue class Availability...
  • Page 246 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 in the Output panel: Boolean var t: TypedValue = new TypedValue (true, "Boolean", null); trace(t.typeName);...
  • Page 247: Datagrid Component (Flash Professional Only)

    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.
  • Page 248 When you design an application with the DataGrid component, it is helpful to understand how the List class underlying it was designed. The following are some fundamental assumptions and requirements that Macromedia used when developing the List class: •...
  • Page 249 • 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 property) you have on the Stage, the more work the list rowCount must to do to render.
  • Page 250 The view consists of three main parts: • 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.
  • Page 251 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 property to the DataGrid.dataProvider...
  • Page 252 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 Both...
  • Page 253 Style Theme Description hGridLines Both A Boolean value that indicates whether to show horizontal grid lines ( ) or not ( ). The default value is true false false Both The color of the vertical grid lines. The default value is vGridLineColor 0x666666 (medium gray).
  • Page 254 target.setStyle(style, source.getStyle(style)); For more information about class-level styles, see “Setting styles for a component class” on page 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”...
  • Page 255 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 Creates an object on the specified class. UIObject.createClassObject() Creates a subobject on an object. UIObject.createObject() Destroys a component instance.
  • Page 256 Method Description Sorts the items in the list according to the specified compare List.sortItems() function. Sorts the items in the list according to a specified property. List.sortItemsBy() Property summary for the DataGrid class The following table lists the properties of the DataGrid class. Property Description Read-only;...
  • Page 257 Property Description A number indicating the scaling factor in the x direction of the UIObject.scaleX object, relative to its parent. A number indicating the scaling factor in the y direction of the UIObject.scaleY object, relative to its parent. The position of the top edge of the object, relative to its parent. UIObject.top Read-only.
  • Page 258 Property Description The number of pixels the list can scroll to the right, when List.maxHPosition is set to List.hScrollPolicy "on" Indicates whether multiple selection is allowed in the list ( ) or List.multipleSelection true not ( false The number of rows that are at least partially visible in the list. List.rowCount The pixel height of every row in the list.
  • Page 259 Event Description Broadcast when the object has moved. UIObject.move Broadcast when an object has been resized. UIObject.resize Broadcast when an object’s state changes from invisible to UIObject.reveal visible. Broadcast when the subobjects are being unloaded. UIObject.unload Events inherited from the UIComponent class The following table lists the events the DataGrid class inherits from the UIComponent class.
  • Page 260 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;...
  • Page 261 DataGrid.addItem() Availability Flash Player 6 (6.0 79.0). Edition Flash MX Professional 2004. Usage myDataGrid.addItem(item) Parameters An instance of an object to be added to the grid. item 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 method in that an object is passed rather than a string.
  • Page 262 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.addEventListener("cellEdit", listenerObject) Description...
  • Page 263 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).
  • Page 264 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.addEventListener("cellFocusOut", listenerObject)
  • Page 265 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.addEventListener("cellPress", listenerObject)
  • Page 266 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;...
  • Page 267 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).
  • Page 268 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. When a DataGrid component dispatches a event, the event is handled by a function (also called a handler) that columnStretch...
  • Page 269 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 , and so on) needed for it to be the data model of a data grid, and can addItem() getItemAt()
  • Page 270 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.
  • Page 271 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 , which are both integers that indicate the columnIndex itemIndex index of the column and item of the cell.
  • Page 272 DataGrid.getColumnIndex() Availability Flash Player 6 (6.0 79.0). Edition Flash MX Professional 2004. Usage myDataGrid.getColumnIndex(columnName) Parameters A string that is the name of a column. columnName Returns A number that specifies the index of the column. Description Method; returns the index of the column specified by the parameter.
  • Page 273 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 property to prevent automatic DataGridColumn.sortOnHeaderRelease sorting and to let you sort as you like.
  • Page 274 Description Property; specifies whether the data grid has a horizontal scroll bar. This property can have the value , or . The default value is "on" "off" "auto" "off" is set to , columns scale proportionally to accommodate the finite width. hScrollPolicy "off"...
  • Page 275 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);...
  • Page 276 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 ( ) or not ( ). This property must be for individual columns to be resizable true false...
  • Page 277 Usage myDataGrid.showHeaders Description Property; a Boolean value that indicates whether the data grid displays the column headers ( true or not ( ). Column headers are shaded to differentiate them from the other rows in a grid. false Users can click column headers to sort the contents of the column if is set to .
  • Page 278 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 when any column header is pressed myGrid and released: myGrid.showHeaders = true myGrid.dataProvider = [{guitar:"Flying V", name:"maggot"}, {guitar:"SG", name:"dreschie"}, {guitar:"jagstang", name:"vitapup"}];...
  • Page 279 • takes in the field names of the desired item fields and generates DataGrid.columnNames 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.
  • Page 280 Parameters A string that indicates the name of the DataGridColumn object. This parameter is the name 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...
  • Page 281 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;...
  • Page 282 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”...
  • Page 283 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, , which is the item being rendered, and must item 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.
  • Page 284 Description Property; a Boolean value that indicates whether a column can be sorted by a user ( ) or not true ). The property must be set to for this property to take false DataGrid.sortableColumns true 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.
  • Page 285 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).width = 25;...
  • Page 286: Dataholder Component (Flash Professional Only)

    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.
  • Page 287 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...
  • Page 288 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.
  • Page 289 // 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;...
  • Page 290: Dataprovider Api

    DataSet component. The DataProvider API is the language with which data-aware components communicate with their data providers. In the Macromedia Flash documentation, “DataProvider” is the name of the API, dataProvider is a property of each component that acts as a view for data, and “data provider” is the generic term for a data source.
  • Page 291 Method Description Sorts the items in the data provider according to a compare DataProvider.sortItems() function or sort options. Sorts the items in the data provider alphabetically or numerically, DataProvider.sortItemsBy() 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.
  • Page 292 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 index insert the item; it is the index of the new item. An object containing the data for the item.
  • Page 293 Returns Nothing. Description Method; changes one field of the data provider. This method triggers the event with the event name modelChanged updateField Example The following code modifies the field of the third item: label myDP.editField(2, "label", "mynewData"); DataProvider.getEditingData() Availability Flash Player 6 (6.0 79.0). Edition Flash MX Professional 2004.
  • Page 294 Usage myDP.getItemAt(index) Parameters A number greater than or equal to 0 and less than . This number index DataProvider.length 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;...
  • Page 295 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 data provider to the Output panel: myArray trace(myArray.length);...
  • Page 296 A series of items has been deleted. removeItems A series of items needs refreshing. updateItems The data has been sorted. sort A field in an item must be changed and needs refreshing. updateField An entire field’s definition in the data provider needs refreshing. updateColumn The model has been filtered, and the view needs refreshing (reset the scroll filterModel...
  • Page 297 Description Method; removes all items in the data provider. This method triggers the event modelChanged 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.
  • Page 298 Parameters A number greater than or equal to 0. This number is the index of the item to change. index An object that is the new item. item Returns Nothing. Description Method; replaces the content of the item at the specified index. This method triggers the event with the event name modelChanged removeItems...
  • Page 299 • , which returns an integer index array that is the result of the Array.RETURNINDEXEDARRAY 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.
  • Page 300 The following are possible values for optionsFlag • —sorts highest to lowest. Array.DESCENDING • —sorts case-insensitively. Array.CASEINSENSITIVE • —sorts numerically if the two elements being compared are numbers. If they Array.NUMERIC aren’t numbers, use a string comparison (which can be case-insensitive if that flag is specified). •...
  • Page 301: Dataset Component (Flash Professional Only)

    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.
  • Page 302 logChanges is a Boolean value that defaults to . If this parameter is set to , the data set true true 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 .
  • Page 303 To create an application using the DataSet component: In Flash MX Professional 2004, select File > New. In the Type column, select Flash Document and click OK. Open the Components panel if it’s not already open. Drag a DataSet component from the Components panel to the Stage. In the Property inspector, give it the instance name userData.
  • Page 304 Double-click the Bound To field in the Component inspector to open the Bound To dialog box. In the Component Path field, select “DataSet <userData>” from the Component Path column, and then select “selectedIndex : Number” from the Schema Location column. Enter the following code in the Actions panel: nextBtn.addEventListener("click", nextBtnClick);...
  • Page 305 Method Description Stops sending DataSet events to listeners. DataSet.disableEvents() Resumes sending DataSet events to listeners. DataSet.enableEvents() Locates an item in the current view of the collection. DataSet.find() Locates the first occurrence of an item in the current view of DataSet.findFirst() the collection.
  • Page 306 Property summary for the DataSet class The following table lists the properties of the DataSet class. Property Description Returns the current item in the collection. DataSet.currentItem Returns the data provider. DataSet.dataProvider Returns changes made to the collection, or assigns changes to be DataSet.deltaPacket made to the collection.
  • Page 307 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. If you set the property of the event object to , the add operation is canceled;...
  • Page 308 DataSet.addItem() Availability Flash Player 7. Edition Flash MX Professional 2004. Usage dataSet.addItem([obj]) Parameters An object to add to this collection. This parameter is optional. Returns A Boolean value: if the item was added to the collection, if it was not. true false Description...
  • Page 309 Parameters A number greater than or equal to 0. This number indicates the position at which to index insert the item; it is the index of the new item. An object containing the data for the item. item Returns A Boolean value indicating whether the item was added: indicates that the item was added, true indicates that the item already exists in the data set.
  • Page 310 exception is thrown when is specified as a sort DataSetError DataSetIterator.Unique 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 array does not exist in this data set. fieldList Returns Nothing.
  • Page 311 Example In this example, a form named (not shown) is made visible once the items in the contactForm data set have been assigned. contact_ds 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.
  • Page 312 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.
  • Page 313 Description Method; returns if the collection, or any item in the collection, has changes pending that true 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.
  • Page 314 DataSet.createItem() Availability Flash Player 7. Edition Flash MX Professional 2004. Usage dataSet.createItem([itemData]) Parameters Data associated with the item. This parameter is optional. itemData 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 property.
  • Page 315 Usage dataSet.currentItem Description Property (read-only); returns the current item in the DataSet collection, or if the collection null 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 property), nor are any of the DataSet.deltaPacket...
  • Page 316 Description Property; returns a delta packet that contains all of the change operations made to the dataSet collection and its items. This property is until is called on null DataSet.applyUpdates() dataSet When is called, a transaction ID is assigned to the delta packet. This DataSet.applyUpdates() transaction ID is used to identify the delta packet on an update round trip from the server and back to the client.
  • Page 317 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.
  • Page 318 Usage dataSet.enableEvents() Returns Nothing. Description Method; reenables events for the DataSet objects after events have been disabled by a call to . To reenable events for the DataSet object, the DataSet.disableEvents() enableEvents() method must be called an equal or greater number of times than was called.
  • Page 319 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 . The empType following filter function returns if the field in the current item is set to true empType ;...
  • Page 320 return(item.empType != "management"); See also DataSet.filtered DataSet.find() Availability Flash Player 7. Edition Flash MX Professional 2004. Usage dataSet.find(searchValues) Parameters An array that contains one or more field values to be found within the searchValues current sort. Returns Returns if the values are found; otherwise, returns true false Description...
  • Page 321 // 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);...
  • Page 322 Example This example searches for the first item in the current collection whose fields name contain . If found, is used to get the unique identifier "Bobby" "13" DataSet.getItemId() for the item in the collection, and is used to position the current iterator DataSet.locateById() on that item.
  • Page 323 Conversion of the data specified is based on the underlying field’s type. For example, if the search value specified is , the underlying date field is used to convert the value with the ["05-02-02"] date’s method. If the value specified is , the date’s setAsString() [new Date().getTime()]...
  • Page 324 Example The following code positions the data set at the first item in its collection, inventoryData and then displays the value of the property contained by that item using the price property. DataSet.currentItem inventoryData.first(); trace("The price of the first item is:" + inventoryData.currentItem.price); See also DataSet.last() DataSet.getItemId()
  • Page 325 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.
  • Page 326 Edition Flash MX Professional 2004. Usage dataSet.hasNext() Returns A Boolean value. Description Method; returns if the current iterator is at the end of its view of the collection; otherwise, false 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 property of each item.
  • Page 327 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 A string that contains the name of a sort created with sortName DataSet.addSort() Returns...
  • Page 328 DataSet.isEmpty() Availability Flash Player 7. Edition Flash MX Professional 2004. Usage dataSet.isEmpty() Returns A Boolean value. Description Method; returns if the specified DataSet object doesn’t contain any items (that is, if true == 0). dataSet.length Example The following code disables a Delete Record button (not shown) if the DataSet object it applies to is empty.
  • Page 329 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.TransferObject { function clone():Object;...
  • Page 330 Description Event; generated immediately after the current iterator has scrolled to a new item in the collection. The event object ( ) contains the following properties: eventObj The DataSet object that generated the event. target The string type "iteratorScrolled" A number that specifies how many items the iterator scrolled; positive values indicate scrolled that the iterator moved forward in the collection;...
  • Page 331 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.
  • Page 332 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 . The DataSet.saveToSharedObj() method overwrites any data or pending changes that might DataSet.loadFromSharedObject() exist in this DataSet collection.
  • Page 333 Example This example uses to search for an item in the current collection whose DataSet.find() name fields contain the values and 105, respectively. If found, "Bobby" DataSet.getItemId() is used to get the unique identifier for that item, and is used to position DataSet.locateById() the current iterator at that item.
  • Page 334 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.addEventListener("modelChanged", listenerObject) Description Event; broadcast when the collection changes in some way—for example, when items are removed or added to the collection, when the value of an item’s property changes, or when the collection is filtered or sorted.
  • Page 335 String value Description " "updateField A field in an item has been changed and needs refreshing. A series of items needs refreshing. "updateItems" 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.
  • Page 336 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.
  • Page 337 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.
  • Page 338 Usage dataSet.readOnly Description Property; a Boolean value that specifies whether this collection can be modified ( ) or is false read-only ( ). Setting this property to prevents updates to the collection. The default true true value is false You can also set this property in the Property inspector. Example The following example makes the DataSet object named read-only, and then attempts...
  • Page 339 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. If you set the property of the event object to , the delete operation is canceled;...
  • Page 340 DataSet.removeItem() Availability Flash Player 7. Edition Flash MX Professional 2004. Usage dataSet.removeItem([item]) Parameters The item to be removed. This parameter is optional. item Returns A Boolean value. Returns if the item was successfully removed; otherwise, returns true false Description Method; removes the specified item from the collection, or removes the current item if parameter is omitted.
  • Page 341 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 event with the event name modelChanged removeItems In addition, it triggers the DataSet.removeItem event, which contains the result...
  • Page 342 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 A string that specifies the name of the sort to remove. sortName Returns Nothing. Description Method; removes the specified sort from this DataSet object if the sort exists. If the specified sort does not exist, this method throws a exception.
  • Page 343 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 is assigned a delta packet whose transaction ID DataSet.deltaPacket matches that of a delta packet previously retrieved from the DataSet object, and that has messages associated with any of the deltas or DeltaItem objects contained by that delta packet.
  • Page 344 for (var i = 0; i<data.length; i++) { cl = data[i].getChangeList(); for (var j = 0; j<cl.length; j++) { di = cl[j]; msg = di.getMessage(); if (msg.length>0) { 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!");...
  • Page 345 Example This example calls in a block and displays an error if there is a saveToSharedObj() try..catch 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.
  • Page 346 Example The following example sets the schema of the data set to a new XML object myDataSet containing appropriately formatted XML: myDataSet.schema = new XML("<properties><property name="billable"> ..etc.. </ properties>"); DataSet.selectedIndex Availability Flash Player 7. Edition Flash MX Professional 2004. Usage dataSet.selectedIndex Description Property;...
  • Page 347 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 on the DataSet DataSet.getIterator() object to which it is being assigned; otherwise; a exception is thrown. DataSetError Example myIterator:ValueListIterator = myDataSet.getIterator();...
  • Page 348 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 An integer specifying the number of records by which to move the iterator position. offSet Returns Nothing. Description Method; moves the current iterator’s position forward or backward in the collection by the amount specified by .
  • Page 349 Parameters A string that contains the name of the sort to use. sortName An integer value that indicates the sort order for the sort; the value must be order DataSetIterator.Ascending DataSetIterator.Descending. Returns Nothing. Description Method; switches the sort for the current iterator to the one specified by , if it exists.
  • Page 350: Datechooser Component (Flash Professional Only)

    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.
  • Page 351 To create an application with the DateChooser component: Double-click the DateChooser component in the Components panel to add it to the Stage. In the Property inspector, enter the instance name flightCalendar. In the Actions panel, enter the following code on Frame 1 of the Timeline to set the range of selectable dates: flightCalendar.selectableRange = {rangeStart:new Date(2003, 9, 15), rangeEnd:new Date(2003, 11, 31)}...
  • Page 352 Style Theme Description headerColor Both The background color for the component heading. The default color is white. Both The background color of a rolled-over date. The default value rollOverColor 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.
  • Page 353 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.
  • Page 354 Customize the symbol as desired. For example, change the tint of the arrow to red. 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. Click the Back button to return to the main Timeline.
  • Page 355 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 Creates an object on the specified class. UIObject.createClassObject() Creates a subobject on an object.
  • Page 356 Property Description A number indicating an element in the array to display in DateChooser.firstDayOfWeek dayNames the first column of the date chooser. An array of strings indicating the month names. DateChooser.monthNames A single selectable date or a range of selectable dates. DateChooser.selectableRange A Date object indicating the selected date.
  • Page 357 Event summary for the DateChooser class The following table lists the events that are exclusive to the DateChooser class. Event Description Broadcast when a date is selected. DateChooser.change Broadcast when the month buttons are clicked. DateChooser.scroll Events inherited from the UIObject class The following table lists the events the DateChooser class inherits from the UIObject class.
  • Page 358 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 handler and must be attached directly to a DateChooser on() instance. The keyword , used inside an handler attached to a component, refers to the this...
  • Page 359 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...
  • Page 360 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 , each of whose value must be rangeStart...
  • Page 361 Description Property; a number indicating which month is displayed. The number indicates an element in array, with 0 being the first month. The default value is the month of the monthNames current date. Example The following example sets the displayed month to December: myDC.displayedMonth = 11;...
  • Page 362 Description Property; a number indicating which day of the week (0-6, 0 being the first element of the array) is displayed in the first column of the DateChooser component. Changing this dayNames property changes the order of the day columns but has no effect on the order of the dayNames property.
  • Page 363 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 handler and must be attached directly to a DateChooser on() instance.
  • Page 364 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 .
  • Page 365 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 property. The default value is selectableRange undefined You cannot set the property within a disabled range, outside a selectable range, or selectedDate...
  • Page 366 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.
  • Page 367: Datefield Component (Flash Professional Only)

    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.
  • Page 368 The DateField component supports the following styles: Style Theme Description Halo The glow color for the rollover and selected dates. Possible themeColor values are , and . The "haloGreen" "haloBlue" "haloOrange" default value is "haloGreen" backgroundColor Both The background color. The default value is 0xEFEBEF (light gray).
  • Page 369 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.
  • Page 370 Ensure that the DateFieldAssets symbol is selected for Export in First Frame. Expand the DateField Assets/States folder in the library of your document. Open the symbols you want to customize for editing. For example, open the openIconUp symbol. Customize the symbol as desired. For example, draw a down arrow over the calendar image.
  • Page 371 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 Creates an object on the specified class. UIObject.createClassObject() Creates a subobject on an object.
  • Page 372 Property Description A number indicating an element in the array to display in DateField.firstDayOfWeek dayNames the first column of the DateField component. An array of strings indicating the month names. DateField.monthNames A reference to the DateChooser subcomponent. This property is DateField.pullDown read-only.
  • Page 373 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 Indicates whether the component can receive focus and input. UIComponent.enabled A number indicating the tab order for a component in a document.
  • Page 374 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 handler and must be attached directly to a DateField on() instance.
  • Page 375 Example This example, written on a frame of the Timeline, sends a message to the Output panel when a date field called is changed. The first line of code creates a listener object called . The myDF form second line defines a function for the event on the listener object.
  • Page 376 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 handler and must be attached directly to a DateField on() instance.
  • Page 377 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.
  • Page 378 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).
  • Page 379 Example The following example defines an array with Date objects that disable rangeStart rangeEnd 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)} ];...
  • Page 380 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.
  • Page 381 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"];...
  • Page 382 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 handler and must be attached directly to a DateField on() instance.
  • Page 383 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.
  • Page 384 Description Event; broadcast to all registered listeners when a month button is clicked. The first usage example uses an handler and must be attached directly to a DateField on() instance. The keyword , used inside an handler attached to a component, refers to the this on() component instance.
  • Page 385 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 .
  • Page 386 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 property. The default value is selectableRange undefined Example The following example sets the selected date to June 7: myDF.selectedDate = new Date(2003, 5, 7);...
  • Page 387 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”...
  • Page 388: Delegate Class

    See also EventDispatcher.addEventListener() Delegate class...
  • Page 389 CHAPTER 6 Components Dictionary Delta interface (Flash Professional only) ActionScript Interface Name 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.
  • Page 390: Delta Interface (Flash Professional Only)

    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 method: addDeltaItem() //... var d:Delta = new DeltaImpl("ID1345678", curItem, DeltaPacketConsts.Added, "", false); d.addDeltaItem(new DeltaItem(DeltaItem.Property, "ID", {oldValue:15, newValue:16}));...
  • Page 391 //... 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.
  • Page 392 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. For example, assuming that the DataSet component sends updates to a server and the server returns new key field values, this method allows the DataSet component to examine the resulting delta packet, find the original transfer object, and make the appropriate updates to it.
  • Page 393 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+= "...
  • Page 394 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 , and DeltaPacketConsts.Added...
  • Page 395 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 method: getSource() 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: ");...
  • Page 396 CHAPTER 6 Components Dictionary DeltaItem class (Flash Professional only) ActionScript Class Name 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.
  • Page 397: Deltaitem Class (Flash Professional Only)

    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.
  • Page 398 Usage deltaitem.kind Description Property; a number that indicates the type of change. Use the following constants to evaluate this property: • The change was made to a property on the transfer object. DeltaItem.Property • The change was made through a method call on the transfer object. DeltaItem.Method DeltaItem.message Availability...
  • Page 399 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.
  • Page 400 CHAPTER 6 Components Dictionary DeltaPacket interface (Flash Professional only) ActionScript Interface Name mx.data.components.datasetclasses.DeltaPacket The DeltaPacket interface is provided by the property of the DataSet component, deltaPacket which is part of the data management functionality in Flash MX Professional 2004. (For more information, see Chapter 14, “Data Integration (Flash Professional Only),”...
  • Page 401: Deltapacket Interface (Flash Professional Only)

    Usage deltaPacket.getConfigInfo(info) Parameters Object; contains information specific to the implementation. info 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.
  • Page 402 Example The following example uses the method to access the iterator for the deltas in a getIterator() delta packet and uses a statement to loop through the deltas: while var deltapkt:DeltaPacket = _parent.myDataSet.deltaPacket; trace("*** Test deltapacket. Trans ID is: " + deltapkt.getTransactionId() + " ***");...
  • Page 403 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 method:...
  • Page 404 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 call.
  • Page 405 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 . It also lets you manage reserved depths in a special highest-depth _root clip on for system-level services such as the cursor or tooltips.
  • Page 406: Depthmanager Class

    Property summary for the DepthManager class The following table lists the properties of the DepthManager class. Property Description A static property with the constant value 202. DepthManager.kBottom A static property with the constant value 101. This is the DepthManager.kCursor cursor depth. A static property with the constant value 204.
  • Page 407 Example The following example creates a instance of the MinuteSymbol movie clip and minuteHand 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 A class name.
  • Page 408 DepthManager.createClassObjectAtDepth() Availability Flash Player 6 (6.0 79.0). Edition Flash MX 2004. Usage DepthManager.createClassObjectAtDepth(className, depthSpace[, initObj]) Parameters A class name. This parameter is of type Function. className One of the following values: depthSpace DepthManager.kCursor DepthManager.kTooltip All depth flags are static properties of the DepthManger class. You must either reference the DepthManager package (for example, ), or use the mx.managers.DepthManager.kCursor...
  • Page 409 One of the following values: depthSpace DepthManager.kCursor DepthManager.kTooltip All depth flags are static properties of the DepthManger class. You must either reference the DepthManager package (for example, ), or use the mx.managers.DepthManager.kCursor statement to import the DepthManager package. import An optional initialization object. initObj Returns A reference to the created object.
  • Page 410 Description Property (static); a property with the constant value 101. This property is passed as a parameter in calls to DepthManager.createClassObjectAtDepth() to request placement at cursor depth. DepthManager.createObjectAtDepth() DepthManager.kNotopmost Availability Flash Player 6 (6.0 79.0). Edition Flash MX Professional 2004. Usage DepthManager.kNotopmost Description...
  • Page 411 Description Property (static); a property with the constant value 201. This property is passed as a parameter in calls to DepthManager.createClassChildAtDepth() to request placement on top of other content but below DepthManager.createChildAtDepth() content. DepthManager.kTopmost DepthManager.kTopmost Availability Flash Player 6 (6.0 79.0). Edition Flash MX Professional 2004.
  • Page 412 DepthManager.setDepthBelow() Availability Flash Player 6 (6.0 79.0). Edition Flash MX 2004 and Flash MX Professional 2004. Usage movieClipInstance.setDepthBelow(instance) Parameters An instance name. This parameter is of type MovieClip. instance 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.
  • Page 413 Example The following example sets the depth of the 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...
  • Page 414 Some event object properties are defined in the W3C specification (www.w3.org/TR/DOM- Level-3-Events/events.html) but aren’t implemented in version 2 of the Macromedia Component Architecture. Every version 2 event object has the properties listed in the table below. Some events have additional properties defined, and if so, the properties are listed in the event’s entry.
  • Page 415: Eventdispatcher Class

    Method summary for the EventDispatcher class The following table lists the methods of the EventDispatcher class. Method Description Registers a listener with a component instance. EventDispatcher.addEventListener() Dispatches an event programmatically. EventDispatcher.dispatchEvent() Removes an event listener from a component EventDispatcher.removeEventListener() instance. EventDispatcher.addEventListener() Availability Flash Player 6 (6.0 79.0).
  • Page 416 You can register multiple listeners to a single component instance, but you must use a separate call for each listener. Also, you can register one listener to multiple addEventListener() component instances, but you must use a separate call to for each instance. addEventListener() For example, the following code defines one listener object and assigns it to two Button component instances, whose...
  • Page 417 Parameters A reference to an event object. The event object must have a property that eventObject type is a string indicating the name of the event. Generally, the event object also has a property target 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.
  • Page 418: Focusmanager Class

    CHAPTER 6 Components Dictionary FocusManager class 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).
  • Page 419 To create a button that receives focus when a user presses Enter (Windows) or Return (Macintosh), set the property to the instance name of the FocusManager.defaultPushButton 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.
  • Page 420 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. To keep tabbing limited to objects inside the Flash application in Flash Player 7 ActiveX control, add the following parameter to the HTML tag:...
  • Page 421 Tip: In a class file that inherits from UIComponent, it is not good practice to refer to . Every UIComponent instance inherits a method, which _root.focusManager getFocusManager() returns a reference to the FocusManager instance responsible for controlling that component’s focus scheme.
  • Page 422 Property summary for the FocusManager class The following table lists the properties of the FocusManager class. Property Description The object that receives a event when a user FocusManager.defaultPushButton click presses the Return or Enter key. Indicates whether keyboard handling for the default FocusManager.defaultPushButtonEnabled push button is turned on ( ) or off (...
  • Page 423 Properties inherited from the UIComponent class The following table lists the properties the FocusManager class inherits from the UIComponent class. Property Description Indicates whether the component can receive focus and input. UIComponent.enabled A number indicating the tab order for a component in a document. UIComponent.tabIndex Event summary for the FocusManager class There are no events exclusive to the FocusManager class.
  • Page 424 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 event. click The default value is and the data type of this property is object. undefined The Focus Manager uses the emphasized style declaration of the SimpleButton class to visually indicate the current default push button.
  • Page 425 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 ( ) or not ( ) for a true false...
  • Page 426 Example The following code sets the focus to if the object that currently has focus is myOKButton 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;...
  • Page 427 Returns Nothing. Description Method; sends a event to listener objects registered to the default push button. Use this click method to programmatically send a event. click Example The following code triggers the default push button event and fills in the user name and click password fields when a user selects the CheckBox instance (the check box would be labeled...
  • Page 428 FocusManager.setFocus() Availability Flash Player 6 (6.0 79.0). Edition Flash MX 2004 and Flash MX Professional 2004. Usage focusManager.setFocus(object) Parameters A reference to the object to receive focus. object 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);...
  • Page 429 CHAPTER 6 Components Dictionary Form class (Flash Professional only) 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),”...
  • Page 430: Form Class (Flash Professional Only)

    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 ( ), or wait to load until the method is called ( ).
  • Page 431 Method Description Sets a skin in the object. UIObject.setSkin() Sets the style property on the style declaration or object. UIObject.setStyle() 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...
  • Page 432 Property Description Read-only; returns the root of the form tree, or subtree, that Form.parentForm contains the form. Specifies whether the form is visible when its parent form, slide, Form.visible 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.
  • Page 433 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 A Boolean value that indicates whether the content loads Loader.autoLoad automatically ( ) or you must call...
  • Page 434 Events inherited from the UIObject class The following table lists the events the Form class inherits from the UIObject class. Event Description Broadcast when an object is about to draw its graphics. UIObject.draw Broadcast when an object’s state changes from visible to invisible. UIObject.hide Broadcast when subobjects are being created.
  • Page 435 Event Description Broadcast when the mouse is moved while over a screen. Screen.mouseMove Broadcast when the mouse is moved from inside the screen to Screen.mouseOut outside it. Broadcast when the mouse is moved from outside this screen to Screen.mouseOver inside it. Broadcast when the mouse button was released over an object Screen.mouseUp (shape or movie clip) directly owned by the screen.
  • Page 436 Returns A Form object. Description Method; returns the child form of whose index is myForm 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;...
  • Page 437 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 that are derived directly myForm from the class mx.screens.Form. This property does not include any slides that are contained by ;...
  • Page 438 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 The following example code resides on a screen named that is a child of the default...
  • Page 439 Example In the following example, a reference to the root form of is placed in a variable named myForm . If the value assigned to refers to , then is at the top of its form tree. root root myForm myForm var root:mx.screens.Form = myForm.rootForm;...
  • Page 440 CHAPTER 6 Components Dictionary Iterator interface (Flash Professional only) ActionScript Class Name 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 Indicates whether the iterator has more items.
  • Page 441: Iterator Interface (Flash Professional Only)

    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.
  • Page 442 TextInput field that accepts a user’s name. If you’re building an application using components based on version 2 of the Macromedia Component Architecture, it’s a good idea to use a Label component instead of a plain text field because you can use styles to maintain a consistent look and feel.
  • Page 443: Label Component

    Note: The Label component’s property is different from the built-in ActionScript TextField autoSize object’s property. autoSize 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.
  • Page 444 Style Theme Description fontSize Both The point size for the font. The default value is 10. Both The font style: either . The default value fontStyle "normal" "italic" "normal" fontWeight Both The font weight: either . The default value "none" "bold"...
  • Page 445 Method Description Destroys a component instance. UIObject.destroyObject() Calls a function when parameters have been set in the Property UIObject.doLater() and Component inspectors. Gets the style property from the style declaration or object. UIObject.getStyle() Marks the object so it will be redrawn on the next frame interval. UIObject.invalidate() Moves the object to the requested position.
  • Page 446 Property Description A Boolean value indicating whether the object is visible ( ) or UIObject.visible true not ( false The width of the object, in pixels. Read-only. UIObject.width The left edge of the object, in pixels. Read-only. UIObject.x The top edge of the object, in pixels. Read-only. UIObject.y Event summary for the Label class There are no events exclusive to the Label class.
  • Page 447 • The bottom side of the label resizes to fit the text. The horizontal center of the label center stays anchored at its original horizontal center position. • The left and bottom sides of the label resize to fit the text. The top and right sides right don’t resize.
  • Page 448 Description Property; the text of a label. The default value is "Label" Example The following code sets the property of the Label instance and sends the text labelControl value to the Output panel: labelControl.text = "The Royal Nonesuch"; trace(labelControl.text); Label component...
  • Page 449 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 methods to add items to the list.
  • Page 450: List Component

    When you design an application with the List component, or any component that extends the List class, it is helpful to understand how the list was designed. The following are some fundamental assumptions and requirements that Macromedia used when developing the List class: •...
  • Page 451 • 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.
  • Page 452 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 , the list will fill with data. (For more myDP information about data providers, see List.dataProvider Select Control >...
  • Page 453 Style Theme Description embedFonts Both A Boolean value that indicates whether the font specified in is an embedded font. This style must be set to fontFamily refers to an embedded font. Otherwise, true fontFamily the embedded font will not be used. If this style is set to true does not refer to an embedded font, no text fontFamily...
  • Page 454 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 , the selection is not visible when backgroundDisabledColor the component is disabled unless one of these style properties is changed.
  • Page 455 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.Tree = new CSSStyleDeclaration();...
  • Page 456 To add a List component to the tab order of an application, set its property (see tabIndex ). The List component uses the Focus Manager to override the default UIComponent.tabIndex Flash Player focus rectangle and draw a custom focus rectangle with rounded corners. For more information, see “Creating custom focus navigation”...
  • Page 457 Method Description Forces validation of the object so it is drawn in the current frame. UIObject.redraw() Resizes the object to the requested size. UIObject.setSize() Sets a skin in the object. UIObject.setSkin() Sets the style property on the style declaration or object. UIObject.setStyle() Methods inherited from the UIComponent class The following table lists the methods the List class inherits from the UIComponent class.
  • Page 458 Property Description The selected item in a single-selection list. This property is read- List.selectedItem only. The selected item objects in a multiple-selection list. This property List.selectedItems is read-only. The topmost visible item of the list. List.vPosition Indicates whether the vertical scroll bar is displayed ( ), not List.vScrollPolicy "on"...
  • Page 459 Event summary for the List class The following table lists events that of the List class. Event Description Broadcast whenever user interaction causes the selection to List.change change. Broadcast when the pointer rolls over and then off of list items. List.itemRollOut Broadcast when the pointer rolls over list items.
  • Page 460 Usage listInstance.addItem(label[, data]) listInstance.addItem(itemObject) Parameters A string that indicates the label for the new item. label The data for the item. This parameter is optional and can be of any data type. data An item object that usually has properties. itemObject label data...
  • Page 461 The data for the item. This parameter is optional and can be of any data type. data An item object that usually has properties. itemObject label data Returns The index at which the item was added. Description Method; adds a new item to the position specified by the parameter.
  • Page 462 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.
  • Page 463 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.
  • Page 464 This example creates a data provider array and assigns it to the property, as in dataProvider the following: myDP = new Array(); list.dataProvider = myDP; for (var i=0; i<accounts.length; i++) { // these changes to the data provider will be broadcast to the list myDP.addItem({label: accounts[i].name, data: accounts[i].accountID});...
  • Page 465 Description Property; scrolls the list horizontally to the number of pixels specified. You can’t set hPosition unless the value of and the list has a that is greater than 0. hScrollPolicy "on" maxHPosition Example The following example gets the horizontal scroll position of myList var scrollPos = myList.hPosition;...
  • Page 466 Description Property; specifies the name of a field to be used as an icon identifier. If the field has a value of , the default icon specified by the style is used. If the style undefined defaultIcon defaultIcon , no icon is used. undefined Example The following example sets the...
  • Page 467 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 event has an itemRollOut index...
  • Page 468 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...
  • Page 469 The second usage example uses a dispatcher/listener event model. A component instance ) dispatches an event (in this case, ) and the event is handled by a listInstance itemRollOver function, also called a handler, on a listener object ( ) that you create. You define listenerObject a method with the same name as the event on the listener object;...
  • Page 470 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, , which is the item being rendered, and must item return a string representing the text to display.
  • Page 471 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 is set to List.hScrollPolicy . The list doesn’t precisely measure the width of text that it contains. You must set "on"...
  • Page 472 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.
  • Page 473 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).
  • Page 474 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.
  • Page 475 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 property is the best way to make sure items are fully rowHeight displayed. The default value is 20. Example The following example sets each row to 30 pixels: myList.rowHeight = 30;...
  • Page 476 The second usage example uses a dispatcher/listener event model. A component instance ) dispatches an event (in this case, ) and the event is handled by a function, listInstance scroll also called a handler, on a listener object ( ) that you create. You define a method listenerObject with the same name as the event on the listener object;...
  • Page 477 Description Property; the selected index of a single-selection list. The value is if nothing is undefined selected; the value is equal to the last item selected if there are multiple selections. If you assign a value to , any current selection is cleared and the indicated item is selected. selectedIndex Using the property to change selection doesn’t dispatch a...
  • Page 478 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, returns the item that was most recently selected.) If there selectedItem is no selection, the value is undefined...
  • Page 479 List.setPropertiesAt() Availability Flash Player 6 (6.0 79.0). Edition Flash MX 2004. Usage listInstance.setPropertiesAt(index, styleObj) Parameters A number greater than 0 or less than indicating the index of the item index List.length to change. An object that enumerates the properties and values to set. styleObj Returns Nothing.
  • Page 480 Description Method; sorts the items in the list by using the function specified in the parameter. compareFunc Example The following example sorts the items according to uppercase labels. Note that the parameters that are passed to the function are items that have properties.
  • Page 481 • , which returns an integer index array that is the result of the Array.RETURNINDEXEDARRAY 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.
  • Page 482 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 .
  • Page 483 CHAPTER 6 Components Dictionary Loader component 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.
  • Page 484: Loader Component

    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.
  • Page 485 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.
  • Page 486 Method Description Sets a skin in the object. UIObject.setSkin() Sets the style property on the style declaration or object. UIObject.setStyle() 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...
  • Page 487 Property Description The position of the right edge of the object, relative to the right UIObject.right edge of its parent. Read-only. A number indicating the scaling factor in the x direction of the UIObject.scaleX object, relative to its parent. A number indicating the scaling factor in the y direction of the UIObject.scaleY object, relative to its parent.
  • Page 488 Event Description Broadcast when an object has been resized. UIObject.resize Broadcast when an object’s state changes from invisible to visible. UIObject.reveal Broadcast when the subobjects are being unloaded. UIObject.unload Events inherited from the UIComponent class The following table lists the events the Loader class inherits from the UIComponent class. Event Description Broadcast when an object receives focus.
  • Page 489 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 event handler that shows the progress of the load.
  • Page 490 // 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:...
  • Page 491 The second usage example uses a dispatcher/listener event model. A component instance ) dispatches an event (in this case, ) and the event is handled by a loaderInstance complete function, also called a handler, on a listener object ( ) that you create. You define listenerObject a method with the same name as the event on the listener object;...
  • Page 492 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.
  • Page 493 Example The following code creates a Loader instance and sets the property to so that the autoload false loader must wait for a call to to begin loading content. Next, the property load() contentPath 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);...
  • Page 494 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 parameter or by a call to .
  • Page 495 Example The following code creates a Loader instance and then creates a listener object with an event handler for the event that sends a message to the Output panel telling what percent of progress the content has loaded: createClassObject(mx.controls.Loader, "loader", 0); loadListener = new Object();...
  • Page 496 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: •...
  • Page 497: Media Components (Flash Professional Only)

    Target Navigation Description Slider controls of a Move slider back The playbar indicates the user’s position within the given controller and forth 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.
  • Page 498 • Cue point objects, along with their name, time, and player properties (see ). The name of the cue point is arbitrary; use a Media.addCuePoint() Media.cuePoints name that will have meaning when using listener and trace events. A cue point broadcasts a event when the value of its time property is equal to that of the playhead location of cuePoint the MediaPlayback or MediaDisplay component with which it is associated.
  • Page 499 For FLV files, when is set to , the media is displayed at its preferred size, Media.autoSize true 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.
  • Page 500 You can associate the MediaDisplay and MediaController components with each other by using methods. These Media.associateDisplay() Media.associateController() 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.
  • Page 501 Set the desired options for the Automatically Play, Use Preferred Media Size, and Respect Aspect Ratio check boxes. Set the control placement to the desired side of the MediaPlayback component. 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.
  • Page 502 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: In Flash, select File >...
  • Page 503 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: •...
  • Page 504 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).
  • Page 505 To use a Labeled Frame CuePoint Navigation behavior: Place a MediaDisplay or MediaPlayback component instance on the Stage. Select the desired frame that you want the media to navigate to and, using the Property inspector, enter the frame name myLabeledFrame. Select your MediaDisplay or MediaPlayback instance.
  • Page 506 MediaDisplay parameters Name Type Default value Description Automatically Play Boolean Selected Determines if the media plays as soon as it has loaded. Media.autoPlay Use Preferred Media Size Boolean Selected Determines whether the media associated with the MediaDisplay instance conforms to Media.autoSize the component size or simply uses its default size.
  • Page 507 Name Type Default value Description horizontal Boolean true Determines whether the controller portion of the instance is vertically or horizontally Media.horizontal oriented. A value indicates that the true component will have a horizontal orientation. enabled Boolean Determines whether this control can be true modified by the user.
  • Page 508 You can find the media component source document at the following locations: • Windows: C:\Documents and Settings\user\Local Settings\Application Data\Macromedia\ Flash MX 2004\language\Configuration\ComponentFLA\MediaComponents.fla •...
  • Page 509 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 property, which is a class property. Class properties are version available only for the class itself. The property returns a string that indicates the version version of the component.
  • Page 510 Property summary for the Media class The following table lists properties of the Media class. Property Components Description MediaController Determines the component state when loaded Media.activePlayControl at runtime. MediaDisplay, Determines if the component instance maintains Media.aspectRatio MediaPlayback its video aspect ratio. MediaDisplay, Determines if the component instance Media.autoPlay...
  • Page 511 Property Components Description MediaDisplay, The default value of the width of a FLV file. Media.preferredWidth MediaPlayback MediaDisplay, An integer that indicates the total length of the Media.totalTime MediaPlayback media, in seconds. MediaDisplay, An integer from 0 (minimum) to 100 (maximum) Media.volume MediaPlayback that represents the volume level.
  • Page 512 Description Property; a string value that specifies the state the MediaController component should be in when it is loaded at runtime. A value of indicates a play state; a value of indicates a "play" "pause" paused state. Set this property and the property such that both indicate the same state.
  • Page 513 Description Method; adds a cue point object to a MediaPlayback or MediaDisplay instance. When the playhead time equals a cue point time, a event is broadcast. cuePoint Example The following code adds a cue point called when the playhead time equals Homerun myMedia 16 seconds.
  • Page 514 Edition Flash MX Professional 2004. Usage myMedia.associateController(instanceName) Parameters A string that specifies the instance name of the MediaController component instanceName 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 , you do not need to use Media.associateDisplay() Media.associateController()
  • Page 515 Description Method; associates a MediaController instance with a MediaDisplay instance. If you associate a MediaDisplay instance with a MediaController instance by using , you do not need to use Media.associateController() Media.associateDisplay() Example The following code associates with myMedia myDisplay myMedia.associateDisplay(myDisplay); See also Media.associateController() Media.autoPlay...
  • Page 516 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: •...
  • Page 517 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 indicates that the chrome background is drawn, and a value of "default"...
  • Page 518 // 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.
  • Page 519 When the event is triggered, it automatically passes an event object ( ) to the eventObject 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 event’s event object has Media.change two additional properties:...
  • Page 520 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();...
  • Page 521 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 property is equivalent to calling the contentPath Media.setMedia() method without specifying a...
  • Page 522 The possible values for this property are as follows: • specifies that the controls are always expanded. "on" • specifies that the controls are always collapsed. "off" • (the default) specifies that the control remains in the collapsed state until the user "auto"...
  • Page 523 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 event Media.cuePoint object has the following properties: A string that indicates the name of the cue point. name A number, expressed in frames or seconds, that indicates when the cue point was reached.
  • Page 524 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:...
  • Page 525 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();...
  • Page 526 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.
  • Page 527 Property; indicates the type of media (FLV or MP3) to be played. The default value is . See "FLV" “Importing Macromedia Flash Video (FLV) files” in Using Flash. Example The following example determines the current media type being played: var currentMedia = myMedia.mediaType;...
  • Page 528 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 startingPoint the media should begin playing. 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 Example...
  • Page 529 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 The string type...
  • Page 530 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 ( ) or paused true ). This property is read-only for the MediaDisplay and MediaPlayback components, and false read/write for the MediaController component.
  • Page 531 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...
  • Page 532 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 The string type "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;...
  • Page 533 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.removeCuePoint(cuePoint) Parameters...
  • Page 534 Media.setMedia() Applies to MediaDisplay, MediaPlayback Availability Flash Player 7. Edition Flash MX Professional 2004. Usage myMedia.setMedia(contentPath [, mediaType]) Parameters A string that indicates the URL of the media to be played. The default value is contentPath undefined A string used to set the media type to either FLV or MP3. This parameter mediaType is optional.
  • Page 535 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...
  • Page 536 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;...
  • Page 537 Description Event; broadcast when the volume value is adjusted by the user. The event object Media.volume has the following properties: An integer between 0 and 100 that represents the volume level. detail The string type "volume" Example The following example informs the user that the volume is being adjusted: var myVolListener = new Object();...
  • Page 538: Menu Component (Flash Professional Only)

    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.
  • Page 539 radio The item’s attribute is set to , and the previously selected item’s selected true selected attribute in the radio group is set to . The property of the corresponding radio false selection 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.
  • Page 540 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);...
  • Page 541 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 Type Default...
  • Page 542 Normal menu items menu item doesn’t have a attribute, which means that the attribute Normal Item type type defaults to . Normal items can be command activators or submenu activators, depending normal on whether they have nested subitems. Separator menu items A menu item whose attribute is set to acts as a visual divider in a menu.
  • Page 543 Radio button menu items Menu items whose attribute is set to can be grouped together so that only one of the type radio items can be selected at a time. You create a radio group by giving the menu items the same value for their attribute, as in the following example: groupName...
  • Page 544 About initialization object properties (Flash Professional only) (initialization object) parameter is a fundamental concept in creating the layout initObject 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 parameter, see “About menu item XML attributes”...
  • Page 545 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: Select File >...
  • Page 546 To use XML data from a server to create and populate a menu: Select File > New and create a Flash document. 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.
  • Page 547 To use the MenuDataProvider class to create and populate a menu: Select File > New and create a Flash document. 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.
  • Page 548 Using styles with the Menu component You can call the method to change the style of the menu, its items, and its setStyle() submenus.The Menu component supports the following styles: Style Theme Description themeColor Halo The base color scheme of a component. Possible values are , and .
  • Page 549 Style Theme Description textDecoration Both The text decoration: either . The "none" "underline" default value is "none" Both A number indicating the text indent. The default value is 0. textIndent defaultIcon Both The name of the default icon to display on each row. The default value is , which means no icon is undefined...
  • Page 550 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.
  • Page 551 Open the symbols you want to customize for editing. For example, open the MenuCheckEnabled symbol. Customize the symbol as desired. For example, change the image to be an X instead of a check mark. Repeat steps 6-7 for all symbols you want to customize. Click the Back button to return to the main Timeline.
  • Page 552 Method Description Returns the index of a given menu item. Menu.indexOf() Removes all items from a menu. Menu.removeAll() Removes the specified menu item. Menu.removeMenuItem() Removes a menu item from a menu at a specified location. Menu.removeMenuItemAt() Indicates whether a menu item is enabled ( ) or not ( Menu.setMenuItemEnabled() true...
  • Page 553 Property summary for the Menu class The following table lists the property of the Menu class. Property Description The data source for a menu. Menu.dataProvider 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...
  • Page 554 Event summary for the Menu class The following table lists events of the Menu class. Event Description Broadcast when a user causes a change in a menu. Menu.change Broadcast when a menu closes. Menu.menuHide Broadcast when a menu opens. Menu.menuShow Broadcast when the pointer rolls off an item.
  • Page 555 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 initObject menu item XML attributes” on page 541. An XML node object. childMenuItem Returns A reference to the added XML node. Description Method;...
  • Page 556 Parameters An integer indicating the index position (among the child nodes) at which the item is index added. An object containing properties that initialize a menu item’s attributes. See “About initObject menu item XML attributes” on page 541. An XML node object. childMenuItem Returns A reference to the added XML node.
  • Page 557 When the event is triggered, it automatically passes an event object ( ) to the eventObject 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 event’s event object has Menu.change the following additional properties:...
  • Page 558 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 parameter is omitted or null, the Menu is attached to the Timeline.
  • Page 559 Description Property; the data source for items in a Menu component. is an XML node object. Setting this property replaces the existing data Menu.dataProvider 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.
  • Page 560 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.
  • Page 561 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();...
  • Page 562 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.
  • Page 563 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();...
  • Page 564 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 The index of the menu item to remove. index Returns A reference to the returned menu item (XML node). This value is if there is no item undefined in that position.
  • Page 565 Version 2 components use a dispatcher-listener event model. When a Menu component broadcasts a event, the event is handled by a function (also called a handler) that is rollOut attached to a listener object ( ) that you create. You call the listenerObject method and pass it the name of the handler as a parameter.
  • Page 566 When the event is triggered, it automatically passes an event object ( ) to the eventObject 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 event’s event object has Menu.rollOver one additional property:...
  • Page 567 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 An XML node. The target menu item’s node in the data provider. item A Boolean value indicating whether the item is selected ( ) or not ( ).
  • Page 568 Parameters The x coordinate. 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.
  • Page 569 Method summary for the MenuDataProvider class The following table lists the methods of the MenuDataProvider class. Method Description Adds a child item. MenuDataProvider.addMenuItem() Adds a child item at a specified location. MenuDataProvider.addMenuItemAt() Gets a reference to a menu item at a specified location. MenuDataProvider.getMenuItemAt() Returns the index of a specified menu item.
  • Page 570 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)
  • Page 571 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.
  • Page 572 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"});...
  • Page 573 Parameters The index of the menu item. index Returns A reference to the removed menu item. This value is if there is no item in that undefined position. Description Method; removes the child item of the menu item specified by the parameter.
  • Page 574: Menubar Component (Flash Professional Only)

    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.
  • Page 575 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...
  • Page 576 This code creates a listener object, , that uses the event object, , to catch menu listen item selections. Note: You must call the method to register the listener with the menu addEventListener() instance, not with the menu bar instance. Select Control >...
  • Page 577 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”...
  • Page 578 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 pop- up 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.
  • Page 579 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 Returns a reference to the object that has focus. UIComponent.getFocus() Sets focus to the component instance.
  • Page 580 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 Indicates whether the component can receive focus and input. UIComponent.enabled A number indicating the tab order for a component in a document.
  • Page 581 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 Broadcast when an object receives focus. UIComponent.focusIn Broadcast when an object loses focus.
  • Page 582 Usage 2 adds a single menu and a labeled menu activator at the specified index. The content for the menu is defined in the parameter. menuDataProvider Example Usage 1: The following example places a menu to the left of all MenuBar menus: menu = myMenuBar.addMenuAt(0,"Toreador"); menu.addMenuItem("About Macromedia Flash", instanceName:"aboutInst"); menu.addMenuItem("Preferences", instanceName:"PrefInst"); Chapter 6: Components Dictionary...
  • Page 583 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.addMenuAt(0,"Edit",myMenuDP);...
  • Page 584 MenuBar.getMenuAt() Availability Flash Player 6 (6.0 79.0). Edition Flash MX Professional 2004. Usage myMenuBar.getMenuAt(index) Parameters An integer indicating the position of the menu. index Returns A reference to the menu at the specified index. This value is if there is no menu at undefined that position.
  • Page 585 Description Method; returns a Boolean value that indicates whether this menu can be chosen ( ) or true 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).
  • Page 586 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).
  • Page 587 A Boolean value indicating whether the menu item at the specified index is enabled boolean ) or not ( true 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.
  • Page 588: Numericstepper Component

    CHAPTER 6 Components Dictionary NumericStepper component 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 parameter, until the user releases the buttons or until the stepSize...
  • Page 589 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.
  • Page 590 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 method (see setSize() ) or any applicable properties and methods of the NumericStepper class.
  • Page 591 Style Theme Description textDecoration Both The text decoration: either . The default "none" "underline" value is "none" Both The number of milliseconds of delay between when a user first repeatDelay presses a button and when the action begins to repeat. The default value is 500 (half a second).
  • Page 592 To create movie clip symbols for NumericStepper skins: Create a new FLA file. 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”...
  • Page 593 Each component class has a property, which is a class property. Class properties are version available only on the class itself. The property returns a string that indicates the version version of the component. To access this property, use the following code: trace(mx.controls.NumericStepper.version);...
  • Page 594 Property summary for the NumericStepper class The following table lists properties of the NumericStepper class. Property Description A number indicating the maximum range value. NumericStepper.maximum A number indicating the minimum range value. NumericStepper.minimum A number indicating the next sequential value. This property is NumericStepper.nextValue read-only.
  • Page 595 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 Indicates whether the component can receive focus and input. UIComponent.enabled A number indicating the tab order for a component in a document.
  • Page 596 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 handler and must be attached directly to a NumericStepper on()
  • Page 597 Example This example, written on a frame of the Timeline, sends a message to the Output panel when a stepper called is changed. The first line of code creates a listener object called myNumericStepper . The second line defines a function for the event on the listener object.
  • Page 598 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;...
  • Page 599 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 property to 1 and the starting value to 4, which would stepSize make the value of nextValue myStepper.stepSize = 1;...
  • Page 600 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:...
  • Page 601: Popupmanager Class

    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.
  • Page 602 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();...
  • Page 603: Progressbar Component

    CHAPTER 6 Components Dictionary ProgressBar component 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.
  • Page 604 labelPlacement indicates the position of the label in relation to the progress bar. This parameter can be one of the following values: . The default value is bottom left right center bottom conversion is a number by which to divide the %1 and %2 values in the label string before they are displayed.
  • Page 605 To create an application with the ProgressBar component in polled mode: Drag a ProgressBar component from the Components panel to the Stage. In the Property inspector, do the following: Enter the instance name pBar. Select Polled for the mode parameter. Enter loader for the source parameter.
  • Page 606 A ProgressBar component supports the following styles: Style Theme Description Halo The base color scheme of a component. Possible values are themeColor , and . The default value "haloGreen" "haloBlue" "haloOrange" "haloGreen" color Both The text color. The default value is 0x0B333C for the Halo theme and blank for the Sample theme.
  • Page 607 A ProgressBar component supports the following skin properties: Property Description The expandable middle of the track. The default value is progTrackMiddleName ProgTrackMiddle The fixed-size left cap. The default value is progTrackLeftName ProgTrackLeft The fixed-size right cap. The default value is progTrackRightName ProgTrackRight progBarMiddleName...
  • Page 608 Each component class has a property, which is a class property. Class properties are version available only on the class itself. The property returns a string that indicates the version version of the component. To access this property, use the following code: trace(mx.controls.ProgressBar.version);...
  • Page 609 Property Description Indicates whether the size of the loading source is unknown. ProgressBar.indeterminate The text that accompanies the progress bar. ProgressBar.label The location of the label in relation to the progress bar. ProgressBar.labelPlacement The maximum value of the progress bar in manual mode. ProgressBar.maximum The minimum value of the progress bar in manual mode.
  • Page 610 Event summary for the ProgressBar class The following table lists events of the ProgressBar class. Event Description Triggered when loading is complete. ProgressBar.complete Triggered as content loads in manual or polled mode. ProgressBar.progress 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...
  • Page 611 Event object In addition to the standard event object properties, there are two additional properties defined for the event: (the loaded value equals total), and (the ProgressBar.complete current total total value Description Event; broadcast to all registered listeners when the loading progress has completed. The first usage example uses an handler and must be attached directly to a ProgressBar on()
  • Page 612 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 property.
  • Page 613 = new Object(); pbListener.complete = function(evt:Object) { evt.target._visible = false; my_pb.addEventListener("complete", pbListener); my_pb.mode = "polled"; my_pb.indeterminate = true; my_pb.source = my_ldr; my_ldr.autoLoad = false; my_ldr.scaleContent = false; my_ldr.load("http://www.macromedia.com/software/flex/images/ flex_presentation_eyes.jpg"); ProgressBar.label Availability Flash Player 6 (6.0 79.0). Edition Flash MX 2004. Usage pBarInstance.label...
  • Page 614 Description Property; text that indicates the loading progress. This property is a string in the format "%1 out . In this string, is a placeholder for the current bytes loaded, is a of %2 loaded (%3%%)" placeholder for the total bytes loaded, and is a placeholder for the percentage of content loaded.
  • Page 615 Usage pBarInstance.maximum Description Property; the largest value for the progress bar when the property is set ProgressBar.mode "manual" Example The following code sets the property to the total frames of a Flash application maximum that’s loading: pBar.maximum = _totalframes; See also ProgressBar.minimum ProgressBar.mode ProgressBar.minimum...
  • Page 616 = new Object(); pbListener.complete = function(evt:Object) { evt.target._visible = false; my_pb.addEventListener("complete", pbListener); my_pb.mode = "polled"; my_pb.indeterminate = true; my_pb.source = my_ldr; my_ldr.autoLoad = false; my_ldr.scaleContent = false; my_ldr.load("http://www.macromedia.com/software/flex/images/ flex_presentation_eyes.jpg"); ProgressBar.percentComplete Availability Flash Player 6 (6.0 79.0). Edition Flash MX 2004. Usage pBarInstance.percentComplete...
  • Page 617 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...
  • Page 618 The second usage example uses a dispatcher/listener event model. A component instance ) dispatches an event (in this case, ) and the event is handled by a pBarInstance progress function, also called a handler, on a listener object ( ) that you create. You define listenerObject a method with the same name as the event on the listener object;...
  • Page 619 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 property is set to . You can call this method to make the bar reflect ProgressBar.mode "manual"...
  • Page 620 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 . The default ProgressBar.minimum ProgressBar.maximum value is 0. Chapter 6: Components Dictionary...
  • Page 621: Radiobutton Component

    CHAPTER 6 Components Dictionary RadioButton component 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.
  • Page 622 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.
  • Page 623 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 method (see setSize() UIObject.setSize()
  • Page 624 Style Theme Description symbolBackgroundColor Sample The background color of the radio button. The default value is 0xFFFFFF (white). Sample The background color of the radio button when symbolBackgroundDisabledColor disabled. The default value is 0xEFEEEF (light gray). Sample The background color of the radio button when symbolBackgroundPressedColor pressed.
  • Page 625 To create movie clip symbols for RadioButton skins: Create a new FLA file. 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”...
  • Page 626 Note: The code returns trace(myRadioButtonInstance.version); 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...
  • Page 627 Property Description The text that appears next to a radio button. RadioButton.label The orientation of the label text in relation to a radio button or radio RadioButton.labelPlacement button group. Selects the radio button, and deselects the previously selected RadioButton.selected radio button. This property can be used with a RadioButton instance or a RadioButtonGroup instance.
  • Page 628 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 Indicates whether the component can receive focus and input. UIComponent.enabled A number indicating the tab order for a component in a document.
  • Page 629 Events inherited from the UIObject class The following table lists the events the RadioButton class inherits from the UIObject class. Event Description Broadcast when an object is about to draw its graphics. UIObject.draw Broadcast when an object’s state changes from visible to invisible. UIObject.hide Broadcast when subobjects are being created.
  • Page 630 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.
  • Page 631 radioGroup.addEventListener("click", form); The following code also sends a message to the Output panel when radioButtonInstance is clicked. The handler must be attached directly to on() radioButtonInstance on(click){ trace("radio button component was clicked"); RadioButton.data Availability Flash Player 6 (6.0 79.0). Edition Flash MX 2004.
  • Page 632 Example The following example sets the group name of a radio button instance to and then colorChoice changes the group name to . To test this example, place a radio button on the Stage, sizeChoice name the instance name , and enter the following code on Frame 1: myRadioButton myRadioButton.groupName = "colorChoice";...
  • Page 633 The following are the four possible values: • The radio button is pinned to the upper left corner of the bounding area. The label "right" is placed to the right of the radio button. • The radio button is pinned to the upper right corner of the bounding area. The label "left"...
  • Page 634 Usage radioButtonGroup.selectedData Description Property; selects the radio button with the specified data value and deselects the previously selected radio button. If the property is not specified for a selected instance, the value data label of the selected instance is selected and returned. The property can be of any selectedData data type.
  • Page 635: Radiobuttongroup Component

    CHAPTER 6 Components Dictionary RadioButtonGroup component For information about the RadioButtonGroup class, see RadioButton component. RadioButtonGroup component...
  • Page 636: Rdbmsresolver Component (Flash Professional Only)

    (Flash Professional only)” in Using Flash. For a complete example of an application that updates data using the RDBMSResolver component, see www.macromedia.com/ devnet/mx/flash/articles/delta_packet.html. Note: You can use the RDBMSResolver component to send data updates to any object you write that can parse XML and generate SQL statements against a database—for example, an ASP page, a...
  • Page 637 • The default value. This setting uses the old value of the key fields. This implies umUsingKey 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.
  • Page 638 ActionScript. In addition to these steps, you can also use the RDBMSResolver component to create bindings to apply the result packet sent back from the server to the data set. www.macromedia.com/devnet/mx/flash/ data_integration.html. RDBMSResolver class (Flash Professional only) Inheritance MovieClip >...
  • Page 639 Property summary for the RDBMSResolver component The following table lists properties of the RDBMSResolver class. Property Description The DataSet object’s property should be bound RDBMSResolver.deltaPacket deltaPacket to this property so that when DataSet.applyUpdates() called, the binding will copy it across and the resolver will create the update packet.
  • Page 640 Parameters String; provides the name of the field that this information object describes. fieldName String; provides the name of the table that owns this field. If this name is the same ownerName as the RDBMSResolver instance’s property, you can leave this parameter blank ( tableName ""...
  • Page 641 Property Description type String; the name of the event. XML object; the XML object about to be applied. updatePacket Returns Nothing. Description Property; a property of type . It receives a delta packet to be translated into an deltaPacket update packet, and outputs a delta packet from any server results placed in the updateResults property.
  • Page 642 Messages in the property are treated as errors. This means that a delta with updateResults 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.
  • Page 643 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 eventObject packets. This event object should contain the following properties: Property Description Object; the resolver broadcasting this event. target type String;...
  • Page 644 Edition This method is not currently available; for more information, see Flash MX 2004 release notes. Usage resolveData.reconcileUpdates(eventObject) Parameters Resolver event object; describes the customizations to the XML packet before the eventObject update is sent through the connector to the database. This event object should contain the following properties: Property Description...
  • Page 645 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 property.
  • Page 646 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.
  • Page 647: Rectborder Class

    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.
  • Page 648 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.
  • Page 649 // 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;...
  • Page 650 Ensure that the graphics are flush against the upper left corner with x and y coordinates set to (0,0). Your custom implementation will set the width and height according to the drawBorder component requirements. Click Back to return to the main Timeline. Drag several components that use RectBorder to the Stage.
  • Page 651: Screen Class (Flash Professional Only)

    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),”...
  • Page 652 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.
  • Page 653 Referencing loaded screens with ActionScript The Loader class creates an internal movie clip named into which it loads the SWF contentNode or JPEG file specified by the property. This movie clip, in effect, adds an extra contentPath screen node between the “placeholder” slide (that you created in the “master” presentation above) and the first slide in the loaded slide presentation.
  • Page 654 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 Returns the child screen of this screen at a particular index. Screen.getChildScreen() Methods inherited from the UIObject class The following table lists the methods the Screen class inherits from the UIObject class.
  • Page 655 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 Loads the content specified by the property.
  • Page 656 Property Description A Boolean value indicating whether the object is visible ( ) or UIObject.visible true not ( false The width of the object, in pixels. Read-only. UIObject.width The left edge of the object, in pixels. Read-only. UIObject.x The top edge of the object, in pixels. Read-only. UIObject.y Properties inherited from the UIComponent class The following table lists the properties the Screen class inherits from the UIComponent class.
  • Page 657 Event summary for the Screen class The following table lists events of the Screen class. Event Description Broadcast when all “in” transitions applied to a screen Screen.allTransitionsInDone have finished. Broadcast when all “out” transitions applied to a screen Screen.allTransitionsOutDone have finished. Broadcast when the mouse button was pressed over an object Screen.mouseDown (shape or movie clip) directly owned by the screen.
  • Page 658 Event Description Broadcast when a key is pressed. UIComponent.keyDown Broadcast when a key is released. UIComponent.keyUp Events inherited from the Loader class The following table lists the events the Screen class inherits from the Loader class. Event Description Triggered when the content finished loading. Loader.complete Triggered while content is loading.
  • Page 659 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. The event is broadcast by the Transition Manager associated with allTransitionsOutDone screenObj...
  • Page 660 screen2 subscreen1_2 has focus, the leafmost screen containing the focus is , which is myUIButton subscreen1_1 what would return. In this case, , and currentFocusedScreen presentation screen1 all contain the focus but the one that is “closest” (in the screen hierarchy) to the subscreen1_1 leaves of the tree (that is, farthest away from the root) is subscreen1_1...
  • Page 661 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 in its parent’s list of child myScreen screens. Example The following example displays the relative position of the screen in its parent screen’s myScreen list of child screens.
  • Page 662 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...
  • Page 663 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 ( ) to the handler. eventObj Each event object has properties that contain information about the event.
  • Page 664 // 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 ( ) to the handler.
  • Page 665 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. When the event is triggered, it automatically passes an event object ( ) to the handler.
  • Page 666 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 ( ) or not ( ).
  • Page 667 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...
  • Page 668: Scrollpane Component

    CHAPTER 6 Components Dictionary ScrollPane component 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.
  • Page 669 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.
  • Page 670 The first block of code is a event handler on the instance that displays scroll myScrollPane the value of the property in a TextField instance called . The second vPosition txtPosition block of code creates an event handler for the event that sends a message to the complete Output panel.
  • Page 671 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 “Using skins with the UIScrollBar component” on page 831.
  • Page 672 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 Creates an object on the specified class. UIObject.createClassObject() Creates a subobject on an object.
  • Page 673 Method Description The horizontal pixel position of the scroll pane’s horizontal scroll ScrollPane.hPosition bar. The status of the horizontal scroll bar. It can be always on ( ScrollPane.hScrollPolicy "on" always off ( ), or on when needed ( ). The default value "off"...
  • Page 674 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 Indicates whether the component can receive focus and input. UIComponent.enabled A number indicating the tab order for a component in a document.
  • Page 675 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 handler and must be attached directly to a ScrollPane on() instance.
  • Page 676 Example The following example creates a listener object with a event handler for the complete instance: scrollPane 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);...
  • Page 677 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 property: contentPath...
  • Page 678 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("...
  • Page 679 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).
  • Page 680 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 ( ), is never present "on"...
  • Page 681 Description Event; broadcast to all registered listeners while content is loading. The progress event is not always broadcast; the event may be broadcast without any events being complete progress dispatched. This can happen especially if the loaded content is a local file. Your application triggers the event when the content starts loading by setting the value of the progress...
  • Page 682 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.
  • Page 683 Event object In addition to the standard event object properties, there are two additional properties defined for event: a property whose value is , and a property whose scroll type "scroll" direction value can be "vertical" "horizontal" In addition to the standard event object properties, there are two additional properties defined for the event: (the loaded value equals...
  • Page 684 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 ( ) or not ( ) when a true false 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:...
  • Page 685 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;...
  • Page 686: Simplebutton Class

    CHAPTER 6 Components Dictionary SimpleButton class Inheritance MovieClip > UIObject class > UIComponent class > SimpleButton ActionScript Class Name mx.controls.SimpleButton The properties of the SimpleButton class let you control the following at runtime: • Whether a button has the emphasized look of a default push button •...
  • Page 687 Property summary for the SimpleButton class The following table lists properties of the SimpleButton class. Property Description Indicates whether a button has the appearance of a SimpleButton.emphasized default push button. The style declaration when the property is SimpleButton.emphasizedStyleDeclaration emphasized set to true A Boolean value indicating whether the button is SimpleButton.selected...
  • Page 688 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 Indicates whether the component can receive focus and input. UIComponent.enabled A number indicating the tab order for a component in a document.
  • Page 689 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.
  • Page 690 The second usage example uses a dispatcher/listener event model. A component instance ) dispatches an event (in this case, ) and the event is handled by a buttonInstance click function, also called a handler, on a listener object ( ) that you create. You define listenerObject a method with the same name as the event on the listener object;...
  • Page 691 Description Property; indicates whether the button is in an emphasized state ( ) or not ( ). The true false emphasized state is equivalent to the appearance of a default push button. In general, use the property instead of setting the property FocusManager.defaultPushButton emphasized...
  • Page 692 Usage buttonInstance.selected Description Property; a Boolean value that indicates whether the button is selected ( ) or not ( true 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;...
  • Page 693: Slide Class (Flash Professional Only)

    CHAPTER 6 Components Dictionary Slide class (Flash Professional only) 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),”...
  • Page 694 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.
  • Page 695 Select the Presentation slide and open the Components panel. Drag a Button component from the Components panel to the bottom of the Stage. In the Property inspector, type Next Slide for the Button component’s Label property. In the Actions panel, type the following code: on(click) { _parent.currentSlide.gotoNextSlide();...
  • Page 696 Method Description Marks the object so it will be redrawn on the next frame interval. UIObject.invalidate() Moves the object to the requested position. UIObject.move() Forces validation of the object so it is drawn in the current frame. UIObject.redraw() Resizes the object to the requested size. UIObject.setSize() Sets a skin in the object.
  • Page 697 Property Description Read-only; returns the currently active slide. Slide.currentSlide Callback handler that overrides the default keyboard navigation Slide.defaultKeydownHandler (Left and Right Arrow keys). Read-only; returns the slide’s first child slide that has no children. Slide.firstSlide Read-only; returns the slide’s index (zero-based) in its parent’s list Slide.indexInParentSlide of subslides.
  • Page 698 Property Description A Boolean value indicating whether the object is visible ( ) or UIObject.visible true not ( false The width of the object, in pixels. Read-only. UIObject.width The left edge of the object, in pixels. Read-only. UIObject.x The top edge of the object, in pixels. Read-only. UIObject.y Properties inherited from the UIComponent class The following table lists the properties the Slide class inherits from the UIComponent class.
  • Page 699 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 Read-only; returns the screen that contains the global current Screen.currentFocusedScreen focus.
  • Page 700 Events inherited from the UIComponent class The following table lists the events the Slide class inherits from the UIComponent class. Event Description Broadcast when an object receives focus. UIComponent.focusIn Broadcast when an object loses focus. UIComponent.focusOut Broadcast when a key is pressed. UIComponent.keyDown Broadcast when a key is released.
  • Page 701 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 has focus. This property accepts the string values mySlide "true"...
  • Page 702 Description Property (read-only); returns the immediate child of that contains the currently active mySlide slide; returns if no child slide contained by has the current focus. null mySlide Example Consider the following screen outline: Presentation Slide_1 Bullet1_1 SubBullet1_1_1 Bullet1_2 SubBullet1_2_1 Slide_2 Assuming that is the current slide, then the following statements are all true:...
  • Page 703 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.
  • Page 704 • A Boolean value indicating if the Shift key is currently being pressed ( ) or not shiftKey true false • A Boolean value indicating if the Control key is currently being pressed ( ) or ctrlKey true not ( false Returns Nothing.
  • Page 705 Description Property (read-only); returns the first child slide of that has no child slides. mySlide 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.
  • Page 706 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...
  • Page 707 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 .
  • Page 708 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.
  • Page 709 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 event.
  • Page 710 Also, still assuming that the current slide is , calling Intro_bullet_1_1 would have no effect, because does not contain the current Results.gotoNextSlide() Results slide (that is, Results.currentSlide null See also Slide.currentSlide Slide.gotoPreviousSlide() Slide.nextSlide Slide.gotoPreviousSlide() Availability Flash Player 6 (6.0 79.0). Edition Flash MX Professional 2004.
  • Page 711 Example Suppose that, in the following slide hierarchy, the slide named is the current Intro_bullet_1_2 slide being viewed (that is, _root.Presentation.currentSlide._name == Intro_bullet_1_2 In this case, calling would navigate to Intro_bullet_1_2.gotoPreviousSlide() , which is the previous sibling slide of Intro_bullet_1_1 Intro_bullet_1_2 However, calling would navigate to...
  • Page 712 Usage mySlide.gotoSlide(newSlide) Parameters The slide to navigate to. newSlide Returns A Boolean value indicating if the navigation succeeded ( ) or not ( true false Description Method; navigates to the slide specified by . For the navigation to succeed, the newSlide following must be true: •...
  • Page 713 on(click) { _parent.gotoSlide(_parent.currentSlide.nextSlide); This is equivalent to the following code, which uses the method: Slide.gotoNextSlide() 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;...
  • Page 714 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 in its parent’s list of child slides. mySlide Example The following code uses the properties to indexInParentSlide Slide.numChildSlides display the index of the current slide being viewed and the total number of slides contained by its parent slide.
  • Page 715 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. For example, you can use this property to display the name of the next slide in a presentation and let users select whether they want to navigate to that slide.
  • Page 716 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 contains. A slide can mySlide contain either forms or other slides;...
  • Page 717 Description Property; determines whether child slides of remain visible when navigating from one mySlide child slide to the next. When this property is , the previous slide remains visible when true control passes to its next sibling slide; when this property is , the previous slide is invisible false when control passes to its next sibling slide.
  • Page 718 is the root slide in a presentation, this property returns , because the mySlide false presentation slide’s parent is the main Timeline (_level0), not a slide. This property also returns if a form is the parent of false mySlide Example The following code determines whether the parent object of the slide is itself a slide.
  • Page 719 Description Property (read-only); returns the slide you would reach if you called , but does not actually navigate to that slide. For example, you mySlide.gotoPreviousSlide() 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.
  • Page 720 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.
  • Page 721: Stylemanager Class

    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/.
  • Page 722 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, colorStyle "highlightColor" , and so on). "shadowColor" "disabledColor" Returns Nothing. Description Method; adds a new color style to the Style Manager. Example The following example registers as a color style:...
  • Page 723 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.
  • Page 724: Systemmanager Class

    CHAPTER 6 Components Dictionary SystemManager class ActionScript Class Name mx.managers.SystemManager The SystemManager class works automatically with the FocusManager class to handle which top- level window is activated in an application that contains version 2 components. It also provides a property that allows components to access Stage coordinates. screen Property summary for the SystemManager class The following table lists the property of the SystemManager class.
  • Page 725: Textarea Component

    CHAPTER 6 Components Dictionary TextArea component 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.
  • Page 726 editable indicates whether the TextArea component is editable ( ) or not ( ). The true false default value is true wordWrap indicates whether the text wraps ( ) or not ( ). The default value is true false true You can write ActionScript to control these and additional options for the TextArea component using its properties, methods, and events.
  • Page 727 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 true The TextArea component has its...
  • Page 728 Style Theme Description textAlign Both The text alignment: either , or . The "left" "right" "center" default value is "left" Both A number indicating the text indent. The default value is 0. textIndent textDecoration Both The text decoration: either . The default "none"...
  • Page 729 Each component class has a property, which is a class property. Class properties are version available only on the class itself. The property returns a string that indicates the version version of the component. To access this property, use the following code: trace(mx.controls.TextArea.version);...
  • Page 730 Property summary for the TextArea class The following table lists properties of the TextArea class. Property Description A Boolean value indicating whether the field is editable ( ) or TextArea.editable true not ( false Defines the horizontal position of the text in the field. TextArea.hPosition Indicates whether the horizontal scroll bar is always on ( ), is...
  • Page 731 Property Description A number indicating the scaling factor in the y direction of the UIObject.scaleY object, relative to its parent. The position of the top edge of the object, relative to its parent. UIObject.top Read-only. A Boolean value indicating whether the object is visible ( ) or UIObject.visible true...
  • Page 732 Events inherited from the UIComponent class The following table lists the events the TextArea class inherits from the UIComponent class. Event Description Broadcast when an object receives focus. UIComponent.focusIn Broadcast when an object loses focus. UIComponent.focusOut Broadcast when a key is pressed. UIComponent.keyDown Broadcast when a key is released.
  • Page 733 The second usage example uses a dispatcher/listener event model. A component instance ) dispatches an event (in this case, ) and the event is handled by a textAreaInstance change function, also called a handler, on a listener object ( ) that you create. You define listenerObject a method with the same name as the event on the listener object;...
  • Page 734 Description Property; a Boolean value that indicates whether the component is editable ( ) or not true ). The default value is false 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;...
  • Page 735 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 ( ) or true not ( ). If the property is , the text field is an HTML text field. If false html true...
  • Page 736 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 property allows; the property indicates only how much text a user maxChars can enter.
  • Page 737 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 . The default value TextArea.vPosition is 0. Example The following code causes the text to scroll to the bottom of the component: myTextArea.vPosition = myTextArea.maxVPosition;...
  • Page 738 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 . If this property is , users can enter any character. If this property is an empty undefined null string, no characters can be entered.
  • Page 739 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 to remove the style sheet. If the style sheet in use is null undefined removed, the TextArea component is redrawn without a style sheet.
  • Page 740 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 instance, and then traces that string to the myTextArea Output panel: myTextArea.text = "The Royal Nonesuch"; trace(myTextArea.text);...
  • Page 741 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 ( ) or not ( ).
  • Page 742: Textinput Component

    CHAPTER 6 Components Dictionary TextInput component 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.
  • Page 743 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.
  • Page 744 Using styles with the TextInput component The TextInput component has its style properties defined backgroundColor borderStyle on a class style declaration. Class styles override global styles; therefore, if you want to set the style properties, you must create a different custom style backgroundColor borderStyle declaration or define it on the instance.
  • Page 745 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.
  • Page 746 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...
  • Page 747 Property Description The number of characters in a TextInput component. This property TextInput.length is read-only. The maximum number of characters that a user can enter in the text TextInput.maxChars field. The maximum possible value for . This TextInput.maxHPosition TextField.hPosition property is read-only. A Boolean value that indicates whether the text field is a password TextInput.password field that hides the entered characters.
  • Page 748 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 Indicates whether the component can receive focus and input. UIComponent.enabled A number indicating the tab order for a component in a document.
  • Page 749 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. This event cannot be used to prevent certain characters from being added to the component’s text field;...
  • Page 750 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;...
  • Page 751 textInputInstance.addEventListener("enter", listenerObject) Description Event; notifies listeners that the Enter key has been pressed. The first usage example uses an handler and must be attached directly to a TextInput on() instance. The keyword , used inside an handler attached to a component, refers to the this on() component instance.
  • Page 752 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.
  • Page 753 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 . The default value TextInput.hPosition is 0.
  • Page 754 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 . If this property is or an empty string ( ), a user can enter any character.
  • Page 755 property restricts only user interaction; a script may put any text into the text restrict 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.
  • Page 756: Transferobject Interface

    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 property specifies the name of the DataSet.itemClassName 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.
  • Page 757 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];...
  • Page 758 TransferObject.setPropertyData() Availability Flash Player 7. Edition Flash MX 2004. Usage class yourClass implements TransferObject { function setPropertyData(propData) { // your code here Parameters An object that contains the data assigned to this transfer object. propData Returns Nothing. Description Method; sets the data for this transfer object. The parameter is an object whose fields propData contain the data assigned by the DataSet component to this transfer object.
  • Page 759: Tree Component (Flash Professional Only)

    CHAPTER 6 Components Dictionary Tree component (Flash Professional only) 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.
  • Page 760 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.
  • Page 761 When a Tree displays a node, it uses the attribute of the node by default as the text label. 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.
  • Page 762 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 “Creating an application with the Tree component”...
  • Page 763 XML file. Create a new file called TreeNavMenu.xml in a text editor. Enter the following code in the file: <node> <node label="My Bookmarks"> <node label="Macromedia Web site" url="http://www.macromedia.com" /> <node label="MXNA blog aggregator" url="http://www.markme.com/mxna" /> </node> <node label="Google" url="http://www.google.com" /> </node>...
  • Page 764 myTree.addEventListener("change", treeListener); This code creates an XML object called and calls the method to load an myTreeDP XML.load() XML data source. The code then defines an event handler that sets the onLoad dataProvider property of the instance to the new XML object when the XML loads. For more myTree information about the XML object, see its entry in Flash ActionScript Language Reference.
  • Page 765 This code creates an XML object called . Any XML object on the same frame as a myTreeDP 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.
  • Page 766 To use a well-formed string to create XML in Flash while authoring: In Flash, select File > New and select Flash Document. Drag an instance of the Tree component onto the Stage. Select the Tree instance. In the Property inspector, enter the instance name myTree. In the Actions panel on Frame 1, enter the following code: var myTreeDP:XML = new XML("<node label='Local Folders'><node label='Inbox' data='0'/><node label='Outbox' data='1'/></node>");...
  • Page 767 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" Both The text color. color Both The color for text when the component is disabled.
  • Page 768 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 , which is a yellow open file folder "TreeFolderOpen" image. Both The number of pixels to indent each row of a Tree indentation component.
  • Page 769 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 , because the two must complement rollOverColor each other so that text is easily viewable during a rollover. Both The color of text in the selected row.
  • Page 770 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.
  • Page 771 Method Description Gets the style property from the style declaration or object. UIObject.getStyle() Marks the object so it will be redrawn on the next frame interval. UIObject.invalidate() Moves the object to the requested position. UIObject.move() Forces validation of the object so it is drawn in the current frame. UIObject.redraw() Resizes the object to the requested size.
  • Page 772 Property summary for the Tree class The following table lists properties of the Tree class. Property Description Specifies an XML data source. Tree.dataProvider Specifies the first node at the top of the display. Tree.firstVisibleNode Specifies the selected node in a Tree instance. Tree.selectedNode Specifies the selected nodes in a Tree instance.
  • Page 773 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 Assigns the class or symbol to use to display each row of the list. List.cellRenderer The source of the list items.
  • Page 774 Events inherited from the UIObject class The following table lists the events the Tree class inherits from the UIObject class. Event Description Broadcast when an object is about to draw its graphics. UIObject.draw Broadcast when an object’s state changes from visible to invisible. UIObject.hide Broadcast when subobjects are being created.
  • Page 775 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 label name is specified by the property). labelField An object of any type that is associated with the node. This parameter is optional. data Any XMLNode object.
  • Page 776 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 An object of any type that is associated with the node. This parameter is optional. data Any XMLNode object.
  • Page 777 Example The following example imports an XML file and assigns it to the instance of the myTree 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 property to XML.ignoreWhite true...
  • Page 778 Parameters An XMLNode object. node Returns The index of the specified node, or if the node is not currently displayed. undefined Description Method; returns the display index of the node specified in the parameter. node The display index indicates the item’s position in the list of items that are visible in the tree window.
  • Page 779 Tree.getIsOpen() Availability Flash Player 6 (6.0 79.0). Edition Flash MX Professional 2004. Usage myTree.getIsOpen(node) Parameters An XMLNode object. node Returns A Boolean value that indicates whether the tree is open ( ) or closed ( true false Description Method; indicates whether the specified node is open or closed. Note: Display indices change every time nodes open and close.
  • Page 780 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.
  • Page 781 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 event when one of its nodes is clicked closed; the event is handled by a function, also nodeClose called a handler, that is attached to a listener object ( ) that you create.
  • Page 782 Version 2 components use a dispatcher/listener event model. The Tree component dispatches a event when a node is clicked open by a user; the event is handled by a function, also nodeOpen called a handler, that is attached to a listener object ( ) that you create.
  • Page 783 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.
  • Page 784 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...
  • Page 785 Tree.setIcon() Availability Flash Player 6 (6.0 79.0). Edition Flash MX Professional 2004. Usage myTree.setIcon(node, linkID [, linkID2]) Parameters An XML node. node The linkage identifier of a symbol to be used as an icon beside the node. This parameter linkID is used for leaf nodes and for the closed state of branch nodes.
  • Page 786 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 when you want to create an empty folder.
  • Page 787: Treedataprovider Interface (Flash Professional Only)

    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.
  • Page 788 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 A string that displays the node. label An object of any type that is associated with the node. data Any XMLNode object.
  • Page 789 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 index should be added. A string that displays the node.
  • Page 790 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.
  • Page 791 TreeDataProvider.getTreeNodeAt() Availability Flash Player 6 (6.0 79.0). Edition Flash MX Professional 2004. Usage someNode.getTreeNodeAt(index) Parameters An integer representing the position of the child node in the current node. index 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...
  • Page 792 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 An integer indicating the position of the node to be removed. index Returns The removed XML node, or if an error occurs.
  • Page 793: Uicomponent Class

    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. The UIComponent class lets you do the following: •...
  • Page 794 Method Description Calls a function when parameters have been set in the Property and UIObject.doLater() Component inspectors. Gets the style property from the style declaration or object. UIObject.getStyle() Marks the object so it will be redrawn on the next frame interval. UIObject.invalidate() Moves the object to the requested position.
  • Page 795 Property Description The left edge of the object, in pixels. Read-only. UIObject.x The top edge of the object, in pixels. Read-only. UIObject.y Event summary for the UIComponent class The following table lists events of the UIComponent class. Event Description Broadcast when an object receives focus. UIComponent.focusIn Broadcast when an object loses focus.
  • Page 796 Example The following example sets the property of a CheckBox component to enabled 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;...
  • Page 797 Example The following code disables a Button component, , while a user types in the TextInput component, , 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;...
  • Page 798 The second usage example uses a dispatcher/listener event model. A component instance ) dispatches an event (in this case, ) and the event is handled by a componentInstance focusOut function, also called a handler, on a listener object ( ) that you create. You define listenerObject a method with the same name as the event on the listener object;...
  • Page 799 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 variable: var tmp = checkbox.getFocus();...
  • Page 800 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.addEventListener("keyUp", listenerObject) Description Event;...
  • Page 801 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 instance: checkbox...
  • Page 802: Uieventdispatcher Class

    CHAPTER 6 Components Dictionary UIEventDispatcher class ActionScript Class Name mx.events.UIEventDispatcher Inheritance 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.
  • Page 803 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.
  • Page 804 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 ( ) to the eventObject...
  • Page 805 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.
  • Page 806 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.
  • Page 807 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 ( ) to the eventObject...
  • Page 808: Uiobject Class

    RadioButton component, you would write the following code: myRadioButton.setSize(30, 30); You only need to create an instance of UIObject if you are using version 2 of the Macromedia Component Architecture to create a new component. Even in that case, UIObject is often created implicitly by other subclasses like Button.
  • Page 809 Method Description Sets a skin in the object. UIObject.setSkin() Sets the style property on the style declaration or object. UIObject.setStyle() Property summary for the UIObject class The following table lists properties of the UIObject class. Property Description The position of the bottom edge of the object, relative to the UIObject.bottom bottom edge of its parent.
  • Page 810 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);...
  • Page 811 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"});...
  • Page 812 UIObject.destroyObject() Availability Flash Player 6 (6.0 79.0). Edition Flash MX 2004. Usage componentInstance.destroyObject(instanceName) Parameters A string indicating the instance name of the object to be destroyed. instanceName Returns Nothing. Description Method; destroys a component instance. UIObject.doLater() Availability Flash Player 6 (6.0 79.0). Edition Flash MX 2004.
  • Page 813 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 method.
  • Page 814 The second usage example uses a dispatcher/listener event model. A component instance ) dispatches an event (in this case, ) and the event is handled by a componentInstance draw function, also called a handler, on a listener object ( ) that you create. You define listenerObject a method with the same name as the event on the listener object;...
  • Page 815 Example The following code sets the instance’s style property to bold if the instance’s fontWeight style property is bold: fontWeight 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);...
  • Page 816 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.
  • Page 817 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.
  • Page 818 The second usage example uses a dispatcher/listener event model. A component instance ) dispatches an event (in this case, ) and the event is handled by a componentInstance load function, also called a handler, on a listener object ( ) that you create. You define listenerObject a method with the same name as the event on the listener object;...
  • Page 819 The second usage example uses a dispatcher/listener event model. A component instance ) dispatches an event (in this case, ) and the event is handled by a componentInstance move function, also called a handler, on a listener object ( ) that you create. You define listenerObject a method with the same name as the event on the listener object;...
  • Page 820 UIObject.redraw() Availability Flash Player 6 (6.0 79.0). Edition Flash MX 2004. Usage componentInstance.redraw(always) Parameters A Boolean value. If , the method draws the object, even if wasn’t always true invalidate() called. If , the method draws the object only if was called.
  • Page 821 Description Event; notifies listeners that an object has been resized. The first usage example uses an handler and must be attached directly to a on() component instance. The second usage example uses a dispatcher/listener event model. A component instance ) dispatches an event (in this case, ) and the event is handled by a componentInstance resize...
  • Page 822 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);...
  • Page 823 Example The following example makes the check box twice as wide and sets the 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;...
  • Page 824 Description Method; resizes the object to the requested size. You should pass only integral values to , or the component may appear fuzzy. This method (like all methods and UIObject.setSize() 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 property of the contained list is also changed.
  • Page 825 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 A string indicating the name of the style property (for example, propertyName "fontWeight"...
  • Page 826 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.
  • Page 827 The second usage example uses a dispatcher/listener event model. A component instance ) dispatches an event (in this case, ) and the event is handled by a componentInstance unload function, also called a handler, on a listener object ( ) that you create. You define listenerObject a method with the same name as the event on the listener object;...
  • Page 828 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.
  • Page 829: Uiscrollbar Component

    CHAPTER 6 Components Dictionary UIScrollBar component 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.
  • Page 830 Verify that object snapping is turned on (View > Snapping > Snap to Objects). 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.
  • Page 831 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.
  • Page 832 Property Description scrollTrackName The symbol used for the scroll bar’s track (background). The default value ScrollTrack The symbol used for the scroll track (background) when rolled over. The scrollTrackOverName default value is undefined The symbol used for the scroll track (background) when pressed. The scrollTrackDownName default value is undefined...
  • Page 833 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.
  • Page 834 Method Description Sets a skin in the object. UIObject.setSkin() Sets the style property on the style declaration or object. UIObject.setStyle() 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...
  • Page 835 Property Description A number indicating the scaling factor in the y direction of the UIObject.scaleY object, relative to its parent. The position of the top edge of the object, relative to its UIObject.top parent. Read-only. A Boolean value indicating whether the object is visible ( UIObject.visible true or not (...
  • Page 836 Event Description Broadcast when an object’s state changes from invisible to UIObject.reveal visible. Broadcast when the subobjects are being unloaded. UIObject.unload Events inherited from the UIComponent class The following table lists the events the UIScrollBar class inherits from the UIComponent class. Event Description Broadcast when an object receives focus.
  • Page 837 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.
  • Page 838 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. property and the scroll bar’s onscreen image are updated UIScrollBar.scrollPosition before this event is broadcast.
  • Page 839 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. on(scroll){ trace("UIScrollBar component was clicked");...
  • Page 840 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).
  • Page 841 UIScrollBar.setScrollTarget() Availability Flash Player 6 (6.0 79.0). Edition Flash MX 2004. Usage scrollBarInstance.setScrollTarget(textInstance) Parameters The text field to assign to the scroll bar. textInstance 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.
  • Page 842: Web Service Classes (Flash Professional Only)

    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. In contrast, the WebServiceConnector component is an API unique to Flash MX Professional 2004 and provides an ActionScript interface to the visual WebServiceConnector component.
  • Page 843 Callback summary for the Log object The following table lists the callback of the Log object. Callback Description Called by Flash Player when a log message is sent to a log file. Log.onLog() Constructor for the Log class Availability Flash Player 6 (6.0 79.0). Edition Flash MX Professional 2004.
  • Page 844 As the web services code executes and messages are sent to the Log object, the function onLog() 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. The following are examples of log messages: 7/30 15:22:43 [INFO] SOAP: Decoding PendingCall response 7/30 15:22:43 [DEBUG] SOAP: Decoding SOAP response envelope...
  • Page 845 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)”...
  • Page 846 Method Description Retrieves the output value according to the specified PendingCall.getOutputValue() index. Retrieves an array of all the output values. PendingCall.getOutputValues() Property summary for the PendingCall object The following table lists properties of the PendingCall class. Property Description The SOAPCall operation descriptor for the PendingCall PendingCall.myCall operation.
  • Page 847 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 parameter of the callback result onResult...
  • Page 848 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 parameter of the callback function, but result onResult...
  • Page 849 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 parameter of the callback result onResult...
  • Page 850 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.
  • Page 851 Example The following callback traces the name of the SOAPCall operation. onResult 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...
  • Page 852 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)
  • Page 853 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;...
  • Page 854 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)”...
  • Page 855 Description Property; the number of concurrent requests. Possible values are listed in the table below: Value Description SOAPCall.MULTIPLE_CONCURRENCY Allows multiple active calls. Allows only one call at a time by causing a fault after one is active. SOAPCall.SINGLE_CONCURRENCY Allows only one call by cancelling previous ones. SOAPCall.LAST_CONCURRENCY SOAPCall.doDecoding Availability...
  • Page 856 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)”...
  • Page 857 Method summary for the WebService object The following table lists methods of the WebService object. Method Description Gets the SOAPCall object for a given operation. WebService.getCall() Invokes a specific web service operation defined by the WSDL. WebService.myMethodName() Callback summary for the WebService object The following table lists the callbacks of the WebService object.
  • Page 858 XML schema type ActionScript binding byte Number Number unsignedLong Number unsignedShort unsignedInt Number unsignedByte Number Number float Number double Date and Time Simple types XML schema type ActionScript binding Date object date Date object datetime duration Date object Date object gDay Date object gMonth...
  • Page 859 Object types XML schema type ActionScript binding XML object Complex Type ActionScript object composed of properties of any supported type ActionScript array composed of any supported object or type Array Supported XML schema object elements The following schema description illustrates the supported XML schema object elements: schema complexType complexContent...
  • Page 860 Usage myWebServiceObject = new WebService(wsdlURI [, logObject]); Parameters The URI of the web service WSDL file. wsdlURI An optional parameter specifying the name of the Log object for this web service. If logObject this parameter is used, the Log object must be created first. For more information, see “Log class (Flash Professional only)”...
  • Page 861 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).
  • Page 862 Usage callbackObj = myWebServiceObject.myMethodName(param1, ... paramN); Parameters Various parameters, depending on the web service method that is called. param1, ... paramN 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)”...
  • Page 863 Parameters Decoded ActionScript object version of the error with properties. If the error fault information came from a server in the form of XML, then the SOAPFault object will be the decoded ActionScript version of that XML. The type of error object returned to methods is a object.
  • Page 864 Usage myService.onLoad = function(wsdlDocument) // your code here Parameters The WSDL XML document. wsdlDocument 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.
  • Page 865: Webserviceconnector Component (Flash Professional Only)

    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.
  • Page 866 Create a binding between a web service parameter and a UI control, and set its Kind property to AutoTrigger. For more information, see “Schema kinds” in Using Flash. For a step-by-step example that connects and displays a web service using the WebServiceConnector component, see “Web Service Tutorial: Macromedia Tips”. WebServiceConnector class (Flash Professional only) Inheritance RPC >...
  • Page 867 Method summary for the WebServiceConnector class The following table lists the method of the WebServiceConnector class. Method Description Initiates a call to a web service. WebServiceConnector.trigger() Property summary for the WebServiceConnector class The following table lists properties of the WebServiceConnector class. Property Description Indicates whether multiple calls can take...
  • Page 868 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 ( ) or cannot ( ) take place at the same true false time. If this property is , the method performs a call if false WebServiceConnector.trigger()
  • Page 869 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;...
  • Page 870 Example The following example sets the property for a web service component named params 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. The parameter to the event handler is an object with the following fields: •...
  • Page 871 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 operation. trigger() Each WebServiceConnector component defines how this data is fetched, and what the valid types are.
  • Page 872 Example The following example defines a function for the event and assigns the sendFunction send function to the event handler: addEventListener 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.
  • Page 873 Here are the possible web service faults: faultcode faultstring detail Timeout Timeout while calling method MustUnderstand No callback for header xxx Server.Connection Unable to connect to endpoint: xxx VersionMismatch Request implements version: xxx Response implements version yyy Client.Disconnected Could not load WSDL Unable to load WSDL, if currently online, please verify the URI and/or format of the...
  • Page 874 faultcode faultstring detail Unknown.Call.Failure WebService invocation failed for unknown reasons Client.Disconnected Could not load imported Unable to load schema; if schema currently online, please verify the URI and/or format of the schema at (XXXX) Example The following example defines a function for the event and assigns the statusFunction...
  • Page 875 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"];...
  • Page 876 method performs the following steps: trigger() If any data is bound to the property, the method executes all the bindings to ensure that params up-to-date data is available. This also causes data validation to occur. If the data is not valid and is set to , the operation is suppressInvalidCalls...
  • Page 877 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.trigger(); WebServiceConnector component (Flash Professional only)
  • Page 878: Window Component

    CHAPTER 6 Components Dictionary Window component 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.
  • Page 879 title indicates the title of the window. closeButton indicates whether a close button is displayed ( ) or not ( ). Clicking the true false close button broadcasts a event, but doesn’t close the window. You must write a handler click that calls to explicitly close the window.
  • Page 880 This handler calls to instantiate a Window component with PopUpManager.createPopUp() 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.
  • Page 881 Style Theme Description fontWeight Both The font weight: either . The default value "none" "bold" . All components can also accept the value "none" "normal" in place of during a call, but subsequent "none" setStyle() calls to will return getStyle() "none"...
  • Page 882 Property Description skinCloseDisabled The close button in its disabled state. The default value is CloseButtonDisabled The close button in its over state. The default value is skinCloseOver CloseButtonOver The following example demonstrates how to create a new movie clip symbol to use as the title background.
  • Page 883 The best way to instantiate a window is to call . This method PopUpManager.createPopUp() 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);...
  • Page 884 Method Description Destroys a component instance. UIObject.destroyObject() Calls a function when parameters have been set in the Property and UIObject.doLater() Component inspectors. Gets the style property from the style declaration or object. UIObject.getStyle() Marks the object so it will be redrawn on the next frame interval. UIObject.invalidate() Moves the object to the requested position.
  • Page 885 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 The position of the bottom edge of the object, relative to the UIObject.bottom bottom edge of its parent.
  • Page 886 Event Description Broadcast when a window is created. Window.complete Broadcast when the mouse is clicked (released) outside the modal Window.mouseDownOutside window. Events inherited from the UIObject class The following table lists the events the Window class inherits from the UIObject class. Event Description Broadcast when an object is about to draw its graphics.
  • Page 887 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 handler and must be attached directly to a Window on() instance.
  • Page 888 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 ( ) or true not ( ). This property must be set in the parameter of the false initObject...
  • Page 889 A component instance ( ) dispatches an event (in this case, ) and the windowInstance complete event is handled by a function, also called a handler, on a listener object ( ) that listenerObject 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.
  • Page 890 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.
  • Page 891 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();...
  • Page 892 The second usage example uses a dispatcher/listener event model. A component instance ) dispatches an event (in this case, ) and the event is windowInstance mouseDownOutside handled by a function, also called a handler, on a listener object ( ) that you listenerObject create.
  • Page 893 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 , which indicates bold, white text. undefined Example With a Window component in the library, use the following ActionScript to format the style of the window’s title bar.
  • Page 894: Xmlconnector Component (Flash Professional Only)

    CHAPTER 6 Components Dictionary XMLConnector component (Flash Professional only) The XMLConnector component lets you read or write XML documents using HTTP operations. It acts as a connector between other components and external XML data POST sources. The XMLConnector component communicates with components in your application using either ActionScript code or data binding features in the Flash authoring environment.
  • Page 895 AutoTrigger. For more information, see “Schema kinds” in Using Flash. For a step-by-step example that connects and displays XML using the XMLConnector component, see “XML Tutorial: Timesheet” in the Data Integration tutorials at www.macromedia.com/go/data_integration. XMLConnector class (Flash Professional only) Inheritance RPCCall >...
  • Page 896 Property summary for the XMLConnector class The following table lists properties of the XMLConnector class. Property Description Indicates whether data is being sent, received, XMLConnector.direction or both. Indicates whether text nodes containing only white XMLConnector.ignorewhite space are discarded during the parsing process. Indicates whether multiple calls can take place at the XMLConnector.multipleSimultaneousAllowed same time.
  • Page 897 Description Property; indicates whether data is being sent, received, or both. The values are the following: • XML data for the property is sent by HTTP method to the URL for the send params POST XML document. Any data that is returned is ignored. The property is not set to results anything, and there is no...
  • Page 898 Usage componentInstance.multipleSimultaneousAllowed Description Property; indicates whether multiple calls can take place at the same time. If this property is , the method performs a call if another call is already in false XMLConnector.trigger() progress. A event is emitted, with the code .
  • Page 899 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 operation is trigger() executed. Each RPC component defines how this data is used, and what the valid types are. Example The following example defines parameters for...
  • Page 900 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 operation. trigger() 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 event.
  • Page 901 You can retrieve or modify the actual parameter values by using the property. params Example The following example defines a function for the event and assigns the sendFunction send function to the event handler: addEventListener var sendFunction = function (sendEnv) { sendEnv.target.params = [newParam_txt.text];...
  • Page 902 The following are the faults that can occur with the event: status FaultCode FaultString Notes params is not an XML value must be an XMLConnector.Not.XML params object ActionScript XML object. params had XML property of the XMLConnector.Parse.Error status params parsing error NN. XML object had a nonzero value NN.
  • Page 903 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 , the true method does not perform a call if the bound parameters fail the validation. A trigger() status event is emitted, with the code...
  • Page 904 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 property.
  • Page 905 This code specifies the URL of the XML file and sets multipleSimultaneousAllowed false It triggers the XMLConnector instance three times, which causes the event listener's status method to display the error code two times in the Output panel. The CallAlreadyInProgress first attempt is successfully sent from Flash to the server.
  • Page 906 This code specifies the URL of the XML file and sets multipleSimultaneousAllowed false It triggers the XMLConnector instance three times, which causes the event listener’s status() method to display the error code two times in the Output panel. The CallAlreadyInProgress first attempt is successfully sent from Flash to the server.
  • Page 907: Xupdateresolver Component (Flash Professional Only)

    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 object and convert it to an update packet in a format appropriate DataSet.deltaPacket to the type of resolver.
  • Page 908 XUpdateResolver component parameter The XUpdateResolver component has one authoring parameter, the Boolean parameter. When this parameter is set to , the update packet includeDeltaPacketInfo true includes additional information that can be used by an external data source to generate results that can be sent back to your application.
  • Page 909 XUpdateResolver component. For a step-by-step example that resolves data to an external data source using XUpdate, see “Update the timesheet” in the Data Integration tutorials at www.macromedia.com/go/ data_integration. XUpdateResolver class (Flash Professional only) Inheritance MovieClip >...
  • Page 910 Property summary for the XUpdateResolver class The following table lists properties of the XUpdateResolver class. Property Description Contains a description of the changes to the XUpdateResolver.deltaPacket DataSet component. The DataSet component’s property should be bound to this property deltaPacket so that when is called, the DataSet.applyUpdates() binding will copy it across and the resolver will create...
  • Page 911 Parameters Resolver event object; describes the customizations to the XML packet before the eventObject update is sent through the connector to the database. This event object should contain the following properties: Property Description Object; the resolver generating this event. target String;...
  • Page 912 Messages in the property are treated as errors. This means that a delta with updateResults 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.
  • Page 913 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.
  • Page 914 XUpdateResolver.xupdatePacket Availability Flash Player 7. Edition Flash MX Professional 2004. Usage resolveData.xupdatePacket Description Property; property of type 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.
  • Page 915: Chapter 7: Creating Components

    The source files for the version 2 components that install with Macromedia Flash MX 2004 and Macromedia Flash MX Professional 2004 are also installed with Flash. It is helpful to open a few of these files, look through them, and try to understand their structure before you build your own components.
  • Page 916: 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.
  • Page 917: Overview Of Component Structure

    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.
  • Page 918: Building Your First Component

    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,...
  • Page 919 In the Assets layer, select Frame 2 and drag an instance of UIComponent to the Stage. Choose File > Import > Open External Library and choose the DialAssets.fla file from the Macromedia/Flash MX 2004/Samples/HelpExamples/DialComponent folder. In the Assets layer, select Frame 2 and drag an instance of the DialFinal movie clip from the DialAssets library to the Dial library.
  • Page 920 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.
  • Page 921 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.
  • Page 922 // 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.
  • Page 923 To test the Dial component: 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.
  • Page 924: Selecting A Parent Class

    SWC file or compiled clip, use built-in live preview, view inspectable properties, and so on. However, if you want your components to work with the Macromedia version 2 components, and use the manager classes, you need to extend UIObject or UIComponent.
  • Page 925 • Handling low-level mouse and keyboard events. Understanding the UIObject class Components based on version 2 of the Macromedia Component Architecture descend from the UIObject class, which is a subclass of the MovieClip class. The MovieClip class is the base class for all classes in Flash that represent visual objects on the screen.
  • Page 926 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.
  • Page 927: Creating A Component Movie Clip

    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.
  • Page 928 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.
  • Page 929 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.
  • Page 930: Creating The Actionscript Class File

    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.
  • Page 931 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.
  • Page 932 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: (Optional) Import classes.
  • Page 933 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;...
  • Page 934 The following table describes these variables: Variable Type Description String The name of the ActionScript class (for example, ComboBox). symbolName This name must match the symbol’s Linkage Identifier. This variable must be static. Object The fully qualified class name (for example, mypackage.MyComponent). symbolOwner Do not use quotation marks around the value, because is is...
  • Page 935 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 property, the component flavorStr typically must perform an action to update itself in response to the property change.
  • Page 936 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.
  • Page 937 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.
  • Page 938 The following table describes the attributes of the Inspectable tag: Attribute Type Description String or (Optional) A default value for the inspectable property. defaultValue Number String (Optional) Specifies a comma-delimited list of legal values for enumeration the property. Number (Optional) Added for backward compatibility with Flash MX listOffset components.
  • Page 939 The InspectableList tag must immediately precede the class definition because it applies to the entire class. The following example allows the properties to be displayed in the flavorStr colorStr Property inspector, but excludes other inspectable properties from the Parent class: [InspectableList("flavorStr","colorStr")] class BlackDot extends DotParent { [Inspectable(defaultValue="strawberry")]...
  • Page 940 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 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.
  • Page 941 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.
  • Page 942 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 attribute. A collection property contains a series of collection items that you collectionItem define in a separate class.
  • Page 943 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. String (Required) Specifies the name of an inspectable property within the identifier collection item class that Flash MX uses as the default identifier when the user adds a new collection item through the Values dialog box.
  • Page 944 [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.
  • Page 945 If your component extends UIComponent or UIObject, Flash automatically calls init() , and methods and you can leave your constructor function empty, as createChildren() size() shown here: class MyComponent extends UIComponent{ // this is the constructor function function MyComponent(){ All version 2 components should define an function that is called after the constructor init() has been called.
  • Page 946 method is called from UIObject’s constructor, so the flow of control climbs up the init() chain of constructors until it reaches UIObject. UIObject’s constructor calls the method init() that is defined on lowest subclass. Each implementation of should call init() super.init() that its base class can finish initializing.
  • Page 947 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 method to create or modify visual elements of a component. In draw() other words, in the method, a component draws itself to match its state variables.
  • Page 948 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 method. (This method indicates that just the visuals for the object have invalidate() changed, but size and position of subobjects have not changed.
  • Page 949 The description of each event in the Flash MX 2004 documentation lists the event properties that are optional and required. For example, the event takes a property in ScrollBar.scroll detail addition to the properties. For more information, see the event descriptions in type target Chapter 6, “Components Dictionary,”...
  • Page 950 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.
  • Page 951 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 style. themeColor To register a skin to a style: Create a new ActionScript file and copy the following code into it: import mx.core.UIComponent;...
  • Page 952 Select the Shape movie clip in the library, select Component Definition from the Library options menu, and enter the AS 2.0 class Shape. 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 to red: shape...
  • Page 953: Exporting And Distributing A Component

    SWC files can be used to distribute components for use in Macromedia Flash MX 2004, Macromedia Dreamweaver MX 2004, and Macromedia Director MX 2004.
  • Page 954 You can optionally include other files in the SWC file, after you generate it from the Flash environment. For example, you might want to include a Read Me file, or the FLA file if you want users to have access to the component’s source code. To add additional files, use the Macromedia Extension Manager (see www.macromedia.com/exchange/em_download/).
  • Page 955: Adding The Finishing Touches

    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: Select the component movie clip in the Flash library. Select Export SWC File from the Library options menu.
  • Page 956 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: Create a new image. The image must measure 18 pixels square, and you must save it in PNG format. It must be 8- bit with alpha transparency, and the upper left pixel must be transparent to support masking.
  • Page 957 • 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.
  • Page 958 Chapter 7: Creating Components...
  • Page 959: Appendix: Collection Properties

    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.
  • Page 960: Defining A Collection Property

    This appendix contains the following sections: Defining a collection property ..........960 Simple collection example .
  • Page 961 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.Collection return myCompactDiscs;...
  • Page 962: Defining The Class For A Collection Item

    Choose Window > Other Panels > Common Libraries > Classes, and drag UtilClasses to the library of MyShelf.fla. In the MyShelf symbol’s Timeline, name one layer Assets. Create another layer and name it Actions. Place a function on Frame 1 of the Actions layer. stop() Select Frame 2 of the Assets layer and select Insert >...
  • Page 963: Accessing Collection Information Programmatically

    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. There are two scenarios in which to use the Collection and Iterator interfaces: •...
  • Page 964: Exporting Components That Have Collections To Swc Files

    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.
  • Page 965: Using A Component That Has A Collection Property

    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. To include the collection implementation class and collection item class in the SWC file, you define private variables in your component’s ActionScript file, as the following example shows: // collection item class...
  • Page 966 Appendix: Collection Properties...
  • Page 967: Index

    INDEX Binding tab, in sample application (tutorial) 32 borders. See RectBorder class accessibility 18 broadcaster 56 Accordion component Button component 131 creating an application with 97 creating an application with 132 customizing 99 customizing 133 events 107 events 142 inheritance 105 inheritance 139 methods 105 methods 140, 686...
  • Page 968 class style sheets 67 SimpleButton 686 classes Slide 695 Accordion 105 SOAPCall 854 Alert 119 StyleManager 721 and component inheritance 16 SystemManager 724 Binding 214 TextArea 728 Button 139 TextInput 745 CheckBox 161 Tree 770 ComboBox 182 TypedValue 244 ComponentMixins 229 UIComponent 925 creating references to (tutorial) 33 UIEventDispatcher 802...
  • Page 969 compiled clips class file example 930 about 17 class overview 932 in Library panel 47 className variable 933 component categories common events 949 data 92 creating a movie clip 927 managers 93 creating subobjects 946 media 93 defining 929 other 94 defining draw() 947 screens 94 defining init() 945...
  • Page 970 TypedValue class 244 methods 304 using at runtime 213 package 304 data binding, with XML file (tutorial) 31 parameters 301 data components 92 properties 306 data grids. See DataGrid component tutorial 23 data integration with components (tutorial) 22 DataType class 234 data models methods 235 DataGrid component 249...
  • Page 971 dispatcher 56 Form class 430 dispatching events 948 events 434 documentation inheritance 431 guide to terminology 9 methods 431 overview 8 package 431 draw() method, defining 947 parameters 431 properties 432 element (PendingCall.onFault) 851 element (WebService.onFault) 863 getters and setters 935 EndPoint class global style declarations 73 about 224...
  • Page 972 parameters 443 properties 446 manager components 93 tutorial 28 Media components 93, 497 using styles 444 behaviors 504 library Component inspector and 503 adding instances to 23 creating applications 508 compiled clips in 47 customizing 509 Library panel 47 design 498 StandardComponents 928 events 511 linkage identifiers for skins 81...
  • Page 973 parameters 575 properties 608 properties 579 using skins 606 using skins 577 using styles 605 using styles 576 Property inspector 47 MenuDataProvider class 568 prototype 89 events 569 methods 569 metadata 935 RadioButton component 621, 635 Collection tag 942 creating an application 622 Event tag 939 customizing 623 Inspectable tag 937...
  • Page 974 separator 542 using (tutorial) 35 SimpleButton class 686 See also individual component names events 688 subclasses, using to replace skins 89 methods 686 subcomponents, applying skins 86 properties 687 subobjects, creating 946 size() method, defining 947 superclass keyword 933 skin properties suppressInvalidCalls parameter 865 changing in the prototype 89 SWC files 17...
  • Page 975 themes 77 UIScrollBar component 829 applying 79 creating an application 829 creating 77 customizing 830 tip text, adding 956 events 835 TransferObject interface inheritance 833 about 756 methods 833 methods 756 package 833 Tree component 759 parameters 829 creating an application 762 properties 834 customizing 766 using skins 831...
  • Page 976 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 attributes of menu item 541 formatting for the Tree component 760 schema types 857 XMLConnector component 894 binding to DataSet (tutorial) 31...

This manual is also suitable for:

Flash mx

Table of Contents