MACROMEDIA FLASH 8-COMPONENTS LANGUAGE Reference

Components language reference
Table of Contents

Advertisement

Components Language Reference

Advertisement

Table of Contents
loading

Summary of Contents for MACROMEDIA FLASH 8-COMPONENTS LANGUAGE

  • Page 1 Components Language Reference...
  • Page 2 If you access a third-party website mentioned in this guide, then you do so at your own risk. Macromedia provides these links only as a convenience, and the inclusion of the link does not imply that Macromedia endorses or accepts any responsibility for the content on those third-party sites.
  • Page 3: Table Of Contents

    Contents Chapter 1: Components Dictionary ......29 Types of components ......... 30 Other listings in this chapter.
  • Page 4 Chapter 4: Button component ......89 Using the Button component ........90 Customizing the Button component .
  • Page 5 Chapter 8: ComboBox component ......157 Using the ComboBox component ......159 Customizing the ComboBox component .
  • Page 6 Chapter 9: Data binding classes (Flash Professional only) . . . 207 Making data binding classes available at runtime (Flash Professional only) ........207 Classes in the mx.data.binding package (Flash Professional only) .
  • Page 7 TypedValue.type..........246 TypedValue.typeName .
  • Page 8 DataGridColumn.columnName ....... 303 DataGridColumn.editable ........304 DataGridColumn.headerRenderer.
  • Page 9 DataSet.calcFields......... . . 348 DataSet.changesPending() .
  • Page 10 DataSet.removeSort() ........399 DataSet.resolveDelta .
  • Page 11 DateField.firstDayOfWeek........452 DateField.monthNames ........452 DateField.open().
  • Page 12 Chapter 20: DepthManager class ......487 DepthManager.createChildAtDepth() ......489 DepthManager.createClassChildAtDepth() .
  • Page 13 FocusManager.getFocus()........731 FocusManager.nextTabIndex ....... . . 732 FocusManager.sendDefaultPushButtonEvent().
  • Page 14 List.iconField ..........784 List.iconFunction .
  • Page 15 Chapter 29: Media components (Flash Professional only) ..831 Interacting with media components (Flash Professional only)..832 Understanding media components (Flash Professional only) ..833 Using media components (Flash Professional only) ... . . 836 Media component parameters (Flash Professional only) .
  • Page 16 Media.removeCuePoint()........878 Media.setMedia()..........879 Media.stop() .
  • Page 17 Chapter 31: MenuBar component (Flash Professional only)....... . 945 Interacting with the MenuBar component (Flash Professional only) .
  • Page 18 ProgressBar.label ......... . .1008 ProgressBar.labelPlacement .
  • Page 19 Chapter 38: RectBorder class......1063 Using styles with the RectBorder class ......1064 Creating a custom RectBorder implementation .
  • Page 20 ScrollPane.vLineScrollSize ........1119 ScrollPane.vPageScrollSize........1120 ScrollPane.vPosition .
  • Page 21 Chapter 43: StyleManager class ......1171 StyleManager.registerColorName() ......1172 StyleManager.registerColorStyle().
  • Page 22 TextInput.password......... . 1228 TextInput.restrict .
  • Page 23 Tree.getDisplayIndex() ........1291 Tree.getIsBranch() .
  • Page 24 Chapter 52: UIComponent class......1339 UIComponent class (API) ........1339 UIComponent.enabled .
  • Page 25 UIObject.right ..........1379 UIObject.scaleX .
  • Page 26 PendingCall.getOutputValues() ....... 1429 PendingCall.myCall ......... .1430 PendingCall.onFault .
  • Page 27 Window.closeButton ........1478 Window.complete .
  • Page 28 Contents...
  • Page 29: Chapter 1: Components Dictionary

    CHAPTER 1 Components Dictionary The Components Language Reference book describes each component and its application programming interface (API). To learn how to use, customize, and create components, see Using Components. In Components Language Reference, each component description contains information about the following: Keyboard interaction Live preview Accessibility...
  • Page 30: Types Of Components

    (Flash Professional only) DateField component (Flash An nonselectable text field with a calendar icon. When a user Professional only) clicks 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 31 Component Description ScrollPane component Displays movie clips, bitmaps, and SWF files in a limited area using automatic scroll bars. TextArea component An optionally editable, multiline text field. TextInput component An optionally editable, single-line text input field. Tree component (Flash Allows a user to manipulate hierarchical information. Professional only) Window component A draggable window with a title bar, caption, border, and...
  • Page 32 Media components Component Description FLVPlayback Component Lets you include a video player in your Flash application to (Flash Professional Only) play progressive streaming video over HTTP, from a Flash Video Streaming Service (FVSS), or from Flash Communication Server (FCS). MediaController component Controls streaming media playback in an application (see (Flash Professional only) “Media components (Flash Professional only)”...
  • Page 33: Other Listings In This Chapter

    Other listings in this chapter This book also describes several classes and APIs that are not included in the categories of components listed in the previous section. These classes and APIs are listed in the following table. Item Description CellRenderer API 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...
  • Page 34: Chapter 52: Uicomponent Class

    Item Description SimpleButton class Lets you control some aspects of button appearance and behavior. TransferObject interface Defines a set of methods that items managed by the DataSet component must implement. TreeDataProvider interface A set of properties and methods used to create XML for the (Flash Professional only) property.
  • Page 35 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 36 Description Page Up Selects the previous child. Selection cycles from the first child to the last child. Shift+Tab Moves focus to the previous component. This component may be inside the selected child, or outside the accordion; it is never another header in the same accordion.
  • Page 37: Chapter 2: Accordion Component (Flash Professional Only)

    enabled is a Boolean value that indicates whether the component can receive focus and input. The default value is true visible is a Boolean value that indicates whether the object is visible ( ) or not ( true false The default value is true The minHeight and minWidth properties are used by internal sizing routines.
  • Page 38: Using The Accordion Component (Flash Professional Only)

    Create a new screen named accordionForm. Drag an Accordion component from the Components panel to the accordionForm form, and name it my_acc. With my_acc selected, in the Property inspector, do the following: For the childSymbols property, enter addressForm, addressForm, and checkoutForm. These strings specify the names of the screens used to create the accordion’s children.
  • Page 39 In the Property inspector, do the following: Enter the instance name my_acc. For the property, enter AddressForm, AddressForm, and childSymbols CheckoutForm. These strings specify the names of the movie clips used to create the accordion’s children. The first two children are instances of the same movie clip, because the shipping address form and the billing address form are identical.
  • Page 40 In the Actions panel in Frame 1, below the code you entered in step 5, enter the following code (this code adds two TextInput component instances to the accordion’s children): // Create child text input for the shippingAddress panel. var firstNameChild_obj:Object = my_acc.shippingAddress.createChild("TextInput", "firstName", {text: "First Name"});...
  • Page 41 Using styles with the Accordion component You can set style properties to change the appearance of the border and background of an Accordion component. An Accordion component uses the following styles: Style Theme Description Halo The base color scheme of a component. This is the only color themeColor style that doesn’t inherit its value.
  • Page 42: Customizing The Accordion Component (Flash Professional Only)

    Style Theme Description Both The text decoration; either textDecoration "none" "underline" Both The duration, in milliseconds, of the transition animation. openDuration Both A reference to a tweening function that controls the openEasing animation. Defaults to sine in/out. For more information, see “Customizing component animations”...
  • Page 43 Property Description Default value The pressed state of the header above the trueDownSkin accordionHeaderSkin expanded child. The rolled-over state of the header above the trueOverSkin accordionHeaderSkin expanded child. The disabled state of the header above the trueDisabledSkin accordionHeaderSkin expanded child. Using ActionScript to draw the Accordion header The default headers in both the Halo and Sample themes use the same skin element for all states and draw the actual graphics through ActionScript.
  • Page 44 To create an ActionScript-customized Accordion header skin: Create a new ActionScript class file. For this example, name the file RedGreenBlueHeader.as. Copy the following ActionScript to the file: import mx.skins.RectBorder; import mx.core.ext.UIObjectExtensions; class RedGreenBlueHeader extends RectBorder static var symbolName_str:String = "RedGreenBlueHeader"; static var symbolOwner_obj:Object = RedGreenBlueHeader;...
  • Page 45 _global.skinRegistry["AccordionHeaderSkin"] = true; return true; static var classConstructed_bl:Boolean = classConstruct(); static var UIObjectExtensionsDependency_obj:Object = UIObjectExtensions; 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.
  • Page 46 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 47 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 48 Methods inherited from the UIObject class The following table lists the methods the Accordion class inherits from the UIObject class. When calling these methods from the Accordion object, use the form accordionInstance.methodName Method Description Creates an object on the specified class. UIObject.createClassObject() Creates a subobject on an object.
  • Page 49: Accordion Class (Flash Professional Only)

    Property summary for the Accordion class The following table lists properties of the Accordion class. Property Description The number of children of an Accordion instance. Accordion.numChildren A reference to the selected child. Accordion.selectedChild The index position of the selected child. Accordion.selectedIndex Properties inherited from the UIObject class The following table lists the properties the Accordion class inherits from the UIObject class.
  • Page 50: Uicomponent.enabled

    Properties inherited from the UIComponent class The following table lists the properties the Accordion class inherits from the UIComponent class. When accessing these properties, use the form accordionInstance.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 UIComponent.tabIndex document.
  • Page 51: Accordion.change

    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 52 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. For more information, see “EventDispatcher class”...
  • Page 53: Accordion.createchild()

    Accordion.createChild() Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage accordionInstance.createChild(classOrSymbolName, instanceName[, initialProperties]) Parameters Either the constructor function for the class of the UIObject to be classOrSymbolName instantiated, or the linkage name (a reference to the symbol to be instantiated). The class must be UIObject or a subclass of UIObject, but most often it is View object or a subclass of View.
  • Page 54 Example Start with an Accordion instance on the Stage named . Add a symbol to the library my_acc with the Linkage Identifier to be the icon for the child header. The following code payIcon creates a child named (with the label “Payment”) that is an instance of the billing View class: var child_obj:Object = my_acc.createChild(mx.core.View, "billing", {label:...
  • Page 55: Accordion.createsegment()

    cardType_label.text = "Card Type"; cardNumber_label.text = "Card Number"; Accordion.createSegment() Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage accordionInstance.createSegment(classOrSymbolName, instanceName[, label[, icon]]) Parameters Either a reference to the constructor function for the class of the classOrSymbolName UIObject to be instantiated, or the linkage name of the symbol to be instantiated. The class must be UIObject or a subclass of UIObject, but most often it is View or a subclass of View.
  • Page 56 Example Start with an Accordion instance on the Stage named . Add a movie clip symbol to the my_acc library with the Linkage Identifier to be the Accordion child. Then, add a PaymentForm symbol to the library with Linkage Identifier to be the icon for the child header.
  • Page 57: Accordion.destroychildat()

    Accordion.destroyChildAt() Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage accordionInstance.destroyChildAt(index) Parameters The index number of the accordion child to destroy. Each child of an accordion is index assigned a zero-based index number in the order in which it was created. Returns Nothing.
  • Page 58: Accordion.getchildat()

    Example The following code destroys the first child of when the third child is selected: my_acc import mx.core.View; // Create child panels with instances of the View class. my_acc.createSegment(View, "myMainItem1", "Menu Item 1"); my_acc.createSegment(View, "myMainItem2", "Menu Item 2"); my_acc.createSegment(View, "myMainItem3", "Menu Item 3"); // Create new Listener object.
  • Page 59: Accordion.getheaderat()

    Description Method; returns a reference to the child at the specified index. 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. Example The following code gets a reference to the last child of and changes the label to...
  • Page 60: Accordion.numchildren

    Example The following code gets a reference to the last header of and displays the label in the my_acc Output panel: import mx.core.View; // Create child panels for each form to be displayed in my_acc object. my_acc.createChild(View, "shippingAddress", {label: "Shipping Address"}); my_acc.createChild(View, "billingAddress", {label: "Billing Address"});...
  • Page 61: Accordion.selectedchild

    Example The following code uses to get a reference to the last child of numChildren my_acc changes the label to “Last Child”: import mx.core.View; // Create child panels with instances of the View class. my_acc.createSegment(View, "myMainItem1", "Menu Item 1"); my_acc.createSegment(View, "myMainItem2", "Menu Item 2"); my_acc.createSegment(View, "myMainItem3", "Menu Item 3");...
  • Page 62: Accordion.selectedindex

    Example The following example detects when a child is selected and displays the child’s order in the Output panel each time a header is selected: // Create new Listener object. var my_accListener:Object = new Object(); my_accListener.change = function() { trace("Changed to different view"); // Assign label of child panel to variable var selectedChild_str:String = my_acc.selectedChild.label;...
  • Page 63 Description Property; the zero-based index of the selected child in an accordion with one or more children. For an accordion with no child views, the only valid value is undefined 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 64 Accordion component (Flash Professional only)
  • Page 65 CHAPTER 3 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 66 Using the Alert component (Flash Professional only) You can use an Alert component whenever you want to announce something to a user. For example, you could display an alert when a user doesn’t fill out a form properly, when a stock hits a certain price, or when a user quits an application without saving the session.
  • Page 67: Chapter 3: Alert Component (Flash Professional Only)

    This code creates an Alert window with OK and Cancel buttons. When the user clicks either button, Flash calls the function. The function myClickHandler myClickHandler instructs Flash to trace “start stock app” when you click the OK button. method includes an optional parameter that displays an icon in the Alert.show() Alert window (in this example, an icon with the linkage identifier “stockIcon”).
  • Page 68: Using The Alert Component (Flash Professional Only)

    Style Theme Description Both The Alert component uses a RectBorder instance as its borderStyle border and responds to the styles defined on that class. For more information, see “RectBorder class” on page 1063. The Alert component has a component-specific setting of “ ”...
  • Page 69: Customizing The Alert Component (Flash Professional Only)

    To set the text styles for one category individually, the Alert component provides static properties that are references to a CSSStyleDeclaration instance. Static property Text affected Button buttonStyleDeclaration Message messageStyleDeclaration Title titleStyleDeclaration The following example demonstrates how to set the title of an Alert component to be italicized: import mx.controls.Alert;...
  • Page 70 SkinElement is a simple class that can be used for all skin elements that don’t provide their own ActionScript implementation. It provides movement and sizing functionality for components of version 2 of the Macromedia Component Architecture. Make sure that Export in First Frame is already selected.
  • Page 71 Drag an Alert component to the Stage and delete it. This action adds the Alert component to the library and makes it available at runtime. Add ActionScript code to the main timeline to create a sample Alert instance. import mx.controls.Alert; Alert.show("This is a skinned Alert component","Title");...
  • Page 72: Uicomponent.setfocus()

    Methods inherited from the UIObject class The following table lists the methods the Alert class inherits from the UIObject class. Method Description Creates an object on the specified class. UIObject.createClassObject Creates a subobject on an object. UIObject.createObject() Destroys a component instance. UIObject.destroyObject() Calls a function when parameters have been set in the UIObject.doLater()
  • Page 73: Alert Class (Flash Professional Only)

    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 Alert.buttonHeight The width of each button, in pixels. The default value is Alert.buttonWidth 100.
  • Page 74 Property Description Read-only; the position of the top edge of the object, relative UIObject.top to its parent. A Boolean value indicating whether the object is visible ( UIObject.visible true or not ( false Read-only; the width of the object, in pixels. UIObject.width Read-only;...
  • Page 75 Events inherited from the UIObject class The following table lists the events the Alert class inherits from the UIObject class. When calling these events from the Alert object, use the form Alert.eventName Event Description Broadcast when an object is about to draw its graphics. UIObject.draw Broadcast when an object’s state changes from visible to UIObject.hide...
  • Page 76: Alert.buttonheight

    Alert.buttonHeight Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage Alert.buttonHeight Description Property (class); a class (static) property that changes the height of the buttons. The default value is 22. Example With an Alert component already in the library, this example resizes the buttons: import mx.controls.Alert;...
  • Page 77: Alert.cancel

    Description Property (class); a class (static) property that changes the width of the buttons. The default value is 100. Example With an Alert component already in the library, add this ActionScript to the first frame of the main timeline to resize the buttons: import mx.controls.Alert;...
  • Page 78: Alert.cancellabel

    Example The following example uses as values for the parameter Alert.CANCEL Alert.OK flags and displays an Alert component with an OK button and a Cancel button: import mx.controls.Alert; Alert.show("This is a generic Alert window", "Alert Test", Alert.OK | Alert.CANCEL, this); Alert.cancelLabel Availability Flash Player 6 (6.0.79.0).
  • Page 79: Alert.click

    Alert.click Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage var clickHandler:Object = function(eventObject:Object) { // Insert code here. Alert.show(message[, title[, flags[, parent[, clickHandler[, icon[, defaultButton]]]]]]) Description Event; broadcast to the registered listener when the OK, Yes, No, or Cancel button is clicked. Version 2 components use a dispatcher/listener event model.
  • Page 80 Example With an Alert component already in the library, add this ActionScript to the first frame of the main timeline to create an event handler called . The event handler is passed myClickHandler to the method as the fifth parameter. The event object is captured by Alert.show() in the parameter.
  • Page 81: Alert.nolabel

    Description Property (constant); a property with the constant hexadecimal value 0x2. This property can be used for the parameter of the method. When flags defaultButton Alert.show() used as a value for the parameter, this property indicates that a No button should be flags displayed in the Alert window.
  • Page 82: Alert.no

    Alert.NONMODAL Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage Alert.NONMODAL Description Property (constant); a property with the constant hexadecimal value 0x8000. This property can be used for the parameter of the method. This property indicates flags Alert.show() that an Alert window should be nonmodal, which allows users to interact with buttons and instances underneath the displayed window.
  • Page 83 nonmodal_button.addEventListener("click", nonmodalListener); function nonmodalListener(evt_obj:Object):Void { var a:MovieClip = Alert.show("This is a nonmodal Alert window", "Alert Test", Alert.OK | Alert.NONMODAL, this); a.move(100, 100); Alert.OK Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage Alert.OK Description Property (constant); a property with the constant hexadecimal value 0x4. This property can be used for the parameter of the method.
  • Page 84: Alert.oklabel

    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 85: Alert.ok

    You can also use to indicate that the Alert window is nonmodal. A Alert.NONMODAL nonmodal window allows a user to interact with other windows in the application. The parent window for the Alert component. The Alert window centers itself in the parent parent window.
  • Page 86: Alert.yes

    The following code defines a click handler that sends a message to the Output panel about which button was clicked. (You must have an Alert component in the library for this code to display an alert; to add the component to the library, drag it to the Stage and then delete it): import mx.controls.Alert;...
  • Page 87: Alert.yeslabel

    Example The following example uses as values for the parameter and Alert.NO Alert.YES flags displays an Alert component with a No button and a Yes button: import mx.controls.Alert; Alert.show("This is a generic Alert window", "Alert Test", Alert.NO | Alert.YES, this); Alert.yesLabel Availability Flash Player 6 (6.0.79.0).
  • Page 88 Alert component (Flash Professional only)
  • Page 89 CHAPTER 4 Button component The Button component is a resizable rectangular user interface button. You can add a custom icon to a button. You can also change the behavior of a button from push to toggle. A toggle button stays pressed when clicked and returns to its up state when clicked again. A button can be enabled or disabled in an application.
  • Page 90 Using the Button component A button is a fundamental part of any form or web application. You can use buttons wherever you want a user to initiate an event. For example, most forms have a Submit button. You could also add Previous and Next buttons to a presentation. To add an icon to a button, you need to select or create a movie clip or graphic symbol to use as the icon.
  • Page 91: Chapter 4: Button Component

    enabled is a Boolean value that indicates whether the component can receive focus and input. The default value is true visible is a Boolean value that indicates whether the object is visible ( ) or not ( true false The default value is true The minHeight and minWidth properties are used by internal sizing routines.
  • Page 92: Using The Button Component

    Select Control > Test Movie. When you click the button, Flash displays the message “You clicked the button!”. To create a Button using ActionScript: Drag the Button component from the Components panel to the current document’s library. This adds the component to the library, but doesn’t make it visible in the application. In the first frame of the main timeline, add the following ActionScript to the Actions panel to create a Button instance: this.createClassObject(mx.controls.Button, "my_button", 10,...
  • Page 93 In the first frame of the main timeline, add the following ActionScript to the Actions panel to create a Button instance: this.createClassObject(mx.containers.Accordion, "my_acc", 0); my_acc.move(10, 40); my_acc.createChild(mx.core.View, "panelOne", {label: "Panel One"}); my_acc.createChild(mx.core.View, "panelTwo", {label: "Panel Two"}); this.createClassObject(mx.controls.Button, "panelOne_button", 10, {label:"Panel One"}); panelOne_button.move(10, 10);...
  • Page 94 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 95 Style Theme Description Both The text color. The default value is 0x0B333C for the color Halo theme and blank for the Sample theme. Both The color for text when the component is disabled. The disabledColor default color is 0x848384 (dark gray). Both A Boolean value that indicates whether the font embedFonts...
  • Page 96: Customizing The Button Component

    The Button component has many skins because a button has so many states, and a border and icon for each state. The state of a Button instance is controlled by four properties and user interaction. The following properties affect skins: Property Description Provides two different looks for Button instances and is typically...
  • Page 97 Property Description The pressed state of an emphasized button. falseDownSkinEmphasized The over state of an emphasized button. falseOverSkinEmphasized The disabled state of an emphasized button. falseDisabledSkinEmphasized The toggled state of an emphasized button. trueUpSkinEmphasized The pressed-toggled state of an emphasized button. trueDownSkinEmphasized The over-toggled state of an emphasized button.
  • Page 98 In addition to the icon skins, the Button component also supports a standard property. icon The difference between the standard property and style property is that through the style property you can set icons for the individual states, whereas with the standard property only one icon can be set and it applies to all states.
  • Page 99 function size():Void var c:Number; // color var borderStyle:String = getStyle("borderStyle"); switch (borderStyle) { case "falseup": case "falserollover": case "falsedisabled": c = 0x7777FF; break; case "falsedown": c = 0x77FF77; break; case "trueup": case "truedown": case "truerollover": case "truedisabled": c = 0xFF7777; break;...
  • Page 100 Save the file. Create a new FLA file and save it in the same folder as the AS file. Create a new symbol by selecting Insert > New Symbol. Set the name to ButtonSkin If the advanced view is not displayed, click the Advanced button. Select Export for ActionScript.
  • Page 101 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 102: Uiobject.createclassobject()

    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.Button.version);...
  • Page 103: Button Class

    Methods inherited from the UIComponent class The following table lists the methods the Button class inherits from the UIComponent class. When calling these methods from the Button object, use the form buttonInstance.methodName Method Description Returns a reference to the object that has focus. UIComponent.getFocus() Sets focus to the component instance.
  • Page 104: Uiobject.height

    Properties inherited from the UIObject class The following table lists the properties the Button class inherits from the UIObject class. When accessing these properties from the Button object, use the form buttonInstance.propertyName Property Description Read-only; the position of the bottom edge of the object, UIObject.bottom relative to the bottom edge of its parent.
  • Page 105: Uiobject.reveal

    Event summary for the Button class There are no events exclusive to the Button class. Events inherited from the SimpleButton class The following table lists the events the Button class inherits from the SimpleButton class. Property Description Broadcast when a button is clicked. SimpleButton.click Events inherited from the UIObject class The following table lists the events the Button class inherits from the UIObject class.
  • Page 106: Button.icon

    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 107 You can also create the button and assign the icon entirely in ActionScript using the method (you still must have already created an icon for the button UIObject.createClassObject() with the linkage identifier . First drag the Button component from the happiness) Components panel to the current document’s library, so the component appears in the library, but not on the Stage.
  • Page 108: Button.labelplacement

    You can also create the button and assign the label entirely in ActionScript using the method . First drag the Button component from the Components UIObject.createClassObject() panel to the current document’s library, so the component appears in the library, but not on the Stage.
  • Page 109: Button.label

    Example With a button on the Stage with instance name , and a symbol in the Library panel my_button with the linkage identifier , the following code sets the label alignment to the left happiness of the icon: my_button.icon = "happiness"; my_button.label = "Test Button";...
  • Page 110 Button component...
  • Page 111: Chapter 5: Cellrenderer Api

    CHAPTER 5 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 112 About the composition of the List component List components are composed of rows. These rows display rollover and selection highlights, are used as hit states for row selection, and play a vital part in scrolling. Aside from selection highlights and icons (such as the node icons and expander arrows of a Tree component), a row consists of one cell (or, in the case of the DataGrid component, many cells).
  • Page 113: Using The Cellrenderer Api

    Using the CellRenderer API You must write a class with four methods ( CellRenderer.getPreferredHeight() CellRenderer.getPreferredWidth() CellRenderer.setSize() ) that the list-based component uses to communicate with the CellRenderer.setValue() cell (if the class extends UIObject, you can use instead of size() ). The class must be specified in the AS 2.0 Class text box in the CellRenderer.setSize() Linkage Properties dialog box of a movie clip symbol in your Flash application.
  • Page 114 The following tutorial shows how to create a cell renderer class that displays multiple lines of text in the cells of a DataGrid component. The completed files, MultiLineCell.as and CellRenderer_tutorial.fla are located at www.macromedia.com/go/component_samples. Creating the MultiLineCell cell renderer class A cell renderer class must implement the following methods: CellRenderer.getPreferredHeight()
  • Page 115 private var owner; // The row that contains this cell. private var listOwner; // The List, data grid or tree containing this cell. // Cell height offset from the row height total and preferred cell width. private static var PREFERRED_HEIGHT_OFFSET = 4; private static var PREFERRED_WIDTH = 100;...
  • Page 116 c.setSize(__width, __height); // Provides the preferred height of the cell. Inherited method. public function getPreferredHeight():Number /* The cell is given a property, "owner", that references the row. It’s always preferred that the cell take up most of the row's height. In this case we will keep the cell slightly smaller.*/ return owner.__height - PREFERRED_HEIGHT_OFFSET;...
  • Page 117 Click the Advanced button in the lower-right corner of the Create New Symbol dialog box to enable more options. The Advanced button is available when you are in the basic mode of the Create New Symbol dialog box. If you don’t see the Advanced button, you are probably already in the Advanced view of the dialog box.
  • Page 118 myDP.addItem({firstName:"Kevin", lastName:"Wade", note:aLongString, item:103}); myDP.addItem({firstName:"Kimberly", lastName:"Dietrich", note:aLongString, item:104}); myDP.addItem({firstName:"AJ", lastName:"Bilow", note:aLongString, item:105}); myDP.addItem({firstName:"Chuck", lastName:"Yushan", note:aLongString, item:106}); myDP.addItem({firstName:"John", lastName:"Roo", note:aLongString, item:107}); /* Assign the data provider to the DataGrid to populate it. Note: This has to be done before applying the cellRenderers. */ myGrid_dg.dataProvider = myDP;...
  • Page 119 Additional examples of cell renderer classes that display a ComboBox and a CheckCell component are also provided. These files are located in the CellRenderers_sample folder within the Samples and Tutorials folder on your hard disk at www.macromedia.com/go/ component_samples. The additional installed sample named CellRenderers_Sample displaying a ComboBox and CheckBox.
  • Page 120: Cellrenderer.getcellindex()

    Methods provided by the CellRenderer API The List, DataGrid, Tree, and Menu components give the following methods to the cell when it is created within the component. You do not need to implement these methods. Method Description Returns an object with two fields, CellRenderer.getCellIndex() columnIndex , that indicate the position of the cell.
  • Page 121: Cellrenderer.getdatalabel()

    Description Method; returns an object with two fields, , that locate the cell columnIndex itemIndex in the component. Each field is an integer that indicates a cell’s column position and item position. For any components other than the DataGrid component, the value of is always 0.
  • Page 122: Cellrenderer.getpreferredheight()

    Example The following code tells the cell the name of the data field that it is rendering. For example, if the name of the data field currently being rendered by the cell is , the variable "Price" now equal to "Price"...
  • Page 123: Cellrenderer.getpreferredwidth()

    This example returns a value that is 4 pixels less that the height of the row: function getPreferredHeight():Number /* You know the cell is given a property, "owner", which is the row. It’s always preferred for the cell to take up most of the row's height. return owner.__height - 4;...
  • Page 124: Cellrenderer.listowner

    Example This example returns the value multiplied by 3, which indicates that the cell should be three times bigger than the length of the string it is rendering: function getPreferredWidth():Number return myString.length*3; This example comments out the method: getPreferredWidth() // function getPreferredWidth :: only for a menu or datagrid CellRenderer.listOwner Availability Flash Player 6 (6.0.79.0).
  • Page 125: Cellrenderer.owner

    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 126: Cellrenderer.setvalue()

    Description Method; lets the list tell its cells the size at which they should lay themselves out. The cell renderer should do layout so that it fits in the specified area, or the cell may bleed into other parts of the list and appear broken. If the cell renderer extends the UIObject class, you should implement the method size()
  • Page 127 Parameters A value to be used for the cell renderer’s text, if any is needed. suggested An object that is the entire item to be rendered. The cell renderer can use properties of item this object for rendering. A string with the following possible values: , and selected "normal"...
  • Page 128 Because a cell might not exist on the Stage (it might be scrolled out of the display area or it might be reused to render another value) at any time, you cannot directly reference a specific cell renderer instance in the grid. Instead, use the data provider to communicate with a specific cell in the grid.
  • Page 129 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 ) calls to refresh the display of the grid. This DataProvider.editField() setValue() code would be written in the Flash application, either on a frame, on an object, or in another...
  • Page 130 The following example is from a radio button renderer. If the item parameter is undefined, then the cell may be scrolled out of the display area and should be visibly empty. An statement is used to determine if the parameter is undefined. If the parameter is item item...
  • Page 131: Chapter 6: Checkbox Component

    CHAPTER 6 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 132: Using The Checkbox Component

    You enable accessibility for a component only once, regardless of how many instances you have of the component. For more information, see Chapter 19, “Creating Accessible Content,” in Using Flash. Using the CheckBox component A check box is a fundamental part of any form or web application. You can use check boxes wherever you need to gather a set of values that aren’t mutually exclusive.
  • Page 133 To create an application with the CheckBox component: Drag two TextInput components from the Components panel to the Stage. In the Property inspector, enter the instance names minimumAge and maximumAge. Drag a CheckBox component from the Components panel to the Stage. In the Property inspector, do the following: Enter restrictAge for the instance name.
  • Page 134: Customizing The Checkbox Component

    Now, add the following ActionScript to create an event listener and an event handler function: // Create handler for checkBox event. function checkboxHandler(evt_obj:Object) { minimumAge_ti.enabled = evt_obj.target.selected; maximumAge_ti.enabled = evt_obj.target.selected; // Add Listener. testAge_ch.addEventListener("click", checkboxHandler); This code creates a event handler that enables and disables the click minimumAge text field components.
  • Page 135 A CheckBox component supports the following styles: Style Theme Description Halo The base color scheme of a component. themeColor Possible values are "haloGreen" "haloBlue" . The default value is "haloOrange" "haloGreen" Both The text color. The default value is 0x0B333C color for the Halo theme and blank for the Sample theme.
  • Page 136 Style Theme Description Sample The color of the check mark. The default value is symbolColor 0x000000 (black). Sample The color of the disabled check mark. The symbolDisabledColor default value is 0x848384 (dark gray). Using skins with the CheckBox component The CheckBox component uses symbols in the library to represent the button states. To skin the CheckBox component while authoring, modify symbols in the Library panel.
  • Page 137: Checkbox Class

    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. Customize the symbol as desired. For example, change the inner white square to a light gray. Repeat steps 5-6 for all symbols you want to customize.
  • Page 138 Method summary for the CheckBox class There are no methods exclusive to the CheckBox class. 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...
  • Page 139 Property summary for the CheckBox class The following table lists properties of the CheckBox class. Property Description Specifies the text that appears next to a check box. CheckBox.label Specifies the orientation of the label text in relation to a CheckBox.labelPlacement check box.
  • Page 140 Properties inherited from the UIComponent class The following table lists the properties the CheckBox class inherits from the UIComponent class. When accessing these properties from the CheckBox object, use the form checkBoxInstance.propertyName Property Description Indicates whether the component can receive focus and UIComponent.enabled input.
  • Page 141 Event summary for the CheckBox class The following table lists an event of the CheckBox class. Event Description Triggered when the mouse is clicked (released) over the CheckBox.click check box, or if the check box has focus and the Spacebar is pressed.
  • Page 142: Checkbox.click

    Events inherited from the SimpleButton class The following table lists the event the CheckBox class inherits from the SimpleButton class. Event Description Broadcast when a button is clicked. SimpleButton.click CheckBox.click Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage Usage 1: var listenerObject:Object = new Object();...
  • Page 143 The first usage example uses a dispatcher-listener event model. A component instance ) dispatches an event (in this case, ), and the event is handled by a checkBoxInstance click 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 144: Checkbox.label

    The following code sends a message to the Output panel when is clicked. checkBoxInstance handler must be attached directly to on() checkBoxInstance on (click) { trace("check box component was clicked"); See also EventDispatcher.addEventListener() CheckBox.label Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004.
  • Page 145: Checkbox.labelplacement

    This example creates the check box in ActionScript, and then resizes the label when checked. For this example, drag a CheckBox component from the Components panel to the current document’s library (so the CheckBox component appears in your library, but not on the Stage).
  • Page 146 The label is set below the check box. The check box and label are centered "bottom" horizontally and vertically. The label is placed below the check box. The check box and label are centered "top" horizontally and vertically. You can change the bounding area of a component while authoring by using the Transform command or at runtime using the property.
  • Page 147: Checkbox.selected

    CheckBox.selected Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage checkBoxInstance.selected Description Property; a Boolean value that selects ( ) or deselects ( ) the check box. true false Example The following example shows a check box that has its selected property set to , by true default, and then uses the...
  • Page 148 CheckBox component...
  • Page 149: Chapter 7: Collection Interface (Flash Professional Only)

    CHAPTER 7 Collection interface (Flash Professional only) The collection class is distributed in the common classes library as a compiled clip symbol. To access this class, select Window > Common Libraries > Classes, which contains the compiled clip UtilsClasses. Collection class (Flash Professional only) ActionScript Class Name mx.utils.Collection The collection interface lets you programmatically manage a group of related items, called...
  • Page 150: Collection.additem()

    Method summary for the Collection interface The following table lists the methods of the Collection interface. Method Description Adds a new item to the end of the collection. Collection.addItem() Indicates whether the collection contains the specified Collection.contains() item. Removes all elements from the collection. Collection.clear() Returns an item within the collection by using its index.
  • Page 151: Collection.contains()

    Example The following example calls addItem() on (click) { import CompactDisc; var myColl:mx.utils.Collection; myColl = _parent.thisShelf.MyCompactDiscs; myCD = new CompactDisc(); myCD.Artist = "John Coltrane"; myCD.Title = "Giant Steps"; var wasAdded:Boolean = myColl.addItem(myCD); Collection.contains() Availability Flash Player 7. Edition Flash MX Professional 2004. Usage collection.contains(item) Parameters...
  • Page 152: Collection.clear()

    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 153: Collection.getitemat()

    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- index item based 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 154: Collection.getiterator()

    Collection.getIterator() Availability Flash Player 7. Edition Flash MX Professional 2004. Usage collection.getIterator() Returns An Iterator object that you can use to step through the collection. 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).
  • Page 155: Collection.getlength()

    Collection.getLength() Availability Flash Player 7. Edition Flash MX Professional 2004. Usage collection.getLength() Returns The number of items in the collection. Description Method; returns the number of items in the collection. Example The following example calls getLength() //... var myColl:mx.utils.Collection; myColl = _parent.thisShelf.MyCompactDiscs; trace ("Collection size is: "...
  • Page 156: Collection.removeitem()

    Description Method; indicates whether the collection is empty. Example The following example calls isEmpty() on (click) { var myColl:mx.utils.Collection; myColl = _parent.thisShelf.MyCompactDiscs; if (myColl.isEmpty()) { trace("No CDs in the collection"); //... Collection.removeItem() Availability Flash Player 7. Edition Flash MX Professional 2004. Usage collection.removeItem(item) Parameters...
  • Page 157 Example The following example calls removeItem() var myColl:mx.utils.Collection; myColl = _parent.thisShelf.MyCompactDiscs; // get this from a text input box var removeArtist:String = _parent.tArtistToRemove.text; var removeSize:Number = 0; if (myColl.isEmpty()) { trace("No CDs in the collection"); else { var toRemove:Array = new Array(); var itr:mx.utils.Iterator = myColl.getIterator();...
  • Page 158 Collection interface (Flash Professional only)
  • Page 159: Chapter 8: Combobox Component

    CHAPTER 8 ComboBox component A combo box allows a user to make a single selection from a pop-up 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 pop-up list.
  • Page 160 Description Selection moves to the bottom of the list. Escape Closes the drop-down list and returns focus to the combo box in test mode. Enter Closes the drop-down list and returns focus to the combo box. Home Moves the selection to the top of the list. Page Down Moves the selection down one page.
  • Page 161: Using The Combobox Component

    For more information about controlling focus, see “FocusManager class” on page 721 “Creating custom focus navigation” in Using Components. A live preview of each ComboBox component instance on the Stage reflects changes made to parameters in the Property inspector or Component inspector during authoring. However, the drop-down list does not open in the live preview, and the first item is displayed as the selected item.
  • Page 162 You can set the following additional parameters for each ComboBox component instance in the Component inspector (Window > Component Inspector): restrict indicates the set of characters that a user can enter in the text field of a combo box. The default value is .
  • Page 163 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 To create a ComboBox component using ActionScript: Drag the ComboBox component from the Components panel to the current document’s library.
  • Page 164: Customizing The Combobox Component

    Customizing the ComboBox component You can transform a ComboBox component horizontally and vertically while authoring. While authoring, select the component on the Stage and use the Free Transform tool or any of the Modify > Transform commands. If text is too long to fit in the combo box, the text is clipped to fit. You must resize the combo box while authoring to fit the label text.
  • Page 165 A ComboBox component uses the following styles: Style Theme Description Halo The base color scheme of a component. Possible themeColor values are , and "haloGreen" "haloBlue" "haloOrange" The default value is "haloGreen" Both The background color. The default color is white. backgroundColor Both The Button subcomponent uses two RectBorder...
  • Page 166 Style Theme Description Both The duration, in milliseconds, of the transition openDuration animation. The default value is 250. Both A reference to a tweening function that controls the openEasing animation. Defaults to sine in/out. For more information, see “Customizing component animations” in Using Components.
  • Page 167: Combobox Class

    To create movie clip symbols for ComboBox 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 168 Items in a combo box list are indexed by position, starting with the number 0. An item can be one of the following: A primitive data type. An object that contains a property and a property label data An object may use the property to ComboBox.labelFunction ComboBox.labelField...
  • Page 169 Methods inherited from the UIObject class The following table lists the methods the ComboBox class inherits from the UIObject class. When calling these methods from the ComboBox object, use the form comboBoxInstance.methodName Method Description Creates an object on the specified class. UIObject.createClassObject() Creates a subobject on an object.
  • Page 170 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 171 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. Read-only; the position of the top edge of the object, relative UIObject.top to its parent.
  • Page 172 Event Description Broadcast when the drop-down list begins to open. ComboBox.open Broadcast when the drop-down list is scrolled. ComboBox.scroll Events inherited from the UIObject class The following table lists the events the ComboBox class inherits from the UIObject class. Event Description Broadcast when an object is about to draw its graphics.
  • Page 173: Combobox.additem()

    ComboBox.addItem() Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage comboBoxInstance.addItem(label[, data]) comboBoxInstance.addItem({label:label[, data:data]}) comboBoxInstance.addItem(obj); Parameters A string that indicates the label for the new item. label The data for the item; it can be of any data type. This parameter is optional. data An object with a property and an optional...
  • Page 174: Combobox.additemat()

    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 175: Combobox.change

    ComboBox.change Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage var listenerObject:Object = new Object(); listenerObject.change = function(eventObject:Object) { // 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 Using a dispatcher/listener event model, a component instance ( comboBoxInstance...
  • Page 176: Combobox.close()

    // Assign function to Listener Object. cbListener.change = function(event_obj:Object) { trace("Value changed to: "+event_obj.target.selectedItem.label); // Add Listener. my_cb.addEventListener("change", cbListener); See also EventDispatcher.addEventListener() ComboBox.close() Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage comboBoxInstance.close() Parameters None. Returns Nothing. Description Method; closes the drop-down list. Example With a ComboBox component instance on the Stage, and a Button component...
  • Page 177: Combobox.close

    See also ComboBox.open() ComboBox.close Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage var listenerObject:Object = new Object(); listenerObject.close = function(eventObject:Object) { // Your code here. comboBoxInstance.addEventListener("close", listenerObject) Description Event; broadcast to all registered listeners when the drop-down list of the combo box is fully retracted.
  • Page 178: Combobox.dataprovider

    Example With a ComboBox component instance on the Stage, the following example sends a my_cb message to the Output panel when the drop-down list opens or closes: // Add Items to List. my_cb.addItem({data:1, label:"First Item"}); my_cb.addItem({data:2, label:"Second Item"}); // Create Listener Object. var cbListener:Object = new Object();...
  • Page 179 The List component, like other data-aware components, adds methods to the Array object’s prototype so that they conform to the DataProvider API (see DataProvider.as for details). Therefore, any array that exists at the same time as a list automatically has all the methods , and so on) needed for it to be the model of a list, and can be used addItem() getItemAt()
  • Page 180: Combobox.dropdown

    ComboBox.dropdown Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage comboBoxInstance.dropdown 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.
  • Page 181: Combobox.dropdownwidth

    ComboBox.dropdownWidth Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage comboBoxInstance.dropdownWidth Description Property; the width limit of the drop-down list, in pixels. The default value is the width of the ComboBox component (the TextInput instance plus the SimpleButton instance). Example With a ComboBox component instance on the Stage, the following ActionScript sets...
  • Page 182 Description Property; indicates whether the combo box is editable ( ) or not ( ). In an editable true false combo box, a user can enter values into the text box that do not appear in the drop-down list. If a combo box is not editable, you cannot enter text into the text box. The text box displays the text of the item in the list.
  • Page 183: Combobox.enter

    ComboBox.enter Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage var listenerObject:Object = new Object(); listenerObject.enter = function(eventObject:Object) { // Your code here. comboBoxInstance.addEventListener("enter", listenerObject) Description Event; broadcast to all registered listeners when the user presses the Enter key in the text box. This event is a TextInput event that is broadcast only from editable combo boxes.
  • Page 184: Combobox.getitemat()

    Example With a ComboBox component instance on the Stage, the following ActionScript my_cb creates a combo box list and two listeners. The first listener handles clicking the “Add new item” label to make the combo box field editable. The second listener handles the user pressing the Enter key to add their entry to the combo box list: // Add items to the combo box list.
  • Page 185: Combobox.itemrollout

    Parameters The index of the item to retrieve. The index must be a number greater than or equal index to 0, and less than the value of ComboBox.length Returns The indexed item object or value. The value is undefined if the index is out of range. Description Method;...
  • Page 186 Using a dispatcher/listener event model, a component instance ( comboBoxInstance dispatches an event (in this case, ) and the event is handled by a function, also itemRollOut 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 187: Combobox.itemrollover

    ComboBox.itemRollOver Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage var listenerObject:Object = new Object(); listenerObject.itemRollOver = function(eventObject:Object) { // Your code here. comboBoxInstance.addEventListener("itemRollOver", listenerObject) Event object In addition to the standard properties of the event object, the event has an itemRollOver property.
  • Page 188: Combobox.labelfield

    Example With a ComboBox instance on the Stage, the following ActionScript sends a message my_cb to the Output panel that indicates the item index and the event when the pointer rolls on or off an item: my_cb.addItem({data:1, label:"First Item"}); my_cb.addItem({data:2, label:"Second Item"}); // Create Listener Object.
  • Page 189: Combobox.labelfunction

    Example The following example sets the property to an array of strings and sets the dataProvider property to indicate that the field should be used as the label for the labelField name drop-down list: my_cb.dataProvider = [ {name:"Gary", gender:"male"}, {name:"Susan", gender:"female"} ]; my_cb.labelField = "name";...
  • Page 190: Combobox.length

    See also List.labelField ComboBox.length Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage comboBoxInstance.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 191: Combobox.open

    Description Method; opens the drop-down list. Example With a ComboBox component instance on the Stage, and a Button component my_cb instance , the following example opens the drop-down list of the combo my_button my_cb box when the button is clicked: my_button my_cb.addItem({data:2, label:"second value"});...
  • Page 192 Description Event; broadcast to all registered listeners when the drop-down list is completely open. Using the dispatcher/listener event model, a component instance ( comboBoxInstance dispatches an event (in this case, ) and the event is handled by a function, also called a open handler, on a listener object ( ) that you create.
  • Page 193: Combobox.removeall()

    ComboBox.removeAll() Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage comboBoxInstance.removeAll() Parameters None. Returns Nothing. Description Method; removes all items in the list. This is a method of the List component that is available from an instance of the ComboBox component. Example With a ComboBox instance on the Stage, and a Button component instance...
  • Page 194: Combobox.removeitemat()

    See also ComboBox.removeItemAt() ComboBox.replaceItemAt() ComboBox.removeItemAt() Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage comboBoxInstance.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;...
  • Page 195: Combobox.replaceitemat()

    // Define event listener object. var clearListener:Object = new Object(); clearListener.click = function(evt_obj:Object){ my_cb.removeItemAt(1); // Add Listener. clear_button.addEventListener("click", clearListener); See also ComboBox.removeAll() ComboBox.replaceItemAt() ComboBox.replaceItemAt() Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage comboBoxInstance.replaceItemAt(index, label[, data]) comboBoxInstance.replaceItemAt(index, {label:label[, data:data]}) comboBoxInstance.replaceItemAt(index, obj);...
  • Page 196: Combobox.restrict

    Example With a ComboBox component instance , and a TextInput component instance my_cb on the Stage, the following ActionScript code adds the user input to the combo box label_ti when the user presses the Enter key: // Add Items to List. my_cb.addItem({data:1, label:"First Item"});...
  • Page 197 You can use the backslash ( ) to enter a hyphen ( ), caret ( ), or backslash ( ) character, as shown here: When you enter a backslash in the Actions panel within double quotation marks, it has a special meaning for the Actions panel’s double-quote interpreter.
  • Page 198: Combobox.rowcount

    In the following example, the first line of code limits the text field to uppercase letters, numbers, and spaces. The second line of code allows all characters except lowercase letters. my_combo.restrict = "A-Z 0-9"; my_combo.restrict = "^a-z"; The following code allows a user to enter the characters “0 1 2 3 4 5 6 7 8 9 - ^ \” in the instance .
  • Page 199: Combobox.scroll

    Example With a ComboBox component instance , the following ActionScript sets the combo my_cb box to show the first three items, and add a scrollbar to see the fourth: // Add Items to List. my_cb.addItem({data:1, label:"First Item"}); my_cb.addItem({data:2, label:"Second Item"}); my_cb.addItem({data:3, label:"Third Item"});...
  • Page 200 Using a dispatcher/listener event model, a component instance ( comboBoxInstance dispatches an event (in this case, ) and the event is handled by a function, also called a scroll handler, on a listener object ( ) that you create. You define a method with the listenerObject same name as the event on the listener object;...
  • Page 201: Combobox.selectedindex

    ComboBox.selectedIndex Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage comboBoxInstance.selectedIndex Description Property; the index number of the selected item in the drop-down list. The default value is 0. Assigning this property clears the current selection, selects the indicated item, and displays the label of that item in the combo box’s text box.
  • Page 202: Combobox.selecteditem

    ComboBox.selectedItem Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage comboBoxInstance.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 selectedItem undefined the text box.
  • Page 203: Combobox.sortitems()

    ComboBox.sortItems() Availability Flash Player 7. Edition Flash MX Professional 2004. Usage comboBoxInstance.sortItems([compareFunc], [optionsFlag]) Parameters A reference to a function that compares two items to determine their sort compareFunc order. For details, see in ActionScript 2.0 Language Reference. This parameter Array.sort() is optional.
  • Page 204: Combobox.sortitemsby()

    Description Method; sorts the items in the combo box according to the specified compare function or according to the specified sort options. Example This example sorts according to uppercase labels. The items are passed to the function and contain fields: label data myComboBox.sortItems(upperCaseFunc);...
  • Page 205 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. This parameter is optional, but if used, should replace the parameter. order The following are possible values for optionsFlag , which sorts highest to lowest.
  • Page 206 Example The following examples are based on a ComboBox instance named , which myComboBox contains four elements labeled , and "Apples" "Bananas" "cherries" "Grapes" // First, populate the ComboBox with the elements. myComboBox.addItem("Bananas"); myComboBox.addItem("Apples"); myComboBox.addItem("cherries"); myComboBox.addItem("Grapes"); // The following statement sorts using the order parameter set to "ASC", // and results in a sort that places "cherries"...
  • Page 207: Combobox.text

    ComboBox.text Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage comboBoxInstance.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...
  • Page 208: Combobox.value

    Example The following code restricts the text box of so that it only accept numbers to myComboBox maximum of six characters: // Add Items to List. my_cb.addItem({data:0xFFFFFF, label:"white"}); my_cb.addItem({data:0x000000, label:"black"}); my_cb.editable = true; // Restrict what can be entered into textfield to only 0-9. my_cb.restrict = "0-9";...
  • Page 209: Chapter 9: Data Binding Classes (Flash Professional Only)

    CHAPTER 9 Data binding classes (Flash Professional only) The data binding classes provide the runtime functionality for the data binding feature in Flash Professional 8. 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 210: Classes In The Mx.data.binding Package

    Classes in the mx.data.binding package (Flash Professional only) The following table lists the classes in the mx.data.binding package: Class Description Binding class (Flash Creates a binding between two endpoints. Professional only) ComponentMixins class (Flash Adds data binding functionality to components. Professional only) CustomFormatter class (Flash The base class for creating custom formatter classes.
  • Page 211: Constructor For The Binding Class

    Method summary for the Binding class The following table lists the methods of the Binding class. Method Description Fetches the data from the source component, formats it, and Binding.execute() assigns it to the destination component. Constructor for the Binding class Availability Flash Player 6 (6.0.79.0).
  • Page 212 Description Constructor; creates a new Binding object. You can bind data to any ActionScript object that has properties and emits events including, but not limited to, components. A binding object exists as long as the innermost movie clip contains both the source and destination components.
  • Page 213: Binding.execute()

    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 reverse the destination to the source ( ), or only from the source to the destination ( ).
  • Page 214: Customformatter Class (Flash Professional Only)

    CustomFormatter class (Flash Professional only) ActionScript Class Name mx.data.binding.CustomFormatter The CustomFormatter class defines two methods, , that provide format() unformat() the ability to transform data values from a specific data type to String, and vice versa. By default, these methods do nothing; you must implement them in a subclass of mx.data.binding.CustomFormatter.
  • Page 215 To create and use a custom formatter: In Flash, create a new ActionScript file. Add the following code to the file: // NumberFormatter.as class NumberFormatter extends mx.data.binding.CustomFormatter { // Format a Number, return a String function format(rawValue) { var returnValue; var strArray = new Array('one', 'two', 'three');...
  • Page 216: Customformatter.format()

    Select Window > Common Libraries > Classes to open the Classes library. Select Window > Library to open your document’s library. Drag DataBindingClasses from the Classes library to your document’s library. This makes the data binding runtime classes available for your document. Save the FLA file to the same folder that contains NumberFormatter.as.
  • Page 217: Customformatter.unformat()

    Description Method; converts from a raw data type to a new object. This method is not implemented by default. You must define it in your subclass of mx.data.binding.CustomFormatter. For more information, see “Sample custom formatter” on page 212. CustomFormatter.unformat() Availability Flash Player 6 (6.0.79.0).
  • Page 218: Customvalidator Class (Flash Professional Only)

    CustomValidator class (Flash Professional only) ActionScript Class Name mx.data.binding.CustomValidator You use the CustomValidator class when you want to perform custom validation of a data field contained by a component. To create a custom validator class, you first create a subclass of mx.data.binding.CustomValidator that implements a method named .
  • Page 219: Customvalidator.validate()

    CustomValidator.validate() Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage This method is called automatically; you don’t invoke it directly. Parameters The data to be validated; it can be of any type. value Returns Nothing. Description Method; called automatically to validate the data contained by the parameter.
  • Page 220 To create and use a custom validator class: In Flash, 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 221: Customvalidator.validationerror()

    In the Schema Attributes pane, select Custom from the Data Type pop-up menu. Double-click the Validation Options field in the Schema Attributes pane to open the Custom Validation Settings dialog box. In the ActionScript Class text box, enter OddNumbersOnly, which is the name of the ActionScript class you created previously.
  • Page 222: Endpoint Class (Flash Professional Only)

    Usage this.validationError(errorMessage) This method can be invoked only from within a custom validator class; the keyword this refers to the current CustomValidator object. Parameters A string that contains the error message to be reported. errorMessage Returns Nothing. Description Method; called from the method of your subclass of CustomValidator to report validate() validation errors.
  • Page 223 The EndPoint objects, , might be defined as follows: srcEndPoint destEndPoint var srcEndPoint = new mx.data.binding.EndPoint(); var destEndPoint = new mx.data.binding.EndPoint(); srcEndPoint.component = source_txt; srcEndPoint.property = "text"; srcEndPoint.event = "focusOut"; destEndPoint.component = dest_txt; destEndPoint.property = "text"; In English, the above code means “When the source text field loses focus, copy the value of its property into the property of the destination text field.”...
  • Page 224: Constructor For The Endpoint Class

    Constructor for the EndPoint class Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage new EndPoint() Returns Nothing. Description Constructor; creates a new EndPoint object. Example This example creates a new EndPoint object named and assigns values to its source_obj properties: component...
  • Page 225: Endpoint.constant

    Example This example assigns an instance of the List component ( ) as the component listBox1 parameter of an EndPoint object. var sourceEndPoint = new mx.data.binding.EndPoint(); sourceEndPoint.component = listBox1; EndPoint.constant Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage endPoint_src.constant Description...
  • Page 226: Endpoint.location

    Usage endPointObj.event 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 227 For XML and ActionScript objects, you can also specify a string that contains an ActionScript path. An ActionScript path contains the names of fields separated by dots (for example, "a.b.c" You can also specify an array of strings as a location. Each string in the array “drills down” another level of nesting.
  • Page 228: Endpoint.property

    EndPoint.property Availability Flash Player 6 (6.0.79.0) Edition Flash MX Professional 2004. Usage endPointObj.property Description Property; specifies a property name of the component instance specified by that contains the bindable data. EndPoint.component must combine to form a valid ActionScript EndPoint.component EndPoint.property object/property combination.
  • Page 229: Componentmixins.getfield()

    Method summary for the ComponentMixins class The following table lists the methods of the ComponentMixins class. Method Description Returns an object for getting and setting the value ComponentMixins.getField() of a field at a specific location in a component property. Adds the ComponentMixins methods to a ComponentMixins.initComponent() component.
  • Page 230: Componentmixins.initcomponent()

    A string that contains field names, separated by dots—for example, . This form is "a.b.c" permitted for any complex data (ActionScript or XML). An array of strings, where each string is a field name—for example, ["a", "b", "c"] This form is permitted for any complex data (ActionScript or XML). Returns A DataType object.
  • Page 231: Componentmixins.refreshdestinations()

    Description Method (static); adds all the ComponentMixins methods to the component specified by . This method is called automatically for all components involved in a componentInstance data binding. To make the ComponentMixins methods available for a component that is not involved in a data binding, you must explicitly call this method for that component.
  • Page 232: Componentmixins.refreshfromsources()

    ComponentMixins.refreshFromSources() Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage componentInstance.refreshFromSources() Parameters None. Returns Nothing. Description Method; executes all bindings for which is the destination EndPoint componentInstance object. This method lets you execute bindings that have constant sources, or sources that do not emit a “data changed”...
  • Page 233 Parameters A string that contains the name of a property that belongs to propertyName componentInstance Returns An array, or null Description Method; determines if the data in is valid based on the property’s schema propertyName settings. The property’s schema settings are those specified on the Schema tab in the Component inspector.
  • Page 234 To validate text entered by a user in a TextInput component: Drag a TextInput component from the Components panel to the Stage, and name it zipCode_txt. Select the TextInput component and, in the Component inspector, click the Schema tab. In the Schema Tree pane (the top pane of the Schema tab), select the property.
  • Page 235: Datatype Class (Flash Professional Only)

    DataType class (Flash Professional only) ActionScript Class Name mx.data.binding.DataType The DataType class provides read and write access to data fields of a component property. To get a DataType object, you call the method on a component. ComponentMixins.getField() You can then call methods of the DataType object to get and set the value of the field. If you get and set field values directly on the component instance instead of using DataType class methods, the data is provided in its “raw”...
  • Page 236: Datatype.encoder

    Method summary for the DataType class The following table lists the methods of the DataType class. Method Description Fetches the current value of the field. DataType.getAnyTypedValue() Fetches the current value of the field as a Boolean value. DataType.getAsBoolean() Fetches the current value of the field as a number. DataType.getAsNumber() Fetches the current value of the field as a String value.
  • Page 237: Datatype.formatter

    Usage dataTypeObject.encoder Description Property; provides a reference to the encoder object associated with this field, if one exists. You can use this property to access any properties and methods defined by the specific encoder applied to the field in the Component inspector’s Schema tab. If no encoder was applied to the field in question, then this property returns undefined For more information about the encoders provided with Flash, see “Schema encoders”...
  • Page 238: Datatype.getanytypedvalue()

    Example This example assumes that the field being accessed is using the Number Formatter ) provided with Flash Professional 8. This mx.data.formatters.NumberFormatter formatter contains a property named that specifies how many digits to display precision after the decimal point. This code sets the property to two decimal places for a precision field using this formatter.
  • Page 239: Datatype.getasboolean()

    If a value can’t be returned in the form of the one of the suggested types, it is returned in the type specified in the Schema tab. 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.
  • Page 240: Datatype.getasnumber()

    DataType.getAsNumber() Availability Flash Player 6. Edition Flash MX Professional 2004. Usage dataTypeObject.getAsNumber() 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...
  • Page 241: Datatype.gettypedvalue()

    Parameters None. Returns A string. Description Method; fetches the current value of the field and converts it to String form, if necessary. Example In this example, a property named that belongs to a component named propName is retrieved as a string and assigned to a variable: myComponent var dataTypeObj:mx.data.binding.DataType = myComponent.getField("propName");...
  • Page 242: Datatype.kind

    is specified as , the method returns the value of the field in its null requestedType default type. Example The following example returns the value of the field converted to the Boolean data type. This is stored in the variable. bool var bool:TypedValue = field.getTypedValue("Boolean");...
  • Page 243: Datatype.setasboolean()

    Returns An array of strings describing any errors that occurred while attempting to set the new value. Errors can occur under any of the following conditions: The data provided cannot be converted to the data type of this field (for example, "abc"...
  • Page 244: Datatype.setasnumber()

    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. Example The following example sets a variable named to the Boolean value...
  • Page 245: Datatype.setasstring()

    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 246: Datatype.settypedvalue()

    DataType.setTypedValue() Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage dataTypeObject.setTypedValue(newTypedValue) Parameters A TypedValue object value to set in the field. newTypedValue For more information about TypedValue objects, see “TypedValue class (Flash Professional only)” on page 245. Returns An array of strings describing any errors that occurred while attempting to set the new value.
  • Page 247: Typedvalue Class (Flash Professional Only)

    Example The following example creates a new TypedValue object (a Boolean value), and then assigns that value to a DataType object named . Any errors that occur are assigned to the field array. errors import mx.data.binding.*; var bool:TypedValue = new TypedValue (true, "Boolean"); var errors: Array = field.setTypedValue (bool);...
  • Page 248: Constructor For The Typedvalue Class

    Constructor for the TypedValue class Availability Flash Player 6 (6.0.79.0). Usage new mx.data.binding.TypedValue(value, typeName, [type]) Parameters A data value of any type. value A string that contains the name of the value’s data type. typeName An optional Schema object that describes in more detail the schema of the data. This type field is required only in certain circumstances, such as when setting data into a DataSet component’s...
  • Page 249: Typedvalue.typename

    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 250 Data binding classes (Flash Professional only)
  • Page 251: Chapter 10: Datagrid Component (Flash Professional Only)

    You can use the DataGrid component to instantiate a recordset (retrieved from a database query in Macromedia ColdFusion, Java, or .Net) using Macromedia Flash Remoting and display it in columns. You can also use data from a data set or from an array to fill a DataGrid component.
  • Page 252: Interacting With The Datagrid Component

    Interacting with the DataGrid component (Flash Professional only) You can use the mouse and the keyboard to interact with a DataGrid component. are both DataGrid.sortableColumns DataGridColumn.sortOnHeaderRelease , clicking in a column header causes the grid to sort based on the column’s cell values. true , clicking in the area between columns lets you resize DataGrid.resizableColumns...
  • Page 253: Using The Datagrid Component (Flash Professional Only)

    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: Keep it small, fast, and simple. Don’t make something more complicated than absolutely necessary. This was the prime design directive.
  • Page 254 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 rowCount the list must to do to render.
  • Page 255 Field Identifiers that indicate the names of the columns within the items. This corresponds to property in the columns list. In the List component, the fields are columnNames usually , but in the DataGrid component the fields can be any identifier. label data In the following code, the fields are...
  • Page 256 The data for a grid can come from a recordset that is fed from a database query in Macromedia ColdFusion, Java, or .Net using Flash Remoting. Data can also come from a data set or an array. To pull the data into a grid, you set the DataGrid.dataProvider...
  • Page 257 In the Actions panel on Frame 1, enter the following code: myDP = new Array({name:"Chris", price:"Priceless"}, {name:"Nigel", price:"Cheap"}); myDataGrid.dataProvider = myDP; fields are used as the column headings, and their values fill the cells name price in each row. Select Control > Test Movie. To specify columns and add sorting for a DataGrid component in an application: In Flash, select File >...
  • Page 258: Datagrid Performance Strategies

    To create a DataGrid component instance using ActionScript: Drag the DataGrid component from the Components panel to the current document’s library. This adds the component to the library, but doesn’t make it visible in the application. Select the first frame in the main Timeline, open the Actions panel, and enter the following code: this.createClassObject(mx.controls.DataGrid, "my_dg", 10, {columnNames:["name", "score"]});...
  • Page 259 You may be tempted to make a loop to call for all the DataGrid.addColumn() columns needed. Although this seems like a simple and obvious approach, do not use it. Each time that is called, the data grid adds event listeners, sorts, DataGrid.addColumn() and redraws itself to present the new column.
  • Page 260: Customizing The Datagrid Component (Flash Professional Only)

    Separate data processing from CellRenderer processing. The CellRenderer API lets you display custom cell content in a data grid. A functional requirement might require that you populate the data grid with a ComboBox component or other UI control conditionally. For example, based on a selection in column two, you may repopulate or auto-select options in column four.
  • Page 261 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 766.) The DataGrid component also supports the following styles: Style Theme Description Both...
  • Page 262 Style Theme Description Both The font weight: either . The default fontWeight "none" "bold" value is . All components can also accept the "none" value in place of during a "normal" "none" setStyle() call, but subsequent calls to return getStyle() "none"...
  • Page 263 Setting styles for all DataGrid components in a document The DataGrid class inherits from the List class, which inherits from the ScrollSelectList class. The default class-level style properties are defined on the ScrollSelectList class, which the Menu component and all List-based components extend. You can set new default style values on this class directly, and these new settings are reflected in all affected components.
  • Page 264: Datagrid Class (Flash Professional Only)

    DataGrid class (Flash Professional only) Inheritance MovieClip > UIObject class > UIComponent class > View > ScrollView > ScrollSelectList > List component > DataGrid ActionScript Class Name mx.controls.DataGrid Each component class has a property, which is a class property. Class properties are version available only on the class itself.
  • Page 265 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 266 Method Description Removes all items from the list. List.removeAll() Removes the item at the specified index. List.removeItemAt() Replaces the item at the specified index with another item. List.replaceItemAt() Applies the specified properties to the specified item. List.setPropertiesAt() Sorts the items in the list according to the specified List.sortItems() compare function.
  • Page 267 Properties inherited from the UIObject class The following table lists the properties the DataGrid class inherits from the UIObject class. When accessing these properties from the DataGrid object, use the form dataGridInstance.propertyName Property Description The position of the bottom edge of the object, relative to UIObject.bottom the bottom edge of its parent.
  • Page 268 Properties inherited from the List class The following table lists the properties the DataGrid class inherits from the List class. When accessing these properties from the DataGrid object, use the form dataGridInstance.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 269 Event summary for the DataGrid class The following table lists the events of the DataGrid class. Event Description Broadcast when the cell value has changed. DataGrid.cellEdit Broadcast when a cell receives focus. DataGrid.cellFocusIn Broadcast when a cell loses focus. DataGrid.cellFocusOut Broadcast when a cell is pressed (clicked).
  • Page 270: Datagrid.addcolumn()

    Events inherited from the List class The following table lists the events the DataGrid class inherits from the List class. Event Description Broadcast whenever user interaction causes the selection List.change to change. Broadcast when the mouse pointer rolls over and then off List.itemRollOut of list items.
  • Page 271: Datagrid.addcolumnat()

    Example This example shows three different ways of creating columns for a DataGrid component. With a DataGrid instance named on the Stage, paste the following code in the first my_dg frame of the main timeline (notice that it imports the DataGridColumn class first): import mx.controls.gridclasses.DataGridColumn;...
  • Page 272: Datagrid.additem()

    Description Method; adds a new column at the specified position. Columns are shifted to the right and their indexes are incremented. For more information, see “DataGridColumn class (Flash Professional only)” on page 300. Example This example shows two ways to use and sets the column widths.
  • Page 273: Datagrid.additemat()

    Description Method; adds an item to the end of the grid (after the last item index). This differs from the method in that an object is passed rather than a List.addItem() string. Example This example creates one column with the heading “name” and then inserts the item_obj value for “name”.
  • Page 274: Datagrid.celledit

    // Insert your code here. myDataGridInstance.addEventListener("cellEdit", listenerObject) Description Event; broadcast to all registered listeners when cell value changes. Version 2 Macromedia Component Architecture components use a dispatcher/listener event model. The DataGrid component dispatches a event when the value of a cell has cellEdit...
  • Page 275 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 DataGrid.cellEdit event object has four additional properties:...
  • Page 276: Datagrid.cellfocusin

    DataGrid.cellFocusIn Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage listenerObject = new Object(); listenerObject.cellFocusIn = function(eventObject){ // Insert your code here. myDataGridInstance.addEventListener("cellFocusIn", listenerObject) Description Event; broadcast to all registered listeners when a particular cell receives focus. This event is broadcast after any previously edited cell’s events are broadcast.
  • Page 277: Datagrid.cellfocusout

    Example In the following example, a handler called is defined and passed to dgListener as the second parameter. When the event is my_dg.addEventListener() cellFocusIn broadcast, a statement is sent to the Output panel. With a DataGrid instance named trace on the Stage, paste the following code in the first frame of the main timeline: my_dg // Set up sample data.
  • Page 278 Usage listenerObject = new Object(); listenerObject.cellFocusOut = function(eventObject){ // Insert your code here. myDataGridInstance.addEventListener("cellFocusOut", listenerObject) Description Event; broadcast to all registered listeners whenever a user moves off a cell that has focus. You can use the event object properties to isolate the cell that was left. This event is broadcast after event and before any subsequent events are broadcast by the cellEdit...
  • Page 279: Datagrid.cellpress

    // Create listener object. var dgListener:Object = new Object(); dgListener.cellFocusOut = function(evt_obj:Object) { var cell_str:String = "(" + evt_obj.columnIndex + ", " + evt_obj.itemIndex + ")"; trace("The cell at " + cell_str + " has lost focus"); // Add listener. my_dg.addEventListener("cellFocusOut", dgListener);...
  • Page 280: Datagrid.change

    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 DataGrid.cellPress event object has three additional properties:...
  • Page 281 Usage listenerObject = new Object(); listenerObject.change = function(eventObject){ // Insert your code here. myDataGridInstance.addEventListener("change", listenerObject) Description Event; broadcast to all registered listeners when an item has been selected. 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 is change...
  • Page 282: Datagrid.columncount

    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 displays the total number of columns in the Output panel. With a DataGrid instance named on the Stage, paste the following code in the first frame of my_dg the main timeline:...
  • Page 283: Datagrid.columnstretch

    Example The following example displays the column name in the Output panel when the title is clicked. With a DataGrid instance named on the Stage, paste the following code in the my_dg first frame of the main timeline: my_dg.setSize(200, 100); my_dg.columnNames = ["Name", "Description", "Price"];...
  • Page 284: Datagrid.dataprovider

    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 DataGrid.columnStretch event’s event object has two additional properties: A number that indicates the index of the target column.
  • Page 285: Datagrid.editable

    Description Property; the data model for items viewed in a DataGrid component. 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 addItem()
  • Page 286 Usage myDataGrid.editable Description Property; determines whether the data grid can be edited by a user ( ) or not ( true false This property must be in order for individual columns to be editable and for any cell to true receive focus.
  • Page 287: Datagrid.editfield()

    DataGrid.editField() Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage myDataGrid.editField(index, colName, data) Parameters The index of the target cell. This number is zero-based. index A string indicating the name of the column (field) that contains the target cell. colName The value to be stored in the target cell.
  • Page 288: Datagrid.focusedcell

    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 columnIndex itemIndex indicate the index of the column and item of the cell.
  • Page 289: Datagrid.getcolumnat()

    DataGrid.getColumnAt() Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage myDataGrid.getColumnAt(index) Parameters The index of the DataGridColumn object to be returned. This number is zero-based. index Returns A DataGridColumn object. Description Method; gets a reference to the DataGridColumn object at the specified index. Example The following example gets the DataGridColumn object at index 0 and changes the text.
  • Page 290: Datagrid.getcolumnindex()

    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 291: Datagrid.headerheight

    DataGrid.headerHeight Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage myDataGrid.headerHeight Description Property; the height of the header bar of the data grid, in pixels. The default value is 20. Example The following example sets the height of the header bar to 40. With a DataGrid instance named on the Stage, paste the following code in the first frame of the main timeline: my_dg...
  • Page 292 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 DataGridColumn.sortOnHeaderRelease automatic sorting and to let you sort as you like.
  • Page 293: Datagrid.hscrollpolicy

    In the following example, you change the sort direction using a column. With a DataGrid instance named on the Stage paste the following code in the first frame of the my_dg main timeline: var my_dg:mx.controls.DataGrid; my_dg.setSize(150, 100); my_dg.spaceColumnsEqually(); var myListener:Object = new Object(); myListener.headerRelease = function(evt:Object) { trace("column "+evt.columnIndex+"...
  • Page 294: Datagrid.removeallcolumns()

    Example The following example sets horizontal scroll policy to automatic, which means that the horizontal scroll bar appears if it’s necessary to display all the content: my_dg.setSize(150, 100); // Add columns to grid and add data. var myDP_array:Array = new Array(); myDP_array.push({name:"Clark", score:3135});...
  • Page 295: Datagrid.removecolumnat()

    Example The following example removes all DataGridColumn objects from the DataGrid when the button is clicked. With a DataGrid instance named and a Button instance named my_dg on the Stage, paste the following code in the first frame of the main timeline: clear_button my_dg.setSize(140, 100);...
  • Page 296: Datagrid.replaceitemat()

    Example The following example removes the first DataGridColumn object when the button is clicked. With a DataGrid instance named and a Button instance named on the my_dg name_button Stage, paste the following code in the first frame of the main timeline: my_dg.setSize(140, 100);...
  • Page 297: Datagrid.resizablecolumns

    Description Method; replaces the item at a specified index and refreshes the display of the grid. Example The following example replaces the item at row index 2 with new entries. With a DataGrid instance named and a Button instance named on the Stage, paste my_dg replace_button...
  • Page 298: Datagrid.selectable

    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 true false true resizable by the user. The default value is true Example The following example prevents users from resizing columns.
  • Page 299: Datagrid.showheaders

    Example The following example prevents the grid from being selected. With a DataGrid instance named on the Stage paste the following code in the first frame of the main timeline: my_dg my_dg.setSize(140, 100); // Set up sample data. var myDP_array:Array = new Array(); myDP_array.push({name:"Clark", score:3135});...
  • Page 300: Datagrid.sortablecolumns

    See also DataGrid.sortableColumns DataGrid.sortableColumns Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage myDataGrid.sortableColumns Description Property; a Boolean value that determines whether the columns of the data grid can be sorted ) or not ( ) when a user clicks the column headers. This property must be true false true...
  • Page 301: Datagrid.spacecolumnsequally()

    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 the button is clicked. With a my_dg DataGrid instance named and a Button instance named on the my_dg...
  • Page 302: Datagridcolumn Class (Flash Professional Only)

    DataGridColumn class (Flash Professional only) ActionScript Class Name mx.controls.gridclasses.DataGridColumn You can create and configure DataGridColumn objects to use as columns of a data grid. Many of the methods of the DataGrid class are dedicated to managing DataGridColumn objects. DataGridColumn objects are stored in an zero-based array in the data grid; 0 is the leftmost column.
  • Page 303 Property summary for the DataGridColumn class The following table lists the properties of the DataGridColumn class. Property Description The linkage identifier of a symbol to be used to display DataGridColumn.cellRenderer the cells in this column. Read-only; the name of the field associated with DataGridColumn.columnName the column.
  • Page 304: Constructor For The Datagridcolumn Class

    Constructor for the DataGridColumn class Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage new DataGridColumn(name) Parameters A string that indicates the name of the DataGridColumn object. This parameter is the name field of each item to display. Returns Nothing.
  • Page 305: Datagridcolumn.cellrenderer

    DataGridColumn.cellRenderer Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage myDataGrid.getColumnAt(index).cellRenderer Description Property; a linkage identifier for a symbol to be used to display cells in this column. Any class used for this property must implement the CellRenderer API (see “CellRenderer API”...
  • Page 306: Datagridcolumn.editable

    Example The following example displays the name of the column as index position 1: import mx.controls.gridclasses.DataGridColumn; // Set grid attributes. my_dg.setSize(150, 100); // Add columns to grid. var name_dgc:DataGridColumn = my_dg.addColumn(new DataGridColumn("name")); name_dgc.headerText = "Name:"; var score_dgc:DataGridColumn = my_dg.addColumn(new DataGridColumn("score")); score_dgc.headerText = "Score:";...
  • Page 307 Description Property; determines whether the column can be edited by a user ( ) or not ( ). The true false property must be in order for individual columns to be editable, DataGrid.editable true even when is set to . The default value is DataGridColumn.editable true true...
  • Page 308: Datagridcolumn.headerrenderer

    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 309: Datagridcolumn.labelfunction

    Example The following example sets the column header text to “Price (USD)”: import mx.controls.gridclasses.DataGridColumn; var my_dg:mx.controls.DataGrid; var price_dgc:DataGridColumn = new DataGridColumn("price"); price_dgc.headerText = "Price (USD)"; price_dgc.width = 80; my_dg.addColumn(price_dgc); my_dg.addItem({price:"$14.99"}); DataGridColumn.labelFunction Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage myDataGrid.getColumnAt(index).labelFunction Description...
  • Page 310: Datagridcolumn.resizable

    Example The following example calculates a value for the “Subtotal” column: import mx.controls.gridclasses.DataGridColumn; var my_dg:mx.controls.DataGrid; my_dg.setSize(300, 200); // Set up columns. var guitar_dgc:DataGridColumn = new DataGridColumn("guitar"); var value_dgc:DataGridColumn = new DataGridColumn("value"); var tax_dgc:DataGridColumn = new DataGridColumn("tax"); var st_dgc:DataGridColumn = new DataGridColumn("Subtotal"); //Define labelFunction for Subtotal column.
  • Page 311: Datagridcolumn.sortable

    Example The following example prevents the column at index 0 from being resized: // Set grid attributes. my_dg.setSize(150, 100); my_dg.addColumn("name"); my_dg.addColumn("score"); // Set up sample data. my_dg.addItem({name:"Clark", score:3135}); my_dg.addItem({name:"Bruce", score:403}); my_dg.addItem({name:"Peter", score:25}); // Don't allow resize of the first column my_dg.getColumnAt(0).resizable = false;...
  • Page 312: Datagridcolumn.sortonheaderrelease

    Example The following example prevents the column at index 1 from being sorted: // Set grid attributes. my_dg.setSize(150, 100); // Set up sample data. my_dg.addItem({name:"Clark", score:3135}); my_dg.addItem({name:"Bruce", score:403}); my_dg.addItem({name:"Peter", score:25}); // Don't allow sort of the second column. my_dg.getColumnAt(1).sortable = false; DataGridColumn.sortOnHeaderRelease Availability Flash Player 6 (6.0.79.0).
  • Page 313: Datagridcolumn.width

    Example The following example disables sorting of the second column: // Set grid attributes. my_dg.setSize(150, 100); // Set up sample data. my_dg.addItem({name:"Clark", score:3135}); my_dg.addItem({name:"Bruce", score:403}); my_dg.addItem({name:"Peter", score:25}); // Don’t allow sort of the second column by clicking the header. my_dg.getColumnAt(1).sortOnHeaderRelease = false; DataGridColumn.width Availability Flash Player 6 (6.0.79.0).
  • Page 314 DataGrid component (Flash Professional only)
  • Page 315: Chapter 11: Dataholder Component (Flash Professional Only)

    CHAPTER 11 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 316: Creating An Application With The Dataholder Component

    You might have a data value that results from a complex indexed data binding, as shown in the following diagram. Results Web Service Method UI ListBox getMovies movieList Results[movieList.selectedIndex] data.movieTitle UI TextField title data.movieRating DataModel UI TextField myDataModel rating data.movieTimes UI ListBox times In this case it is convenient to bind the data value to a DataHolder component (called...
  • Page 317: Dataholder Class

    Drag a DataGrid component to the Stage and name it namesGrid. Select the DataHolder component and open the Component inspector. Click the Schema tab in the Component inspector. Click the Add Component Property (+) button located in the top pane of the Schema tab. In the bottom pane of the Schema tab, type namesArray in the Field Name field, and select Array from the Data Type pop-up menu.
  • Page 318: Dataholder.data

    DataHolder.data Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage dataHolder.data Description Property; the default item in a DataHolder object’s schema. This property is not a “permanent” member of the DataHolder component. Rather, it is the default bindable property for each instance of the component.
  • Page 319: Chapter 12: Dataprovider Api

    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 class, is a property of each component that acts as a view for data, and “data dataProvider provider”...
  • Page 320 Method summary for the DataProvider API The following table lists the methods of the DataProvider API. Method Description Adds an item at the end of the data provider. DataProvider.addItem() Adds an item to the data provider at the specified position. DataProvider.addItemAt() Changes one field of the data provider.
  • Page 321: Dataprovider.additem()

    DataProvider.addItem() Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage myDP.addItem(item) Parameters An object that contains data. This constitutes an item in a data provider. item Returns Nothing. Description Method; adds a new item at the end of the data provider. This method triggers the event with the event name modelChanged addItems...
  • Page 322: Dataprovider.editfield()

    Returns Nothing. Description Method; adds a new item to the data provider at the specified index. Indices greater than the data provider’s length are ignored. This method triggers the event with the event name modelChanged addItems Example The following example adds an item to the data provider at the fourth position: myDP myDP.addItemAt(3, {label : "this is the fourth Item"});...
  • Page 323: Dataprovider.geteditingdata()

    DataProvider.getEditingData() Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage myDP.getEditingData(index, fieldName) Parameters A number greater than or equal to 0 and less than . This index DataProvider.length number is the index of the item to retrieve. A string indicating the name of the field being edited. fieldName Returns The editable formatted data to be used.
  • Page 324: Dataprovider.getitemid()

    Parameters A number greater than or equal to 0 and less than . This index DataProvider.length number is the index of the item to retrieve. Returns A reference to the retrieved item; undefined if the index is out of range. Description Method;...
  • Page 325: Dataprovider.length

    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 326 event’s event object has five additional properties: Menu.modelChanged property is used to subcategorize events. eventName eventName modelChanged Data-aware components use this information to avoid completely refreshing the component instance (view) that is using the data provider. The property eventName supports the following values: The entire view needs refreshing, excluding scroll position.
  • Page 327: Dataprovider.removeall()

    DataProvider.removeAll() Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage myDP.removeAll() Parameters None. Returns Nothing. Description Method; removes all items in the data provider. This method triggers the modelChanged event with the event name removeItems Example This example removes all the items in the data provider: myDP.removeAll();...
  • Page 328: Dataprovider.replaceitemat()

    Returns Nothing. 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 Example This example removes the item at the fourth position: myDP.removeItemAt(3);...
  • Page 329: Dataprovider.sortitems()

    DataProvider.sortItems() Availability Flash Player 7. Edition Flash MX Professional 2004. Usage myDP.sortItems([compareFunc], [optionsFlag]) Parameters A reference to a function that compares two items to determine their sort compareFunc order. For more information, see sort (Array.sort method) in ActionScript 2.0 Language Reference.This parameter is optional.
  • Page 330: Dataprovider.sortitemsby()

    Description Method; sorts the items in the data provider according to the specified compare function or according to one or more specified sort options. This method triggers the event with the event name modelChanged sort Example This example sorts according to uppercase labels. The items are passed to the function and contain fields:...
  • Page 331 —if two objects in the array are identical or have identical sort fields, Array.UNIQUESORT this method returns an error code (0) instead of a sorted array. —returns an integer index array that is the result of the sort. Array.RETURNINDEXEDARRAY 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]...
  • Page 332 DataProvider API...
  • Page 333: Chapter 13: Dataset Component (Flash Professional Only)

    CHAPTER 13 CHAPTER 13 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 334 The DataSet component uses functionality in the data binding classes. If you intend to work with the DataSet component in ActionScript only, without using the Binding and Schema tabs in the Component inspector to set properties, you’ll need to import the data binding classes into your FLA file and set required properties in your code.
  • Page 335 Common workflow for the DataSet component The typical workflow for the DataSet component is as follows. To use a DataSet component: Add an instance of the DataSet component to your application and give it an instance name. Select the Schema tab for the DataSet component and create component properties to represent the persistent fields of the data set.
  • Page 336 To create an application using the DataSet component: In Flash Professional 8, 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 user_ds.
  • Page 337: Dataset Class (Flash Professional Only)

    To bind the selected index of the DataSet component to the selected index of the DataGrid component, select the DataGrid component on the Stage and click the Add Binding (+) button again in the Component inspector. In the dialog box that appears, select “selectedIndex : Number”. Click OK. Double-click the Bound To field in the Component inspector to open the Bound To dialog box.
  • Page 338 Method summary for the DataSet class The following table lists the methods of the DataSet class. Method Description Adds the specified item to the collection. DataSet.addItem() Adds an item to the data set at the specified position. DataSet.addItemAt() Creates a new sorted view of the items in the collection. DataSet.addSort() Signals that the property has a value that you can...
  • Page 339 Method Description Moves to the next item in the current view of the collection. DataSet.next() Moves to the previous item in the current view of DataSet.previous() the collection. Removes all the items from the collection. DataSet.removeAll() Removes the specified item from the collection. DataSet.removeItem() Removes a data set item at a specified position.
  • Page 340: Dataset.additem

    Property Description Indicates whether the collection can be modified. DataSet.readOnly Specifies the collection’s schema in XML format. DataSet.schema Contains the current item’s index in the collection. DataSet.selectedIndex Event summary for the DataSet class The following table lists the events of the DataSet class. Event Description Broadcast before an item is added to the collection.
  • Page 341 // ... dataSetInstance.addEventListener("addItem", listenerObject); Usage 2: on (addItem) { // ... 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; if result false you set it to...
  • Page 342: Dataset.additem()

    See also DataSet.removeItem DataSet.addItem() Availability Flash Player 7. Edition Flash MX Professional 2004. Usage dataSetInstance.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 343 The following example demonstrates how you can accept or reject an item’s insertion into the DataSet by setting the result to within the handler for the event. true false addItem Drag a DataSet component to the Stage, and assign it an instance name of .
  • Page 344: Dataset.additemat()

    DataSet.addItemAt() Availability Flash Player 7. Edition Flash MX Professional 2004. Usage dataSetInstance.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 345: Dataset.addsort()

    DataSet.addSort() Availability Flash Player 7. Edition Flash MX Professional 2004. Usage dataSetInstance.addSort(name, fieldList, sortOptions) Parameters A string that specifies the name of the sort. name An array of strings that specify the field names to sort on. fieldList One or more of the following integer (constant) values, which indicate what sortOptions options are used for this sort.
  • Page 346 Example The following code creates a new sort named that performs a descending, case- "nameSort" insensitive sort on the DataSet object’s field. "name" import mx.data.components.datasetclasses.DataSetIterator; my_ds.addItem({name:"Milton", years:3}); my_ds.addItem({name:"mark", years:3}); my_ds.addItem({name:"Sarah", years:1}); my_ds.addItem({name:"michael", years:2}); my_ds.addItem({name:"Frank", years:2}); my_ds.addSort("nameSort", ["name"], DataSetIterator.Descending | DataSetIterator.Unique | DataSetIterator.CaseInsensitive); In the following example, you can dynamically add data to a DataSet component by entering first and last names into TextInput component instances on the Stage and clicking the Submit button.
  • Page 347 function modelChangedListener(evt_obj:Object):Void { my_dg.enabled = (evt_obj.target.length > 0); clear_button.enabled = my_dg.enabled; function submitListener(evt_obj:Object):Void { my_ds.addItem({firstName:firstName_ti.text, lastName:lastName_ti.text}); function addItemListener(evt_obj:Object):Void { if ((evt_obj.item.firstName.length == 0) || (evt_obj.item.lastName.length == 0)) { Alert.show("Error, first name or last name cannot be blank.", "Error", Alert.OK, _level0); evt_obj.result = false;...
  • Page 348: Dataset.afterloaded

    DataSet.afterLoaded Availability Flash Player 7. Edition Flash MX Professional 2004. Usage Usage 1: var listenerObject:Object = new Object(); listenerObject.afterLoaded = function (eventObj:Object):Void { // ... dataSetInstance.addEventListener("afterLoaded", listenerObject); Usage 2: on (afterLoaded) { // ... Description Event; broadcast immediately after the property has been assigned.
  • Page 349: Dataset.applyupdates()

    The following example uses the event of the DataSet component to populate afterLoaded property for a List component on the Stage. Drag a List component and a dataProvider DataSet component to the Stage, and give them instance names of my_list my_ds, respectively.
  • Page 350: Dataset.calcfields

    Example The following code calls the method on the DataSet. applyUpdates() my_ds my_ds.applyUpdates(); The following example adds four items to the DataSet instance on the Stage and my_ds displays each item in the top-level of the property: deltaPacket my_ds.addItem({name:"Thomas", age:35, gender:"M"}); my_ds.addItem({name:"Orville", age:33, gender:"M"});...
  • Page 351: Dataset.changespending()

    Description Event; generated when values of calculated fields for the current item in the collection need to be determined. A calculated field is one whose Kind property is set to Calculated on the Schema tab of the Component inspector. The event listener that you create calcFields should perform the required calculation and set the value for the calculated field.
  • Page 352: Dataset.clear()

    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. my_ds.addItem({name:"Milton", years:3}); my_ds.addItem({name:"Mark", years:3}); my_ds.addItem({name:"Sarah", years:1}); my_ds.addItem({name:"Michael", years:2});...
  • Page 353: Dataset.createitem()

    Example The following example removes all items from the current view of the DataSet collection. Because the property is set to , the removal of those items is logged. logChanges true my_ds.addItem({name:"Milton", years:3}); my_ds.addItem({name:"Mark", years:3}); my_ds.addItem({name:"Sarah", years:1}); my_ds.addItem({name:"Michael", years:2}); my_ds.addItem({name:"Frank", years:2}); my_ds.addSort("nameSort", ["name"]);...
  • Page 354: Dataset.currentitem

    Description Method; creates an item that isn’t associated with the collection. You can specify the class of object created by using the property. If no DataSet.itemClassName value is specified and the parameter is omitted, an DataSet.itemClassName itemData anonymous object is constructed. This anonymous object’s properties are set to the default values based on the schema currently specified by DataSet.schema When this method is invoked, any listeners for the...
  • Page 355: Dataset.dataprovider

    Description Property (read-only); returns the current item in the DataSet collection, or if the null collection is empty or if the current iterator’s view of the collection is empty. This property provides direct access to the item in the collection. Changes made by directly accessing this object are not tracked (in the property), nor are any of DataSet.deltaPacket...
  • Page 356: Dataset.deltapacket

    DataSet.deltaPacket Availability Flash Player 7. Edition Flash MX Professional 2004. Usage dataSetInstance.deltaPacket Description Property; returns a delta packet that contains all of the change operations made to the collection and its items. This property is until dataSet null DataSet.applyUpdates() called on dataSet When is called, a transaction ID is assigned to the delta packet.
  • Page 357: Dataset.deltapacketchanged

    DataSet.deltaPacketChanged Availability Flash Player 7. Edition Flash MX Professional 2004. Usage Usage 1: var listenerObject:Object = new Object(); listenerObject.deltaPacketChanged = function (eventObj:Object):Void { // ... dataSetInstance.addEventListener("deltaPacketChanged", listenerObject); Usage 2: on (deltaPacketChanged) { // ... Description Event; broadcast when the specified DataSet object’s property has been changed deltaPacket and is ready to be used.
  • Page 358: Dataset.disableevents()

    DataSet.disableEvents() Availability Flash Player 7. Edition Flash MX Professional 2004. Usage dataSetInstance.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 359: Dataset.enableevents()

    trace("After:"); traceItems(); // Tell the dataset it's time to update the controls now. my_ds.enableEvents(); function traceItems():Void { for (var i:Number = 0; i < my_ds.items.length; i++) { trace("\t" + my_ds.items[i].name + " - $" + my_ds.items[i].price); trace(""); See also DataSet.enableEvents() DataSet.enableEvents() Availability Flash Player 7.
  • Page 360 Example In the following example, events are disabled before changes are made to items in the collection, so that the DataSet object won’t affect performance by trying to refresh controls. my_ds.addEventListener("modelChanged", onModelChanged); function onModelChanged(evt_obj:Object):Void { trace("model changed, DataSet now has " + evt_obj.target.items.length + " items");...
  • Page 361: Dataset.filtered

    DataSet.filtered Availability Flash Player 7. Edition Flash MX Professional 2004. Usage dataSetInstance.filtered Description Property; a Boolean value that indicates whether the data in the current iterator is filtered. The default value is .When this property is , the filter function specified by false true is called for each item in the collection.
  • Page 362 Download a copy of the following XML document and save it to your local hard disk: http:/ . This XML document will be loaded /www.helpexamples.com/flash/xml/reviews.xml dynamically using the XMLConnector component, but you’ll use the local copy to import the XML schema into the DataSet component. Select the XMLConnector instance on the Stage and select the Schema tab from the Component inspector.
  • Page 363: Dataset.filterfunc

    Select Control > Test Movie. By default, the DataGrid component should display each of the reviews from the external XML document. Clicking on the Editor’s Choice CheckBox component causes the DataSet component to be filtered, so that only the specific reviews flagged as an editor’s choice appear.
  • Page 364 Example In the following example, filtering is enabled on the DataSet object named employee_ds The specified filter function returns if the field in each item is set to true empType ; otherwise, it returns "management" false employee_ds.filtered = true; employee_ds.filterFunc = function (item:Object):Boolean { // Filter out employees who are managers.
  • Page 365 The following example populates a DataGrid component from content dynamically loaded using the XMLConnector component. When a user clicks a CheckBox instance on the Stage, the contents of the DataSet component are filtered and are updated automatically in the DataGrid component. Drag the following components to the Stage, and give them the following instance names: CheckBox ( editorsChoice_ch...
  • Page 366: Dataset.find()

    Add the following code to Frame 1 of the main timeline: editorsChoice_ch.label = "Editor's Choice"; reviews_xmlconn.direction = "receive"; reviews_xmlconn.multipleSimultaneousAllowed = false; reviews_xmlconn.URL = "http://www.helpexamples.com/flash/xml/reviews.xml"; reviews_xmlconn.trigger(); reviews_dg.setSize(320, 240); reviews_dg.addColumn("name"); reviews_dg.addColumn("rating"); reviews_dg.addColumn("reviewDate"); reviews_dg.getColumnAt(0).width = 100; reviews_dg.getColumnAt(1).width = 100; reviews_dg.getColumnAt(2).width = 100; reviews_dg.setStyle("alternatingRowColors", [0xFFFFFF, 0xF6F6F6]); editorsChoice_ch.addEventListener("click", editorsChoiceListener);...
  • Page 367 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 Method; searches the current view of the collection for an item with the field values specified .
  • Page 368: Dataset.findfirst()

    DataSet.findFirst() Availability Flash Player 7. Edition Flash MX Professional 2004. Usage dataSetInstance.findFirst(searchValues) Parameters An array that contains one or more field values to be found within the searchValues current sort. Returns Returns if the items are found; otherwise, returns true false Description Method;...
  • Page 369: Dataset.findlast()

    To test this example, drag a DataSet component to the Stage, and give it an instance name of . Add two properties, (data type: String) and (data type: Number) to the student_ds name DataSet by using the Schema tab of the Component inspector. If you don’t already have a copy of the compiled clip in your library, drag a copy of the compiled DataBindingClasses...
  • Page 370 Description Method; searches the current view of the collection for the last item with the field values specified by . Which items are in the current view depends on any current filter searchValues and range settings. The values specified by must be in the same order as the field list specified by searchValues the current sort (see the example below).
  • Page 371: Dataset.first()

    DataSet.first() Availability Flash Player 7. Edition Flash MX Professional 2004. Usage dataSetInstance.first() Returns Nothing. Description Method; makes the first 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. Example The following code positions the data set at the first item in its collection,...
  • Page 372: Dataset.getitemid()

    DataSet.getItemId() Availability Flash Player 7. Edition Flash MX Professional 2004. Usage dataSetInstance.getItemId([index]) Parameters A number specifying the item in the current view for which to get the ID. This index parameter is optional. Returns A string. Description Method; returns the identifier of the current item in the collection, or that of the item specified by .
  • Page 373: Dataset.getiterator()

    To test this example, drag a DataSet component to the Stage, and give it an instance name of . Add two properties, (data type: String) and (data type: Number) to the student_ds name DataSet by using the Schema tab of the Component inspector. If you don’t already have a copy of the compiled clip in your library, drag a copy of the compiled DataBindingClasses...
  • Page 374 Description Method; returns a new iterator for this collection; this iterator is a clone of the current iterator in use, including its current position in the collection. This method is mainly for advanced users who want access to multiple, simultaneous views of the same collection. Example The following example uses to search for an item in the current collection...
  • Page 375: Dataset.getlength()

    DataSet.getLength() Availability Flash Player 7. Edition Flash MX Professional 2004. Usage dataSetInstance.getLength() Returns The number of items in the data set. Description Method; returns the number of items in the data set. Example The following example calls getLength() //... var my_ds:mx.data.components.DataSet; my_ds = _parent.thisShelf.compactDiscs_ds;...
  • Page 376: Dataset.hasprevious()

    Description Method; returns if the current iterator is at the end of its view of the collection; false otherwise, returns true Example The following 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 377: Dataset.hassort()

    Example The following example iterates over all the items in the current view of the collection (starting from the its last item) and performs a calculation on the property of each item: price my_ds.addItem({name:"item a", price:16}); my_ds.addItem({name:"item b", price:9}); my_ds.last(); while (my_ds.hasPrevious()) { my_ds.currentItem.price *= 0.5;...
  • Page 378: Dataset.isempty()

    Example The following code tests whether a sort named “nameSort” exists. If the sort already exists, it is made the current sort by means of . If a sort by that name doesn’t exist, DataSet.useSort() one is created by means of .
  • Page 379: Dataset.items

    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: if (my_ds.isEmpty()) { delete_button.enabled = false;...
  • Page 380: Dataset.itemclassname

    DataSet.itemClassName Availability Flash Player 7. Edition Flash MX Professional 2004. Usage dataSetInstance.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.
  • Page 381 Usage Usage 1: var listenerObject:Object = new Object(); listenerObject.iteratorScrolled = function (eventObj:Object) { // ... dataSetInstance.addEventListener("iteratorScrolled", listenerObject); Usage 2: on (iteratorScrolled) { // ... 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...
  • Page 382: Dataset.last()

    DataSet.last() Availability Flash Player 7. Edition Flash MX Professional 2004. Usage dataSetInstance.last() Returns Nothing. Description Method; makes the last item in the current view of the collection the current item. Example The following code, attached to a Button component, goes to the last item in the DataSet collection: function goLast(evt_obj:obj):Void { inventory_ds.last();...
  • Page 383: Dataset.length

    The following example iterates over all the items in the current view of the collection (starting from the its last item) and performs a calculation on the property of each item: price my_ds.addItem({name:"item a", price:16}); my_ds.addItem({name:"item b", price:9}); my_ds.last(); while (my_ds.hasPrevious()) { my_ds.currentItem.price *= 0.5;...
  • Page 384: Dataset.loadfromsharedobj()

    Example In the following example, events are disabled before changes are made to items in the collection, so that the DataSet object won’t affect performance by trying to refresh controls: my_ds.addEventListener("modelChanged", onModelChanged); function onModelChanged(evt_obj:Object):Void { trace("model changed, DataSet now has " + evt_obj.target.length + " items");...
  • Page 385 Usage dataSetInstance.loadFromSharedObj(objName, [localPath]) Parameters A string specifying the name of the shared object to retrieve. The name can objName include forward slashes (for example, “work/addresses”). Spaces and the following characters are not allowed in the specified name: ~ % & \ ; : " ' , < > ? # An optional string parameter that specifies the full or partial path to the SWF localPath file that created the shared object.
  • Page 386: Dataset.locatebyid()

    DataSet.locateById() Availability Flash Player 7. Edition Flash MX Professional 2004. Usage dataSetInstance.locateById(id) Parameters A string identifier for the item in the collection to be located. Returns A Boolean value. Description Method; positions the current iterator on the collection item whose ID matches .
  • Page 387: Dataset.logchanges

    To test this example, drag a DataSet component to the Stage, and give it an instance name of . Add two properties, (String) and (Number) to the DataSet by using the student_ds name Schema tab of the Component inspector. If you don’t already have a copy of the compiled clip in your library, drag a copy of the compiled clip from DataBindingClasses the Classes library (Window >...
  • Page 388: Dataset.modelchanged

    When this property is set to , operations performed at the collection level and item level true are logged. Collection-level changes include the addition and removal of items from the collection. Item-level changes include property changes made to items and method calls made on items by means of the DataSet component.
  • Page 389 The event object ( ) contains the following properties: eventObj The DataSet object that generated the event. target The string type "iteratorScrolled" The index (number) of the first item in the collection that was affected by firstItem the change. The index (number) of the last item in the collection that was affected by the lastItem change (equals if only one item was affected).
  • Page 390 In the following 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: my_ds.addEventListener("modelChanged", onModelChanged); function onModelChanged(evt_obj:Object):Void { trace("model changed, DataSet now has " + evt_obj.target.items.length + " items");...
  • Page 391: Dataset.newitem

    DataSet.newItem Availability Flash Player 7. Edition Flash MX Professional 2004. Usage Usage 1: var listenerObject:Object = new Object(); listenerObject.newItem = function (eventObj:Object) { // ... dataSetInstance.addEventListener("newItem", listenerObject); Usage 2: on (newItem) { // ... Description Event; broadcast when a new transfer object is constructed by means of .
  • Page 392: Dataset.next()

    DataSet.next() Availability Flash Player 7. Edition Flash MX Professional 2004. Usage dataSetInstance.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. Example The following example iterates over all the items in the current view of the collection (starting at its beginning) and performs a calculation on the...
  • Page 393: Dataset.previous()

    DataSet.previous() Availability Flash Player 7. Edition Flash MX Professional 2004. Usage dataSetInstance.previous() 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. Example The following example loops over each item in a data set and traces each item’s price: my_ds.addItem({name:"item a", price:16});...
  • Page 394: Dataset.properties

    DataSet.properties Availability Flash Player 7. Edition Flash MX Professional 2004. Usage dataSetInstance.properties Description Property (read-only); returns an object that contains all of the exposed properties (fields) for any transfer object within this collection. Example The following example displays all the names of the properties in the DataSet object named my_ds var i:String;...
  • Page 395: Dataset.removeall()

    Example The following example makes the DataSet object named read-only, and then attempts my_ds to change the value of a property that belongs to the current item in the collection. This attempt throws a exception. DataSetError import mx.data.components.datasetclasses.DataSetError; my_ds.readOnly = true; try { // This throws an exception.
  • Page 396: Dataset.removeitem

    DataSet.removeItem Availability Flash Player 7. Edition Flash MX Professional 2004. Usage Usage 1: var listenerObject:Object = new Object(); listenerObject.removeItem = function (eventObj:Object):Void { // ... dataSetInstance.addEventListener("removeItem", listenerObject); Usage 2: on (removeItem) { // ... 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 397 Example In the following example, an event handler cancels the deletion of the new on(removeItem) item if a user-defined function named returns ; otherwise, the userHasAdminPrivs() false deletion is allowed: on (removeItem) { if (globalObj.userHasAdminPrivs()) { // Allow the item deletion. eventObj.result = true;...
  • Page 398: Dataset.removeitem()

    DataSet.removeItem() Availability Flash Player 7. Edition Flash MX Professional 2004. Usage dataSetInstance.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 399: Dataset.removeitemat()

    DataSet.removeItemAt() Availability Flash Player 7. Edition Flash MX Professional 2004. Usage dataSetInstance.removeItemAt(index) Parameters A number greater than or equal to 0. This number is the index of the item to remove. index Returns A Boolean value indicating whether the item was removed. Description Method;...
  • Page 400: Dataset.removerange()

    Example The following example removes an item from the data set at the first position: my_ds.addItem({name:"Milton", years:3}); my_ds.addItem({name:"Mark", years:3}); my_ds.addItem({name:"Sarah", years:1}); my_ds.addItem({name:"Michael", years:2}); my_ds.addItem({name:"Frank", years:2}); trace(my_ds.getLength()); // 5 trace(my_ds.currentItem.name); // Frank my_ds.removeItemAt(0); trace(my_ds.getLength()); // 4 trace(my_ds.currentItem.name); // Frank DataSet.removeRange() Availability Flash Player 7.
  • Page 401: Dataset.removesort()

    Example my_ds.addSort("name_id", ["name", "id"]); my_ds.setRange(["Bobby", 105],["Cathy", 110]); while (my_ds.hasNext()) { my_ds.gradeLevel ="5"; // Change all of the grades in this range. my_ds.next(); my_ds.removeRange(); my_ds.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 dataSetInstance.removeSort(sortName) Parameters...
  • Page 402 Example The following example creates a range of items in the DataSet component and modifies the gradeLevel property of each item. To test this example, drag a DataSet component to the Stage, and give it an instance name of . With the DataSet component selected, create my_ds three new properties in the schema of the DataSet component by using the Schema tab in the Component inspector.
  • Page 403: Dataset.resolvedelta

    DataSet.resolveDelta Availability Flash Player 7. Edition Flash MX Professional 2004. Usage Usage 1: var listenerObject:Object = new Object(); listenerObject.resolveDelta = function (eventObj:Object):Void { // ... dataSetInstance.addEventListener("resolveDelta", listenerObject); Usage 2: on (resolveDelta) { // ... Description Event; broadcast when is assigned a delta packet whose transaction DataSet.deltaPacket ID 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 404: Dataset.savetosharedobj()

    Example The following example displays a form called (not shown) and calls a method reconcileForm on that form object ( ) that allows the user to reconcile any conflicting setReconcileData() values returned by the server: import mx.data.components.datasetclasses.*; my_ds.addEventListener("resolveDelta", onResolveDelta); function onResolveDelta(eventObj:Object) { reconcileForm.visible = true;...
  • Page 405 Parameters A string that specifies the name of the shared object to create. The name can objName include forward slashes (for example, “work/addresses”). Spaces and the following characters are not allowed in the specified name: ~ % & \ ; : " ' , < > ? # An optional string parameter that specifies the full or partial path to the SWF localPath file that created the shared object.
  • Page 406: Dataset.schema

    DataSet.schema Availability Flash Player 7. Edition Flash MX Professional 2004. Usage dataSetInstance.schema Description Property; provides the XML representation of the schema for this DataSet object. The XML assigned to this property must have the following format: <?xml version="1.0"?> <properties> <property name="propertyName"> <type name="dataType"...
  • Page 407: Dataset.selectedindex

    DataSet.selectedIndex Availability Flash Player 7. Edition Flash MX Professional 2004. Usage dataSetInstance.selectedIndex Description Property; specifies the selected index in the collection. You can bind this property to the selected item in a DataGrid or List component, and vice versa. For a complete example that demonstrates this, see “Creating an application with the DataSet component”...
  • Page 408: Dataset.setrange()

    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.getIterator() DataSet object to which it is being assigned; otherwise; a exception is thrown. DataSetError Example import mx.data.to.ValueListIterator;...
  • Page 409: Dataset.skip()

    Example The following example selects a range of students and traces each of their names to the Output panel: my_ds.addItem({name:"Billy", id:104, gradeLevel:4}); my_ds.addItem({name:"Bobby", id:105, gradeLevel:4}); my_ds.addItem({name:"Carrie", id:106, gradeLevel:4}); my_ds.addItem({name:"Cathy", id:110, gradeLevel:4}); my_ds.addItem({name:"Mally", id:112, gradeLevel:3}); my_ds.addSort("name_id",["name", "id"]); my_ds.setRange(["Bobby", 105],["Cathy", 110]); while (my_ds.hasNext()) { trace(my_ds.name);...
  • Page 410: Dataset.usesort()

    If the specified offset is beyond the beginning (or end) of the collection, the iterator is positioned at the beginning (or end) of the collection. Example The following example positions the current iterator at the first item in the collection, moves to the next-to-last item, and performs a calculation on a field belonging to that item: my_ds.addItem({name:"Billy", id:104, gradeLevel:4});...
  • Page 411 Example The following example uses to determine if a sort named DataSet.hasSort() "customer" exists. If it does, the code calls to make the current sort. DataSet.useSort() "customer" Otherwise, the code creates a sort by that name using DataSet.addSort() if (my_ds.hasSort("customer")) { my_ds.useSort("customer");...
  • Page 412 Components Dictionary...
  • Page 413: Chapter 14: Datechooser Component

    CHAPTER 14 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 414 monthNames sets the month names that are displayed in the heading row of the calendar. The value is an array and the default value is ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October","November", "December"] showToday indicates whether to highlight today’s date. The default value is true You can set the following additional parameters for each DateChooser component instance in the Component inspector (Window >...
  • Page 415: Customizing The Datechooser Component

    This code assigns a value to the property in an ActionScript object that selectableRange contains two Date objects with the variable names . This rangeStart rangeEnd defines an upper and lower end of a range in which the user can select a date. In the Actions panel, enter the following code on Frame 1 of the timeline to set a range of holiday disabled dates: flightCalendar.disabledRanges = [{rangeStart: new Date(2003, 11, 15),...
  • Page 416 A DateChooser component supports the following styles: Style Theme Description Halo The glow color for the rollover and selected dates. themeColor Possible values are , and "haloGreen" "haloBlue" . The default value is "haloOrange" "haloGreen" Both The background color. The default value is 0xEFEBEF backgroundColor (light gray).
  • Page 417 Style Theme Description Both The font weight: either . The default fontWeight "none" "bold" value is . All components can also accept the "none" value in place of during a "normal" "none" setStyle() call, but subsequent calls to returns getStyle() "none"...
  • Page 418 Only the month scrolling buttons can be dynamically skinned in this component. A DateChooser component uses the following skin properties: Property Description The month back button up state. The default value is backMonthButtonUpSymbolName backMonthUp The month back button pressed state. The default backMonthButtonDownSymbolName value is backMonthDown...
  • Page 419: Datechooser Class (Flash Professional Only)

    Click the Back button to return to the main timeline. Drag a DateChooser component to the Stage. Select Control > Test Movie. The DateChooser Assets/States folder also contains a Day Skins folder with a single skin element, . This element can be modified during authoring to cal_todayIndicator customize the today indicator.
  • Page 420 Method summary for the DateChooser class There are no methods exclusive to the DateChooser class. 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...
  • Page 421 Property summary for the DateChooser class The following table lists the properties that are exclusive to the DateChooser class. Property Description An array indicating the names of the days of the week. DateChooser.dayNames An array indicating the days of the week that are disabled for DateChooser.disabledDays all applicable dates in the date chooser.
  • Page 422 Property Description 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 ( false The width of the object, in pixels. Read-only. UIObject.width The left edge of the object, in pixels.
  • Page 423: Datechooser.change

    Event Description 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 DateChooser class inherits from the UIComponent class.
  • Page 424 Description Event; broadcast to all registered listeners when a date is selected. The first usage example uses a dispatcher/listener event model. A component instance ) dispatches an event (in this case, ) and the event is handled dataChooserInstance change by a function, also called a handler, on a listener object ( ) that you create.
  • Page 425: Datechooser.daynames

    DateChooser.dayNames Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage dateChooserInstance.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 426: Datechooser.disabledranges

    DateChooser.disabledRanges Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage dateChooserInstance.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 rangeStart...
  • Page 427: Datechooser.displayedmonth

    DateChooser.displayedMonth Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage dateChooserInstance.displayedMonth 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.
  • Page 428: Datechooser.firstdayofweek

    Example The following example sets the displayed year to 2010: my_dc.displayedYear = 2010; See also DateChooser.displayedMonth DateChooser.firstDayOfWeek Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage dateChooserInstance.firstDayOfWeek 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.
  • Page 429: Datechooser.monthnames

    DateChooser.monthNames Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage dateChooserInstance.monthNames Description Property; an array of strings indicating the month names at the top of the DateChooser 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 my_dc...
  • Page 430 Description Event; broadcast to all registered listeners when a month button is clicked. The first usage example uses a dispatcher/listener event model. A component instance ( myDC dispatches an event (in this case, ) and the event is handled by a function, also called a scroll handler, on a listener object ( ) that you create.
  • Page 431: Datechooser.selectablerange

    DateChooser.selectableRange Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage dateChooserInstance.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 432: Datechooser.selecteddate

    Example The following example defines the selectable range as the dates between and including May 7 and June 7: my_dc.selectableRange = {rangeStart: new Date(2001, 4, 7), rangeEnd: new Date(2003, 5, 7)}; The following example defines the selectable range as the dates after and including May 7: my_dc.selectableRange = {rangeStart: new Date(2005, 4, 7)};...
  • Page 433: Datechooser.showtoday

    DateChooser.showToday Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage dateChooserInstance.showToday Description Property; a Boolean value that determines whether the current date is highlighted. The default value is true Example The following example turns off the highlighting on today’s date: my_dc.showToday = false;...
  • Page 434 DateChooser component (Flash Professional only)
  • Page 435: Chapter 15: Datefield Component

    CHAPTER 15 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 436 DateField parameters You can set the following authoring parameters for each DateField component instance in the Property inspector or in the Component inspector: dayNames sets the names of the days of the week. The value is an array and the default value ["S", "M", "T", "W", "T", "F", "S"] disabledDays indicates the disabled days of the week.
  • Page 437: Customizing The Datefield Component (Flash Professional Only)

    This code assigns a value to the property in an ActionScript object that selectableRange contains two Date objects with the variable names . This rangeStart rangeEnd defines an upper and lower end of a range within which the user can select a date. In the Actions panel, enter the following code on Frame 1 of the timeline to set the ranges of disabled dates, one during December, and one for all dates before the current date: flightCalendar.disabledRanges = [{rangeStart: new Date(2003, 11, 15),...
  • Page 438 Using styles with the DateField component You can set style properties to change the appearance of a date field instance. If the name of a style property ends in “Color”, it is a color style property and behaves differently than noncolor style properties.
  • Page 439 Style Theme Description Both A Boolean value that indicates whether the font embedFonts specified in is an embedded font. This style fontFamily must be set to refers to an embedded true fontFamily font. Otherwise, the embedded font is not used. If this style is set to does not refer to an true...
  • Page 440 Using skins with the DateField component The DateField component uses skins to represent the visual states of the pop-up icon, a RectBorder instance for the border around the text input, and a DateChooser instance for the pop-up. To skin the pop-up icon while authoring, modify skin symbols in the Flash UI Components 2/Themes/MMDefault/DateField Assets/States folder in the library of one of the themes’...
  • Page 441: Datefield Class (Flash Professional Only)

    Drag a DateField component to the Stage. Select Control > Test Movie. DateField class (Flash Professional only) Inheritance MovieClip > UIObject class > UIComponent class > ComboBase > DateField ActionScript Class Name mx.controls.DateField The properties of the DateField class let you access the selected date and the displayed month and year.
  • Page 442 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 443 Property summary for the DateField class The following table lists properties of the DateField class. Property Description A function that formats the date to be displayed in the DateField.dateFormatter text field. An array indicating the names of the days of the week. DateField.dayNames An array indicating the disabled days of the week.
  • Page 444 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 UIObject.top parent.
  • Page 445 Events inherited from the UIObject class The following table lists the events the DateField 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 UIObject.hide invisible.
  • Page 446: Datefield.change

    DateField.change Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage Usage 1: var listenerObject:Object = new Object(); listenerObject.change = function(eventObject:Object) { // ... dateFieldInstance.addEventListener("change", listenerObject); Usage 2: on (change) { // ... Description Event; broadcast to all registered listeners when a date is selected. The first usage example uses a dispatcher/listener event model.
  • Page 447: Datefield.close()

    Example The following 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 my_df called . The second line defines a function for the event on the listener dfListener change...
  • Page 448: Datefield.close

    Example The following code closes the date chooser pop-up of the date field instance when the my_df button is clicked: my_btn //Create listener object. var btnListener:Object = new Object(); btnListener.click = function() { my_df.close(); //Add Button listener. my_btn.addEventListener("click", btnListener); DateField.close Availability Flash Player 6 (6.0.79.0).
  • Page 449 The first usage example uses a dispatcher/listener event model. A component instance ) dispatches an event (in this case, ) and the event is handled by a dateFieldInstance close 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 450: Datefield.dateformatter

    DateField.dateFormatter Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage dateFieldInstance.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. Example The following example sets the function to return the format of the date to be displayed: my_df.dateFormatter = function(d:Date){...
  • Page 451: Datefield.disableddays

    Example The following example changes the value of the fifth day of the week (Thursday) from “T” to “R”: my_df.dayNames[4] = "R"; The following example changes the value of all the days, accordingly: my_df.dayNames = new Array("Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"); DateField.disabledDays Availability Flash Player 6 (6.0.79.0).
  • Page 452: Datefield.displayedmonth

    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 specifying a single day to disable, or an object containing either or both of the properties , each of whose value rangeStart rangeEnd...
  • Page 453: Datefield.displayedyear

    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: my_df.displayedMonth = 11;...
  • Page 454: Datefield.firstdayofweek

    DateField.firstDayOfWeek Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage dateFieldInstance.firstDayOfWeek 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 DateField component. Changing this dayNames property changes the order of the day columns but has no effect on the order of the dayNames...
  • Page 455: Datefield.open()

    Example The following example sets the month names for the instance my_df my_df.monthNames = ["Jan", "Feb","Mar","Apr", "May", "June","July", "Aug", "Sept","Oct", "Nov", "Dec"]; DateField.open() Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage dateFieldInstance.open() Returns Nothing. Description Method; opens the pop-up DateChooser subcomponent. Example The following code opens the date chooser pop-up of the date field instance when the...
  • Page 456: Datefield.open

    DateField.open Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage Usage 1: var listenerObject:Object = new Object(); listenerObject.open = function(eventObject:Object) { // ... dateFieldInstance.addEventListener("open", listenerObject); Usage 2: on (open) { // ... Description Event; broadcast to all registered listeners when a DateChooser subcomponent opens after a user clicks the icon.
  • Page 457: Datefield.pulldown

    The second 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 this on() the component instance. For example, the following code, attached to the date field my_df sends “_level0.my_df ”...
  • Page 458: Datefield.scroll

    Description Property (read-only); a reference to the DateChooser component contained by the DateField component. The DateChooser subcomponent is instantiated when a user clicks on the DateField component. However, if the property is referenced before the user clicks pullDown on the component, the DateChooser is instantiated and then hidden. Example The following example sets the visibility of the DateChooser subcomponent to false...
  • Page 459 The first usage example uses a dispatcher/listener event model. A component instance ) dispatches an event (in this case, ) and the event is handled by dateFieldInstance scroll 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 460: Datefield.selectablerange

    DateField.selectableRange Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage dateFieldInstance.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 461: Datefield.selecteddate

    Example The following example defines the selectable range as the dates between and including May 7 and June 7: my_df.selectableRange = {rangeStart: new Date(2001, 4, 7), rangeEnd: new Date(2003, 5, 7)}; The following example defines the selectable range as the dates after and including May 7: my_df.selectableRange = {rangeStart: new Date(2003, 4, 7)};...
  • Page 462: Datefield.showtoday

    DateField.showToday Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage dateFieldInstance.showToday Description Property; a Boolean value that determines whether the current date is highlighted. The default value is true Example The following example turns off the highlighting on today’s date: my_df.showToday = false;...
  • Page 463: Chapter 16: Delegate Class

    CHAPTER 16 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 464: Delegate.create()

    Delegate.create() Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage Delegate.create(scopeObject, function) Parameters A reference to an object. This is the scope in which to run the function. scopeObject A reference to a function. function Description Method (static); allows you to delegate events to specific scopes and functions. Use the following syntax: import mx.utils.Delegate;...
  • Page 465: Chapter 17: Deltaitem Class (Flash Professional Only)

    CHAPTER 17 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. It also provides the original state of properties on a transfer object.
  • Page 466: Deltaitem.arglist

    Property Description The name of the property or method that changed. This DeltaItem.name property is read-only. If a change was made to a property, this is the new value DeltaItem.newValue of the property. This property is read-only. If a change was made to a property, this is the old value DeltaItem.oldValue of the property.
  • Page 467: Deltaitem.delta

    Description Property (read-only); an object containing the current property value on the server’s copy of the transfer object. This property applies only if the change’s kind is DeltaItem.Property and the property is relevant only in a delta that has been returned from a server and is being applied to the data set for user resolution.
  • Page 468: Deltaitem.message

    DeltaItem.message Availability Flash Player 7. Edition Flash MX Professional 2004. Usage deltaitem.message Description Property; a string containing a server message associated with this DeltaItem object. This can be any message for the property or method call change attempted in the delta packet. This message is usually relevant only in a delta that has been returned from a server and is being applied to the DataSet for resolution.
  • Page 469: Deltaitem.newvalue

    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 470 DeltaItem class (Flash Professional only)
  • Page 471: Chapter 18: Delta Interface (Flash Professional Only)

    CHAPTER 18 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 472: Delta.adddeltaitem()

    Delta.addDeltaItem() Availability Flash Player 7. Edition Flash MX Professional 2004. Usage delta.addDeltaItem(deltaitem) Parameters DeltaItem instance to add to this delta. deltaitem 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:...
  • Page 473: Delta.getdeltapacket()

    Parameters None. Returns An array of associated DeltaItem instances. Description Method; returns an array of associated DeltaItem instances. Each DeltaItem instance in the array describes a change made to the item. Example The following example calls the method.: getChangeList() //... case mx.data.components.datasetclasses.DeltaPacketConsts.Modified: { // dpDelta is a variable of type Delta.
  • Page 474: Delta.getid()

    Description Method; returns the delta packet that contains this delta. This method lets you write code that can handle delta packets generically at the delta level. Example The following example uses the method to access the delta packet’s getDeltaPacket() data source: while(dpCursor.hasNext()) { dpDelta = Delta(dpCursor.next());...
  • Page 475: Delta.getitembyname()

    Example The following example calls the method: getId() while(dpCursor.hasNext()) { dpDelta = Delta(dpCursor.next()); trace("id ["+dpDelta.getId()+"]"); Delta.getItemByName() Availability Flash Player 7. Edition Flash MX Professional 2004. Usage delta.getItemByName(name) Parameters A string that specifies the name of the property or method for the associated name DeltaItem object.
  • Page 476: Delta.getmessage()

    Example The following example calls the method: getItemByName() private function buildFieldTag(deltaObj:Delta, field:Object, isKey:Boolean):String { var chgItem:DeltaItem = deltaObj.getItemByName(field.name); var result:String= "<field name=\"" + field.name + "\" type=\"" + field.type.name + "\""; var oldValue:String; var newValue:String; if (deltaObj.getOperation() != DeltaPacketConsts.Added) { oldValue = (chgItem != null ? (chgItem.oldValue != null ? encodeFieldValue(field.name, chgItem.oldValue) : __nullValue) : encodeFieldValue(field.name, deltaObj.getSource()[field.name]));...
  • Page 477: Delta.getoperation()

    Description Method; returns the associated message for this delta. Typically this message is only populated if the delta packet has been returned from a server in response to attempted updates. For more information, see “RDBMSResolver component (Flash Professional only)” on page 1047.
  • Page 478: Delta.getsource()

    Example The following example calls the method: getOperation() while(dpCursor.hasNext()) { dpDelta = Delta(dpCursor.next()); op=dpDelta.getOperation(); trace("DeltaPacket source is: " + dpDelta.getDeltaPacket().getSource()); switch(op) { case mx.data.components.datasetclasses.DeltaPacketConsts.Added: trace("***In case DeltaPacketConsts.Added ***"); case mx.data.components.datasetclasses.DeltaPacketConsts.Modified: { trace("***In case DeltaPacketConsts.Modified ***"); Delta.getSource() Availability Flash Player 7. Edition Flash MX Professional 2004.
  • Page 479 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: "); var src = dpDelta.getDeltaPacket().getSource(); for(var i in src){ if(typeof(src[i]) != "function"){ trace(i+"="+src[i]); Delta.getSource()
  • Page 480 Delta interface (Flash Professional only)
  • Page 481: Chapter 19: Deltapacket Interface (Flash Professional Only)

    CHAPTER 19 DeltaPacket interface (Flash Professional only) ActionScript Interface Name mx.data.components.datasetclasses.DeltaPacket The DeltaPacket interface is provided by the property of the DataSet deltaPacket component, which is part of the data management functionality in Flash MX Professional 2004. (For more information, see Chapter 16, “Data Integration (Flash Professional Only),” in Using Flash).
  • Page 482: Deltapacket.getconfiginfo()

    Method summary for the DeltaPacket interface The following table lists the methods of the DeltaPacket interface. Method Description Returns configuration information that is specific to the DeltaPacket.getConfigInfo() implementation of the DeltaPacket interface. Returns the iterator for the delta packet that iterates DeltaPacket.getIterator() through the delta packet’s list of deltas.
  • Page 483: Deltapacket.getiterator()

    Description Method; returns configuration information that is specific to the implementation of the DeltaPacket interface. This method allows implementations of the DeltaPacket interface to access custom information. Example The following example calls the method: getConfigInfo() // ... new DeltaPacketImpl(source, getTransactionId(), null, logChanges(), getConfigInfo());...
  • Page 484: Deltapacket.getsource()

    Example The following example uses the method to access the iterator for the deltas in getIterator() a 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 485: Deltapacket.gettimestamp()

    Example The following example calls the method: getSource() // ... var deltapkt:DeltaPacket = _parent.myDataSet.deltaPacket; var dpSourceText:String = "Source: " + deltapkt.getSource(); trace(dpSourceText); // ... 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;...
  • Page 486: Deltapacket.gettransactionid()

    DeltaPacket.getTransactionId() Availability Flash Player 7. Edition Flash MX Professional 2004. Usage deltaPacket.getTransactionId() Parameters None. Returns A string; the unique transaction ID for a single transaction grouping of delta packets. 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.
  • Page 487: Deltapacket.logchanges()

    DeltaPacket.logChanges() Availability Flash Player 7. Edition Flash MX Professional 2004. Usage deltaPacket.logChanges() Parameters None. Returns A Boolean value; if the consumer of the delta packet should log changes found in the true delta packet. Description Method; returns if the consumer of this delta packet should log the changes it specifies. true This value is used mainly for communication of changes between data sets by means of shared objects or from a server to a local data set.
  • Page 488 DeltaPacket interface (Flash Professional only)
  • Page 489: Chapter 20: Depthmanager Class

    CHAPTER 20 DepthManager class ActionScript Class Name mx.managers.DepthManager The DepthManager class allows you to manage the relative depth assignments of any component or movie clip, including . It also lets you manage reserved depths in a _root special highest-depth clip on for system-level services such as the pointer and tooltips.
  • Page 490 Method summary for the DepthManager class The following table lists the methods of the DepthManager class. Method Description Creates a child of the specified symbol at the DepthManager.createChildAtDepth() specified depth. Creates an object of the specified class at the DepthManager.createClassChildAtDepth() specified depth.
  • Page 491: Depthmanager.createchildatdepth()

    Property Description A static property with the constant value 201. DepthManager.kTop A static property with the constant value 203. DepthManager.kTopmost DepthManager.createChildAtDepth() Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage movieClipInstance.createChildAtDepth(linkageName, depthFlag[, initObj]) Parameters A linkage identifier. This parameter is a string. linkageName One of the following values: depthFlag...
  • Page 492: Depthmanager.createclasschildatdepth()

    DepthManager.createClassChildAtDepth() Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage movieClipInstance.createClassChildAtDepth(className, depthFlag[, initObj]) Parameters A class name. This parameter is a of type Function. className One of the following values: depthFlag DepthManager.kTop DepthManager.kBottom . All depth flags are static properties DepthManager.kTopmost DepthManager.kNotopmost of the DepthManger class.
  • Page 493: Depthmanager.createclassobjectatdepth()

    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 . All depth flags are static properties of the DepthManger class. You DepthManager.kTooltip must either reference the DepthManager package (for example, ), or use the...
  • Page 494: Depthmanager.createobjectatdepth()

    DepthManager.createObjectAtDepth() Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage DepthManager.createObjectAtDepth(linkageName, depthSpace[, initObj]) Parameters A linkage identifier. This parameter is of type String. linkageName One of the following values: depthSpace DepthManager.kCursor . All depth flags are static properties of the DepthManger class. You DepthManager.kTooltip must either reference the DepthManager package (for example, ), or use the...
  • Page 495: Depthmanager.kbottom

    DepthManager.kBottom Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage DepthManager.kBottom Description Property (static); a property with the constant value 202. This property is passed as a parameter in calls to DepthManager.createClassChildAtDepth() to place content behind other content. DepthManager.createChildAtDepth() DepthManager.kCursor Availability Flash Player 6 (6.0.79.0).
  • Page 496: Depthmanager.ktooltip

    Usage DepthManager.kNotopmost Description Property (static); a property with the constant value 204. This property is passed as a parameter in calls to DepthManager.createClassChildAtDepth() to request removal from the topmost layer. DepthManager.createChildAtDepth() DepthManager.kTooltip Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage DepthManager.kTooltip Description...
  • Page 497: Depthmanager.ktopmost

    DepthManager.kTopmost Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage DepthManager.kTopmost Description Property (static); a property with the constant value 203. This property is used in calls to DepthManager.createClassChildAtDepth() DepthManager.createChildAtDepth() to request placement on top of other content, including objects.
  • Page 498: Depthmanager.setdepthbelow()

    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 499 Parameters One of the following values: depthFlag DepthManager.kTop DepthManager.kBottom . All depth flags are static properties DepthManager.kTopmost DepthManager.kNotopmost of the DepthManger class. You must either reference the DepthManager package (for example, ) or use the statement to import mx.managers.DepthManager.kTopmost import the DepthManager package.
  • Page 500 Test the SWF file. When you click the top button, the other button changes depth and moves to the front, and the Output panel displays that button’s depth. The values are 20, then 40, then 60, incremented by 20 each time you click. If you use DepthManager with movie clip instances instead of component instances, you may need to add a UI component to your library (if one isn’t already there) for DepthManager to operate properly.
  • Page 501: Chapter 21: Eventdispatcher Class

    CHAPTER 21 EventDispatcher class Events let your application know when the user has interacted with a component, and when important changes have occurred in the appearance or life cycle of a component—such as its creation, destruction, or resizing. The methods of the EventDispatcher class let you add and remove event listeners so that your code can react to events appropriately.
  • Page 502: Eventdispatcher Class (Api)

    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 503: Eventdispatcher.addeventlistener()

    EventDispatcher.addEventListener() Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004 and Flash MX Professional 2004. Usage componentInstance.addEventListener(event, listener) Parameters A string that is the name of the event. event A reference to a listener object or function. listener Returns Nothing. Description Method;...
  • Page 504 You can register multiple listeners to a single component instance, but you must use a separate call to for each listener. Also, you can register one listener to multiple addEventListener() component instances, but you must use a separate call to for each addEventListener() instance.
  • Page 505: Eventdispatcher.dispatchevent()

    EventDispatcher.dispatchEvent() Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004 and Flash MX Professional 2004. Usage dispatchEvent(eventObject) Parameters A reference to an event object. The event object must have a property eventObject type that is a string indicating the name of the event. Generally, the event object also has a target property that is the name of the instance broadcasting the event.
  • Page 506: Eventdispatcher.removeeventlistener()

    EventDispatcher.removeEventListener() Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004 and Flash MX Professional 2004. Usage componentInstance.removeEventListener(event, listener) Parameters A string that is the name of the event. event A reference to a listener object or function. listener Returns Nothing. Description Method;...
  • Page 507: Chapter 22: Flvplayback Component

    CHAPTER 22 FLVPlayback Component (Flash Professional Only) The FLVPlayback component lets you easily include a video player in your Flash application to play progressively downloaded Flash video (FLV) files over HTTP or play streaming FLV files from a Flash Communication Server (FCS) or from a Flash Video Streaming Service (FVSS).
  • Page 508 The FLVPlayback component includes the FLV Playback Custom UI components. The FLVPlayback component is a combination of the display area, or video player, in which you view the FLV file and the controls that allow you to operate it. The FLV Playback Custom UI components provide control buttons and mechanisms that you can use to play, stop, pause, and otherwise control the FLV file.
  • Page 509: Using The Flvplayback Component

    The FLVPlayback component also includes an ActionScript application programming interface (API). The API includes the FLVPlayback, VideoError, and VideoPlayer classes. For more information on these classes, see “FLVPlayback class” on page 539, the “VideoPlayer class” on page 706, and the “VideoError class”...
  • Page 510 Click the magnifying-glass icon to open the Select Skin dialog box. Select one of the following options: From the drop-down Skin list, select one of the predesigned skins to attach a set of playback controls to the component. If you created a custom skin, select Custom Skin URL from the pop-up menu, and enter, in the URL text box, the URL for the SWF file that contains the skin.
  • Page 511 Skins folder for your installation: import mx.video.*; this.attachMovie("FLVPlayback", "my_FLVPlybk", 10, {width:320, height:240, x:100, y:100}); my_FLVPlybk.skin = "file:///install_drive|/Program Files/Macromedia/ Flash 8/en/Configuration/Skins/ClearOverPlaySeekMute.swf" my_FLVPlybk.contentPath = "http://www.helpexamples.com/flash/video/ water.flv"; method belongs to the MovieClip class. You can use it create an...
  • Page 512 FLVPlayback component parameters For each instance of the FLVPlayback component, you can set the following parameters in the Component inspector or the Property inspector: autoPlay A Boolean value that determines how to play the FLV file. If , the true component plays the FLV file immediately when it is loaded.
  • Page 513 isLive A Boolean value that, if , specifies that the FLV file is streaming live from Flash true Communication Server. One example of a live stream is a video of news events as they are taking place. The default value is .
  • Page 514 Specifying the contentPath parameter parameter lets you specify the name and location of the FLV file, both of contentPath which inform Flash how to play the file. Open the Content Path dialog box by double-clicking the Value cell for the contentPath parameter in the Component inspector.
  • Page 515: Using Cue Points

    You can also specify the name and location of the FLV file using the ActionScript property and the FLVPlayback contentPath FLVPlayback.play() methods. These three alternatives take precedence over the FLVPlayback.load() parameter in the Component inspector. For more information, see contentPath on page 579, on page 620...
  • Page 516 A navigation cue point allows you to seek to a particular frame in the FLV file because it creates a keyframe within the FLV file as near as possible to the time that you specify. A keyframe is a data segment that occurs between image frames in the FLV file stream. When you seek to a navigation cue point, the component seeks to the keyframe and starts the event.
  • Page 517 Using the Flash Video Cue Points dialog box Open the Flash Video Cue Points dialog box by double-clicking the Value cell of the parameter in the Component inspector. The dialog box looks like the cuePoints following figure: The dialog box displays embedded and ActionScript cue points. You can use this dialog box to add and delete ActionScript cue points as well as cue point parameters.
  • Page 518 To add a parameter for the selected cue point, click the plus (+) sign above the Parameters section, and enter values in the Name and Value columns. Repeat this step for each parameter. To add more ActionScript cue points, repeat steps 2 through 5 for each one. Click OK to save your changes.
  • Page 519 Adding ActionScript cue points You can add ActionScript cue points to an FLV file using the method. The addASCuePoint() following example adds two ActionScript cue points to the FLV file when it is ready to play. It adds the first cue point using a cue point object, which specifies the time, name, and type of the cue point in its properties.
  • Page 520 event handler in the following example calls the method to find ready findCuePoint() the cue point and then calls the method to find the ASpt1 findNearestCuePoint() navigation cue point that is nearest to the time of cue point ASpt1 import mx.video.*; my_FLVPlybk.contentPath = "http://www.helpexamples.com/flash/video/ cuepoints.flv"...
  • Page 521 Seeking navigation cue points You can seek to a navigation cue point, seek to the next navigation cue point from a specified time, and seek to the previous navigation cue point from a specified time. The following example plays the FLV file cuepoints.flv and seeks to the cue point at 7.748 when the ready event occurs.
  • Page 522 You can test whether an embedded FLV file cue point is enabled using the method. The following example disables the embedded cue isFLVCuePointEnabled() points when the video is ready to play. When the first event point2 point3 cuePoint occurs, however, the event handler tests to see if cue point is disabled and, if so, point3 enables it.
  • Page 523: Playing Multiple Flv Files

    Playing multiple FLV files You can play FLV files sequentially in an FLVPlayback instance simply by loading a new URL in the property when the previous FLV file finishes playing. For example, the contentPath following ActionScript code listens for the event, which occurs when an FLV file complete finishes playing.
  • Page 524 The following ActionScript code loads the property to play an FLV file in the contentPath default video player and adds a cue point for it. When the event occurs, the event ready handler opens a second video player by setting the property to the activeVideoPlayerIndex number 1.
  • Page 525 my_FLVPlybk.visibleVideoPlayerIndex = 0; // make the 1st player visible my_FLVPlybk.play(); // begin playing the 1st player // add listener for a cuePoint event my_FLVPlybk.addEventListener("cuePoint", listenerObject); listenerObject.complete = function(eventObject:Object):Void { trace("Hit complete event for player: " + eventObject.vp); if (eventObject.vp == 0) { my_FLVPlybk.activeVideoPlayerIndex = 1;...
  • Page 526: Streaming Flv Files From A Fcs

    For more information on administering the Flash Communication Server, including how to set up a live stream, see the FCS documentation at www.macromedia.com/support/ documentation/en/flashcom/. When playing a live stream with FCS, you need to set the FLVPlayback property . For more information, see...
  • Page 527 Selecting a predesigned skin You can select a skin for the FLVPlayback component by clicking the cell for the value skin parameter in the Component inspector. Then click the magnifying glass icon to open the following Select Skin dialog box, in which you can select a skin or provide a URL that specifies the location of the skin SWF file.
  • Page 528 To begin, simply drag the FLV Playback Custom UI components that you want from the Components panel, place them where you want them on the Stage, and give each one an instance name in the Property inspector. After your components are on the Stage, you edit them as you would any other symbol.
  • Page 529 Most of the buttons, as supplied, are based on a common set of movie clips so that you can change the appearance of all the buttons at once. You can use this capability, or you can replace those common clips and make every button look different. BufferingBar component The buffering bar component is simple: It consists of an animation that is made visible when the component enters the buffering state, and it does not require any special ActionScript to...
  • Page 530 You might notice that the handle movie clip has a rectangle in the background with alpha set to 0. This rectangle increases the size of the handle’s hit area, making it easier to grab without changing its appearance, similar to the hit state of a button. Because the handle is created dynamically at runtime, it must be a movie clip and not a button.
  • Page 531 Progress and fullness movie clips The SeekBar component has a progress movie clip and the VolumeBar has a fullness movie clip, but in practice, any SeekBar or VolumeBar can have either, neither, or both of these movie clips. They are structurally the same and behave similarly but track different values. A progress movie clip fills up as the FLV file downloads (which is useful for an HTTP download only, because it is always full if streaming from FCS) and a fullness movie clip fills up as the handle moves from left to right.
  • Page 532 The progress or fullness movie clip is scaled horizontally based on the percentage. At 0%, the instance’s is set to 0, making it invisible. As the percentage grows, the _xscale _xscale adjusted until, at 100%, the clip is the same size it was on the Stage when it was created. Again, this is not necessarily = 100 because the clip instance might have been scaled _xscale...
  • Page 533 In the Library panel, open the FLVPlayback Skins folder, and then open the SquareButton folder below it. Select the SquareBgDown movie clip, and double-click it to open it on the Stage. Right-click (Windows) or Control-click (Macintosh), select Select All from the menu, and delete the symbol.
  • Page 534 In the Actions panel on Frame 1 of the Timeline, add an import statement for the video classes, and assign the button and seek bar names to the corresponding FLVPlayback properties, as shown in the following example: import mx.video.*; my_FLVPlybk.stopButton = my_stopbttn; my_FLVPlybk.playPausebttn = my_plypausbttn;...
  • Page 535 Although layout_mc looks a lot like how the skin will look like at runtime, the contents of this clip are not visible at runtime. It is used only to calculate where to place the controls. The other controls on the Stage will be used at runtime. Within layout_mc is a placeholder for the FLVPlayback component named video_mc.
  • Page 536 The initial ActionScript code defines the minimum width and height for the skin. The Select Skin dialog box shows these values and they are used at runtime to prevent the skin from scaling below its minimum size. If you do not want to specify a minimum size, leave it as undefined or less than or equal to zero.
  • Page 537 Button states All the button states are laid out on the Stage, but where these movie clip instances are placed on the Stage is not important. It is important, however, that they are nested within movie clips in a specific way and that every clip instance has the correct instance name. The structure of the clip instances and their instance names are shown in the following example: playpause_mc...
  • Page 538 Buffering bar The buffering bar has two movie clips: bufferingBar_mc and bufferingBarFill_mc. Each clip’s position on the Stage relative to the other clip is important because this relative positioning is maintained. The buffering bar uses two separate clips because the component scales bufferingBar_mc but not bufferingBarFill_mc.
  • Page 539 The seekBarProgress_mc clip works without a fill_mc, much like the way a progress_mc clip works in FLV Playback Custom UI Components. In other words, it is not masked and is scaled horizontally. The exact dimensions of the bufferingBarProgress_mc at 100% is defined by left and right margins within the bufferingBar_mc clip.
  • Page 540 ActionScript The seek bar and volume bar support the following additional properties: Property Description The movie clip for the handle. Defaults to handle_mc:MovieClip seekBarHandle_mc or volumeBarHandle_mc The movie clip for progress. Defaults to progress_mc:MovieClip seekBarProgress_mc or volumeBarProgress_mc. The movie clip for fullness. Defaults to seekBarFullness or fullness_mc:MovieClip volumeBarFullness.
  • Page 541: Flvplayback Class

    FLVPlayback class Inheritance MovieClip > FLVPlayback class ActionScript Class Name mx.video.FLVPlayback FLVPlayback extends the MovieClip class and wraps a VideoPlayer object. For information on the VideoPlayer class, see “VideoPlayer class” on page 706. Unlike other components, the FLVPlayback component does not extend UIObject or UIComponent and, therefore, does not support the methods and properties of these classes.
  • Page 542 Method Description Finds the next cue point with the same name as a FLVPlayback.findNextCuePointWithName() cue point returned by the findCuePoint() methods. findNearestCuePoint() Gets the video player specified by the FLVPlayback.getVideoPlayer() index parameter. Returns if the FLV file embedded cue point FLVPlayback.isFLVCuePointEnabled() false is disabled by ActionScript.
  • Page 543 Property summary for the FLVPlayback class The FLVPlayback class has both class and instance properties. FLVPlayback Class properties The following properties occur only for the FLVPlayback class. They are read-only constants that apply to all instances of the FLVPlayback component in your application. Property Value Description...
  • Page 544 Instance properties The following table lists the instance properties of the FLVPlayback class This set of properties applies to each instance of an FLVPlayback component in the application. For example, if you drag two instances of the FLVPlayback component to the Stage, each instance has a set of these properties.
  • Page 545 Property Description A number that indicates the extent of FLVPlayback.bytesLoaded downloading in number of bytes for an HTTP download. Read only. A number that specifies the total number FLVPlayback.bytesTotal of bytes downloaded for an HTTP download. Read-only. A string that specifies the URL of an FLVPlayback.contentPath FLV file to load.
  • Page 546 Property Description An INCManager object that provides FLVPlayback.ncMgr access to an instance of the class implementing INCManager. Read-only. A MovieClip object that is the FLVPlayback.pauseButton PauseButton control. A Boolean value that is if the FLV FLVPlayback.paused true file is in a paused state. Read-only. A MovieClip object that is the FLVPlayback.playButton PlayButton control.
  • Page 547 Property Description A MovieClip object that is the SeekBar FLVPlayback.seekBar control. A number that specifies, in milliseconds, FLVPlayback.seekBarInterval how often to check the seekBar handle when scrubbing. The default value is 250. A number (percentage) that specifies FLVPlayback.seekBarScrubTolerance how far a user can move the scrubBar handle before an update occurs.
  • Page 548 Property Description A number that you can use to manage FLVPlayback.visibleVideoPlayerIndex multiple FLV file streams. Sets which video player instance is visible and audible. Default is 0. A number in the range of 0 to 100 that FLVPlayback.volume indicates the volume control setting. A MovieClip object that is the FLVPlayback.volumeBar VolumeBar control.
  • Page 549 Event Description Dispatched when the pause state is entered. FLVPlayback.paused Dispatched every .25 seconds by default while the FLV file FLVPlayback.playheadUpdate is playing. You can specify frequency with the property. playheadUpdateInterval Dispatched when the playing state is entered. FLVPlayback.playing Dispatched every .25 seconds, starting when the FLVPlayback.progress load() method is called and ending when all bytes are loaded or...
  • Page 550 FLVPlayback.ACTIONSCRIPT Availability Flash Player 8. Edition Flash Professional 8. Usage mx.video.FLVPlayback.ACTIONSCRIPT Description A read-only FLVPlayback class property that contains the string constant, "actionscript" for use as the property with the type findCuePoint() findNearestCuePoint() methods. Example The following example uses the constant to set the property of the ACTIONSCRIPT...
  • Page 551 See also FLVPlayback.findCuePoint() FLVPlayback.activeVideoPlayerIndex Availability Flash Player 8. Edition Flash Professional 8. Usage my_FLVPlybk.activeVideoPlayerIndex Description Property; a number that specifies which video player instance is affected by other APIs. Use this property to manage multiple FLV file streams. The default value is 0. This property does not make the video player visible;...
  • Page 552 APIs that control volume, positioning, dimensions, visibility, and UI controls are always global, and their behavior is not affected by setting . Specifically, activeVideoPlayerIndex setting the property does not affect the following properties activeVideoPlayerIndex and methods. Properties and Methods Not Affected by activeVideoPlayerIndex backButton playPauseButton skin...
  • Page 553 Drag an FLVPlayback component to the Stage, and give it an instance name of my_FLVPlybk. Then add the following code to the Actions panel on Frame 1 of the Timeline: Requires: - FLVPlayback component on the Stage with an instance name of my_FLVPlybk import mx.video.*;...
  • Page 554 FLVPlayback.addASCuePoint() Availability Flash Player 8. Edition Flash Professional 8. Usage my_FLVplybk.addASCuePoint(cuePoint:Object) my_FLVplybk.addASCuePoint(time:Number, name:String[, parameters:Object]) Parameters An object having (in seconds) properties, which cuePoint name String time Number describe the cue point. It also might have a property that holds name/ parameters Object value pairs.
  • Page 555 Example The following example adds two ActionScript cue points to an FLV file. The example adds the first one using a parameter and the second one using the CuePoint time name parameters. When each cue point occurs while playing, a listener for cuePoint events shows the value of the property in a text area.
  • Page 556 Usage: my_FLVPlybk.addEventListener(event:String, listener:Object):Void my_FLVPlybk.addEventListener(event:String, listener:Function):Void Parameters A string that specifies the name of the event for which you are registering a listener. If event the listener is an object, this is also the name of the listener object function to call. The name of the listener object or function that you are registering for the event.
  • Page 557 Usage 2: listener function Requires: - FLVPlayback component on the Stage with an instance name of my_FLVPlybk - TextArea component on the Stage with an instance name of my_ta import mx.video.*; my_ta.visible = false; my_FLVPlybk.contentPath = "http://www.helpexamples.com/flash/video/ water.flv"; function the_end(eventObject:Object):Void { my_ta.text = "That's All Folks!";...
  • Page 558 Drag an FLVPlayback component to the Stage, and give it an instance name of my_FLVPlybk. Then add the following code to the Actions panel on Frame 1 of the Timeline: Requires: - FLVPlayback component on the Stage with an instance name of my_FLVPlybk import mx.video.*;...
  • Page 559 Description Property; a Boolean value that, if set to , causes the FLV file to play immediately when true property is set. If set to , the component waits for the play command. contentPath false Even if is set to , the component loads the content immediately.
  • Page 560 Description Property; a Boolean value that, if , causes the FLV file to rewind to Frame 1 when play true stops, either because the player reached the end of the stream or the method was stop() called. This property is meaningless for live streams. The default value is true Example The following example sets the...
  • Page 561 Example The following example first show the source dimensions of the FLV file ( preferredWidth ) when the FLV file is ready to play. Then it calls the preferredHeight setSize() change the dimensions of the FLVPlayback instance, triggering a event. Next, it sets resize property to , triggering another...
  • Page 562 Usage my_FLVPlybk.backButton Description Property; a MovieClip object that is the BackButton playback control. For more information on using FLV Playback Custom UI components for playback controls, see “Skinning FLV Playback Custom UI components individually” on page 525. Clicking the BackButton control causes a event.
  • Page 563 FLVPlayback.bitrate Availability Flash Player 8. Edition Flash Professional 8. Usage my_FLVplybk bitrate Description Property; a number that specifies the bits per second at which to transfer the FLV file. When doing a progressive download, you can use the SMIL format, but you must set the bit rate because there is no automatic detection.
  • Page 564 Drag an FLVPlayback component to the Stage, and give it an instance name of my_FLVPlybk. Drag a RadioButton component and then a Label component to the Library panel. Then add the following code to the Actions panel on Frame 1 of the Timeline. In the statement that loads the property, replace the italicized text with the name and contentPath...
  • Page 565 FLVPlayback.bringVideoPlayerToFront() Availability Flash Player 8. Edition Flash Professional 8. Usage my_FLVPlybk.bringVideoPlayerToFront(index:Number) Parameters A number that is the index of the video player to move to the front index Description Method; brings a video player to the front of the stack of video players. Useful for custom transitions between video players.
  • Page 566 Drag an FLVPlayback component to the Stage, and give it an instance name of my_FLVPlybk Then add the following code to the Actions panel on Frame 1 of the Timeline: Requires: - FLVPlayback component on the Stage with an instance name of my_FLVPlybk my_FLVPlybk.load("http://www.helpexamples.com/flash/video/cuepoints.flv");...
  • Page 567 See also FLVPlayback.activeVideoPlayerIndex FLVPlayback.getVideoPlayer() VideoPlayer class FLVPlayback.visibleVideoPlayerIndex FLVPlayback.buffering Availability Flash Player 8. Edition Flash Professional 8. Usage var listenerObject:Object = new Object(); listenerObject.buffering = function(eventObject:Object):Void { // insert event-handling code here my_FLVplybk.addEventListener("buffering", listenerObject); Description Event; dispatched when the FLVPlayback instance enters the buffering state. The FLVPlayback instance typically enters this immediately after a call to the method or play()
  • Page 568 Drag an FLVPlayback component to the Stage, and give it an instance name of my_FLVPlybk. Then add the following code to the Actions panel on Frame 1 of the Timeline: Requires: - FLVPlayback component on the Stage with an instance name of my_FLVPlybk import mx.video.*;...
  • Page 569 Drag an FLVPlayback component to the Stage, and give it an instance name of my_FLVPlybk. Then add the following code to the Actions panel on Frame 1 of the Timeline: Requires: - FLVPlayback component on the Stage with an instance name of my_FLVPlybk import mx.video.*;...
  • Page 570 Drag an FLVPlayback component to the Stage, and give it an instance name of my_FLVPlybk. Then add the following code to the Actions panel on Frame 1 of the Timeline: Requires: - FLVPlayback component on the Stage with an instance name of my_FLVPlybk import mx.video.*;...
  • Page 571 Example The following example attaches individual FLV Playback Custom UI controls to an FLVPlayback component by setting the following properties: playPauseButton , and . The buffering bar appears stopButton backButton forwardButton bufferingBar only while the FLV file is buffering before it begins to play. Drag an FLVPlayback component to the Stage, give it an instance name of my_FLVPlybk, and set the parameter to None in the Component inspector.
  • Page 572 FLVPlayback.bufferingBarHidesAndDisablesOthers Availability Flash Player 8. Edition Flash Professional 8. Usage my_FLVPlybk.bufferingBarHidesAndDisablesOthers Description Property; if set to , hides the SeekBar control and disables the Play, Pause, PlayPause, true BackButton and ForwardButton controls while the FLV file is in the buffering state. This can be useful to prevent a user from using these controls to try to speed up playing the FLV file when it is downloading or streaming over a slow connection.
  • Page 573 FLVPlayback.bufferTime Availability Flash Player 8. Edition Flash Professional 8. Usage my_FLVPlybk.bufferTime Description Property; a number that specifies the number of seconds to buffer in memory before beginning to play a video stream. For FLV files streaming over RTMP, which are not downloaded and buffer only in memory, it can be important to increase this setting from the default value of 0.1.
  • Page 574 FLVPlayback.bytesLoaded Availability Flash Player 8. Edition Flash Professional 8. Usage my_FLVPlybk.bytesLoaded Description Property; a number that indicates the extent of downloading, in number of bytes, for an HTTP download. Returns –1 when there is no stream, when the stream is from a FCS, or if the information is not yet available.
  • Page 575 FLVPlayback.bytesTotal Availability Flash Player 8. Edition Flash Professional 8. Usage my_FLVPlybk.bytesTotal Description Property; a number that specifies the total number of bytes downloaded for an HTTP download. Returns -1 when there is no stream, when the stream is from a FCS, or if the information is not yet available.
  • Page 576 FLVPlayback.close Availability Flash Player 8. Edition Flash Professional 8. Usage var listenerObject:Object = new Object(); listenerObject.close = function(eventObject:Object):Void { // insert event-handling code here my_FLVplybk.addEventListener("close", listenerObject); Description Event; the FLVPlayback instance dispatches this event when it closes the NetConnection, by timing out or through a call to the method, or when you call the closeVideoPlayer()
  • Page 577 trace("Closed connection for video player: " + eventObject.vp); my_FLVPlybk.addEventListener("close", listenerObject); // listen for complete event; play new FLV listenerObject.complete = function(eventObject:Object) { if (my_FLVPlybk.contentPath != "http://www.helpexamples.com/flash/video/ water.flv") { my_FLVPlybk.play("http://www.helpexamples.com/flash/video/water.flv"); my_FLVPlybk.addEventListener("complete", listenerObject); my_FLVPlybk.contentPath = "rtmp://my_servername/my_application/stream.flv"; See also FLVPlayback.activeVideoPlayerIndex FLVPlayback.closeVideoPlayer() FLVPlayback.contentPath FLVPlayback.load() FLVPlayback.play() FLVPlayback.visibleVideoPlayerIndex FLVPlayback.closeVideoPlayer()
  • Page 578 Example The following example creates two video players to play two FLV files consecutively in a single FLVPlayback instance. When the second FLV file finishes, the event handler for the event calls the method to close the second player. If you complete closeVideoPlayer() click the Play button to play the FLV files a second time, you see that the video player for the...
  • Page 579 FLVPlayback.complete Availability Flash Player 8. Edition Flash Professional 8. Usage var listenerObject:Object = new Object(); listenerObject.complete = function(eventObject:Object):Void { // insert event-handling code here my_FLVplybk.addEventListener("complete", listenerObject); Description Event; dispatched when playing completes because the player reached the end of the FLV file. The component does not dispatch the event if you call the methods or stop()
  • Page 580 See also FLVPlayback.playheadTime FLVPlayback.state FLVPlayback.stateChange FLVPlayback.stopped FLVPlayback.totalTime FLVPlayback.CONNECTION_ERROR Availability Flash Player 8. Edition Flash Professional 8. Usage mx.video.FLVPlayback.CONNECTION_ERROR Description A read-only FLVPlayback class property that contains the string constant . You can compare this property to the property to determine if a "connectionError"...
  • Page 581 FLVPlayback.contentPath Availability Flash Player 8. Edition Flash Professional 8. Usage my_FLVPlybk.contentPath Description Property; a string that specifies the URL of the FLV file to stream and how to stream it. The URL can be an HTTP URL to an FLV file, an RTMP URL to a stream, or an HTTP URL to an XML file.
  • Page 582: See Also

    Drag an FLVPlayback component to the Stage, and give it an instance name of my_FLVPlybk. Do not assign a value to the parameter in the Component contentPath inspector. Add the following code to Frame 1 of the Timeline: Requires: - FLVPlayback component on the Stage with an instance name of my_FLVPlybk import mx.video.*;...
  • Page 583 Example The following example adds two ActionScript cue points to an FLV file. The example adds the first one using a parameter and the second one using the cuePoint time name parameters. When each cue point occurs, a listener for events shows the value of the cuePoint property in a text area.
  • Page 584 FLVPlayback.cuePoints Availability Flash Player 8. Edition Flash Professional 8. Usage my_FLVPlybk.cuePoints Description Property; an array that describes ActionScript cue points and disabled embedded FLV file cue points. This property is created specifically for use by the Component inspector and does not work if it is set any other way.
  • Page 585: A Read-Only Flvplayback Class Property That Contains The String Constant

    FLVPlayback.DISCONNECTED Availability Flash Player 8. Edition Flash Professional 8. Usage mx.video.FLVPlayback.DISCONNECTED Description A read-only FLVPlayback class property that contains the string constant "disconnected" You can compare this property to the property to determine if a disconnected state state exists. The FLVPlayback instance is in a disconnected state until you set the property.
  • Page 586 FLVPlayback.EVENT Availability Flash Player 8. Edition Flash Professional 8. Usage mx.video.FLVPlayback.EVENT Description A read-only FLVPlayback class property that contains the String constant, . You can "event" use this property as the parameter for the type findCuePoint() methods. findNearesstCuePoint() Example The following example uses the property to specify that it wants to find FLVPlayback.EVENT a cue point named...
  • Page 587 my_FLVPlybk.addEventListener("ready", listenerObject); var listenerObject:Object = new Object(); listenerObject.cuePoint = function(eventObject:Object):Void { if(eventObject.info.name == "myCue") trace("Hit it!"); my_FLVPlybk.addEventListener("cuePoint", listenerObject); See also FLVPlayback.findCuePoint() FLVPlayback.fastForward Availability Flash Player 8. Edition Flash Professional 8. Usage var listenerObject:Object = new Object(); listenerObject.fastForward = function(eventObject:Object):Void { // insert event-handling code here my_FLVplybk.addEventListener("fastForward", listenerObject);...
  • Page 588 Drag an FLVPlayback component to the Stage, and give it an instance name of my_FLVPlybk. Then add the following code to the Actions panel on Frame 1 of the Timeline: Requires: - FLVPlayback component on the Stage with an instance name of my_FLVPlybk import mx.video.*;...
  • Page 589: Videoerror Class

    Parameters A number that is the time, in seconds, of the cue point for which to search. The time method uses only the first three decimal places and rounds any additional decimal places that you provide. The method returns the cue point that matches this time. If multiple ActionScript cue points have the same time, the method returns only the name that is first in alphabetical order.
  • Page 590 The method includes disabled cue points in the search. Use the isFLVCuePointEnabled() method to determine if a cue point is disabled. Example The following example adds two ActionScript cue points to an FLV file, and then calls the method three times. The first call looks for a navigation cue point with a findCuePoint() time of 7.748.
  • Page 591 // trace array of cue points function tracer(cuepts:Array) { for (i in cuepts) { if (typeof cuepts[i] == "object") { //if object in object tracer(cuepts[i]); //trace object } else { // trace the name : value pair trace(i + " " + cuepts[i]); See also FLVPlayback.addASCuePoint() FLVPlayback.cuePoints...
  • Page 592 An object that is a cue point object containing properties for cuePoint time name which to search. If you provide a time and the property has no value or is , the name null search behaves as if the parameter is a number representing the time for which to search. If you provide a name and the property has no value, is , or is less than zero, the...
  • Page 593 Example The following example creates an ActionScript cue point for the FLV file at 4.07 seconds. When this cue point occurs, the event handler calls the cuePoint findNearestCuePoint() method to find a cue point of any type that is nearest to 5 seconds later. The Output panel shows the name, time, and type of the cue point that is returned.
  • Page 594 FLVPlayback.findNextCuePointWithName() Availability Flash Player 8. Edition Flash Professional 8. Usage my_FLVplybk.findNextCuePointWithName(my_cuePoint:Object) Parameters A cue point object that has been returned by either the my_cuePoint findCuePoint() method, the method, or a previous call to this method. findNearestCuePoint() Returns An object that is a copy of the found cue point object with the following additional properties: The array of cue points searched.
  • Page 595: The Timeline

    Drag an FLVPlayback component to the Stage, and give it an instance name of my_FLVPlybk. Then add the following code to the Actions panel on Frame 1 of the Timeline: Requires: - FLVPlayback component on the Stage with an instance name of my_FLVPlybk import mx.video.*;...
  • Page 596 FLVPlayback.FLV Availability Flash Player 8. Edition Flash Professional 8. Usage mx.video.FLVPlayback.FLV Description A read-only FLVPlayback class property that contains the string constant, . You can use "flv" this property as the parameter for the type findCuePoint() findNearestCuePoint() methods. Example The following example looks for a cue point named with a time of 7.748 among FLV point2 file cue points and displays the type and time found.
  • Page 597 See also FLVPlayback.findCuePoint() FLVPlayback.findNearestCuePoint() FLVPlayback.forwardButton Availability Flash Player 8. Edition Flash Professional 8. Usage my_FLVPlybk.forwardButton Description Property; a MovieClip object that is the Forward button control. For more information on using FLV Playback Custom UI components for playback controls, see “Skinning FLV Playback Custom UI components individually”...
  • Page 598 See also FLVPlayback.fastForward FLVPlayback.seek FLVPlayback.state FLVPlayback.stateChange FLVPlayback.getVideoPlayer() Availability Flash Player 8. Edition Flash Professional 8. Usage my_FLVplybk.getVideoPlayer(index:Number) Returns A VideoPlayer object. Description Method; gets the video player specified by . When possible, it is best to access index VideoPlayer methods and properties using FLVPlayback methods and properties. Each property is its index.
  • Page 599 //this fires after the first flv is ready my_FLVPlybk.activeVideoPlayerIndex = 1; my_FLVPlybk.load("http://www.helpexamples.com/flash/video/ plane_cuepoints.flv"); } else { //this fires after the second flv is ready eventObject.target.activeVideoPlayerIndex = 0; eventObject.target.play(); eventObject.target.activeVideoPlayerIndex = 1; eventObject.target.play(); var layerOnTop:MovieClip = eventObject.target.getVideoPlayer(1); layerOnTop._alpha = 50; layerOnTop._visible = true; my_FLVPlybk.addEventListener("ready", listenerObject);...
  • Page 600 Drag an FLVPlayback component to the Stage, and give it an instance name of my_FLVPlybk. Then add the following code to the Actions panel on Frame 1 of the Timeline: Requires: - FLVPlayback component on the Stage with an instance name of my_FLVPlybk import mx.video.*;...
  • Page 601 Example The following example assumes playing a streaming FLV file from a FCS or FVSS. The example sets the property to a low value of 10 milliseconds, which triggers a idleTimeout timeout and, consequently, a event on the RTMP connection. The listener for the close event shows the index number of the video player for which the event occurred.
  • Page 602 A cue point object with properties for the cue point. The method cuePoint time name does not check any other properties on the incoming cue point object. If time name undefined, the method uses only the property that is defined. Returns A Boolean value that is if the cue point or cue points are found and are disabled, and...
  • Page 603 my_FLVPlybk.addEventListener("ready", ready); var listenerObject:Object = new Object(); listenerObject.cuePoint = function(eventObject:Object) { trace("Elapsed time in seconds: " + my_FLVPlybk.playheadTime); trace("Cue point name is: " + eventObject.info.name); trace("Cue point type is: " + eventObject.info.type); if (my_FLVPlybk.isFLVCuePointEnabled("point2") == false) { my_FLVPlybk.setFLVCuePointEnabled(true, "point2"); my_FLVPlybk.addEventListener("cuePoint", listenerObject); my_FLVPlybk.contentPath = "http://www.helpexamples.com/flash/video/ cuepoints.flv";...
  • Page 604 Drag an FLVPlayback component to the Stage, and give it an instance name of my_FLVPlybk. Then add the following code to the Actions panel on Frame 1 of the Timeline. In the statement that loads the property, replace the italicized text contentPath with the name and location of an FLV file on your FCS.
  • Page 605 Drag an FLVPlayback component to the Stage, and give it an instance name of my_FLVPlybk. Then add the following code to the Actions panel on Frame 1 of the Timeline. In the statement that loads the property, replace the italicized text contentPath with the name and location of an FLV file on your FCS.
  • Page 606 Returns Nothing. Description Method; begins loading the FLV file and provides a shortcut for setting the autoPlay property to and setting the , and properties, if given. false contentPath totalTime isLive If the properties are undefined, they are not set. If the totalTime isLive contentPath...
  • Page 607 Description A read-only FLVPlayback class property that contains the string constant, . You "loading" can compare this property to the property to determine whether the component is in state the loading state. Example The following example displays the value of the property if the FLV FLVPlayback.LOADING file is in the loading state.
  • Page 608 Description Property; a Boolean value that, if , maintains the video aspect ratio. If this property is true changed from and the property is after an FLV file has been false true autoSize false loaded, an automatic resize of the video starts immediately. The default value is true Example The following example calls the...
  • Page 609 FLVPlayback.metadata Availability Flash Player 8. Edition Flash Professional 8. Usage my_FLVPlybk.metadata Description Property; an object that is a metadata information packet that is received from a call to the callback function, if available. Read only. NetSteam.onMetaData() If the FLV file is encoded with the Flash 8 encoder, the property contains the metadata following information.
  • Page 610 Parameter Description A number that is the frame rate of the FLV file. framerate A number that is the video data rate of the FLV file. videodatarate A number that is the height of the FLV file. height A number that is the width of the FLV file. width A number that specifies the duration of the FLV file in seconds.
  • Page 611 Edition Flash Professional 8. Usage my_FLVPlybk.metadataLoaded Description Property; a Boolean value that is if a metadata packet has been encountered and true processed or if the FLV file was encoded without the metadata packet. In other words, the value is if the metadata is received, or if you are never going to get any metadata.
  • Page 612 FLVPlayback.metadataReceived Availability Flash Player 8. Edition Flash Professional 8. Usage var listenerObject:Object = new Object(); listenerObject.metadataReceived = function(eventObject:Object):Void { // insert event-handling code here my_FLVplybk.addEventListener("metadataReceived", listenerObject); Description Event; dispatched the first time the FLV file metadata is reached. The event object has an property that contains the object received by the info...
  • Page 613 Drag an FLVPlayback component to the Stage, and give it an instance name of my_FLVPlybk. Then add the following code to the Actions panel on Frame 1 of the Timeline: Requires: - FLVPlayback component on the Stage with an instance name of my_FLVPlybk import mx.video.*;...
  • Page 614 Example The following example uses the backButton forwardButton playPauseButton , and properties to attach individual FLV Custom UI controls to an stopButton muteButton FLVPlayback component. Drag an FLVPlayback component to the Stage, and give it an instance name of my_FLVPlybk and set the parameter to None in the Component inspector.
  • Page 615 Description A read-only FLVPlayback class property that contains the string constant, "navigation" You can use this property for the parameter of the type findCuePoint() methods. findNearestCuePoint() Example The following example uses the property to specify the type of FLVPlayback.NAVIGATION cue point to find. Drag an FLVPlayback component to the Stage, and give it an instance name of my_FLVPlybk.
  • Page 616 Description Property; an INCManager object that provides access to an instance of the class implementing , which is an interface to the class. INCManager NCManager You can use this property to implement a custom INCManager that requires custom initialization. Read-only. Example The following example shows the value of the NetConnection property...
  • Page 617 Parameters None. Returns Nothing. Description Method; pauses playing the video stream. Example The following example creates a listener for the event. When it occurs, the playheadUpdate event handler checks to see whether the playhead time is between 5 and 5.05 seconds. If it is, the event handler calls the method to suspend playing the FLV file.
  • Page 618 FLVPlayback.pauseButton Availability Flash Player 8. Edition Flash Professional 8. Usage my_FLVPlybk.pauseButton Description Property; a MovieClip that is the PauseButton control. For more information on using the FLV Playback Custom UI components for playback control, see “Skinning FLV Playback Custom UI components individually” on page 525.
  • Page 619 FLVPlayback.PAUSED Availability Flash Player 8. Edition Flash Professional 8. Usage mx.video.FLVPlayback.PAUSED Description A read-only FLVPlayback class property that contains the string constant, . You can "paused" compare this property to the property to see if the component is in the paused state. state Example The following example uses the...
  • Page 620 FLVPlayback.paused Availability Flash Player 8. Edition Flash Professional 8. Usage var listenerObject:Object = new Object(); listenerObject.paused = function(eventObject:Object):Void { // insert event-handling code here my_FLVplybk.addEventListener("paused", listenerObject); Description Event; dispatched when the player enters the paused state. This happens when you call the method or click the corresponding control and it also happens in some cases when pause() the FLV file is loaded if...
  • Page 621 Drag an FLVPlayback component to the Stage, and give it an instance name of my_FLVPlybk. Then add the following code to the Actions panel on Frame 1 of the Timeline: Requires: - FLVPlayback component on the Stage with an instance name of my_FLVPlybk import mx.video.*;...
  • Page 622 Example The following example creates a listener for the event. When the event occurs, stateChange it checks the property to determine whether the component is in the paused state. If paused so, it shows a message to that effect in the Output panel. You must click the Pause button while the FLV file is playing to cause the paused state to occur.
  • Page 623 A number that is the total playing time for the video. Optional. totalTime A Boolean value that is if the video stream is live. This value is effective only isLive true when streaming from a FCS or FVSS. The value of this property is ignored for an HTTP download.
  • Page 624 FLVPlayback.playButton Availability Flash Player 8. Edition Flash Professional 8. Usage my_FLVPlybk.playButton Description Property; a MovieClip object that is the Play button. For more information on using FLV Playback Custom UI components for playback controls, see “Skinning FLV Playback Custom UI components individually” on page 525.
  • Page 625 FLVPlayback.playheadPercentage Availability Flash Player 8. Edition Flash Professional 8. Usage my_FLVPlybk.playheadPercentage Description Property; a number that specifies the current as a percentage of the playheadTime totalTime property. If you access this property, it contains the percentage of playing time that has elapsed.
  • Page 626 Drag an FLVPlayback component to the Stage, and give it an instance name of my_FLVPlybk. Then add the following code to the Actions panel on Frame 1 of the Timeline: Requires: - FLVPlayback component on the Stage with an instance name of my_FLVPlybk import mx.video.*;...
  • Page 627 For several reasons, the property might not have the expected value playheadTime immediately after calling one of the seek methods or setting to cause seeking. playheadTime First, for a progressive download, you can seek only to a keyframe, so a seek takes you to the time of the first keyframe after the specified time.
  • Page 628 Usage var listenerObject:Object = new Object(); listenerObject.playheadUpdate = function(eventObject:Object):Void { // insert event-handling code here my_FLVplybk.addEventListener("playheadUpdate", listenerObject); Description Event; dispatched while the FLV file is playing at the frequency specified by the property. The default is .25 seconds. The component does not playheadUpdateInterval dispatch this event when the video player is paused or stopped unless a seek occurs.
  • Page 629 Usage my_FLVPlybk.playheadUpdateInterval Description Property; a number that is the amount of time, in milliseconds, between each event. Setting this property while the FLV file is playing restarts the timer. playheadUpdate The default is 250. Because ActionScript cue points start on playhead updates, lowering the value of the property can increase the accuracy of ActionScript cue points.
  • Page 630 FLVPlayback.PLAYING Availability Flash Player 8. Edition Flash Professional 8. Usage mx.video.FLVPlayback.PLAYING Description A read-only FLVPlayback class property that contains the string constant, . You "playing" can compare this property to the property to determine if the component is in the state playing state.
  • Page 631 FLVPlayback.playing Availability Flash Player 8. Edition Flash Professional 8. Usage var :Object = new Object(); listenerObject.playing = function(eventObject:Object):Void { // insert event-handling code here my_FLVplybk.addEventListener("playing", listenerObject); Description Event; dispatched when the playing state is entered. This may not occur immediately after the method is called or the corresponding control is clicked;...
  • Page 632 See also FLVPlayback.play() FLVPlayback.playing FLVPlayback.state FLVPlayback.stateChange FLVPlayback.playing Availability Flash Player 8. Edition Flash Professional 8. Usage my_FLVPlybk.playing Description Property; a Boolean value that is if the FLV file is in the playing state. Read-only. true Example The following example listens for occurrences of the event as it occurs while the stateChange FLV file plays.
  • Page 633 FLVPlayback.playPauseButton Availability Flash Player 8. Edition Flash Professional 8. Usage my_FLVPlybk.playPauseButton Description Property; a MovieClip object that is the PlayPauseButton. For more information on using FLV Playback Custom UI components for playback controls, see “Skinning FLV Playback Custom UI components individually” on page 525.
  • Page 634 FLVPlayback.preferredHeight Availability Flash Player 8. Edition Flash Professional 8. Usage my_FLVPlybk.preferredHeight Description Property; a number that specifies the height of the source FLV file. This information is not valid immediately upon calling the methods. It is valid when the play() load() ready event starts.
  • Page 635 my_FLVPlybk.addEventListener("ready", listenerObject); listenerObject.cuePoint = function(eventObject:Object):Void { my_FLVPlybk.setSize(my_FLVPlybk.preferredWidth, my_FLVPlybk.preferredHeight); my_FLVPlybk.addEventListener("cuePoint", listenerObject); my_FLVPlybk.contentPath = "http://www.helpexamples.com/flash/video/ water.flv"; my_FLVPlybk.addASCuePoint(1.5, "AScp1"); See also FLVPlayback.autoSize FLVPlayback.height FLVPlayback.maintainAspectRatio FLVPlayback.preferredWidth FLVPlayback.ready FLVPlayback.setSize() FLVPlayback.setScale() FLVPlayback.width FLVPlayback.preferredWidth Availability Flash Player 8. Edition Flash Professional 8. Usage my_FLVPlybk.preferredWidth Description Property; gives the width of the source FLV file. This information is not valid immediately when the methods are called;...
  • Page 636 Drag an FLVPlayback component to the Stage, and give it an instance name of my_FLVPlybk. Then add the following code to the Actions panel on Frame 1 of the Timeline: Requires: - FLVPlayback component on the Stage with an instance name of my_FLVPlybk import mx.video.*;...
  • Page 637 Usage var listenerObject:Object = new Object(); listenerObject.progress = function(eventObject:Object):Void { // insert event-handling code here my_FLVplybk.addEventListener("progress", listenerObject); Description Event; dispatched at the frequency specified by the property, starting progressInterval when the load begins and ending when all bytes are loaded or there is a network error. Default is every .25 seconds.
  • Page 638 FLVPlayback.progressInterval Availability Flash Player 8. Edition Flash Professional 8. Usage my_FLVPlybk.progressInterval Description Property; a number that is the amount of time, in milliseconds, between each progress event. If you set this property while the video stream is playing, the timer restarts. Default value is 250.
  • Page 639 FLVPlayback.ready Availability Flash Player 8. Edition Flash Professional 8. Usage var listenerObject:Object = new Object(); listenerObject.ready = function(eventObject:Object):Void { // insert event-handling code here my_FLVplybk.addEventListener("ready", listenerObject); Description Event; dispatched when FLV file is loaded and ready to display. It starts the first time you enter a responsive state after you load a new FLV file with the method.
  • Page 640 See also FLVPlayback.activeVideoPlayerIndex FLVPlayback.addEventListener() FLVPlayback.state FLVPlayback.visibleVideoPlayerIndex FLVPlayback.removeASCuePoint() Availability Flash Player 8. Edition Flash Professional 8. Usage my_FLVplybk.removeASCuePoint(CuePoint:Object):Object my_FLVplybk.removeASCuePoint(time:Number):Object my_FLVplybk.removeASCuePoint(name:String):Object Parameters A cue point object containing the properties for the cue point to CuePoint time name remove. The method does not check any other properties on the incoming cue point object. If or undefined, the method uses only the available property.
  • Page 641 Example The following example adds an ActionScript cue point to the FLV file, and then calls the method to remove it. It shows the name of the removed cue point in removeASCuePoint() the Output panel. Drag an FLVPlayback component to the Stage, and give it an instance name of my_FLVPlybk.
  • Page 642 Returns Nothing. Description Method; removes an event listener from a component instance. Example The following example removes the listener for a event when the first cue point cuePoint occurs. This causes only the first of three cue points to be detected. Drag an FLVPlayback component to the Stage, and give it an instance name of my_FLVPlybk.
  • Page 643 FLVPlayback.resize Availability Flash Player 8. Edition Flash Professional 8. Usage var listenerObject:Object = new Object(); listenerObject.resize = function(eventObject:Object):Void { // insert event-handling code here my_FLVplybk.addEventListener("resize", listenerObject); Description Event; dispatched when video is resized. This occurs when you set the property and switch to a video player with different dimensions. visibleVideoPlayerIndex The event object has the properties , which is the index...
  • Page 644 Drag an FLVPlayback component to the Stage, and give it an instance name of my_FLVPlybk. Then add the following code to the Actions panel on Frame 1 of the Timeline: Requires: - FLVPlayback component on the Stage with an instance name of my_FLVPlybk import mx.video.*;...
  • Page 645 FLVPlayback.rewind Availability Flash Player 8. Edition Flash Professional 8. Usage var listenerObject:Object = new Object(); listenerObject.rewind = function(eventObject:Object):Void { // insert event-handling code here my_FLVplybk.addEventListener("rewind", listenerObject); Description Event; dispatched when the location of the playhead moves backward by a call to seek() when an automatic rewind completes.
  • Page 646 Drag an FLVPlayback component to the Stage, and give it an instance name of my_FLVPlybk. Then add the following code to the Actions panel on Frame 1 of the Timeline: Requires: - FLVPlayback component on the Stage with an instance name of my_FLVPlybk import mx.video.*;...
  • Page 647 Example The following example creates a listener for the event and uses the stateChange property to determine whether the component is in the FLVPlayback.REWINDING rewinding state. Drag an FLVPlayback component to the Stage, and give it an instance name of my_FLVPlybk.
  • Page 648 Drag an FLVPlayback component to the Stage, and give it an instance name of my_FLVPlybk. Then add the following code to the Actions panel on Frame 1 of the Timeline: Requires: - FLVPlayback component on the Stage with an instance name of my_FLVPlybk import mx.video.*;...
  • Page 649 Drag an FLVPlayback component to the Stage, and give it an instance name of my_FLVPlybk. Then add the following code to the Actions panel on Frame 1 of the Timeline: Requires: - FLVPlayback component on the Stage with an instance name of my_FLVPlybk import mx.video.*;...
  • Page 650 Requires: - FLVPlayback component on the Stage with an instance name of my_FLVPlybk import mx.video.*; my_FLVPlybk.contentPath = "http://www.helpexamples.com/flash/video/ water.flv"; var listenerObject:Object = new Object(); listenerObject.seek = function(eventObject:Object):Void { if(my_FLVPlybk.scrubbing) trace("User is scrubbing at: " + eventObject.playheadTime); my_FLVPlybk.addEventListener("seek", listenerObject); See also FLVPlayback.seek FLVPlayback.seekBar FLVPlayback.scrubFinish...
  • Page 651 Example The following example listens for the event and shows the time at which scrubFinish scrubbing stops. Drag an FLVPlayback component to the Stage, and give it an instance name of my_FLVPlybk. Then add the following code to the Actions panel on Frame 1 of the Timeline: You must grab the handle of the SeekBar, drag it, and release it to cause the event.
  • Page 652 Description Event; dispatched when then user begins scrubbing the FLV file with the SeekBar. Scrubbing refers to grabbing the handle of the SeekBar and dragging it in either direction to locate a particular scene in the FLV file. Scrubbing begins when the user clicks on the SeekBar handle and ends when the user releases it.
  • Page 653 FLVPlayback.seek Availability Flash Player 8. Edition Flash Professional 8. Usage var listenerObject:Object = new Object(); listenerObject.seek = function(eventObject:Object):Void { // insert event-handling code here my_FLVplybk.addEventListener("seek", listenerObject); Description Event; dispatched when the location of playhead is changed by a call to , by setting the seek() property or by using the seekBar control.
  • Page 654 Drag an FLVPlayback component to the Stage, and give it an instance name of my_FLVPlybk. Then add the following code to the Actions panel on Frame 1 of the Timeline: Requires: - FLVPlayback component on the Stage with an instance name of my_FLVPlybk import mx.video.*;...
  • Page 655 Description Method; seeks to a given time in the file, specified in seconds, with a precision of three decimal places (milliseconds). For several reasons, the property might not have the expected value playheadTime immediately after calling one of the seek methods or setting to cause seeking.
  • Page 656 FLVPlayback.seekBar Availability Flash Player 8. Edition Flash Professional 8. Usage my_FLVPlybk.seekBar Description Property; a MovieClip object that is the seek bar control at playtime. For more information on using FLV Playback Custom UI components for playback controls, see “Skinning FLV Playback Custom UI components individually”...
  • Page 657 See also FLVPlayback.scrubbing FLVPlayback.scrubFinish FLVPlayback.scrubStart FLVPlayback.seek FLVPlayback.seekBarInterval Availability Flash Player 8. Edition Flash Professional 8. Usage my_FLVPlybk.seekBarInterval Description Property; a number that specifies, in milliseconds, how often to check the seek bar handle when scrubbing. The default value is 250. Because this interval is set by a call to the global function, the update cannot setInterval()
  • Page 658 See also FLVPlayback.seekBar FLVPlayback.seekBarScrubTolerance FLVPlayback.seekBarScrubTolerance Availability Flash Player 8. Edition Flash Professional 8. Usage my_FLVPlybk.seekBarScrubTolerance Description Property; a number that specifies how far a user can move the SeekBar handle before an update occurs. The value is specified as a percentage, ranging from 1 to 100. The default value is 5.
  • Page 659 See also FLVPlayback.scrubbing FLVPlayback.scrubFinish FLVPlayback.scrubStart FLVPlayback.seekBar FLVPlayback.seekBarInterval FLVPlayback.SEEKING Availability Flash Player 8. Edition Flash Professional 8. Usage mx.video.FLVPlayback.SEEKING Description A read-only FLVPlayback class property that contains the string constant, " ". You can seeking compare this property to the property to determine whether the component is in the state seeking state.
  • Page 660 FLVPlayback.seekPercent() Availability Flash Player 8. Edition Flash Professional 8. Usage my_FLVplybk.seekPercent(percent:Number) Parameters A number that specifies a percentage of the length of the FLV file at which to place percent the playhead. Returns Nothing. Description Method; seeks to a percentage of the file and places the playhead there. The percentage is a number between 0 and 100.
  • Page 661 Drag an FLVPlayback component to the Stage, and give it an instance name of my_FLVPlybk. Then add the following code to the Actions panel on Frame 1 of the Timeline: Requires: - FLVPlayback component on the Stage with an instance name of my_FLVPlybk import mx.video.*;...
  • Page 662 For several reasons, the property might not have the expected value playheadTime immediately after calling one of the seek methods or setting to cause seeking. playheadTime First, for a progressive download, you can seek only to a keyframe, so a seek takes you to the time of the first keyframe after the specified time.
  • Page 663 Usage my_FLVplybk.seekToNavCuePoint(time:Number):Void my_FLVplybk.seekToNavCuePoint(name:String):Void my_FLVplybk.seekToNavCuePoint(cuePoint:Object):Void Parameters A number that is the time of the navigation cue point to seek. The method uses only time the first three decimal places and rounds any additional decimal places. A string that is the name of the cue point to seek. name A cue point object in which you set the properties to specify the...
  • Page 664 Drag an FLVPlayback component to the Stage, and give it an instance name of my_FLVPlybk. Then add the following code to the Actions panel on Frame 1 of the Timeline: Requires: - FLVPlayback component on the Stage with an instance name of my_FLVPlybk import mx.video.*;...
  • Page 665 Description Method; seeks to next navigation cue point, based on the current value of the playheadTime property. The method skips navigation cue points that have been disabled and goes to the end of the FLV file if there is no other cue point. For several reasons, the property might not have the expected value playheadTime...
  • Page 666 FLVPlayback.seekToPrevNavCuePoint() Availability Flash Player 8. Edition Flash Professional 8. Usage my_FLVplybk.seekToPrevCueNavPoint([time:Number]) Parameters A number that is the starting time in seconds from which to look for the previous time navigation cue point. The default is the current value of the property playheadTime Optional.
  • Page 667 Drag an FLVPlayback component to the Stage, and give it an instance name of my_FLVPlybk. Then add the following code to the Actions panel on Frame 1 of the Timeline: Requires: - FLVPlayback component on the Stage with an instance name of my_FLVPlybk import mx.video.*;...
  • Page 668 Example The following example initially sets the property to 10, causing the first seekToPrevOffset call to the method to hit cue point point1. When the initial seekToPrevNavCuePoint() event for point3 occurs, however, the example lowers the cuePoint seekToPrevOffset property to 1 second, causing subsequent calls to the method to seekToPrevNavCuePoint() reach cue point point2.
  • Page 669 Usage my_FLVplybk.setFLVCuePointEnabled(enabled:Boolean, time:Number) my_FLVplybk.setFLVCuePointEnabled(enabled:Boolean, name:String) my_FLVplybk.setFLVCuePointEnabled(enabled:Boolean, cuePoint:Object) Parameters A Boolean value that specifies whether to enable ( ) or disable ( ) an FLV enabled true false file cue point. A number that is the time, in seconds, of the cue point to set. time The name of the cue point to set.
  • Page 670 Drag an FLVPlayback component to the Stage, and give it an instance name of my_FLVPlybk. Then add the following code to the Actions panel on Frame 1 of the Timeline: Requires: - FLVPlayback component on the Stage with an instance name of my_FLVPlybk import mx.video.*;...
  • Page 671 Description Method; sets the properties simultaneously. Because setting either one, scaleX scaleY individually, can cause automatic resizing, setting them simultaneously can be more efficient than setting the properties, individually. scaleX scaleY , this method has no effect because the player sets its own dimensions. If autoSize true property is...
  • Page 672 Parameters A number that specifies the width of the video player. A number that specifies the height of the video player. Returns Nothing. Description Method; sets the width and height simultaneously. Because setting either one, individually, can cause automatic resizing, setting them simultaneously can be more efficient than setting properties individually.
  • Page 673 FLVPlayback.skin Availability Flash Player 8. Edition Flash Professional 8. Usage my_FLVPlybk.skin Description Property; a string that specifies the URL to a skin SWF file. This string could contain a file name, a relative path such as Skins/my_Skin.swf, or an absolute URL such as http:// www.myskins.org/MySkin.swf.
  • Page 674 FLVPlayback.skinAutoHide Availability Flash Player 8. Edition Flash Professional 8. Usage my_FLVplybk skinAutoHide Description Property; a Boolean value that, if , hides the component skin when the mouse is not over true the video. This property affects only skins that are loaded by setting the property and skin not a skin that you create from the FLV Playback Custom UI components.
  • Page 675 FLVPlayback.skinError Availability Flash Player 8. Edition Flash Professional 8. Usage var listenerObject:Object = new Object(); listenerObject.skinError = function(eventObject:Object):Void { // insert event-handling code here my_FLVplybk.addEventListener("skinError", listenerObject); Description Event; dispatched when an error occurs loading a skin SWF file. The event has a message property that contains the error message.
  • Page 676 FLVPlayback.skinLoaded Availability Flash Player 8. Edition Flash Professional 8. Usage var listenerObject:Object = new Object(); listenerObject.skinLoaded = function(eventObject:Object):Void { // insert event-handling code here my_FLVplybk.addEventListener("skinLoaded", listenerObject); Description Event; dispatched when a skin SWF file is loaded. The component does not begin playing an FLV file until the ) events have both started.
  • Page 677 FLVPlayback.state Availability Flash Player 8. Edition Flash Professional 8. Usage my_FLVPlybk.state Description Property; a string that specifies the state of the component. This property is set by the load() , and methods. Read-only. play() stop() pause() seek() The possible values for the property are: state "buffering"...
  • Page 678 FLVPlayback.stateChange Availability Flash Player 8. Edition Flash Professional 8. Usage var listenerObject:Object = new Object(); listenerObject.stateChange = function(eventObject:Object):Void { // insert event-handling code here my_FLVplybk.addEventListener("stateChange", listenerObject); Description Event; dispatched when playback state changes. The event object has properties state playheadTime This event can be used to track when playback enters or leaves unresponsive states (such as in the middle of connecting, resizing, or rewinding) during which times the play()
  • Page 679 Drag an FLVPlayback component to the Stage, and give it an instance name of my_FLVPlybk. Then add the following code to the Actions panel on Frame 1 of the Timeline: Requires: - FLVPlayback component on the Stage with an instance name of my_FLVPlybk import mx.video.*;...
  • Page 680 Drag an FLVPlayback component to the Stage, and give it an instance name of my_FLVPlybk. Then add the following code to the Actions panel on Frame 1 of the Timeline: Requires: - FLVPlayback component on the Stage with an instance name of my_FLVPlybk import mx.video.*;...
  • Page 681 Example The following example listens for the event, and when the elapsed playheadUpdate is greater than or equal to 5 seconds, the listener calls the method to playheadTime stop() stop playing the FLV file. A second listener listens for the event and displays the stopped values of the...
  • Page 682 Description Property; a MovieClip object that is the Stop button control. For more information on using FLV Playback Custom UI components for playback controls, see “Skinning FLV Playback Custom UI components individually” on page 525. Example The following example uses the backButton forwardButton playButton...
  • Page 683 FLVPlayback.STOPPED Availability Flash Player 8. Edition Flash Professional 8. Usage mx.video.FLVPlayback.STOPPED Description A read-only FLVPlayback class property that contains the string constant, . You "stopped" can compare this property to the property to determine whether the component is in state the stopped state.
  • Page 684 FLVPlayback.stopped Availability Flash Player 8. Edition Flash Professional 8. Usage var listenerObject:Object = new Object(); listenerObject.stopped = function(eventObject:Object):Void { // insert event-handling code here my_FLVplybk.addEventListener("stopped", listenerObject); Description Event; dispatched when entering the stopped state. This happens when you call the stop() method or click the control.
  • Page 685 Drag an FLVPlayback component to the Stage, and give it an instance name of my_FLVPlybk. Then add the following code to the Actions panel on Frame 1 of the Timeline: Requires: - FLVPlayback component on the Stage with an instance name of my_FLVPlybk import mx.video.*;...
  • Page 686 Drag an FLVPlayback component to the Stage, and give it an instance name of my_FLVPlybk. Then add the following code to the Actions panel on Frame 1 of the Timeline: Requires: - FLVPlayback component on the Stage with an instance name of my_FLVPlybk import mx.video.*;...
  • Page 687 When you set this property, the value takes effect for the next FLV file that is loaded by setting . It has no effect on an FLV file that has already loaded. Also, this property does contentPath not return the new value passed in until an FLV file is loaded. Playback still works if this property is never set (either explicitly or automatically), but it can cause problems with seek controls.
  • Page 688 Description Property; an object that provides direct access to the Sound.setTransform() methods to provide sound control. You must set this property to an Sound.getTransform() object to initialize it and for changes to take effect. Reading the property provides you with a copy of the current settings, which you can change.
  • Page 689 FLVPlayback.version Availability Flash Player 8. Edition Flash Professional 8. Usage mx.video.FLVPlayback.version Description A read-only FLVPlayback class property that contains the component’s version number. Example The following example shows the component’s version number in the Output panel. Then add the following code to the Actions panel on Frame 1 of the Timeline: import mx.video.*;...
  • Page 690 Drag an FLVPlayback component to the Stage, and give it an instance name of my_FLVPlybk. Then add the following code to the Actions panel on Frame 1 of the Timeline: Requires: - FLVPlayback component on the Stage with an instance name of my_FLVPlybk import mx.video.*;...
  • Page 691 FLVPlayback.visibleVideoPlayerIndex Availability Flash Player 8. Edition Flash Professional 8. Usage my_FLVPlybk.visibleVideoPlayerIndex Description Property; a number that you can use to manage multiple FLV file streams. Sets which video player instance is visible, audible, and controlled by the skin or playback controls, while the the rest of the video players are hidden and muted.
  • Page 692 Drag an FLVPlayback component to the Stage, and give it an instance name of my_FLVPlybk. Then add the following code to the Actions panel on Frame 1 of the Timeline: Requires: - FLVPlayback component on the Stage with an instance name of my_FLVPlybk import mx.video.*;...
  • Page 693 FLVPlayback.volume Availability Flash Player 8. Edition Flash Professional 8. Usage my_FLVPlybk.volume Description Property; a number in the range of 0 to 100 that indicates the volume control setting. The default value is 100. Example The following example sets the initial volume to 10, a relatively low setting. Drag an FLVPlayback component to the Stage, and give it an instance name of my_FLVPlybk.
  • Page 694 FLVPlayback.volumeBar Availability Flash Player 8. Edition Flash Professional 8. Usage my_FLVPlybk.volumeBarInterval Description Property; a MovieClip object that is the volume bar control. For more information on using FLV Playback Custom UI components for playback controls, see “Skinning FLV Playback Custom UI components individually” on page 525.
  • Page 695 See also FLVPlayback.volume FLVPlayback.volumeBarInterval FLVPlayback.volumeBarScrubTolerance FLVPlayback.volumeUpdate FLVPlayback.volumeBarInterval Availability Flash Player 8. Edition Flash Professional 8. Usage my_FLVPlybk.volumeBarInterval Description Property; a number that specifies, in milliseconds, how often to check the volume bar handle location when scrubbing. The default is 250. Example The following example sets the property to 1 second (1000...
  • Page 696 See also FLVPlayback.volume FLVPlayback.volumeBar FLVPlayback.volumeBarScrubTolerance FLVPlayback.volumeUpdate FLVPlayback.volumeBarScrubTolerance Availability Flash Player 8. Edition Flash Professional 8. Usage my_FLVPlybk.volumeBarScrubTolerance Description Property; a number that specifies how far a user can move the volume bar handle before an update occurs. The value is expressed as a percentage. The default value is 5. Example The following example sets the property to...
  • Page 697 FLVPlayback.volumeUpdate Availability Flash Player 8. Edition Flash Professional 8. Usage var listenerObject:Object = new Object(); listenerObject.volumeUpdate = function(eventObject:Object):Void { // insert event-handling code here my_FLVplybk.addEventListener("volumeUpdate", listenerObject); Description Event; dispatched when the volume changes either by the user moving the handle of the volumeBar control or by setting the property in ActionScript.
  • Page 698 FLVPlayback.width Availability Flash Player 8. Edition Flash Professional 8. Usage my_FLVPlybk.width Description Property; a number that specifies the width of the FLVPlayback instance on the Stage. This property affects only the width of the FLVPlayback instance and does not include the width of a skin SWF file that might be loaded.
  • Page 699 See also FLVPlayback.height, FLVPlayback.setSize(), FLVPlayback.preferredHeight, FLVPlayback.preferredWidth FLVPlayback.x Availability Flash Player 8. Edition Flash Professional 8. Usage my_FLVPlybk.x Description Property; a number that specifies the horizontal coordinate (location) of the video player. This property affects only the horizontal location of the FLVPlayback instance and does not include the location of a skin SWF file that, when applied, may alter the location.
  • Page 700 FLVPlayback.y Availability Flash Player 8. Edition Flash Professional 8. Usage my_FLVPlybk.y Description Property; a number that specifies the vertical coordinate (location) of the video player. This property affects only the vertical location of the FLVPlayback instance and does not include the location of a skin SWF file that, when applied, may alter the location.
  • Page 701 VideoError class Inheritance Error > VideoError ActionScript class name mx.video.VideoError The properties of the VideoError class allow you to diagnose error conditions that occur when working with the FLVPlayback component. The mx.video.VideoError class extends the Error class. Property summary for the VideoError class The following table lists the properties of the VideoError class: Property Description...
  • Page 702 VideoError.code Availability Flash Player 8. Edition Flash Professional 8. Usage mx.video.VideoError.code Description The numeric code that identifies the error condition. Example The following example displays the error condition in the Output panel: import mx.video.*; try { } catch (err:VideoError) { trace ("Error code is: "...
  • Page 703 Example The following code checks for the error code: DELETE_DEFAULT_PLAYER import mx.video.*; try { } catch (err:VideoError) { if (err.code == DELETE_DEFAULT_PLAYER) { See also FLVPlayback.activeVideoPlayerIndex VideoError.ILLEGAL_CUE_POINT Availability Flash Player 8. Edition Flash Professional 8. Usage mx.video.VideoError.ILLEGAL_CUE_POINT Description A value of 1002, indicating an invalid cue point was found. Example The following code checks for the error code:...
  • Page 704 VideoError.INVALID_CONTENT_PATH Availability Flash Player 8. Edition Flash Professional 8. Usage mx.video.VideoError.INVALID_CONTENT_PATH Description A value of 1004, indicating an invalid value was found. contentPath Example The following code checks for the error code: INVALID_CONTENT_PATH import mx.video.*; try { } catch (err:VideoError) { if (err.code == INVALID_CONTENT_PATH) { See also FLVPlayback.contentPath...
  • Page 705 Description A value of 1003, indicating an invalid seek was attempted. Example The following code checks for the error code: INVALID_SEEK import mx.video.*; try { } catch (err:VideoError) { if (err.code == INVALID_SEEK) { See also FLVPlayback.seek() VideoError.INVALID_XML Availability Flash Player 8. Edition Flash Professional 8.
  • Page 706 Example The following code checks for the error code: INVALID_XML import mx.video.*; try { } catch (err:VideoError) { if (err.code == INVALID_XML) { See also FLVPlayback.contentPath VideoError.NO_BITRATE_MATCH Availability Flash Player 8. Edition Flash Professional 8. Usage mx.video.VideoError.NO_BITRATE_MATCH Description A value of 1006, which indicates that there is no default FLV file listed that matches any bit rate.
  • Page 707 Example The following code checks for the error code: NO_BITRATE_MATCH import mx.video.*; try { } catch (err:VideoError) { if (err.code == NO_BITRATE_MATCH) { See also FLVPlayback.bitrate VideoError.NO_CONNECTION Availability Flash Player 8. Edition Flash Professional 8. Usage mx.video.VideoError.NO_CONNECTION Description A value of 1000, indicating the method cannot connect to the server or find the FLV file on the server.
  • Page 708: Videoplayer Class

    VideoError.NO_CUE_POINT_MATCH Availability Flash Player 8. Edition Flash Professional 8. Usage mx.video.VideoError.NO_CUE_POINT_MATCH Description A value of 1001, indicating that no matching cue point was found. Example The following code checks for the error code: NO_CUE_POINT_MATCH import mx.video.*; try { } catch (err:VideoError) { if (err.code == NO_CUE_POINT_MATCH) { See also FLVPlayback.findCuePoint()
  • Page 709 VideoPlayer extends the MovieClip class and wraps a Video object. The FLVPlayback class wraps the VideoPlayer class and Macromedia strongly encourages you to use the FLVPlayback class in almost all cases. There is no functionality in the VideoPlayer class that cannot be accessed using the FLVPlayback class.
  • Page 710 Method summary for the VideoPlayer class The following table lists the methods of the VideoPlayer class: Method Description Creates a listener for a specified event. VideoPlayer.addEventListener() VideoPlayer.close() Closes the video stream and FCS connection. Loads the FLV file but does not begin playing. VideoPlayer.load() After resizing (if needed) the FLV file is paused.
  • Page 711 Property Value Description Name of the default VideoPlayer.DEFAULT_INCMANAGER “mx.video.NCManager” (mx.video.NCManager) or custom implementation of the INCManager interface. Possible value for the VideoPlayer.DISCONNECTED "disconnected" state property. Indicates that the FLV file stream is disconnected. Possible value for the VideoPlayer.LOADING "loading" state property.
  • Page 712 Instance Properties The following table lists the instance properties of the VideoPlayer class. This set of properties applies to each instance of a VideoPlayer class. Property Description A Boolean value that, if , causes the FLV file to VideoPlayer.autoRewind true rewind to the first frame when play stops.
  • Page 713 Property Description A number that is the amount of time, in milliseconds, VideoPlayer.playheadUpdateInterval between each event. playheadUpdate A number that is the amount of time, in milliseconds, VideoPlayer.progressInterval between each progress event. A number that specifies the horizontal scale. VideoPlayer.scaleX A number that specifies the vertical scale.
  • Page 714: Using A Smil File

    Event summary for the VideoPlayer class The following table lists the events of the VideoPlayer class: Event Description Dispatched when the video stream is closed, whether VideoPlayer.close through timeout or a call to the method. close() Dispatched when playing completes by reaching the end of VideoPlayer.complete the FLV file.
  • Page 715 Using a SMIL file To handle multiple streams for multiple bandwidths, the VideoPlayer class uses a helper class (NCManager) that supports a subset of SMIL. SMIL is used identify the location of the video stream, the layout (width and height) of the FLV file, and the source FLV files that correspond to the different bandwidths.
  • Page 716 The following example shows a progressive download for a single FLV file that does not use bandwidth detection: <smil> <head> <layout> <root-layout width="240" height="180" /> </layout> </head> <body> <video src=""myvideo.flv" /> </body> </smil> <smil> Availability Flash Professional 8. Usage <smil> child tags </smil>...
  • Page 717 Example The following example shows a SMIL file specifying three FLV files: <smil> <head> <meta base="rtmp://myserver/mypgm/" > <layout> <root-layout width="240" height="180" > </layout> </head> <body> <switch> <video src="myvideo_mdm.flv" system-bitrate="56000" dur="3:00.1"> <video src="myvideo_isdn.flv" system-bitrate="128000" dur="3:00.1"> <ref src="myvideo_cable.flv" dur="3:00.1"/> </switch> </body> </smil> <head>...
  • Page 718 Description Supporting the tags, specifies the location and default layout (height <meta> <layout> and width) of the source FLV files. Example The following example sets the root layout to 240 pixels by 180 pixels: <head> <meta base="rtmp://myserver/mypgm/" > <layout> <root-layout width="240" height="180" > </layout>...
  • Page 719 <layout> Availability Flash Professional 8. Usage <layout> child tags </layout> Attributes None. Child tags <root-layout> Parent tag <meta> Description Specifies the width and height of the FLV file. Example The following example specified the layout of 240 pixels by 180 pixels: <layout>...
  • Page 720 Parent tag <layout> Description Specifies the width and height of the FLV file. Example The following example specified the layout of 240 pixels by 180 pixels: <root-layout width="240" height="180" > <body> Availability Flash Professional 8. Usage <body> child tags </body> Attributes None.
  • Page 721 Example The following example specified three FLV files, two using the tag, and one using the video tag: <body> <switch> <video src="myvideo_mdm.flv" system-bitrate="56000" dur="3:00.1"> <video src="myvideo_isdn.flv" system-bitrate="128000" dur="3:00.1"> <ref src="myvideo_cable.flv" dur="3:00.1"/> </switch> </body> <video> Availability Flash Professional 8. Usage <video...attributes.../> Attributes system-bitrate Child tags...
  • Page 722 <ref> Availability Flash Professional 8. Usage <ref...attributes.../> Attributes system-bitrate Child tags None Parent tag <body> Description Synonymous with tag. Supports the attributes, which specify the name <video> of the source FLV file and its duration. The attribute supports the full (00:03:00:01) and partial (03:00:01) time formats.
  • Page 723: Chapter 23: Focusmanager Class

    <switch> Availability Flash Professional 8. Usage <switch> child tags <switch/> Attributes None Child tags <video> <ref> Parent tag <body> Description Used with either the child tags to list the FLV files for multiple bandwidth <video> <ref> video streaming. The tag supports the attribute, which specifies <switch>...
  • Page 724: Using Focus Manager

    FLVPlayback Component (Flash Professional Only)
  • Page 725 CHAPTER 23 FocusManager class You can use the Focus Manager class 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 726 The Focus Manager handles focus changes caused by mouse clicks. If the user clicks a component, that component is given focus. When testing a script using Focus Manager (Control > Test Movie), select Control > Disable Keyboard Shortcuts in test mode; otherwise, Focus Manager does not appear to work.
  • Page 727: Customizing Focus Manager

    To create a button that receives focus when a user presses Enter (Windows) or Return (Macintosh), set the property to the instance name of FocusManager.defaultPushButton the desired button, as shown here: focusManager.defaultPushButton = okButton; 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 728 // Let Focus Manager know mc has children; // this overrides mc.focusEnabled=true; mc.tabChildren=true; mc.tabEnabled=false; // Set the tabbing sequence. txt1.tabIndex = 1; txt2.tabIndex = 2; mc.grid1.tabIndex = 3; mc.txt3.tabIndex = 4; // Set initial focus to txt1. txt1.text = "focus"; focusManager.setFocus(txt1);...
  • Page 729 Select Control > Test Movie. Select Control > Disable Keyboard Shortcuts. The code sets the tab ordering. Although the comment field doesn’t have an initial focus ring, it has initial focus, so you can start typing in the comment field without clicking in it.
  • Page 730 Method summary for the FocusManager class The following table lists the methods of the FocusManager class. Method Description Returns a reference to the object that has FocusManager.getFocus() focus. Sends a event to listener objects FocusManager.sendDefaultPushButtonEvent() click registered to the default push button. Sets focus to the specified object.
  • Page 731: Focusmanager.defaultpushbutton

    Methods inherited from the UIComponent class The following table lists the methods the FocusManager class inherits from the UIComponent class. Method Description Returns a reference to the object that has focus. UIComponent.getFocus() Sets focus to the component instance. UIComponent.setFocus() Property summary for the FocusManager class The following table lists the properties of the FocusManager class.
  • Page 732 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 ( UIObject.visible true or not ( false The width of the object, in pixels. Read-only. UIObject.width The left edge of the object, in pixels.
  • Page 733 Events inherited from the UIComponent class The following table lists the events the FocusManager 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 734: Focusmanager.defaultpushbuttonenabled

    See also FocusManager.defaultPushButtonEnabled FocusManager.sendDefaultPushButtonEvent() FocusManager.defaultPushButtonEnabled Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage focusManager.defaultPushButtonEnabled Description Property; a Boolean value that determines if keyboard handling of the default push button is turned on ( ) or not ( ). Setting allows a true false...
  • Page 735 Description Property; a Boolean value that determines if tab handling is turned on ( ) or not ( true false for a particular group of focus objects. (For example, another pop-up window could have its own Focus Manager.) Setting allows a component to receive the tab enabled false handling keys and handle them internally.
  • Page 736: Focusmanager.senddefaultpushbuttonevent()

    See also FocusManager.setFocus() FocusManager.nextTabIndex Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage FocusManager.nextTabIndex Description Property; the next available tab index number. Use this property to dynamically set an object’s property. tabIndex Example The following code gives the instance the next highest value: mycheckbox tabIndex...
  • Page 737 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 click and password fields when a user selects the CheckBox instance (the check box would be...
  • Page 738: Focusmanager.setfocus()

    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 739: Using The Form Class (Flash Professional Only)

    CHAPTER 24 Form class (Flash Professional only) The Form class provides the runtime behavior of forms that you create in the Screen Outline pane in Flash. For an overview of working with screens, see “Working with Screens (Flash Professional Only)” in Using Flash. Using the Form class (Flash Professional only) Forms function as containers for graphic objects—user interface elements in an application,...
  • Page 740: Form Class (Flash Professional Only)

    This illustration shows the outline for a sample application called Employee Directory, which consists of several forms. The form named entryForm (selected in the above illustration) contains several user interface objects, including input text fields, labels, and a push button. The developer can easily present this form to the user by toggling its visibility (using the property), while simultaneously toggling the visibility of other forms, as well.
  • Page 741 Method summary for the Form class The following table lists methods of the Form class. Method Description Returns the child form at a specified index. Form.getChildForm() Methods inherited from the UIObject class The following table lists the methods the Form class inherits from the UIObject class. When calling these methods from the Form object, use the syntax formInstance.methodName Method...
  • Page 742 Methods inherited from the Loader class The following table lists the methods the Form class inherits from the Loader class. When calling these methods from the Form object, use the syntax formInstance.methodName Method Description Loads the content specified by the property.
  • Page 743 Properties inherited from the UIObject class The following table lists the properties the Form class inherits from the UIObject class. When accessing these properties from the Form object, use the syntax formInstance.propertyName Property Description The position of the bottom edge of the object, relative to the UIObject.bottom bottom edge of its parent.
  • Page 744 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 745 Event summary for the Form class There are no events exclusive to the Form class. 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 UIObject.hide...
  • Page 746: Form.currentfocusedform

    Events inherited from the Screen class The following table lists the events the Form class inherits from 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.
  • Page 747: Form.getchildform()

    Description Property (read-only); returns the Form object that contains the global current focus. The actual focus may be on the form itself, or on a movie clip, text object, or component inside that form. May be if there is no current focus. null Example The following code, attached to a button (not shown), displays the name of the form with the...
  • Page 748: Form.indexinparentform

    Form.indexInParentForm Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage myForm.indexInParentForm Description Property (read-only); contains the zero-based index of in its parent’s list of child myForm forms. If the parent object of is a screen but not a form (for example, if it is a slide), myForm is always 0.
  • Page 749: Form.parentisform

    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 ; it contains only forms. myForm When using a custom ActionScript 2.0 class that extends mx.screens.Form, the form isn't counted in the property.
  • Page 750: Form.rootform

    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 myForm screen created when you select Flash Form Application from the New Document form1...
  • Page 751: Form.visible

    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 752 Form class (Flash Professional only)
  • Page 753: Chapter 25: Iterator Interface (Flash Professional Only)

    CHAPTER 25 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 754: Iterator.next()

    Example The following example uses the method to control looping through the iterator of hasNext() items in a collection: on (click) { var myColl:mx.utils.Collection; myColl = _parent.thisShelf.MyCompactDisks; var itr:mx.utils.Iterator = myColl.getIterator(); while (itr.hasNext()) { var cd:CompactDisk = CompactDisk(itr.next()); var title:String = cd.Title; var artist:String = cd.Artist;...
  • Page 755: Chapter 26: Label Component

    “Name:” label to the left of a 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 756 Label parameters You can set the following authoring parameters for each Label component instance in the Property inspector or in the Component inspector (Window > Component Inspector menu option): autoSize indicates how the label is sized and aligned to fit the text. The default value is none The parameter can have any of the following four values: , which specifies that the label is not resized or aligned to fit the text.
  • Page 757: Customizing The Label Component

    Creating an application with the Label component The following procedure explains how to add a Label component to an application while authoring. In this example, the label is beside a combo box with dates in a shopping cart application. To create an application with the Label component: Drag a Label component from the Components panel to the Stage.
  • Page 758 A Label component supports the following styles: Style Theme Description Both The text color. The default value is 0x0B333C for the color Halo theme and blank for the Sample theme. Both The color for text when the component is disabled. The disabledColor default color is 0x848384 (dark gray).
  • Page 759: Label Class

    Label class Inheritance MovieClip > UIObject class > Label ActionScript Class Name mx.controls.Label The properties of the Label class allow you at runtime to specify text for the label, indicate whether the text can be formatted with HTML, and indicate whether the label auto-sizes to fit the text.
  • Page 760 Method Description Calls a function when parameters have been set in the UIObject.doLater() Property and Component inspectors. Gets the style property from the style declaration or object. UIObject.getStyle() Marks the object so it is redrawn on the next frame interval. UIObject.invalidate() Moves the object to the requested position.
  • Page 761 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 UIObject.top parent.
  • Page 762: Label.autosize

    Label.autoSize Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage labelInstance.autoSize Description Property; a string that indicates how a label is sized and aligned to fit the value of its text property. There are four possible values: , and .
  • Page 763 Usage labelInstance.html Description Property; a Boolean value that indicates whether the label can be formatted with HTML ) or not ( ). The default value is . Label components with the property true false false html set to cannot be formatted with styles. true To retrieve plain text from HTML-formatted text, set the property to...
  • Page 764 Label component...
  • Page 765: Chapter 27: List Component

    CHAPTER 27 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 766 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: Keep it small, fast, and simple.
  • Page 767 Lists don’t measure text. This restriction has the most potential ramifications. Because a list must scale to thousands of records, any one of which could contain an unusually long string, it shouldn’t grow to fit the largest string of text within it, or add a horizontal scroll bar in “auto”...
  • Page 768 List parameters You can set the following authoring parameters for each List component instance in the Property inspector or in the Component inspector: data is an array of values that populate the data of the list. The default value is (an empty array).
  • Page 769 To populate a List instance with a data provider: Drag a List component from the Components panel to the Stage. Select the Free Transform tool and resize the component to fit your application. In the Property inspector, enter the instance name my_list. Select Frame 1 of the Timeline and, in the Actions panel, enter the following: my_list.dataProvider = myDP;...
  • Page 770: Customizing The List Component

    To create a List component instance using ActionScript: Drag the List component from the Components panel to the library. This adds the component to the library, but doesn’t make it visible in the application. Select the first frame in the main Timeline, open the Actions panel, and enter the following code: this.createClassObject(mx.controls.List, "my_list", 1);...
  • Page 771 A List component uses the following styles: Style Theme Description Halo The base color scheme of a component. Possible themeColor values are , and "haloGreen" "haloBlue" "haloOrange" The default value is "haloGreen" Both Specifies colors for rows in an alternating pattern. alternatingRowColors The value can be an array of two or more colors, for example, 0xFF00FF, 0xCC6699, and 0x996699.
  • Page 772 Style Theme Description Both The font weight: either . The default fontWeight "none" "bold" value is . All components can also accept the "none" value in place of during a "normal" "none" setStyle() call, but subsequent calls to return getStyle() "none"...
  • Page 773 Style Theme Description Both The background color of a selected row. The default selectionDisabledColor value is a 0xDDDDDD (medium gray). Because the default value for this property is the same as the default for , the selection is backgroundDisabledColor not visible when the component is disabled unless one of these style properties is changed.
  • Page 774: List Class

    When creating a new class-level style declaration, you lose all default values provided by the declaration. This includes , which is required for ScrollSelectList backgroundColor supporting mouse events. To create a class-level style declaration and preserve defaults, use a loop to copy the old settings to the new declaration. for..in var source = _global.styles.ScrollSelectList;...
  • Page 775 A row is a component that is used to display an item. Rows are either supplied by default by the list (the SelectableRow class is used), or you can supply them, usually as a subclass of the SelectableRow class. The SelectableRow class implements the CellRenderer API, which is the set of properties and methods that allow the list to manipulate each row and send data and state information (for example, size, selected, and so on) to the row for display.
  • Page 776 Method Description Sorts the items in the list according to the specified List.sortItems() compare function. Sorts the items in the list according to a specified property. List.sortItemsBy() Methods inherited from the UIObject class The following table lists the methods the List class inherits from the UIObject class. When calling these methods, use the form listInstance.methodName Method...
  • Page 777 Property summary for the List class The following table lists properties of the List class. Property Description Assigns the class or symbol to use to display each row of List.cellRenderer the list. The source of the list items. List.dataProvider The horizontal position of the list. List.hPosition Indicates whether the horizontal scroll bar is displayed ( List.hScrollPolicy...
  • Page 778 Properties inherited from the UIObject class The following table lists the properties the List class inherits from the UIObject class. When accessing these properties, use the form listInstance.propertyName Property Description The position of the bottom edge of the object, relative to the UIObject.bottom bottom edge of its parent.
  • Page 779 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 List.change to change. Broadcast when the pointer rolls over and then off of List.itemRollOut list items. Broadcast when the pointer rolls over list items.
  • Page 780: List.additem()

    List.addItem() Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. 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.
  • Page 781: List.additemat()

    List.addItemAt() Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage listInstance.addItemAt(index, label[, data]) listInstance.addItemAt(index, itemObject) Parameters A number greater than or equal to 0 that indicates the position of the item. index A string that indicates the label for the new item. label The data for the item.
  • Page 782: List.cellrenderer

    List.cellRenderer Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage listInstance.cellRenderer Description Property; assigns the cell renderer to use for each row of the list. This property must be a class object reference or a symbol linkage identifier. Any class used for this property must implement the CellRenderer API.
  • Page 783 Description Event; broadcast to all registered listeners when the selected index of the list changes as a result of user interaction. The first 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 change...
  • Page 784 See also EventDispatcher.addEventListener() List.dataProvider Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage listInstance.dataProvider Description Property; the data model for items viewed in a list. The value of this property can be an array or any object that implements the DataProvider API. The default value is .
  • Page 785: List.getitemat()

    This example creates a data provider array and assigns it to the property, as in dataProvider the following: var myDP_array:Array = new Array(); my_list.dataProvider = myDP_array; var accounts_array:Array = new Array(); accounts_array.push({name:"checkings", accountID:12345}); accounts_array.push({name:"savings", accountID:67890}); for (var i:Number = 0; i < accounts_array.length; i++) { // These changes to the data provider will be broadcast to the list.
  • Page 786: List.hposition

    Example The following code displays the label of the item at index position 2. To try this code, drag a List component to the Stage and give it the instance name my_list. Add the following code to Frame 1 in the timeline: var my_list:mx.controls.List;...
  • Page 787: List.hscrollpolicy

    var listListener:Object = new Object(); listListener.scroll = function (evt_obj:Object) { trace("my_list.hPosition = " + my_list.hPosition); my_list.addEventListener("scroll", listListener); List.hScrollPolicy Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage listInstance.hScrollPolicy Description Property; a string that determines whether the horizontal scroll bar is displayed; the value can .
  • Page 788: List.iconfield

    List.iconField Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage listInstance.iconField 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.
  • Page 789: List.iconfunction

    List.iconFunction Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage listInstance.iconFunction Description Property; specifies a function that determines which icon each row uses to display its item. This function receives a parameter, , which is the item being rendered, and must return a item string representing the icon’s symbol identifier.
  • Page 790: List.itemrollout

    my_list.addItem({data:"dreamweaver", label:"Dreamweaver"}); my_list.addItem({data:"coldfusion", label:"ColdFusion"}); my_list.iconFunction = function(item:Object):String { if (item.data == "flash") { // Put icon next to list item with the data "flash". return "flashIcon"; my_list.iconField = "icon"; List.itemRollOut Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage Usage 1: var listenerObject:Object = new Object();...
  • Page 791 The first usage example uses a dispatcher/listener event model. A component instance ) dispatches an event (in this case, ) and the event is handled by listInstance 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 792: List.itemrollover

    List.itemRollOver Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage Usage 1: var listenerObject:Object = new Object(); listenerObject.itemRollOver = function(eventObject:Object) { // Your code here. listInstance.addEventListener("itemRollOver", listenerObject); Usage 2: on (itemRollOver) { // Your code here. Event object In addition to the standard properties of the event object, the event has an itemRollOver property that specifies the number of the item that was rolled over.
  • Page 793: List.labelfield

    The second usage example uses an handler and must be attached directly to a List on() instance. The keyword , used inside an handler attached to a component, refers to this on() the component instance. For example, the following code, attached to the List instance , sends “_level0.my_list”...
  • Page 794: List.labelfunction

    Example The following example sets the property to be the field of each item. labelField "name" “Nina” would display as the label for the item added in the second line of code: var my_list:mx.controls.List; my_list.labelField = "name"; my_list.addItem({name: "Nina", age: 25}); See also List.labelFunction List.labelFunction...
  • Page 795: List.length

    See also List.labelField List.length Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage listInstance.length Description Property (read-only); the number of items in the list. Example The following example displays the number of items currently in the list’s data provider: var my_list:mx.controls.List;...
  • Page 796: List.multipleselection

    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" to indicate the amount of scrolling that the list requires. The list does not maxHPosition scroll horizontally if this property is not set.
  • Page 797: List.removeall()

    Example The following example tests to determine whether multiple items can be selected, and if so, displays instructions in a label component. To try this code, drag a List component to the Stage and give it the instance name my_list. Next, drag a Label component on to the Stage and give it the instance name my_label.
  • Page 798: List.removeitemat()

    Example The following code clears all items in a List component when a button is clicked. To try this code, drag a List component to the Stage and give it the instance name my_list. Next, drag a Button component to the Stage and give it the instance name remove_button. Add the following code to Frame 1 in the timeline: var my_list:mx.controls.List;...
  • Page 799: List.replaceitemat()

    Description Method; removes the item at the specified index position. The list indices after the specified index collapse by one. Calling this method modifies the data provider of the List component. If the data provider is shared with other components, those components are updated as well. Example The following code clears the selected item in a List component when a button is clicked.
  • Page 800 Parameters A number greater than 0 and less than that indicates the position at index List.length which to insert the item (the index of the new item). 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 type. data An object to use as the item, usually containing properties.
  • Page 801: List.rowcount

    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 is displayed, without a partial row at the bottom.
  • Page 802: List.rowheight

    The following example resizes the list using the method and then sets a row count setSize() of 8 items: my_list.addItem({data:"flash", label:"Flash"}); my_list.addItem({data:"dreamweaver", label:"Dreamweaver"}); my_list.addItem({data:"coldfusion", label:"ColdFusion"}); my_list.setSize(200, 30); my_list.rowCount = 8; trace("my_list has " + my_list.rowCount + " rows."); List.rowHeight Availability Flash Player 6 (6.0.79.0).
  • Page 803: List.scroll

    List.scroll Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage Usage 1: var listenerObject:Object = new Object(); listenerObject.scroll = function(eventObject:Object) { // Your code here. listInstance.addEventListener("scroll", listenerObject); Usage 2: on (scroll) { // Your code here. Event object Along with the standard event object properties, the event has one additional scroll property,...
  • Page 804: List.selectable

    The second usage example uses an handler and must be attached directly to a List on() instance. The keyword , used inside an handler attached to a component, refers to this on() the component instance. For example, the following code, attached to the List instance , sends “_level0.my_list”...
  • Page 805: List.selectedindex

    Description Property; a Boolean value that indicates whether the list is selectable ( ) or not ( true false The default value is true Example The following example prevents users from selecting items in the list by setting the selectable property to false var my_list:mx.controls.List;...
  • Page 806: List.selectedindices

    Example The following example selects the first item in a list by default and displays the index of the currently selected whenever the user selects a new item: var my_list:mx.controls.List; my_list.addItem({data:"flash", label:"Flash"}); my_list.addItem({data:"dreamweaver", label:"Dreamweaver"}); my_list.addItem({data:"coldfusion", label:"ColdFusion"}); // Select first item by default. my_list.selectedIndex = 0;...
  • Page 807: List.selecteditem

    Example The following example retrieves the selected indices: var selIndices:Array = my_list.selectedIndices; The following example selects four items: var my_array = new Array (1, 4, 5, 7); my_list.selectedIndices = my_array; The following example selects two list items by default and displays their label property in the Output panel: my_list.multipleSelection = true;...
  • Page 808: List.selecteditems

    Example The following example displays the selected label: trace(my_list.selectedItem.label); The following example displays the contents of a selected whenever the user selects a new item from the list: my_list.multipleSelection = true; my_list.addItem({data:"flash", label:"Flash"}); my_list.addItem({data:"dreamweaver", label:"Dreamweaver"}); my_list.addItem({data:"coldfusion", label:"ColdFusion"}); //Create listener object. var listListener:Object = new Object();...
  • Page 809: List.setpropertiesat()

    Example The following example retrieves an array of selected item objects: var myObjArray:Array = my_list.selectedItems; The following example displays two List instances on the Stage. When a user selects an item from the first list, the selected item is copied to the second list. To try this code, you must add a copy of the List component to the library of the current document.
  • Page 810: List.sortitems()

    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. Description Method; applies the specified properties to the specified item. The supported properties are icon backgroundColor Example...
  • Page 811: List.sortitemsby()

    Parameters A reference to a function. This function is used to compare two items to compareFunc determine their sort order. For more information, see sort (Array.sort method) in ActionScript 2.0 Language Reference. Returns Nothing. Description Method; sorts the items in the list by using the function specified in the compareFunc parameter.
  • Page 812 Usage listInstance.sortItemsBy(fieldName, optionsFlag) listInstance.sortItemsBy(fieldName, order) Parameters A string that specifies the name of the field to use for sorting. This value is fieldName usually "label" "data" A string that specifies whether to sort the items in ascending order ( ) or order "ASC"...
  • Page 813: List.vposition

    Description Method; sorts the items in the list in the specified order, using the specified field name. If the items are a combination of text strings and integers, the integer items are listed fieldName first. The parameter is usually , but you can specify any fieldName "label"...
  • Page 814: List.vscrollpolicy

    Example The following example displays the current value of the vPosition of the list whenever the contents of the list are scrolled: my_list.setSize(200, 60); my_list.rowCount = 4; my_list.vPosition = 2; my_list.addItem({data:"flash", label:"Flash"}); my_list.addItem({data:"flex", label:"Flex"}); my_list.addItem({data:"coldfusion", label:"ColdFusion"}); my_list.addItem({data:"dreamweaver", label:"Dreamweaver"}); my_list.addItem({data:"fireworks", label:"Fireworks"}); my_list.addItem({data:"contribute", label:"Contribute"});...
  • Page 815 Example The following example disables the vertical scroll bar for a list: var my_list:mx.controls.List; my_list.setSize(200, 60); my_list.rowCount = 4; my_list.vScrollPolicy = "off"; my_list.addItem({data:"flash", label:"Flash"}); my_list.addItem({data:"flex", label:"Flex"}); my_list.addItem({data:"coldfusion", label:"ColdFusion"}); my_list.addItem({data:"dreamweaver", label:"Dreamweaver"}); my_list.addItem({data:"fireworks", label:"Fireworks"}); my_list.addItem({data:"contribute", label:"Contribute"}); my_list.addItem({data:"breeze", label:"Breeze"}); var listListener:Object = new Object(); listListener.scroll = function(evt_obj:Object) { trace("my_list.vPosition = "...
  • Page 816 List component...
  • Page 817: Chapter 28: Loader Component

    CHAPTER 28 Loader component The Loader component is a container that can display a SWF or JPEG file (but not progressive JPEG files). You can scale the contents of the loader or resize the loader itself to accommodate the size of the contents. By default, the contents are scaled to fit the loader. You can also load content at runtime and monitor loading progress (although after content has been loaded once it is cached, so the progress jumps to 100% quickly).
  • Page 818 If you load certain version 2 Macromedia Component Architecture components into a SWF file or into the Loader component, the components may not work correctly. These components include the following: Alert, ComboBox, DateField, Menu, MenuBar, and Window. Use the property when calling...
  • Page 819 The Loader can load content from other domains, if you have policy files in those domains. See “Allowing cross-domain data loading” in Learning ActionScript 2.0 in Flash. scaleContent indicates whether the content scales to fit the loader ( ), or the loader scales true to fit the content ( ).
  • Page 820: Customizing The Loader Component

    Customizing the Loader component You can transform a Loader 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 821: Loader Class

    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. Setting a property of the Loader class with ActionScript overrides the parameter of the same name set in the Property inspector or Component inspector.
  • Page 822 Method Description Forces validation of the object so it is drawn in the current UIObject.redraw() frame. 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 Loader class inherits from the UIComponent class.
  • Page 823 Properties inherited from the UIObject class The following table lists the properties the Loader class inherits from the UIObject class. When accessing these properties from the Loader object, use the form LoaderInstance.propertyName Property Description The position of the bottom edge of the object, relative to the UIObject.bottom bottom edge of its parent.
  • Page 824 Event summary for the Loader class The following table lists events of the Loader class. Event Description Triggered when the content finished loading. Loader.complete Triggered while content is loading. Loader.progress Events inherited from the UIObject class The following table lists the events the Loader class inherits from the UIObject class. Event Description Broadcast when an object is about to draw its graphics.
  • Page 825: Loader.autoload

    Loader.autoLoad Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage loaderInstance.autoLoad Description Property; a Boolean value that indicates whether to automatically load the content ( ), or true wait until is called ( ). The default value is Loader.load() false true Example...
  • Page 826: Loader.bytestotal

    When you create an instance with , you have to position it on the createClassObject() Stage with . See move() UIObject.move() import mx.controls.Loader; import mx.controls.ProgressBar; System.security.allowDomain("http://www.flash-mx.com"); this.createClassObject(Loader, "my_ldr", 10); this.createClassObject(ProgressBar, "my_pb", 20, {source:"my_ldr"}); my_ldr.move(1, 50); my_pb.move(1, 1); var loaderListener:Object = new Object(); loaderListener.progress = function(evt_obj:Object) { // evt_obj.target is the component that generated the progress event, // that is, the loader.
  • Page 827: Loader.complete

    Example The following code creates a progress bar and a Loader component. It then creates a load listener object with a event handler that shows the progress of the load. The listener progress is registered with the instance, as follows: my_ldr import mx.controls.Loader;...
  • Page 828 Description Event; broadcast to all registered listeners when the content finishes loading. The first 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.
  • Page 829 trace("loading complete"); //Add listener. my_ldr.addEventListener("complete", loaderListener); my_ldr.load("http://www.flash-mx.com/images/image2.jpg"); Loader.content Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage loaderInstance.content Description Property (read-only); a reference to a movie clip instance that contains the contents of the loaded file. The value is until the load begins.
  • Page 830: Loader.contentpath

    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 831 Parameters An optional parameter that specifies the value for the property before path contentPath the load begins. If a value is not specified, the current value of is used as is. contentPath Returns Nothing. Description Method; tells the loader to begin loading its content. Example The following example creates a Loader instance, , and a Button instance and sets the...
  • Page 832: Loader.percentloaded

    Loader.percentLoaded Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage loaderInstance.percentLoaded Description Property (read-only); a number indicating what percent of the content has loaded. Typically, this property is used to present the progress to the user in an easily readable form. Use the following code to round the figure to the nearest integer: Math.round(bytesLoaded/bytesTotal*100)) Example...
  • Page 833 Usage Usage 1: var listenerObject:Object = new Object(); listenerObject.progress = function(eventObj:Object) { // ... loaderInstance.addEventListener("progress", listenerObject); Usage 2: on (progress) { // ... 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 834: Loader.scalecontent

    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 progress of the content has loaded: //Create loader instance. this.createClassObject(mx.controls.Loader, "my_ldr", 10);...
  • Page 835: Chapter 29: Media Components (Flash Professional Only)

    Media components (Flash Professional only) The streaming media components make it easy to incorporate streaming media into Macromedia Flash presentations. These components let you present your media in a variety of ways. You can use the following three media components: The MediaDisplay component lets media stream into your Flash content without a supporting user interface.
  • Page 836: Interacting With Media Components (Flash Professional Only)

    Interacting with media components (Flash Professional only) The streaming MediaPlayback and MediaController components respond to mouse and keyboard activity; the MediaDisplay component does not. The following table summarizes the actions for the MediaPlayback and MediaController components upon receiving focus: Target Navigation Description Playback controls...
  • Page 837: Understanding Media Components (Flash Professional Only)

    Target Navigation Description Playback controller Tab, Shift+Tab Moves the focus from button to button within the navigation controller component, where the focused element becomes highlighted. This navigation works with the Pause/Play, Go to Beginning, Go to End, Volume Mute, and Volume Max controls. The focus moves from left to right and top to bottom as users tab through the elements.
  • Page 838 The streaming media components broadcast several related events. The following broadcast events can be used to set other items in motion: event is broadcast continuously by the MediaDisplay and MediaPlayback change components while media is playing. (See Media.change event is continuously broadcast by the MediaDisplay and MediaPlayback progress components while media is loading.
  • Page 839 For FLV files, when is set to , the media is displayed at its preferred Media.autoSize true size, regardless of the size of the component. This means that if the size of the MediaDisplay instance is different from the size of the media, the media either spills out of the instance boundaries or does not fill the instance size.
  • Page 840: Using Media Components (Flash Professional Only)

    The MediaController component has an orientation setting, , which you Media.horizontal can use to draw the component with a horizontal orientation (the default) or a vertical one. With a horizontal orientation, the playbar tracks playing media from left to right. With a vertical orientation, the playbar tracks media from bottom to top.
  • Page 841 To create a Flash document that displays a CD or DVD preview: Select File > New; then select Flash Document. Open the Components panel and double-click the MediaPlayback component to place an instance of it on the Stage. Select the MediaPlayback component instance and enter the instance name myMedia in the Property inspector.
  • Page 842 Add the following ActionScript to Frame 1. This code creates a listener to open a pop-up window informing the user that the movie is on sale. // Import the classes necessary to create the pop-up window dynamically. import mx.containers.Window; import mx.managers.PopUpManager; // Create a listener object to open sale pop-up.
  • Page 843 To create a Flash document that displays a CD or DVD preview: In Flash, select File > New; then select Flash Document. From the Components panel, drag a MediaController and a MediaDisplay component to the Stage. Select the MediaDisplay instance and enter the instance name myDisplay in the Property inspector.
  • Page 844 Using the Component inspector with media components The Component inspector makes it easy to set media component parameters, properties, and so on. To use this panel, click the desired component on the Stage and, with the Property inspector open, click Launch Component Inspector. The Component inspector can be used for the following purposes: To automatically play the media (see Media.activePlayControl...
  • Page 845 With the file type set to FLV, you’ll notice a Milliseconds option and (if Milliseconds is unselected) a Frames Per Second (FPS) pop-up menu. When Milliseconds is selected, the FPS control is not visible. In this mode, the time displayed in the playbar at runtime is formatted as HH:MM:SS.mmm (H = hours, M = minutes, S = seconds, m = milliseconds), and cue points are set in seconds.
  • Page 846 To associate a MediaDisplay component with a MediaController component: Place a MediaDisplay instance and a MediaController instance on the Stage. Select the MediaDisplay instance and, using the Property inspector, enter the instance name myMediaDisplay. Select the MediaController instance that will trigger the behavior. In the Behaviors panel, click the Add (+) button and select Media >...
  • Page 847: Media Component Parameters (Flash Professional Only)

    To use a Slide CuePoint Navigation behavior: Open your new document as a Flash slide presentation. Place a MediaDisplay or MediaPlayback component instance on the Stage. In the Screen Outline pane to the left of the Stage, click the Insert Screen (+) button to add a second slide;...
  • Page 848 Name Type Default Description value Cue Points Array Undefined An array of cue point objects, each with a name and position in time in a valid Media.cuePoints HH:MM:SS:FF (Milliseconds option selected) or HH:MM:SS:mmm format. FLV or MP3 FLV or Designates the type of media to be played.
  • Page 849 Name Type Default Description value horizontal Boolean Determines whether the controller true portion of the instance is vertically or Media.horizontal horizontally oriented. A value true indicates that the component has a horizontal orientation. enabled Boolean Determines whether this control can be true modified by the user.
  • Page 850 Name Type Default Description value FLV or MP3 String: Designates the type of media to be FLV or played. Media.mediaType Milliseconds Boolean false Determines whether the playbar uses frames or milliseconds, and whether the cue points use seconds or frames. When this option is selected, the FPS control is disabled.
  • Page 851: Customizing Media Components (Flash Professional Only)

    You can find the media component source document at the following locations: Windows: C:\Program Files\Macromedia\Flash 8\<language>\Configuration\ ComponentFLA\MediaComponents.fla Macintosh: HD/Applications/Macromedia Flash 8/Configuration/ComponentFLA/ MediaComponents.fla...
  • Page 852 Method summary for the Media class The following table lists methods of the Media class. Method Components Description MediaDisplay, Adds a cue point object to the Media.addCuePoint() MediaPlayback component instance. MediaDisplay Associates a MediaDisplay instance with a Media.associateController() MediaController instance. MediaController Associates a MediaController instance with Media.associateDisplay() a MediaDisplay instance.
  • Page 853 Property summary for the Media class The following table lists properties of the Media class. Property Components Description MediaController Determines the component state when Media.activePlayControl loaded at runtime. MediaDisplay, Determines if the component instance Media.aspectRatio MediaPlayback maintains its video aspect ratio. MediaDisplay, Determines if the component instance Media.autoPlay...
  • Page 854 Property Components Description MediaDisplay, For MediaDisplay and MediaPlayback, this Media.playing MediaPlayback, property is read-only and returns a Boolean MediaController value to indicate whether a given component instance is playing media. For MediaController, this property is read/write and controls the image (playing or paused) displayed on the Play/Pause button of the controller.
  • Page 855: Media.activeplaycontrol

    Event Components Description MediaController, Generated when the playhead is dragged. Media.scrubbing MediaPlayback MediaController, Broadcast when the user adjusts the Media.volume MediaPlayback volume. Media.activePlayControl Applies to MediaController. Availability Flash Player 7. Edition Flash MX Professional 2004. Usage myMedia.activePlayControl Description Property; a string value that specifies the state the MediaController component should be in when it is loaded at runtime.
  • Page 856: Media.addcuepoint()

    See also Media.autoPlay Media.addCuePoint() Applies to MediaDisplay, MediaPlayback. Availability Flash Player 7. Edition Flash MX Professional 2004. Usage myMedia.addCuePoint(cuePointName, cuePointTime) Parameters A string that names the cue point. cuePointName A number, in seconds, that indicates when a event is broadcast. cuePointTime cuePoint Returns...
  • Page 857: Media.aspectratio

    Media.aspectRatio Applies to MediaDisplay, MediaPlayback. Availability Flash Player 7. Edition Flash MX Professional 2004. Usage myMedia.aspectRatio Description Property; a Boolean value that determines whether a MediaDisplay or MediaPlayback instance maintains its video aspect ratio during playback. A value indicates that the true aspect ratio should be maintained;...
  • Page 858: Media.associatedisplay()

    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 you use to associate a MediaController instance with a Media.associateDisplay() MediaDisplay instance, you do not need to use Media.associateController() Example The following code associates...
  • Page 859: Media.autoplay

    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 860: Media.autosize

    Media.autoSize Applies to MediaDisplay, MediaPlayback. Availability Flash Player 7. Edition Flash MX Professional 2004. Usage myMedia.autoSize Description Property; a Boolean value that determines the size of the media-viewing portion of the MediaDisplay or MediaPlayback component. For the MediaDisplay component, the property behaves as follows: If you set this property to , Flash displays the media at its preferred size, regardless of true...
  • Page 861: Media.backgroundstyle

    Example The following example indicates that the control is not played back according to its media size: myMedia.autoSize = false; See also Media.aspectRatio Media.backgroundStyle Applies to MediaController. Availability Flash Player 7. Edition Flash MX Professional 2004. Usage myMedia.backgroundStyle Description Property; a string value that indicates which background is drawn for the MediaController instance.
  • Page 862: Media.bytesloaded

    Media.bytesLoaded Applies to MediaDisplay, MediaPlayback. Availability Flash Player 7. Edition Flash MX Professional 2004. Usage myMedia.bytesLoaded Description Read-only property; the number of bytes already loaded into the component that are available for playing. The default value is undefined Example The following code creates a variable called that is set with the number of PlaybackLoad bytes loaded.
  • Page 863: Media.change

    Description Read-only property; the number of bytes to be loaded into the MediaPlayback or MediaDisplay component. The default value is undefined Example The following example tells the user the size of the media to be streamed: myTextField.text = myMedia.bytesTotal; Media.change Applies to MediaDisplay, MediaPlayback.
  • Page 864: Media.click

    Example The following example uses an object listener to determine the playhead position ), from which the percentage complete can be calculated: Media.playheadTime var myPlayerListener:Object = new Object(); myPlayerListener.change = function(eventObj:Object) { var myPosition:Number = myPlayer.playheadTime; var myPercentPosition:Number = (myPosition/myPlayer.totalTime); myPlayer.addEventListener("change", myPlayerListener);...
  • Page 865: Media.complete

    Example For a MediaController component instance named myMedia (and with a Window component in the library), the following example opens a pop-up window when the user clicks the Play/Pause button: var myMediaListener:Object = new Object(); myMediaListener.click = function(eventObj:Object) { mx.managers.PopUpManager.createPopUp(_root, mx.containers.Window, true); myMedia.addEventListener("click", myMediaListener);...
  • Page 866: Media.contentpath

    Example The following example uses an object listener to determine when the media has finished playing: var myListener:Object = new Object(); myListener.complete = function(eventObj:Object) { trace("media is Finished"); myMedia.addEventListener("complete", myListener); Media.contentPath Applies to MediaDisplay, MediaPlayback. Availability Flash Player 7. Edition Flash MX Professional 2004.
  • Page 867: Media.controllerpolicy

    Media.controllerPolicy Applies to MediaController, MediaPlayback. Availability Flash Player 7. Edition Flash MX Professional 2004. Usage myMedia.controllerPolicy Description Property; determines whether the MediaController component (or the controller subcomponent within the MediaPlayback component) is hidden when instantiated and only appears when the user moves the mouse over the controller’s collapsed state. The possible values for this property are as follows: specifies that the controls are always expanded.
  • Page 868: Media.controlplacement

    Media.controlPlacement Applies to MediaPlayback. Availability Flash Player 7. Edition Flash MX Professional 2004. Usage myMedia.controlPlacement Description Property; determines where the controller portion of the MediaPlayback component is positioned in relation to its display. The possible values are , and "top" "bottom"...
  • Page 869: Media.cuepoints

    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. cuePointName A number, expressed in frames or seconds, that indicates when the cue point cuePointTime was reached.
  • Page 870: Media.displayfull()

    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).
  • Page 871: Media.displaynormal()

    Example The following code forces the component to expand to fit the Stage: myMedia.displayFull(); See also Media.displayNormal() Media.displayNormal() Applies to MediaPlayback. Availability Flash Player 7. Edition Flash MX Professional 2004. Usage myMedia.displayNormal() Returns Nothing. Description Method; sets the MediaPlayback instance back to its normal size after a method has been used.
  • Page 872: Media.getcuepoint()

    Media.getCuePoint() Applies to MediaDisplay, MediaPlayback. Availability Flash Player 7. Edition Flash MX Professional 2004. Usage myMedia.getCuePoint(cuePointName) Parameters The string that was provided when was used. cuePointName Media.addCuePoint() 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...
  • Page 873: Media.mediatype

    Usage myMedia.horizontal Description Property; determines whether the MediaController component displays itself in a vertical or horizontal orientation. A value indicates that the component is displayed in a horizontal true orientation; a value indicates a vertical orientation. When set to , the playbar and false false playback slider move from bottom to top.
  • Page 874: Media.pause()

    Media.pause() Applies to MediaDisplay, MediaPlayback. Availability Flash Player 7. Edition Flash MX Professional 2004. Usage myMedia.pause() Returns Nothing, Description Method; pauses the playhead at the current location. Example The following code pauses the playback. myMedia.pause(); Media.play() Applies to MediaDisplay, MediaPlayback. Availability Flash Player 7.
  • Page 875: Media.playheadchange

    Parameters A non-negative integer that indicates the starting point (in seconds) at startingPoint which 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 The following code indicates that the media component should start playing at 120 seconds:...
  • Page 876: Media.playheadtime

    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 event object has the following properties: Media.playheadChange A number that indicates the percentage of the media that has played. detail The string type...
  • Page 877: Media.playing

    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, false and read/write for the MediaController component.
  • Page 878: Media.preferredwidth

    Usage myMedia.preferredHeight Description Property; set according to a FLV file’s default height value. This property applies only to FLV media, because the height is fixed for MP3 files. This property can be used to set the height and width properties (plus some margin for the component itself ). The default value is if no FLV media is set.
  • Page 879: Media.progress

    Media.progress Applies to MediaDisplay, MediaPlayback. Availability Flash Player 7. Edition Flash MX Professional 2004. Usage var listenerObject:Object = new Object(); listenerObject.progress = function(eventObj:Object) { // ... myMedia.addEventListener("progress", listenerObject); Description Event; is generated continuously until media has completely downloaded. The event object has the following properties: Media.progress A reference to the MediaDisplay or MediaPlayback instance.
  • Page 880: Media.scrubbing

    The following example listens for progress and calls another function if the progress event continues for more than 3000 milliseconds (3 seconds): // Duration of delay before calling timeOut. var timeOut:Number = 3000; // If timeOut has been reached, do this: function callback(arg) { trace(arg);...
  • Page 881: Media.removeallcuepoints()

    Example The following example listens for the user to drag the playhead: my_mp.addEventListener("scrubbing", scrubbingListener); function scrubbingListener(evt_obj:Object):Void { trace(evt_obj.type+" @ "+getTimer()+" ms (isScrubbing="+evt_obj.detail+")"); Media.removeAllCuePoints() Applies to MediaDisplay, MediaPlayback. Availability Flash Player 7. Edition Flash MX Professional 2004. Usage myMedia.removeAllCuePoints() Returns Nothing. Description Method;...
  • Page 882: Media.removecuepoint()

    Media.removeCuePoint() Applies to MediaDisplay, MediaPlayback. Availability Flash Player 7. Edition Flash MX Professional 2004. Usage myMedia.removeCuePoint(cuePoint) Parameters A reference to a cue point object that has been assigned previously by means of cuePoint Media.addCuePoint() Returns Nothing. Description Method; deletes a cue point associated with a component instance. Example The following code deletes a cue point named myCuePoint...
  • Page 883: Media.setmedia()

    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 contentPath undefined A string used to set the media type to either FLV or MP3. This parameter mediaType is optional.
  • Page 884: Media.stop()

    Media.stop() Applies to MediaDisplay, MediaPlayback. Availability Flash Player 7. Edition Flash MX Professional 2004. Usage myMedia.stop() 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 885: Media.volume

    Description Property; the total length of the media, in seconds. Since the FLV file format does not provide its play time to a media component until it is completely loaded, you must input manually so that the playbar can accurately reflect the actual play time of Media.totalTime the media.
  • Page 886: Media.volume

    Media.volume Applies to MediaController, MediaPlayback. Availability Flash Player 7. Edition Flash MX Professional 2004. Usage var listenerObject:Object = new Object(); listenerObject.volume = function(eventObj:Object) { // ... myMedia.addEventListener("volume", listenerObject); Description Event; broadcast when the volume value is adjusted by the user. The event Media.volume object has the following properties:...
  • Page 887 CHAPTER 30 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 888: Interacting With The Menu Component (Flash Professional Only)

    Interacting with the Menu component (Flash Professional only) You can use the mouse and keyboard to interact with a Menu component. After a Menu component is opened, it remains visible until it is closed by a script or until the user clicks the mouse outside the menu or inside an enabled item.
  • Page 889: Using The Menu Component (Flash Professional Only)

    When a Menu instance has focus either from clicking or tabbing, you can use the following keys to control it: Description Down Arrow Moves the selection down and up the rows of the menu. The selection Up Arrow cycles at the top or bottom row. Right Arrow Opens a submenu, or moves selection to the next menu in a menu bar (if a menu bar exists).
  • Page 890 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 891 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 892: About Menu Item Types (Flash Professional Only)

    About menu item types (Flash Professional only) There are four kinds of menu items, specified by the attribute: type <menu> <menuitem label="Normal Item" /> <menuitem type="separator" /> <menuitem label="Checkbox Item" type="check" instanceName="check_1"/> <menuitem label="RadioButton Item" type="radio" groupName="radioGroup_1" /> </menu> Normal menu items menu item doesn’t have a attribute, which means that the Normal Item...
  • Page 893 The following example defines three check box menu items: <menu> <menuitem label="Apples" type="check" instanceName="buyApples" selected="true" /> <menuitem label="Oranges" type="check" instanceName="buyOranges" selected="false" /> <menuitem label="Bananas" type="check" instanceName="buyBananas" selected="false" /> </menu> You can use the instance names in ActionScript to access the menu items directly from the menu itself, as in the following example: myMenu.setMenuItemSelected(myMenu.buyapples, true);...
  • Page 894 When the user selects one of the items, the current selection automatically changes, and a event is broadcast to all listeners on the root menu. The currently selected item in a change radio group is available in ActionScript through the property, as follows: selection var selectedMenuItem = myMenu.alignment_group.selection;...
  • Page 895: About Initialization Object Properties (Flash Professional Only)

    About initialization object properties (Flash Professional only) (initialization object) parameter is a fundamental concept in creating the initObject layout for the Menu component. This parameter is an object with properties. Each property represents one of the possible the XML attributes of a menu item. (For a description of the properties allowed in the parameter, see “About menu item XML attributes”...
  • Page 896: Menu Parameters (Flash Professional Only)

    You should treat the , and attributes of a menu item as read- instanceName groupName type only. You should set them only while creating an item (for example, in a call to ). Modifying these attributes after creation may produce addMenuItem() unpredictable results.
  • Page 897 In the Actions panel, on the first frame, enter the following code to add an event listener to listen for events on the button. The code also listens for a event on the click change menu and displays the name of the selected menu item in the Output panel: Requires: - Menu component in library - Button component in library...
  • Page 898 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 library. Menus are created dynamically through ActionScript. In the Actions panel, add the following code to the first frame to create a menu, and use property to load menu items from a web page: dataProvider Requires:...
  • Page 899 To use a well-formed XML string to create and populate a menu: Select File > New and create a Flash document. Drag the Menu component from the Components panel to the library. Menus are created dynamically through ActionScript. In the Actions panel, add the following code to the first frame to create a menu and add some items: Requires: - Menu component in library...
  • Page 900 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 library. Menus are created dynamically through ActionScript. In the Actions panel, add the following code to the first frame to create a menu and add some items: Requires: - Menu component in library...
  • Page 901: Customizing The Menu Component (Flash Professional Only)

    Customizing the Menu component (Flash Professional only) The menu sizes itself horizontally to fit its widest text. You can also call the setSize() method to size the component. Icons should be sized to a maximum of 16 by 16 pixels. Using styles with the Menu component You can call the method to change the style of the menu, its items, and its...
  • Page 902 Style Description Both A Boolean value that indicates whether the font embedFonts specified in is an embedded font. This fontFamily style must be set to refers to an true fontFamily embedded font. Otherwise, the embedded font is not used. If this style is set to does true fontFamily...
  • Page 903 Style Description Both The background color of a selected row. The default selectionColor value is a 0xCDFFC1 (light green) with the Halo theme and 0xEEEEEE (very light gray) with the Sample theme. When is changed through a setStyle() themeColor call, the framework sets to a value selectionColor related to the...
  • Page 904 To set a style property on the Menu components only, you can create a new and store it in CSSStyleDeclaration _global.styles.Menu import mx.styles.CSSStyleDeclaration; if (_global.styles.Menu == undefined) { _global.styles.Menu = new CSSStyleDeclaration(); _global.styles.Menu.setStyle("backgroundColor", 0xFF00AA); When you create a new class-level style declaration, you lose all default values provided by the declaration.
  • Page 905: Menu Class (Flash Professional Only)

    Open the symbols that 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 that you want to customize. Click the Back button to return to the main timeline.
  • Page 906 Method summary for the Menu class The following table lists methods of the Menu class. Method Description Adds a menu item to the menu. Menu.addMenuItem() Adds a menu item to the menu at a specific location. Menu.addMenuItemAt() Creates an instance of the Menu class. This is a static Menu.createMenu() method.
  • Page 907 Method Description Forces validation of the object so it is drawn in the current UIObject.redraw() frame. 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 Menu class inherits from the UIComponent class.
  • Page 908 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 UIObject.top parent.
  • Page 909: Menu.addmenuitem()

    Events inherited from the UIObject class The following table lists the events the Menu 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 UIObject.hide invisible.
  • Page 910 Usage 2: menuInstance.addMenuItem(childMenuItem) Parameters An object containing properties that initialize a menu item’s attributes. See initObject “About menu item XML attributes” on page 887. An XML node object. childMenuItem Returns A reference to the added XML node. Description Method; Usage 1 adds a menu item at the end of the menu. The menu item is constructed from the values supplied in the parameter.
  • Page 911: Menu.addmenuitemat()

    Menu.addMenuItemAt() Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage Usage 1: menuInstance.addMenuItemAt(index, initObject) Usage 2: menuInstance.addMenuItemAt(index, childMenuItem) Parameters An integer indicating the index position (among the child nodes) at which the item index is added. An object containing properties that initialize a menu item’s attributes. See initObject “About menu item XML attributes”...
  • Page 912: Menu.change

    You first drag a Menu component to the library and then add the following code to Frame 1: Requires: - Menu component in library import mx.controls.Menu; // Create the Menu objects. var first_menu:Menu = Menu.createMenu(); first_menu.addMenuItem({label:"1st Item"}); var second_menu:Menu = Menu.createMenu(); second_menu.addMenuItem({label:"1st Item 2nd Menu"});...
  • Page 913 Description Event; broadcast to all registered listeners whenever a user causes a change in the menu. Version 2 Macromedia Component Architecture components use a dispatcher-listener event model. When a Menu component broadcasts a event, the event is handled by a...
  • Page 914: Menu.createmenu()

    // Add the menu items. menuDP_obj.addMenuItem({label:"1st Item"}); menuDP_obj.addMenuItem({label:"2nd Item"}); // Create the Menu object. var my_menu:Menu = Menu.createMenu(this, menuDP_obj); my_menu.show(); var menuListener:Object = new Object(); menuListener.change = function(evt_obj:Object) { trace("Menu item chosen: " + evt_obj.menuItem.attributes.label); my_menu.addEventListener("change", menuListener); Menu.createMenu() Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004.
  • Page 915: Menu.dataprovider

    Example The following example creates a menu with a submenu for the New menu item. It creates the menu by creating an XML object, , and adding menu items to it with calls to my_xml . It then creates the menu with a call to , passing the XML addMenuItem() createMenu()
  • Page 916 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 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 917: Menu.getmenuitemat()

    Menu.getMenuItemAt() Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage menuInstance.getMenuItemAt(index) Parameters An integer indicating the index of the node in the menu. index Returns A reference to the specified node. Description Method; returns a reference to the specified child node of the menu. Example The following example initially creates two menus with a single menu item for each one.
  • Page 918: Menu.hide()

    Menu.hide() Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage menuInstance.hide() Returns Nothing. Description Method; closes a menu. Example The following example creates a button and a two-item menu and displays the menu for an interval of 2000 milliseconds. When the interval expires, the function calls the closeMenu() method to close the menu.
  • Page 919: Menu.indexof()

    var menuDP_obj:Object = my_xml.addMenuItem("Edit"); // Add the menu items. menuDP_obj.addMenuItem({label:"1st Item"}); menuDP_obj.addMenuItem({label:"2nd Item"}); // Create the Menu object. var my_menu:Menu = Menu.createMenu(this, menuDP_obj); my_menu.show(100, 100); // Call closeMenu after 2000 milliseconds. var interval_id:Number = setInterval(closeMenu, 2000, my_menu); function closeMenu(the_menu:Menu):Void { the_menu.hide();...
  • Page 920 Description Method; returns the index of the specified menu item within this menu instance. Example The following example creates a menu with two items from an XML data provider and then adds a third item to the menu and saves the reference that is returned by the addMenuItem() method.
  • Page 921: Menu.menuhide

    Menu.menuHide Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage Usage 1: var listenerObject:Object = new Object(); listenerObject.menuHide = function(eventObject:Object) { // Insert your code here. menuInstance.addEventListener("menuHide", listenerObject); Usage 2: on (menuHide) { // Insert your code here. Description Event;...
  • Page 922 Example The following example creates a button and a two-item menu. When the user clicks the button, a listener for a button click event displays the menu. When the user clicks a second time, the menu is hidden and a listener for the event, , displays menuHide...
  • Page 923: Menu.menushow

    menuListener.menuHide = function(evt_obj:Object) { trace("Menu closed."); // Add listener. my_menu.addEventListener("menuHide", menuListener); See also Menu.menuShow Menu.menuShow Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage Usage 1: var listenerObject:Object = new Object(); listenerObject.menuShow = function(eventObject:Object) { // Insert your code here. menuInstance.addEventListener("menuShow", listenerObject);...
  • Page 924 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 Menu.menuShow object has two additional properties:...
  • Page 925: Menu.removeall()

    buttonListener.click = function(evt_obj:Object) { // get reference to the button var the_button:Button = evt_obj.target; // Display the menu at the bottom of the button. my_menu.show(the_button.x, the_button.y + the_button.height); my_button.addEventListener("click", buttonListener); // Create listener object. var menuListener:Object = new Object(); menuListener.menuShow = function(evt_obj:Object) { trace("Menu open.");...
  • Page 926: Menu.removemenuitem()

    You first drag a Menu component to the library and then add the following code to Frame 1: Requires: - Menu component in library import mx.controls.Menu; // Create an XML object to act as a factory. var my_xml:XML = new XML(); // The item created next does not appear in the menu.
  • Page 927 Returns A reference to the returned menu item (XML node). This value is if there is no undefined item in that position. Description Method; removes the specified menu item and all its children, and refreshes the menu. Example The following example creates a menu with three menu items and sets an interval to cause the menu to be displayed for a couple of seconds (2000 milliseconds).
  • Page 928: Menu.removemenuitemat()

    myItem_obj.removeMenuItem(); clearInterval(interval_id); my_menu.show(100, 20); Menu.removeMenuItemAt() Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage menuInstance.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 undefined item in that position.
  • Page 929: Menu.rollout

    // receive a root element whose children will become // the items. This is just a simple way to create that // root element and give it a convenient name. var menuDP_obj:Object = my_xml.addMenuItem("XXXXX"); // Add the menu items. menuDP_obj.addMenuItem({label:"1st Item"}); menuDP_obj.addMenuItem({label:"2nd Item"});...
  • Page 930 Description Event; broadcast to all registered listeners when the pointer rolls off a menu item. 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.
  • Page 931: Menu.rollover

    my_menu.show(100, 20); // Create listener object. var menuListener:Object = new Object(); menuListener.rollOut = function(evt_obj:Object) { trace("Menu rollOut: " + evt_obj.menuItem.attributes.label); // Add listener. my_menu.addEventListener("rollOut", menuListener); Menu.rollOver Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage Usage 1: var listenerObject:Object = new Object(); listenerObject.rollOver = function(eventObject:Object) { // Insert your code here.
  • Page 932 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 Menu.rollOver object has one additional property:...
  • Page 933: Menu.setmenuitemenabled()

    Menu.setMenuItemEnabled() Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage menuInstance.setMenuItemEnabled(item, enable) Parameters An XML node; the target menu item’s node in the data provider. item A Boolean value indicating whether the item is enabled ( ) or not ( enable true false...
  • Page 934: Menu.setmenuitemselected()

    // Add the menu items. menuDP_obj.addMenuItem({label:"1st Item"}); menuDP_obj.addMenuItem({label:"2nd Item"}); // Create the Menu object. var my_menu:Menu = Menu.createMenu(this, menuDP_obj); // Select the first menu item and disable it. var item_obj:Object = my_menu.getMenuItemAt(0); my_menu.setMenuItemEnabled(item_obj, false); // Show and position the menu. my_menu.show(100, 20);...
  • Page 935 Description Method; changes the attribute of the item to the state specified by the selected select parameter. If this call results in a change of state, the item is redrawn with the new state. This is only meaningful for items whose attribute is set to , because it type...
  • Page 936: Menu.show()

    Menu.show() Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage menuInstance.show(x, y) 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 937: Menudataprovider Class

    my_xml.addMenuItem({label:"Quit", instanceName:"miQuit"}); // Create and show the menu. var my_menu:Menu = Menu.createMenu(myParent_mc, my_xml); my_menu.show(100, 20); See also Menu.hide() MenuDataProvider class ActionScript Class Name mx.controls.menuclasses.MenuDataProvider The MenuDataProvider class is a decorator (mix-in) class that adds functionality to the XMLNode global class. This functionality lets XML instances assigned to a property use the MenuDataProvider methods and properties to Menu.dataProvider manipulate their own data as well as the associated menu views.
  • Page 938: Menudataprovider.addmenuitem()

    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 MenuDataProvider.getMenuItemAt() location.
  • Page 939 Description Method; Usage 1 adds a child item to the end of a parent menu item (which could be the menu itself ). The menu item is constructed from the values passed in the initObject parameter. Usage 2 adds a child item that is defined in the specified XML childMenuItem parameter to the end of a parent menu item.
  • Page 940: Menudataprovider.addmenuitemat()

    MenuDataProvider.addMenuItemAt() Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage Usage 1: myMenuDataProvider.addMenuItemAt(index, initObject) Usage 2: myMenuDataProvider.addMenuItemAt(index, childMenuItem) Parameters An integer. index An object containing the specific attributes that initialize a Menu item’s initObject attributes. For more information, see “About menu item XML attributes”...
  • Page 941 You first drag a Menu component to the library and then add the following code to Frame 1: Requires: - Menu component in library import mx.controls.Menu; // Create an XML object to act as a factory. var my_xml:XML = new XML(); // The item created next does not appear in the menu.
  • Page 942: Menudataprovider.getmenuitemat()

    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 943: Menudataprovider.indexof()

    // root element and give it a convenient name. var menuDP_obj:Object = my_xml.addMenuItem("XXXXX"); // Add the menu items. menuDP_obj.addMenuItem({label:"1st Item"}); var menuItem_obj:Object = menuDP_obj.getMenuItemAt(0); menuItem_obj.addMenuItem({label:"Submenu Item"}); menuDP_obj.addMenuItem({label:"2nd Item"}); // Create the Menu object. var my_menu:Menu = Menu.createMenu(this, menuDP_obj); // Show and position the menus. my_menu.show(100, 20);...
  • Page 944 Example The following example adds a menu item to a menu and calls the method to indexOf() display the item’s index in the Output panel. You first drag a Menu component to the library and then add the following code to Frame 1: Requires: - Menu component in library import mx.controls.Menu;...
  • Page 945: Menudataprovider.removemenuitem()

    MenuDataProvider.removeMenuItem() Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage myMenuDataProvider.removeMenuItem() Returns A reference to the removed Menu item (XML node); if an error occurs. undefined Description Method; removes the target item and any child nodes. Any node or menu item in a MenuDataProvider instance can call the methods of the MenuDataProvider class.
  • Page 946 You first drag a Menu component to the library and then add the following code to Frame 1: Requires: - Menu component in library import mx.controls.Menu; // Create an XML object to act as a factory. var my_xml:XML = new XML(); // The item created next does not appear in the menu.
  • Page 947: Menudataprovider.removemenuitemat()

    MenuDataProvider.removeMenuItemAt() Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage myMenuDataProvider.removeMenuItemAt(index) 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.
  • Page 948 You first drag a Menu component to the library and then add the following code to Frame 1: Requires: - Menu component in library import mx.controls.Menu; // Create an XML object to act as a factory. var my_xml:XML = new XML(); // The item created next does not appear in the menu.
  • Page 949 CHAPTER 31 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 950: Using The Menubar Component (Flash Professional Only)

    Interacting with the MenuBar component (Flash Professional only) You can use the mouse and keyboard to interact with a MenuBar component. Rolling over a menu activator displays an outset border highlight around the activator label. When a MenuBar instance has focus either from clicking or tabbing, you can use the following keys to control it: Description Down Arrow...
  • Page 951 visible is a Boolean value that indicates whether the object is visible ( ) or not ( true false The default value is true The minHeight and minWidth properties are used by internal sizing routines. They are defined in UIObject, and are overridden by different components as needed. These properties can be used if you make a custom layout manager for your application.
  • Page 952: Customizing The Menubar Component (Flash Professional Only)

    In the Actions panel on Frame 1, enter the following code: //Create listener object. var mbListener:Object = new Object(); mbListener.change = function(evt_obj:Object) { var menuItem_obj:Object = evt_obj.menuItem; switch (menuItem_obj.attributes.instanceName) { case "newInstance": trace("New menu item"); break; case "openInstance": trace("Open menu item"); break;...
  • Page 953 Using styles with the MenuBar component The MenuBar component creates an activator label for each menu in a group. You can use styles to change the look of the activator labels. A MenuBar component supports the following styles: Style Theme Description Halo The base color scheme of a component.
  • Page 954 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 in the following table. For information about skinning the Menu component, see “Using skins with the Menu component”...
  • Page 955: Menubar Class (Flash Professional Only)

    Select Control > Test Movie. The border used to highlight individual items in a MenuBar component is an instance of ActivatorSkin found in the Flash UI Components 2/Themes/MMDefault/Button Assets folder. This symbol can be customized to point to a different class to provide a different border.
  • Page 956 Methods inherited from the UIObject class The following table lists the methods the MenuBar class inherits from the UIObject class. When calling these methods from the MenuBar object, use the form MenuBar.methodName Method Description Creates an object on the specified class. UIObject.createClassObject() Creates a subobject on an object.
  • Page 957 Property summary for the MenuBar class The following table lists properties of the MenuBar class. Property Description The data model for a menu bar. MenuBar.dataProvider A string that determines which attribute of each XMLNode to MenuBar.labelField use as the label text of the menu. A function that determines what to display in each menu’s MenuBar.labelFunction label.
  • Page 958 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 UIComponent.enabled input.
  • Page 959: Menubar.addmenu()

    Event Description 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 MenuBar class inherits from the UIComponent class. When calling these events from the MenuBar object, use the form MenuBar.eventName Event...
  • Page 960 Returns A reference to the new Menu object. Description Method; Usage 1 adds a single menu and menu activator at the end of the menu bar and uses the specified label. Usage 2 adds a single menu and menu activator that are defined in the specified XML parameter.
  • Page 961: Menubar.addmenuat()

    MenuBar.addMenuAt() Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage Usage 1: menuBarInstance.addMenuAt(index, label) Usage 2: menuBarInstance.addMenuAt(index, label, menuDataProvider) Parameters An integer indicating the position where the menu should be inserted. The first index position is 0. To append to the end of the menu, call MenuBar.addMenu(label) A string indicating the label of the new menu.
  • Page 962: Menubar.dataprovider

    Requires: - MenuBar component on Stage (instance name: my_mb) var my_mb:mx.controls.MenuBar; var my_menu:mx.controls.Menu = my_mb.addMenuAt(0, "Flash"); my_menu.addMenuItem({label:"About Macromedia Flash", instanceName:"aboutInst"}); my_menu.addMenuItem({label:"Preferences", instanceName:"PrefInst"}); Usage 2: The following example adds an Edit menu with the menu items Undo, Redo, Cut, and Copy, which are defined in the XML data provider .
  • Page 963 Usage menuBarInstance.dataProvider Description Property; the data model for items in a MenuBar component. is an XML node object. Setting this property replaces the existing MenuBar.dataProvider data model of the MenuBar component. Whatever child nodes the data provider might have are used as the items for the menu bar itself; any subnodes of these child nodes are used as the items for their respective menus.
  • Page 964: Menubar.getmenuat()

    MenuBar.getMenuAt() Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage menuBarInstance.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 965: Menubar.getmenuenabledat()

    MenuBar.getMenuEnabledAt() Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage menuBarInstance.getMenuEnabledAt(index) Parameters The index of the menu in the menu bar. index Returns A Boolean value that indicates whether this menu can be chosen ( ) or not ( true false Description...
  • Page 966: Menubar.labelfield

    MenuBar.labelField Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage menuBarInstance.labelField Description Property; a string that specifies which attribute of each XML node to use as the label text of the menu. The value of this property is also passed to any menus that are created from the menu bar.
  • Page 967: Menubar.labelfunction

    MenuBar.labelFunction Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage menuBarInstance.labelFunction Description Property; a function that determines what to display in each menu’s label text. The function accepts the XML node associated with an item as a parameter and returns a string to be used as label text.
  • Page 968: Menubar.removeall()

    MenuBar.removeAll() Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage menuBarInstance.removeAll() Parameters None. Returns Nothing. Description Method; removes all menu items on the menu bar. Example The following example creates File, Edit, Tools, and Window menus on the menu bar. Then when a button is clicked, the script calls to remove the menu items.
  • Page 969: Menubar.removemenuat()

    MenuBar.removeMenuAt() Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage menuBarInstance.removeMenuAt(index) Parameters The index of the menu to be removed from the menu bar. index Returns A reference to the menu at the specified index in the menu bar. This value is undefined there is no menu in that position in the menu bar.
  • Page 970: Menubar.setmenuenabledat()

    Drag an instance of the MenuBar component onto the Stage, and enter the instance name in the Property inspector. Add the following code to Frame 1 of the timeline: my_mb Requires: - MenuBar component on Stage (instance name: my_mb) import mx.controls.Menu; import mx.controls.MenuBar;...
  • Page 971 Description Method; enables the menu at the specified index. If there is no menu at that index, calling this method has no effect. Example The following example adds a File menu to the menu bar and calls the setMenuEnabledAt method to enable or disable the menu, depending on whether the menuEnabled_ch check box is selected or clear.
  • Page 972 MenuBar component (Flash Professional only)
  • Page 973: Chapter 32: Numericstepper Component

    CHAPTER 32 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 stepSize...
  • Page 974: Using The Numericstepper Component

    For more information about controlling focus, see “FocusManager class” on page 721 “Creating custom focus navigation” in Using Components. A live preview of each stepper instance reflects the setting of the value parameter in the Property inspector or Component inspector during authoring. However, there is no mouse or keyboard interaction with the stepper’s arrow buttons in the live preview.
  • Page 975 You can set the following additional parameters for each NumericStepper component instance in the Component inspector (Window > Component Inspector): enabled is a Boolean value that indicates whether the component can receive focus and input. The default value is true visible is a Boolean value that indicates whether the object is visible ( ) or not (...
  • Page 976: Customizing The Numericstepper Component

    Select Frame 1 in the Timeline, open the Actions panel, and enter the following code: Requires: - NumericStepper component on Stage (instance name: my_nstep) - Label component on Stage (instance name: my_label) var my_nstep:mx.controls.NumericStepper; var my_label:mx.controls.Label; my_label.text = "value = " + my_nstep.value; //Create listener object.
  • Page 977 Using styles with the NumericStepper component You can set style properties to change the appearance of a NumericStepper instance. If the name of a style property ends in “Color”, it is a color style property and behaves differently than noncolor style properties. For more information, see “Using styles to customize component color and text”...
  • Page 978 Style Theme Description Both The number of milliseconds between automatic clicks repeatInterval when a user holds the mouse button down on a button. The default value is 35. Sample The color of the arrows. The default value is 0x2B333C symbolColor (dark gray).
  • Page 979: Numericstepper Class

    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 980 The NumericStepper component uses the Focus Manager to override the default Flash Player focus rectangle and draw a custom focus rectangle with rounded corners. For more information, see “Creating custom focus navigation” in Using Components. Each component class has a property, which is a class property.
  • Page 981 Methods inherited from the UIComponent class The following table lists the methods the NumericStepper class inherits from the UIComponent class. When calling these methods from the NumericStepper object, use the form NumericStepper.methodName Method Description Returns a reference to the object that has focus. UIComponent.getFocus() Sets focus to the component instance.
  • Page 982 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 UIObject.top parent.
  • Page 983 Events inherited from the UIObject class The following table lists the events the NumericStepper class inherits from the UIObject class. When calling these events from the NumericStepper object, use the form NumericStepper.eventName Event Description Broadcast when an object is about to draw its graphics. UIObject.draw Broadcast when an object’s state changes from visible to UIObject.hide...
  • Page 984: Numericstepper.change

    NumericStepper.change Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage Usage 1: var listenerObject:Object = new Object(); listenerObject.change = function(eventObject:Object) { //... numericStepperInstance.addEventListener("change", listenerObject); Usage 2: on (change) { // ... Description Event; broadcast to all registered listeners when the value of the stepper is changed. A component instance ( ) dispatches an event (in this case, ) and the...
  • Page 985: Numericstepper.maximum

    Drag an instance of the NumericStepper component onto the Stage, and enter the instance name in the Property inspector. Add the following code to Frame 1 of the timeline: my_nstep Requires: - NumericStepper component on Stage (instance name: my_nstep) var my_nstep:mx.controls.NumericStepper; // Create listener object.
  • Page 986 Drag an instance of the NumericStepper component onto the Stage, and enter the instance name in the Property inspector. Add the following code to Frame 1 of the timeline: my_nstep Requires: - NumericStepper component on Stage (instance name: my_nstep) var my_nstep:mx.controls.NumericStepper; my_nstep.maximum = 20;...
  • Page 987: Numericstepper.nextvalue

    See also NumericStepper.maximum NumericStepper.nextValue Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage numericStepperInstance.nextValue Description Property (read-only); the next sequential value. This property can contain a number of up to three decimal places. Example The following example sets the initial value of the NumericStepper component instance to -6 and sets the property to 3.
  • Page 988: Numericstepper.previousvalue

    NumericStepper.previousValue Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage numericStepperInstance.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 initial value of the NumericStepper instance to equal the minimum value of 6.
  • Page 989: Numericstepper.stepsize

    See also NumericStepper.nextValue NumericStepper.stepSize Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage numericStepperInstance.stepSize Description Property; the unit amount to change from the current value. The default value is 1. This value cannot be 0. This property can contain a number of up to three decimal places. Example The following example sets the initial value of the NumericStepper instance to equal the minimum value of 3.
  • Page 990: Numericstepper.value

    NumericStepper.value Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage numericStepperInstance.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.
  • Page 991: Chapter 33: Popupmanager Class

    CHAPTER 33 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 992: Popupmanager.createpopup()

    PopUpManager.createPopUp() Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004 and Flash MX Professional 2004. Usage PopUpManager.createPopUp(parent, class, modal [, initobj, outsideEvents]) Parameters A reference to a window to pop-up over. parent A reference to the class of object you want to create. class A Boolean value indicating whether the window is modal ( ) or not (...
  • Page 993: Popupmanager.deletepopup()

    PopUpManager.deletePopUp() Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004 and Flash MX Professional 2004 Usage windowInstance.deletePopUp(); Parameters None. Returns Nothing. Description Method; deletes a pop-up window and removes the modal state. It is the responsibility of the overlapped window to call when the window is being PopUpManager.deletePopUp() destroyed.
  • Page 994 PopUpManager class...
  • Page 995: Chapter 34: Progressbar Component

    CHAPTER 34 ProgressBar component The ProgressBar component displays the progress of loading content. The ProgressBar is useful for displaying the status of loading images and pieces of an application. 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.
  • Page 996 ProgressBar parameters You can set the following authoring parameters for each ProgressBar instance in the Property inspector or in the Component inspector (Window > Component Inspector menu option): conversion is a number by which to divide the %1 and %2 values in the label string before they are displayed.
  • Page 997 Creating an application with the ProgressBar component The following procedure explains how to add a ProgressBar component to an application while authoring. In this example, the progress bar is used in event mode. In event mode, the loading content must emit events that the progress bar uses to progress complete...
  • Page 998 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, enter the instance name my_pb. Select Frame 1 in the Timeline, open the Actions panel, and enter the following code, which creates a Sound object called and calls to load a sound into...
  • Page 999 To create an application with the ProgressBar component in manual mode: Drag a ProgressBar component from the Components panel to the Stage. In the Property inspector, do the following: Enter the instance name my_pb. Select Manual for the mode parameter. Select Frame 1 in the Timeline, open the Actions panel, and enter the following code, which updates the progress bar manually on every file download by using calls to setProgress()
  • Page 1000: Customizing The Progressbar Component

    To create an application with the ProgressBar component in manual mode (example 3): Drag a ProgressBar component onto the Stage and give it an instance name my_pb. Select the my_pb ProgressBar on the Stage and, in the Property inspector, set the component's mode parameter to "manual".

This manual is also suitable for:

Flash 8

Table of Contents