-
Components Language Reference
-
Trademarks 1 Step RoboPDF, ActiveEdit, ActiveTest, Authorware, Blue Sky Software, Blue Sky, Breeze, Breezo, Captivate, Central, ColdFusion, Contribute, Database Explorer, Director, Dreamweaver, Fireworks, Flash, FlashCast, FlashHelp, Flash Lite, FlashPaper, Flash Video Encoder, Flex, Flex Builder, Fontographer, FreeHand, Generator, HomeSite, JRun, MacRecorder, Macromedia, MXML, RoboEngine, RoboHelp, RoboInfo, RoboPDF, Roundtrip, Roundtrip HTML, Shockwave, SoundEdit, Studio MX, UltraDev, and WebHelp are eith
-
Contents Chapter 1: Components Dictionary . . . . . . . . . . . . . . . . . . . . . . . . 29 Types of components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30 Other listings in this chapter. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33 Chapter 2: Accordion component (Flash Professional only) . . . 35 Using the Accordion component (Flash Professional only) . . . . . . . . 36 Customizing the Accordion component (Flash Professional only) . .
-
Chapter 4: Button component . . . . . . . . . . . . . . . . . . . . . . . . . . . .89 Using the Button component . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90 Customizing the Button component . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94 Button class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .101 Button.icon . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
-
Chapter 8: ComboBox component . . . . . . . . . . . . . . . . . . . . . . . . 157 Using the ComboBox component . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .159 Customizing the ComboBox component . . . . . . . . . . . . . . . . . . . . . . . .162 ComboBox class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .165 ComboBox.addItem() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171 ComboBox.addItemAt() . . . . . . . . .
-
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) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 208 Binding class (Flash Professional only) . . . . . . . . . . . . . . . . . . . . . . . . 208 Constructor for the Binding class. . . . . . . . . . .
-
TypedValue.type. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 246 TypedValue.typeName . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 247 TypedValue.value . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 247 Chapter 10: DataGrid component (Flash Professional only) . . 249 Interacting with the DataGrid component (Flash Professional only) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
-
DataGridColumn.columnName . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 303 DataGridColumn.editable . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 304 DataGridColumn.headerRenderer. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 306 DataGridColumn.headerText . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 306 DataGridColumn.labelFunction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .307 DataGridColumn.resizable . . . . . .
-
DataSet.calcFields. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 348 DataSet.changesPending() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 349 DataSet.clear() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 350 DataSet.createItem() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .351 DataSet.currentItem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
-
DataSet.removeSort() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 399 DataSet.resolveDelta . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 401 DataSet.saveToSharedObj() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 402 DataSet.schema . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 404 DataSet.selectedIndex . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
-
DateField.firstDayOfWeek. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 452 DateField.monthNames . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 452 DateField.open(). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 453 DateField.open . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 454 DateField.pullDown . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
-
Chapter 20: DepthManager class . . . . . . . . . . . . . . . . . . . . . . . .487 DepthManager.createChildAtDepth() . . . . . . . . . . . . . . . . . . . . . . . . . 489 DepthManager.createClassChildAtDepth() . . . . . . . . . . . . . . . . . . . . 490 DepthManager.createClassObjectAtDepth() . . . . . . . . . . . . . . . . . . . . 491 DepthManager.createObjectAtDepth() . . . . . . . . . . . . . . . . . . . . . . . . 492 DepthManager.kBottom . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
-
FocusManager.getFocus(). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 731 FocusManager.nextTabIndex . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 732 FocusManager.sendDefaultPushButtonEvent(). . . . . . . . . . . . . . . . . 732 FocusManager.setFocus() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 734 Chapter 24: Form class (Flash Professional only) . . . . . . . . . . 735 Using the Form class (Flash Professional only). . . . . . . . .
-
List.iconField . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 784 List.iconFunction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 785 List.itemRollOut . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 786 List.itemRollOver. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 788 List.labelField . . . . . . . . . . . . . . . . . . . . . . .
-
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) . . . . . . . . . 843 Creating applications with media components (Flash Professional only) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
-
Media.removeCuePoint(). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 878 Media.setMedia(). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 879 Media.stop() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .880 Media.totalTime . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .880 Media.volume . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
-
Chapter 31: MenuBar component (Flash Professional only). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 945 Interacting with the MenuBar component (Flash Professional only) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 946 Using the MenuBar component (Flash Professional only) . . . . . . . . 946 Customizing the MenuBar component (Flash Professional only) . . 948 MenuBar class (Flash Professional only) . . . . . . . . . . . . . . . . . . . . . . . .951 MenuBar.
-
ProgressBar.label . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1008 ProgressBar.labelPlacement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1009 ProgressBar.maximum. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1010 ProgressBar.minimum . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1012 ProgressBar.mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
-
Chapter 38: RectBorder class. . . . . . . . . . . . . . . . . . . . . . . . . . 1063 Using styles with the RectBorder class . . . . . . . . . . . . . . . . . . . . . . . . 1064 Creating a custom RectBorder implementation . . . . . . . . . . . . . . . . 1067 Chapter 39: Screen class (Flash Professional only). . . . . . . . . 1071 Loading external content into screens (Flash Professional only) . 1072 Screen class (API) (Flash Professional only) . . . . . . . . . . . . . . . . . . . 1074 Screen.
-
ScrollPane.vLineScrollSize . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1119 ScrollPane.vPageScrollSize. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1120 ScrollPane.vPosition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1121 ScrollPane.vScrollPolicy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1122 Chapter 41: SimpleButton class . . . . . . . . . . . . . . . . . . . . . . . . . 1125 SimpleButton.
-
Chapter 43: StyleManager class . . . . . . . . . . . . . . . . . . . . . . . . .1171 StyleManager.registerColorName() . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1172 StyleManager.registerColorStyle(). . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1173 StyleManager.registerInheritingStyle() . . . . . . . . . . . . . . . . . . . . . . . . . 1174 Chapter 44: SystemManager class . . . . . . . . . . . . . . . . . . . . . . 1175 SystemManager.screen . . . . . . . . . . . . . . . . . . . . .
-
TextInput.password. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1228 TextInput.restrict . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1229 TextInput.text . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1231 Chapter 47: TransferObject interface . . . . . . . . . . . . . . . . . . . .1233 TransferObject.clone() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
-
Tree.getDisplayIndex() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1291 Tree.getIsBranch() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1293 Tree.getIsOpen() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1294 Tree.getNodeDisplayedAt() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1295 Tree.getTreeNodeAt(). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
-
Chapter 52: UIComponent class. . . . . . . . . . . . . . . . . . . . . . . . .1339 UIComponent class (API) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1339 UIComponent.enabled . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1343 UIComponent.focusIn. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1343 UIComponent.focusOut . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1345 UIComponent.
-
UIObject.right . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1379 UIObject.scaleX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1379 UIObject.scaleY . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1380 UIObject.setSize() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1381 UIObject.setSkin() . . . . . . . . . . . . . . . . . . . . . . . . . . .
-
PendingCall.getOutputValues() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1429 PendingCall.myCall . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1430 PendingCall.onFault . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1430 PendingCall.onResult . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1432 PendingCall.request . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
-
Window.closeButton . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1478 Window.complete . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1479 Window.content . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1481 Window.contentPath. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1482 Window.deletePopUp() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
-
Contents
-
1 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.
-
Types of components The following tables list the different components, arranged by category, in version 2 of the Macromedia Component Architecture. User interface (UI) components Component Description Accordion component (Flash A set of vertical overlapping views with buttons along the top Professional only) that allow users to switch views. Alert component (Flash Professional only) A window that presents a message and buttons to capture the user’s response.
-
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 Professional only) Allows a user to manipulate hierarchical information. Window component A draggable window with a title bar, caption, border, and Close button and content-display area.
-
Media components Component Description FLVPlayback Component (Flash Professional Only) Lets you include a video player in your Flash application to play progressive streaming video over HTTP, from a Flash Video Streaming Service (FVSS), or from Flash Communication Server (FCS). MediaController component (Flash Professional only) Controls streaming media playback in an application (see “Media components (Flash Professional only)” on page 831).
-
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 rows.
-
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 (Flash Professional only) A set of properties and methods used to create XML for the Tree.dataProvider property. Tween class Lets you use ActionScript to move, resize, and fade movie clips easily on the Stage.
-
CHAPTER 2 2 Accordion component (Flash Professional only) The Accordion component is a navigator that contains a sequence of children that it displays one at a time. The children must be objects that inherit from the UIObject class (which includes all components and screens built with version 2 of the Macromedia Component Architecture); most often, children are a subclass of the View class. This includes movie clips assigned to the class mx.core.View.
-
Key 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. Tab Moves focus to the next component. This component may be inside the selected child, or outside the accordion; it is never another header in the same accordion.
-
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 (true) or not (false). The default value is true. N OT E 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.
-
6. Create a new screen named accordionForm. 7. Drag an Accordion component from the Components panel to the accordionForm form, and name it my_acc. 8. 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.
-
8. In the Property inspector, do the following: ■ ■ Enter the instance name my_acc. For the childSymbols property, enter AddressForm, AddressForm, and CheckoutForm. These strings specify the names of the movie clips used to create the accordion’s children. NO TE ■ The first two children are instances of the same movie clip, because the shipping address form and the billing address form are identical. For the childNames property, enter shippingAddress, billingAddress, and checkout.
-
6. 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"}); // Set position of text input. firstNameChild_obj.move(10, 38); firstNameChild_obj.setSize(110, 20); // Create another child text input.
-
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 themeColor Halo The base color scheme of a component. This is the only color style that doesn’t inherit its value. Possible values are "haloGreen", "haloBlue", and "haloOrange". backgroundColor Both The background color. The default color is white.
-
Style Theme Description textDecoration Both The text decoration; either "none" or "underline". openDuration Both The duration, in milliseconds, of the transition animation. openEasing Both A reference to a tweening function that controls the animation. Defaults to sine in/out. For more information, see “Customizing component animations” in Using Components. So, for example, the following code sets the style appearance of the font within an accordion instance named my_acc to italic: my_acc.
-
Property Description Default value trueDownSkin The pressed state of the header above the expanded child. accordionHeaderSkin trueOverSkin The rolled-over state of the header above the expanded child. accordionHeaderSkin trueDisabledSkin The disabled state of the header above the expanded child.
-
To create an ActionScript-customized Accordion header skin: 1. Create a new ActionScript class file. For this example, name the file RedGreenBlueHeader.as. 2. Copy the following ActionScript to the file: import mx.skins.RectBorder; import mx.core.ext.
-
_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. 3. Save the file. 4. Create a new FLA file and save it in the same folder as the AS file. 5.
-
To create movie clip symbols for Accordion header skins: 1. Create a new FLA file. 2. Create a new symbol by selecting Insert > New Symbol. 3. Set the name to RedAccordionHeaderSkin. 4. If the advanced view is not displayed, click the Advanced button. 5. Select Export for ActionScript. The identifier is automatically filled out with RedAccordionHeaderSkin. 6. Leave the AS 2.0 Class text box blank. 7. Make sure that Export in First Frame is already selected, and click OK. 8.
-
Accordion class (Flash Professional only) Inheritance MovieClip > UIObject class > UIComponent class > View > Accordion ActionScript Class Name mx.containers.Accordion An Accordion component contains children that are displayed one at a time. Each child has a corresponding header button that is created when the child is created. A child must be an instance of UIObject. A movie clip symbol automatically becomes an instance of the UIObject class when it becomes a child of an accordion.
-
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 UIObject.createClassObject() Creates an object on the specified class. UIObject.createObject() Creates a subobject on an object. UIObject.destroyObject() Destroys a component instance. UIObject.
-
Property summary for the Accordion class The following table lists properties of the Accordion class. Property Description Accordion.numChildren The number of children of an Accordion instance. Accordion.selectedChild A reference to the selected child. Accordion.selectedIndex The index position of the selected child. Properties inherited from the UIObject class The following table lists the properties the Accordion class inherits from the UIObject class.
-
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 UIComponent.enabled Indicates whether the component can receive focus and input. UIComponent.tabIndex A number indicating the tab order for a component in a document.
-
Events inherited from the UIComponent class The following table lists the events the Accordion class inherits from the UIComponent class. Event Description UIComponent.focusIn Broadcast when an object receives focus. UIComponent.focusOut Broadcast when an object loses focus. UIComponent.keyDown Broadcast when a key is pressed. UIComponent.keyUp Broadcast when a key is released. Accordion.change Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004.
-
When the event is triggered, it automatically passes an event object (eventObject) to the handler. Each event object has properties that contain information about the event. You can use these properties to write code that handles the event. For more information, see “EventDispatcher class” on page 499. The Accordion change event also contains two unique event object properties: ■ newValue ■ prevValue Number; the index of the child that is about to be selected.
-
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 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.
-
Example Start with an Accordion instance on the Stage named my_acc. Add a symbol to the library with the Linkage Identifier payIcon to be the icon for the child header. The following code creates a child named billing (with the label “Payment”) that is an instance of the View class: var child_obj:Object = my_acc.createChild(mx.core.
-
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 UIObject to be instantiated, or the linkage name of the symbol to be instantiated.
-
Example Start with an Accordion instance on the Stage named my_acc. Add a movie clip symbol to the library with the Linkage Identifier PaymentForm to be the Accordion child. Then, add a symbol to the library with Linkage Identifier payIcon to be the icon for the child header. The following example creates an instance of the PaymentForm movie clip symbol named billing as the last child of my_acc with header label “Payment” and the icon in the library: var child_obj:Object = my_acc.
-
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 assigned a zero-based index number in the order in which it was created. index Returns Nothing. Description Method (inherited from View); destroys one of the accordion’s children.
-
Example The following code destroys the first child of my_acc when the third child is selected: 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. my_accListener = new Object(); my_accListener.change = function() { if ("myMainItem3"){ my_acc.destroyChildAt(0); } }; my_acc.
-
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 my_acc and 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.
-
Example The following code gets a reference to the last header of my_acc and displays the label in the 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"}); my_acc.createChild(View, "payment", {label: "Payment"}); var head3:Object = my_acc.getHeaderAt(2); trace(head3.label); Accordion.
-
Example The following code uses numChildren to get a reference to the last child of my_acc and 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"); // Get reference for last child object. var lastChild_obj:Object = my_acc.getChildAt(my_acc.
-
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.
-
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 zerobased, so the first child is 0, the second child is 1, and so on. The valid values of selectedIndex are 0, 1, 2, ... , n - 1, where n is the number of children.
-
Accordion component (Flash Professional only)
-
CHAPTER 3 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. An Alert window can have any combination of Yes, No, OK, and Cancel buttons, and you can change the button labels by using the Alert.okLabel, Alert.yesLabel, Alert.noLabel, and Alert.cancelLabel properties.
-
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. Alert parameters The Alert component has no authoring parameters. You must call the ActionScript Alert.show() method to display an Alert window.
-
This code creates an Alert window with OK and Cancel buttons. When the user clicks either button, Flash calls the myClickHandler function. The myClickHandler function instructs Flash to trace “start stock app” when you click the OK button. NO T E 3. The Alert.show() method includes an optional parameter that displays an icon in the Alert window (in this example, an icon with the linkage identifier “stockIcon”).
-
Style Theme Description borderStyle Both The Alert component uses a RectBorder instance as its 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 borderStyle setting of “alert” with the Halo theme and “outset” with the Sample theme. color Both The text color. The default value is 0x0B333C for the Halo theme and blank for the Sample theme.
-
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 buttonStyleDeclaration Button messageStyleDeclaration Message titleStyleDeclaration Title The following example demonstrates how to set the title of an Alert component to be italicized: import mx.controls.Alert; import mx.styles.CSSStyleDeclaration; var titleStyles = new CSSStyleDeclaration(); titleStyles.
-
An Alert component uses the following skin properties to dynamically skin the buttons and title bar: Property Description Default value buttonUp The up state of the buttons. ButtonSkin buttonUpEmphasized The up state of the default button. ButtonSkin buttonDown The pressed state of the buttons. ButtonSkin buttonDownEmphasized The pressed state of the default button. ButtonSkin buttonOver The rolled-over state of the buttons.
-
15. 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. 16. 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"); 17. Select Control > Test Movie.
-
Methods inherited from the UIObject class The following table lists the methods the Alert class inherits from the UIObject class. Method Description UIObject.createClassObject Creates an object on the specified class. () UIObject.createObject() Creates a subobject on an object. UIObject.destroyObject() Destroys a component instance. UIObject.doLater() Calls a function when parameters have been set in the Property and Component inspectors. UIObject.
-
Property summary for the Alert class The following table lists properties of the Alert class. Property Description Alert.buttonHeight The height of each button, in pixels. The default value is 22. Alert.buttonWidth The width of each button, in pixels. The default value is 100. Alert.CANCEL A constant hexadecimal value indicating whether a Cancel button should be displayed in the Alert window. Alert.cancelLabel The label text for the Cancel button. Alert.
-
Property Description UIObject.top Read-only; the position of the top edge of the object, relative to its parent. UIObject.visible A Boolean value indicating whether the object is visible (true) or not (false). UIObject.width Read-only; the width of the object, in pixels. UIObject.x Read-only; the left edge of the object, in pixels. UIObject.y Read-only; the top edge of the object, in pixels.
-
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 UIObject.draw Broadcast when an object is about to draw its graphics. UIObject.hide Broadcast when an object’s state changes from visible to invisible. UIObject.load Broadcast when subobjects are being created. UIObject.move Broadcast when the object has moved. UIObject.
-
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; // Adjust button sizes. Alert.buttonHeight = 50; Alert.buttonWidth = 150; // Show alert dialog box. Alert.
-
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; // Adjust button sizes. Alert.buttonHeight = 50; Alert.buttonWidth = 150; // Show alert dialog box. Alert.show("Launch Stock Application?", "Stock Price Alert", Alert.OK | Alert.CANCEL); See also Alert.
-
Example The following example uses Alert.CANCEL and Alert.OK as values for the flags parameter 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). Edition Flash MX Professional 2004. Usage Alert.
-
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.
-
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 myClickHandler. The event handler is passed to the Alert.show() method as the fifth parameter. The event object is captured by myClickHandler in the evt parameter. The detail property of the event object is then used in a trace statement to send the name of the button that was clicked (Alert.OK or Alert.CANCEL) to the Output panel. import mx.controls.
-
Description Property (constant); a property with the constant hexadecimal value 0x2. This property can be used for the flags or defaultButton parameter of the Alert.show() method. When used as a value for the flags parameter, this property indicates that a No button should be displayed in the Alert window. When used as a value for the defaultButton parameter, the Cancel button has initial focus and is triggered when the user presses Enter (Windows) or Return (Macintosh).
-
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 flags parameter of the Alert.show() method. This property indicates that an Alert window should be nonmodal, which allows users to interact with buttons and instances underneath the displayed window. By default, windows generated with Alert.
-
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 flags or defaultButton parameter of the Alert.
-
Alert.okLabel Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage Alert.okLabel Description Property (class); a class (static) property that indicates the label text on the OK button. Example The following example sets the OK button’s label to “okay”: Alert.okLabel = "okay"; Alert.show() Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage Alert.
-
You can also use Alert.NONMODAL to indicate that the Alert window is nonmodal. A 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 window. Use the value null or undefined to specify the _root timeline.
-
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; // Define button actions. var myClickHandler:Function = function (evt_obj:Object) { if (evt_obj.detail == Alert.OK) { trace(Alert.okLabel); } else if (evt_obj.detail == Alert.CANCEL) { trace(Alert.
-
Example The following example uses Alert.NO and Alert.YES as values for the flags parameter and 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). Edition Flash MX Professional 2004. Usage Alert.yesLabel Description Property (class); a class (static) property that indicates the label text on the Yes button.
-
Alert component (Flash Professional only)
-
4 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. In the disabled state, a button doesn’t receive mouse or keyboard input. An enabled button receives focus if you click it or tab to it.
-
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. The symbol should be registered at 0,0 for appropriate layout on the button.
-
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 (true) or not (false). The default value is true. N OT E 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.
-
4. Select Control > Test Movie. 5. When you click the button, Flash displays the message “You clicked the button!”. To create a Button using ActionScript: 1. 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. 2. 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.
-
3. 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); this.createClassObject(mx.controls.
-
Customizing the Button component You can transform a Button component horizontally and vertically while authoring and at runtime. While authoring, select the component on the Stage and use the Free Transform tool or any of the Modify > Transform commands. At runtime, use the setSize() method (see UIObject.setSize()) or any applicable properties and methods of the Button class (see “Button class” on page 101). Resizing the button does not change the size of the icon or label.
-
Style Theme Description color Both The text color. The default value is 0x0B333C for the Halo theme and blank for the Sample theme. disabledColor Both The color for text when the component is disabled. The default color is 0x848384 (dark gray). embedFonts Both A Boolean value that indicates whether the font specified in fontFamily is an embedded font. This style must be set to true if fontFamily refers to an embedded font. Otherwise, the embedded font is not used.
-
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 emphasized Provides two different looks for Button instances and is typically used to highlight one button, such as the default button in a form. enabled Shows whether or not the button is allowing user interaction.
-
Property Description falseDownSkinEmphasized The pressed state of an emphasized button. falseOverSkinEmphasized The over state of an emphasized button. falseDisabledSkinEmphasized The disabled state of an emphasized button. trueUpSkinEmphasized The toggled state of an emphasized button. trueDownSkinEmphasized The pressed-toggled state of an emphasized button. trueOverSkinEmphasized The over-toggled state of an emphasized button.
-
In addition to the icon skins, the Button component also supports a standard icon property. 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. If a Button instance has both the icon property and icon style properties set, the instance may not behave as anticipated.
-
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; } clear(); var thickness = _parent.emphasized ? 2 : 0; lineStyle(thickness, 0, 100); beginFill(c, 100); drawRect(0, 0, __width, __height); endFill(); } // Required for skins.
-
3. Save the file. 4. Create a new FLA file and save it in the same folder as the AS file. 5. Create a new symbol by selecting Insert > New Symbol. 6. Set the name to ButtonSkin. 7. If the advanced view is not displayed, click the Advanced button. 8. Select Export for ActionScript. The identifier is automatically filled out with ButtonSkin. 9. Set the AS 2.0 class to RedGreenBlueSkin. 10. Make 11. sure that Export in First Frame is already selected, and click OK.
-
12. Repeat 13. steps 2-11 and create green and blue skins, named accordingly. Click the Back button to return to the main timeline. 14. Drag a Button component to the Stage. 15. Set the toggled property value to true to see all three skins. 16. Copy the following ActionScript code to the Actions panel with the Button instance selected.
-
Each component class has a version property, which is a class property. Class properties are available only on the class itself. The version property returns a string that indicates the version of the component. To access this property, use the following code: trace(mx.controls.Button.version); NO TE The code trace(myButtonInstance.version); returns undefined. The Button component class is different from the built-in ActionScript Button object.
-
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 UIComponent.getFocus() Returns a reference to the object that has focus. UIComponent.setFocus() Sets focus to the component instance. Property summary for the Button class The following table lists properties of the Button class.
-
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 UIObject.bottom Read-only; the position of the bottom edge of the object, relative to the bottom edge of its parent. UIObject.height Read-only; the height of the object, in pixels. UIObject.left Read-only; the left edge of the object, in pixels.
-
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 SimpleButton.click Broadcast when a button is clicked. Events inherited from the UIObject class The following table lists the events the Button class inherits from the UIObject class. Event Description UIObject.
-
Button.icon Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage buttonInstance.icon Description Property; a string that specifies the linkage identifier of a symbol in the library to be used as an icon for a button instance. The icon can be a movie clip symbol or a graphic symbol with an upper left registration point. You must resize the button if the icon is too large to fit; neither the button nor the icon resizes automatically.
-
You can also create the button and assign the icon entirely in ActionScript using the method UIObject.createClassObject() (you still must have already created an icon for the button with the linkage identifier happiness). First drag the Button component from the Components panel to the current document’s library, so the component appears in the library, but not on the Stage. Then, in the first frame of the main timeline, add the following ActionScript: this.createClassObject(mx.controls.
-
You can also create the button and assign the label entirely in ActionScript using the method UIObject.createClassObject(). First drag the Button component from the Components panel to the current document’s library, so the component appears in the library, but not on the Stage. Then, in the first frame of the main timeline, add the following ActionScript: this.createClassObject(mx.controls.Button, "my_button", 1, {label: "Test Button"}); See also Button.labelPlacement Button.
-
Example With a button on the Stage with instance name my_button, and a symbol in the Library panel with the linkage identifier happiness, the following code sets the label alignment to the left of the icon: my_button.icon = "happiness"; my_button.label = "Test Button"; my_button.labelPlacement = "left"; You can also create the button and set the alignment entirely in ActionScript using the method UIObject.createClassObject().
-
Button component
-
5 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. Understanding the List class To use the CellRenderer API, you need an advanced understanding of the List class.
-
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). In the default case, these cells are TextField objects that implement the CellRenderer API.
-
Using the CellRenderer API You must write a class with four methods (CellRenderer.getPreferredHeight(), CellRenderer.getPreferredWidth(), CellRenderer.setSize() and CellRenderer.setValue()) that the list-based component uses to communicate with the cell (if the class extends UIObject, you can use size() instead of CellRenderer.setSize()). The class must be specified in the AS 2.0 Class text box in the Linkage Properties dialog box of a movie clip symbol in your Flash application.
-
Simple cell renderer example This section presents an example of a cell renderer that displays multiple lines of text in a cell. 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.
-
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; // Starting depth. private var startDepth:Number = 1; // Constructor. Should be empty.
-
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; } // Called by the owner to set the value in the cell. Inherited method.
-
4. 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. 5. In the Name text box, type MultiLineCell. The default value for Type is Movie Clip. Leave Movie Clip selected. 6. Click the Export for ActionScript check box in the Linkage section.
-
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.
-
Additional cell renderer examples 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.
-
Methods provided by the CellRenderer API The List, DataGrid, Tree, and Menu components give the following methods to the cell when it is created within the component. You do not need to implement these methods. Method Description CellRenderer.getCellIndex() Returns an object with two fields, columnIndex and itemIndex, that indicate the position of the cell. CellRenderer.getDataLabel() Returns a string containing the name of the cell renderer’s data field.
-
Description Method; returns an object with two fields, columnIndex and itemIndex, that locate the cell 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 columnIndex is always 0. This method is provided by the List class; you do not have to implement it.
-
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 "Price", the variable p is now equal to "Price": var p = getDataLabel(); CellRenderer.getPreferredHeight() Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage componentInstance.getPreferredHeight() Parameters None. Returns The correct height for the cell.
-
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; } CellRenderer.getPreferredWidth() Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage componentInstance.getPreferredWidth() Parameters None.
-
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 getPreferredWidth() method: // function getPreferredWidth :: only for a menu or datagrid CellRenderer.listOwner Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage componentInstance.
-
CellRenderer.owner Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage componentInstance.owner Description Property; a reference to the row that contains the cell. This method is provided by the List class; you do not have to implement it. Declare it in your cell renderer class and use it as a reference: var owner:MovieClip; // or UIObject, etc. CellRenderer.setSize() Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage componentInstance.
-
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 size() method instead. Write the same function that you would write for setSize(), but use the width and height properties instead of parameters.
-
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 this object for rendering. item selected A string with the following possible values: "normal", "highlighted", and "selected". Returns Nothing. Description Method; takes the values given and creates a representation of them in the cell.
-
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. The data provider holds all the state information about the grid.
-
If you want to enable the check box on the second row, you communicate through the data provider. Any change to the data provider (when made through a DataProvider method such as DataProvider.editField()) calls setValue() to refresh the display of the grid. This code would be written in the Flash application, either on a frame, on an object, or in another class file (but not in the cell renderer class file): // calls setValue() again myGrid.
-
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 if statement is used to determine if the item parameter is undefined. If the item parameter is undefined, the radio button is hidden by setting its _visible property to false; otherwise, the radio button is updated with the new data and appears.
-
6 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. A check box can be enabled or disabled in an application. If a check box is enabled and a user clicks it or its label, the check box receives input focus and displays its pressed appearance.
-
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 true or false values that aren’t mutually exclusive.
-
To create an application with the CheckBox component: 1. Drag two TextInput components from the Components panel to the Stage. 2. In the Property inspector, enter the instance names minimumAge and maximumAge. 3. Drag a CheckBox component from the Components panel to the Stage. 4. In the Property inspector, do the following: 5. ■ Enter restrictAge for the instance name. ■ Enter Restrict Age for the label parameter.
-
4. 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 click event handler that enables and disables the minimumAge and maximumAge text field components. For more information, see CheckBox.
-
A CheckBox component supports the following styles: Style Theme Description themeColor Halo The base color scheme of a component. Possible values are "haloGreen", "haloBlue", and "haloOrange". The default value is "haloGreen". color Both The text color. The default value is 0x0B333C for the Halo theme and blank for the Sample theme. disabledColor Both The color for text when the component is disabled. The default color is 0x848384 (dark gray).
-
Style Theme Description symbolColor Sample The color of the check mark. The default value is 0x000000 (black). symbolDisabledColor Sample The color of the disabled check mark. The 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.
-
4. Expand the CheckBox Assets/States folder in the library of your document. 5. Open the symbols you want to customize for editing. For example, open the CheckFalseDisabled symbol. 6. Customize the symbol as desired. For example, change the inner white square to a light gray. 7. Repeat steps 5-6 for all symbols you want to customize. For example, repeat the color change for the inner box of the CheckTrueDisabled symbol. 8. Click the Back button to return to the main timeline. 9.
-
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 UIObject.createClassObject() Creates an object on the specified class. UIObject.createObject() Creates a subobject on an object. UIObject.
-
Property summary for the CheckBox class The following table lists properties of the CheckBox class. Property Description CheckBox.label Specifies the text that appears next to a check box. CheckBox.labelPlacement Specifies the orientation of the label text in relation to a check box. CheckBox.selected Specifies whether the check box is selected (true) or deselected (false).
-
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 UIComponent.enabled Indicates whether the component can receive focus and input. UIComponent.tabIndex A number indicating the tab order for a component in a document.
-
Event summary for the CheckBox class The following table lists an event of the CheckBox class. Event Description CheckBox.click Triggered when the mouse is clicked (released) over the check box, or if the check box has focus and the Spacebar is pressed. Events inherited from the UIObject class The following table lists the events the CheckBox class inherits from the UIObject class. Event Description UIObject.draw Broadcast when an object is about to draw its graphics. UIObject.
-
Events inherited from the SimpleButton class The following table lists the event the CheckBox class inherits from the SimpleButton class. Event Description SimpleButton.click Broadcast when a button is clicked. CheckBox.click Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage Usage 1: var listenerObject:Object = new Object(); listenerObject.click = function(eventObject:Object) { // ... }; checkBoxInstance.addEventListener("click", listenerObject); Usage 2: on (click) { // ...
-
The first usage example uses a dispatcher-listener event model. A component instance (checkBoxInstance) dispatches an event (in this case, click), and the event is handled by a function, also called a handler, on a listener object (listenerObject) that you create. You define a method with the same name as the event on the listener object; the method is called when the event is triggered. When the event is triggered, it automatically passes an event object (eventObject) to the listener object method.
-
The following code sends a message to the Output panel when checkBoxInstance is clicked. The on() handler must be attached directly to 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. Usage checkBoxInstance.label Description Property; indicates the text label for the check box. By default, the label appears to the right of the check box.
-
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). Then add the following ActionScript to the first frame of the main timeline: this.createClassObject(mx.controls.
-
The label is set below the check box. The check box and label are centered horizontally and vertically. ■ "bottom" ■ "top" The label is placed below the check box. The check box and label are centered horizontally and vertically. You can change the bounding area of a component while authoring by using the Transform command or at runtime using the UIObject.setSize() property. For more information, see “Customizing the CheckBox component” on page 132.
-
CheckBox.selected Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage checkBoxInstance.selected Description Property; a Boolean value that selects (true) or deselects (false) the check box. Example The following example shows a check box that has its selected property set to true, by default, and then uses the selected property within an event handler function to respond to the user clicking the check box. Drag the CheckBox component to the Stage.
-
146 CheckBox component
-
CHAPTER 7 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 collection items.
-
Method summary for the Collection interface The following table lists the methods of the Collection interface. Method Description Collection.addItem() Adds a new item to the end of the collection. Collection.contains() Indicates whether the collection contains the specified item. Collection.clear() Removes all elements from the collection. Collection.getItemAt() Returns an item within the collection by using its index. Collection.
-
Example The following example calls addItem(): on (click) { import CompactDisc; var myColl:mx.utils.Collection; myColl = _parent.thisShelf.MyCompactDiscs; myCD = new CompactDisc(); myCD.Artist = "John Coltrane"; myCD.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 item The object whose presence in the collection is to be tested.
-
Example The following example calls contains(): var myColl:mx.utils.Collection; myColl = _parent.thisShelf.MyCompactDiscs; var itr:mx.utils.Iterator = myColl.getIterator(); while (itr.hasNext()) { var cd:CompactDisc = CompactDisc(itr.next()); var title:String = cd.Title; var artist:String = cd.Artist; if(myColl.contains(cd)) { trace("myColl contains " + title); } else { trace("myColl does not contain " + title); } } Collection.clear() Availability Flash Player 7. Edition Flash MX Professional 2004.
-
Collection.getItemAt() Availability Flash Player 7. Edition Flash MX Professional 2004. Usage collection.getItemAt(index) Parameters A number that indicates the location of item within the collection. This is a zerobased index, so 0 retrieves the first item, 1 retrieves the second item, and so on. index Returns An object containing a reference to the specified collection item, or null if index is out of bounds. Description Method; returns an item within the collection by using its index.
-
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).
-
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: " + myColl.getLength()); //... Collection.isEmpty() Availability Flash Player 7.
-
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 item The object to be removed from the collection.
-
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(); var cd:CompactDisc = new CompactDisc(); var title:String = ""; var artist:String = ""; while (itr.
-
156 Collection interface (Flash Professional only)
-
8 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. If the pop-up list hits the bottom of the document, it opens up instead of down. The combo box is composed of three subcomponents: a Button component, a TextInput component, and a List component.
-
Key Description End 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 Up Moves the selection up one page. Shift+Tab Moves focus to the previous object. Tab Moves focus to the next object.
-
For more information about controlling focus, see “FocusManager class” on page 721 or “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.
-
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 undefined. See “ComboBox.restrict” on page 194. enabled is a Boolean value that indicates whether the component can receive focus and input. The default value is true.
-
5. Select Frame 1 in the Timeline, open the Actions panel, and enter the following code: function change(evt){ trace(evt.target.selectedItem.label); } comboBox.addEventListener("change", this); The last line of code adds a change event handler to the ComboBox instance. For more information, see ComboBox.change. To create a ComboBox component using ActionScript: 1. Drag the ComboBox component from the Components panel to the current document’s library.
-
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. In editable combo boxes, only the button is the hit area—not the text box.
-
A ComboBox component uses the following styles: Style Theme Description themeColor Halo The base color scheme of a component. Possible values are "haloGreen", "haloBlue", and "haloOrange". The default value is "haloGreen". backgroundColor Both The background color. The default color is white. borderStyle Both The Button subcomponent uses two RectBorder instances for its borders and responds to the styles defined on that class. See “RectBorder class” on page 1063.
-
Style Theme Description openDuration Both The duration, in milliseconds, of the transition animation. The default value is 250. openEasing Both A reference to a tweening function that controls the animation. Defaults to sine in/out. For more information, see “Customizing component animations” in Using Components. The following example demonstrates how to use List styles to control the behavior of the popup portion of a ComboBox component.
-
To create movie clip symbols for ComboBox skins: 1. Create a new FLA file. 2. Select File > Import > Open External Library, and select the HaloTheme.fla file. This file is located in the application-level configuration folder. For the exact location on your operating system, see “About themes” in Using Components. 3. In the theme’s Library panel, expand the Flash UI Components 2/Themes/MMDefault folder and drag the ComboBox Assets folder to the library for your document. 4.
-
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 label property and a data property NO T E An object may use the ComboBox.labelFunction or ComboBox.labelField property to determine the label property. If the item is a primitive data type other than String, it is converted to a string.
-
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 UIObject.createClassObject() Creates an object on the specified class. UIObject.createObject() Creates a subobject on an object. UIObject.destroyObject() Destroys a component instance. UIObject.
-
Property summary for the ComboBox class The following table lists properties of the ComboBox class. Property Description ComboBox.dataProvider The data model for the items in the list. ComboBox.dropdown Returns a reference to the List component contained by the combo box. ComboBox.dropdownWidth The width of the drop-down list, in pixels. ComboBox.editable Indicates whether a combo box is editable. ComboBox.labelField Indicates which data field to use as the label for the dropdown list. ComboBox.
-
Property Description UIObject.scaleX A number indicating the scaling factor in the x direction of the object, relative to its parent. UIObject.scaleY A number indicating the scaling factor in the y direction of the object, relative to its parent. UIObject.top Read-only; the position of the top edge of the object, relative to its parent. UIObject.visible A Boolean value indicating whether the object is visible (true) or not (false). UIObject.width Read-only; the width of the object, in pixels.
-
Event Description ComboBox.open Broadcast when the drop-down list begins to open. ComboBox.scroll Broadcast when the drop-down list is scrolled. Events inherited from the UIObject class The following table lists the events the ComboBox class inherits from the UIObject class. Event Description UIObject.draw Broadcast when an object is about to draw its graphics. UIObject.hide Broadcast when an object’s state changes from visible to invisible. UIObject.
-
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 label data obj A string that indicates the label for the new item. The data for the item; it can be of any data type. This parameter is optional. An object with a label property and an optional data property. Returns The index at which the item was added.
-
ComboBox.addItemAt() Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage comboBoxInstance.addItemAt(index, label[, data]) comboBoxInstance.addItemAt(index, {label:label[, data:data]}) comboBoxInstance.addItemAt(index, obj); Parameters A number 0 or greater that indicates the position at which to insert the item (the index of the new item). index label data obj A string that indicates the label for the new item. The data for the item; it can be of any data type.
-
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 or ComboBox.selectedItem property changes as a result of user interaction.
-
// 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.
-
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.
-
Example With a ComboBox component instance my_cb on the Stage, the following example sends a 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(); cbListener.open = function(evt_obj:Object) { trace("The ComboBox has opened."); } cbListener.close = function(evt_obj:Object){ trace("The ComboBox has closed.
-
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 (addItem(), getItemAt(), and so on) needed for it to be the model of a list, and can be used to broadcast model changes to multiple components.
-
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 dropdown property, the list is created.
-
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).
-
Description Property; indicates whether the combo box is editable (true) or not (false). In an editable 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. The default value is false. Making a combo box editable clears the combo box text field. It also sets the selected index (and item) to undefined.
-
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. For more information, see TextInput.enter.
-
Example With a ComboBox component instance my_cb on the Stage, the following ActionScript 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. my_cb.addItem({data:1, label:"First Item"}); my_cb.addItem({data:2, label:"Second Item"}); my_cb.addItem({data:-1, label:"Add new item...
-
Parameters index The index of the item to retrieve. The index must be a number greater than or equal 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; retrieves the item at a specified index. Example With a ComboBox component instance my_cb on the Stage, the following ActionScript displays the label for the first combo box item in the Output panel: //Add Item to List. my_cb.
-
Using a dispatcher/listener event model, a component instance (comboBoxInstance) dispatches an event (in this case, itemRollOut) and the event is handled by a function, also called a handler, on a listener object (listenerObject) that you create. You define a method with the same name as the event on the listener object; the method is called when the event is triggered. When the event is triggered, it automatically passes an event object (eventObject) to the listener object method.
-
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 itemRollOver event has an index property. The index is the number of the item that the pointer rolled over.
-
Example With a ComboBox instance my_cb on the Stage, the following ActionScript sends a message 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. var cbListener:Object = new Object(); cbListener.itemRollOver = function(evt_obj:Object) { trace("index: " + evt_obj.index + ", event: " + evt_obj.type); }; cbListener.
-
Example The following example sets the dataProvider property to an array of strings and sets the labelField property to indicate that the name field should be used as the label for the drop-down list: my_cb.dataProvider = [ {name:"Gary", gender:"male"}, {name:"Susan", gender:"female"} ]; my_cb.labelField = "name"; See also List.labelFunction ComboBox.labelFunction Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage comboBoxInstance.
-
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 List.length. The default value is 0. Example The following example stores the value of length to a variable: var dropdownItemCount:Number = myComboBox.length; ComboBox.
-
Description Method; opens the drop-down list. Example With a ComboBox component instance my_cb on the Stage, and a Button component instance my_button, the following example opens the drop-down list of the my_cb combo box when the my_button button is clicked: my_cb.addItem({data:2, label:"second value"}); my_cb.addItem({data:3, label:"third value"}); var btnListener:Object = new Object(); btnListener.click = function() { my_cb.open(); }; my_button.
-
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, open) and the event is handled by a function, also called a handler, on a listener object (listenerObject) that you create. You define a method with the same name as the event on the listener object; the method is called when the event is triggered.
-
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 my_cb on the Stage, and a Button component instance clear_button on the Stage, the following ActionScript positions the combo box and button beside each other.
-
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 index A number that indicates the position of the item to remove. The index is zero-based. Returns An object; the removed item (undefined if no item exists). Description Method; removes the item at the specified index position.
-
// 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.
-
Example With a ComboBox component instance my_cb, and a TextInput component instance label_ti on the Stage, the following ActionScript code adds the user input to the combo box when the user presses the Enter key: // Add Items to List. my_cb.addItem({data:1, label:"First Item"}); my_cb.addItem({data:2, label:"Second Item"}); // Create listener for user pressing Enter key on the Text Input field. var tiListener:Object = new Object(); tiListener.enter = function(evt_obj:Object) { my_cb.replaceItemAt(my_cb.
-
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. It signifies that the character following the backslash should be treated “as is.
-
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 myCombo. You must use a double backslash to escape the characters -, ^, and \.
-
Example With a ComboBox component instance my_cb, the following ActionScript sets the combo box to show the first three items, and add a scrollbar to see the fourth: // Add Items to List. my_cb.addItem({data:1, my_cb.addItem({data:2, my_cb.addItem({data:3, my_cb.addItem({data:4, label:"First Item"}); label:"Second Item"}); label:"Third Item"}); label:"Fourth Item"}); // Display scroll bar if ComboBox has more than 3 items. my_cb.rowCount = 3; ComboBox.scroll Availability Flash Player 6 (6.0.79.0).
-
Using a dispatcher/listener event model, a component instance (comboBoxInstance) dispatches an event (in this case, scroll) and the event is handled by a function, also called a handler, on a listener object (listenerObject) that you create. You define a method with the same name as the event on the listener object; the method is called when the event is triggered. When the event is triggered, it automatically passes an event object (eventObject) to the listener object method.
-
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. If you assign an out-of-range value to this property, Flash ignores it.
-
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, selectedItem returns undefined if the user enters any text in the text box. The property only has a value if you select an item from the drop-down list or set the value using ActionScript.
-
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 order. For details, see Array.sort() in ActionScript 2.0 Language Reference. This parameter is optional. compareFunc optionsFlag Lets you perform multiple sorts of different types on a single array without having to replicate the entire array or re-sort it repeatedly.
-
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 a and b are passed to the function and contain label and data fields: myComboBox.sortItems(upperCaseFunc); function upperCaseFunc(a,b){ return a.label.toUpperCase() > b.label.
-
optionsFlag Lets you perform multiple sorts of different types on a single array without having to replicate the entire array or re-sort it repeatedly. This parameter is optional, but if used, should replace the order parameter. The following are possible values for optionsFlag: ■ Array.DESCENDING, ■ Array.CASEINSENSITIVE, which sorts highest to lowest. ■ Array.NUMERIC, ■ Array.UNIQUESORT, ■ Array.
-
Example The following examples are based on a ComboBox instance named myComboBox, which contains four elements labeled "Apples", "Bananas", "cherries", and "Grapes": // First, populate the ComboBox with the elements. myComboBox.addItem("Bananas"); myComboBox.addItem("Apples"); myComboBox.addItem("cherries"); myComboBox.
-
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 text value of an editable combo box: my_cb.addItem("Arkansas"); my_cb.addItem("Georgia"); my_cb.editable = true; my_cb.text = "California"; ComboBox.textField Availability Flash Player 6 (6.0.79.0).
-
Example The following code restricts the text box of myComboBox so that it only accept numbers to 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"; // Limit input to 6 characters. my_cb.textField.maxChars = 6; ComboBox.value Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004.
-
CHAPTER 9 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.
-
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 Professional only) Creates a binding between two endpoints. ComponentMixins class (Flash Adds data binding functionality to components. Professional only) CustomFormatter class (Flash The base class for creating custom formatter classes.
-
Method summary for the Binding class The following table lists the methods of the Binding class. Method Description Binding.execute() Fetches the data from the source component, formats it, and assigns it to the destination component. Constructor for the Binding class Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage new Binding(source, destination, [format], [isTwoWay]) Parameters source A source endpoint of the binding. This parameter is nominally of type mx.data.
-
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. For example, if movie clip named A contains components X and Y, and there is a binding between X and Y, then the binding is in effect as long as movie clip A exists.
-
Binding.execute() Availability Flash Player 6. Edition Flash MX Professional 2004. Usage myBinding.execute([reverse]) Parameters A Boolean value that specifies whether the binding should also be executed from the destination to the source (true), or only from the source to the destination (false). By default, this value is false.
-
CustomFormatter class (Flash Professional only) ActionScript Class Name mx.data.binding.CustomFormatter The CustomFormatter class defines two methods, format() and unformat(), that provide the ability to transform data values from a specific data type to String, and vice versa. By default, these methods do nothing; you must implement them in a subclass of mx.data.binding.CustomFormatter.
-
To create and use a custom formatter: 1. In Flash, create a new ActionScript file. 2. 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'); var numArray = new Array(1, 2, 3); returnValue = 0; for (var i = 0; i
-
8. Select Window > Common Libraries > Classes to open the Classes library. 9. Select Window > Library to open your document’s library. 10. Drag DataBindingClasses from the Classes library to your document’s library. This makes the data binding runtime classes available for your document. 11. Save the FLA file to the same folder that contains NumberFormatter.as. 12. Test the file (Control > Test Movie).
-
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). Edition Flash MX Professional 2004. Usage This method is called automatically; you don’t invoke it directly. Parameters formattedData The formatted data to convert back to the raw data type.
-
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 validate(). This method is automatically passed a value to be validated. For more information about how to implement this method, see CustomValidator.
-
CustomValidator.validate() Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage This method is called automatically; you don’t invoke it directly. Parameters value The data to be validated; it can be of any type. Returns Nothing. Description Method; called automatically to validate the data contained by the value parameter. You must implement this method in your subclass of CustomValidator; the default implementation does nothing.
-
To create and use a custom validator class: 1. In Flash, create a new ActionScript (AS) file. 2. Add the following code to the AS file: class OddNumbersOnly extends mx.data.binding.CustomValidator { public function validate(value) { // make sure the value is of type Number var n = Number(value); if (String(n) == "NaN") { this.validationError("'" + value + "' is not a number."); return; } // make sure the number is odd if (n % 2 == 0) { this.validationError("'" + value + "' is not an odd number.
-
15. In the Schema Attributes pane, select Custom from the Data Type pop-up menu. 16. Double-click the Validation Options field in the Schema Attributes pane to open the Custom Validation Settings dialog box. 17. In the ActionScript Class text box, enter OddNumbersOnly, which is the name of the ActionScript class you created previously. Click OK. 18. Open the Timeline and select the first frame on Layer 1. 19. Open 20.Add the Actions panel.
-
Usage this.validationError(errorMessage) N OT E This method can be invoked only from within a custom validator class; the keyword this refers to the current CustomValidator object. Parameters errorMessage A string that contains the error message to be reported. Returns Nothing. Description Method; called from the validate() method of your subclass of CustomValidator to report validation errors. If you don’t call validationError(), a valid event is generated when validate() finishes executing.
-
The EndPoint objects, srcEndPoint and destEndPoint, might be defined as follows: 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 text property into the text property of the destination text field.
-
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 source_obj and assigns values to its component and property properties: var source_obj = new mx.data.binding.EndPoint(); source_obj.component = myTextField; source_obj.property = "text"; EndPoint.component Availability Flash Player 6 (6.0.79.
-
Example This example assigns an instance of the List component (listBox1) as the component parameter of an EndPoint object. var sourceEndPoint = new mx.data.binding.EndPoint(); sourceEndPoint.component = listBox1; EndPoint.constant Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage endPoint_src.constant Description Property; a constant value assigned to an EndPoint object.
-
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. For more information about creating two-way bindings, see “Binding class (Flash Professional only)” on page 208.
-
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. You can use this technique with both XML and ActionScript data. (See Example 2 below.
-
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 EndPoint.component that contains the bindable data. N OT E EndPoint.component and EndPoint.property must combine to form a valid ActionScript object/property combination.
-
Method summary for the ComponentMixins class The following table lists the methods of the ComponentMixins class. Method Description ComponentMixins.getField() Returns an object for getting and setting the value of a field at a specific location in a component property. ComponentMixins.initComponent() Adds the ComponentMixins methods to a component. ComponentMixins.refreshDestinations() Executes all the bindings that have this object as the source endpoint. ComponentMixins.
-
■ A string that contains field names, separated by dots—for example, "a.b.c". This form is 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. Description Method; returns a DataType object whose methods you can use to get or set the data value in the component property at the specified field location.
-
Description Method (static); adds all the ComponentMixins methods to the component specified by componentInstance. This method is called automatically for all components involved in a data binding. 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. Example The following code makes the ComponentMixins methods available to a DataSet component: mx.data.binding.ComponentMixins.initComponent(_root.
-
ComponentMixins.refreshFromSources() Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage componentInstance.refreshFromSources() Parameters None. Returns Nothing. Description Method; executes all bindings for which componentInstance is the destination EndPoint object. This method lets you execute bindings that have constant sources, or sources that do not emit a “data changed” event.
-
Parameters propertyName A string that contains the name of a property that belongs to componentInstance. Returns An array, or null. Description Method; determines if the data in propertyName is valid based on the property’s schema settings. The property’s schema settings are those specified on the Schema tab in the Component inspector. The method returns null if the data is valid; otherwise, it returns an array of error messages as strings.
-
To validate text entered by a user in a TextInput component: 1. Drag a TextInput component from the Components panel to the Stage, and name it zipCode_txt. 2. Select the TextInput component and, in the Component inspector, click the Schema tab. 3. In the Schema Tree pane (the top pane of the Schema tab), select the text property. 4. In the Schema Attributes pane (the bottom pane of the Schema tab), select ZipCode from the Data Type pop-up menu. 5. Open the Timeline if it is not already open. 6.
-
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 ComponentMixins.getField() method on a component. 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” form.
-
Method summary for the DataType class The following table lists the methods of the DataType class. Method Description DataType.getAnyTypedValue() Fetches the current value of the field. DataType.getAsBoolean() Fetches the current value of the field as a Boolean value. DataType.getAsNumber() Fetches the current value of the field as a number. DataType.getAsString() Fetches the current value of the field as a String value. DataType.
-
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” in Using Flash.
-
Example This example assumes that the field being accessed is using the Number Formatter (mx.data.formatters.NumberFormatter) provided with Flash Professional 8. This formatter contains a property named precision that specifies how many digits to display after the decimal point. This code sets the precision property to two decimal places for a field using this formatter. var myField:DataType = dataGrid.getField("currentBalance"); myField.formatter.precision = 2; DataType.
-
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 (productInfo.available) in an XMLConnector component’s results property first as a number or, if that fails, as a string. import mx.data.binding.DataType; import mx.data.binding.TypedValue; var f: DataType = myXmlConnector.getField("results", "productInfo.available"); var b: TypedValue = f.
-
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 propName that belongs to a component named myComponent is retrieved as a number, and assigned to a variable: var dataTypeObj:mx.data.binding.DataType = myComponent.
-
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 propName that belongs to a component named myComponent is retrieved as a string and assigned to a variable: var dataTypeObj:mx.data.binding.DataType = myComponent.getField("propName"); var propValue:String = dataTypeObj.getAsString(); See also DataType.getAnyTypedValue() DataType.
-
If null is specified as requestedType, the method returns the value of the field in its default type. Example The following example returns the value of the field converted to the Boolean data type. This is stored in the bool variable. var bool:TypedValue = field.getTypedValue("Boolean"); DataType.kind Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage dataTypeObject.kind Description Property; provides a reference to the Kind object associated with this field.
-
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" cannot be converted to Number). ■ The data is an acceptable type but does not meet the validation criteria of the field. ■ The field is read-only.
-
Parameters newBooleanValue A Boolean value. Returns Nothing. Description Method; sets the field to the new value, which is given as a Boolean value. The value is converted to, and stored as, the data type that is appropriate for this field. Example The following example sets a variable named bool to the Boolean value true. It then sets the value referenced by field to true. var bool: Boolean = true; field.setAsBoolean (bool); DataType.setAsNumber() Availability Flash Player 6 (6.0.79.0).
-
Example The following example sets a variable named num to the Number value of 32. It then sets the value referenced by field to num. var num: Number = 32; field.setAsNumber (num); DataType.setAsString() Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage dataTypeObject.setAsString(newStringValue) Parameters newStringValue A string. Returns Nothing. Description Method; sets the field to the new value, which is given as a string.
-
DataType.setTypedValue() Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage dataTypeObject.setTypedValue(newTypedValue) Parameters newTypedValue A TypedValue object value to set in the field. 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.
-
Example The following example creates a new TypedValue object (a Boolean value), and then assigns that value to a DataType object named field. Any errors that occur are assigned to the errors array. import mx.data.binding.*; var bool:TypedValue = new TypedValue (true, "Boolean"); var errors: Array = field.setTypedValue (bool); See also DataType.setTypedValue() TypedValue class (Flash Professional only) ActionScript Class Name mx.data.binding.
-
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 typeName A string that contains the name of the value’s data type. An optional Schema object that describes in more detail the schema of the data. This field is required only in certain circumstances, such as when setting data into a DataSet component’s dataProvider property.
-
TypedValue.typeName Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage typedValueObject.typeName Description Property; contains the name of the data type of the TypedValue object’s value. Example This example displays Boolean in the Output panel: var t: TypedValue = new TypedValue (true, "Boolean", null); trace(t.typeName); TypedValue.value Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage typedValueObject.
-
248 Data binding classes (Flash Professional only)
-
CHAPTER 10 10 DataGrid component (Flash Professional only) The DataGrid component lets you create powerful data-enabled displays and applications. You can use the DataGrid component to instantiate a recordset (retrieved from a database query in Macromedia ColdFusion, Java, or .Net) using Macromedia Flash Remoting and display it in columns. You can also use data from a data set or from an array to fill a DataGrid component.
-
Interacting with the DataGrid component (Flash Professional only) You can use the mouse and the keyboard to interact with a DataGrid component. If DataGrid.sortableColumns and DataGridColumn.sortOnHeaderRelease are both true, clicking in a column header causes the grid to sort based on the column’s cell values. If DataGrid.resizableColumns is true, clicking in the area between columns lets you resize columns.
-
Using the DataGrid component (Flash Professional only) You can use the DataGrid component as the foundation for numerous types of data-driven applications. You can easily display a formatted tabular view of a database query (or other data), but you can also use the cell renderer capabilities to build more sophisticated and editable user interface pieces.
-
■ Lists perform worse as a function of their visible rows. Although lists can display 5000 records, they can’t render 5000 records at once. The more visible rows (specified by the rowCount property) you have on the Stage, the more work the list must to do to render. Limiting the number of visible rows, if at all possible, is the best solution. ■ Lists aren’t tables. DataGrid components are intended to provide an interface for many records.
-
■ Field Identifiers that indicate the names of the columns within the items. This corresponds to the columnNames property in the columns list. In the List component, the fields are usually label and data, but in the DataGrid component the fields can be any identifier.
-
multipleSelection is a Boolean value that indicates whether multiple items can be selected (true) or not (false). The default value is false. rowHeight indicates the height of each row, in pixels. Changing the font size does not change the row height. The default value is 20. You can write ActionScript to control these and additional options for the DataGrid component using its properties, methods, and events. For more information, see “DataGrid class (Flash Professional only)” on page 262.
-
4. 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; The name and price fields are used as the column headings, and their values fill the cells in each row. 5. Select Control > Test Movie. To specify columns and add sorting for a DataGrid component in an application: 1. In Flash, select File > New and then select Flash Document. 2.
-
To create a DataGrid component instance using ActionScript: 1. 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. 2. 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"]}); my_dg.setSize(140, 100); my_dg.
-
You may be tempted to make a for loop to call DataGrid.addColumn() for all the columns needed. Although this seems like a simple and obvious approach, do not use it. Each time that DataGrid.addColumn() is called, the data grid adds event listeners, sorts, and redraws itself to present the new column. Creating 20 columns using DataGrid.addColumn() causes DataGrid to sort itself and redraw 20 times needlessly. Building your data structure in ActionScript requires no rendering or events to account for.
-
■ 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.
-
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 backgroundColor Both The background color, which can be set for the whole grid or for each column.
-
Style Theme Description fontWeight Both The font weight: either "none" or "bold". The default value is "none". All components can also accept the value "normal" in place of "none" during a setStyle() call, but subsequent calls to getStyle() return "none". textAlign Both The text alignment: either "left", "right", or "center". The default value is "left". textDecoration Both The text decoration: either "none" or "underline". The default value is "none".
-
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. _global.styles.ScrollSelectList.
-
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 version property, which is a class property. Class properties are available only on the class itself. The version property returns a string that indicates the version of the component. To access this property, use the following code: trace(mx.controls.DataGrid.
-
Methods inherited from the UIObject class The following table lists the methods the DataGrid class inherits from the UIObject class. When calling these methods, use the form dataGridInstance.methodName. Method Description UIObject.createClassObject() Creates an object on the specified class. UIObject.createObject() Creates a subobject on an object. UIObject.destroyObject() Destroys a component instance. UIObject.
-
Method Description List.removeAll() Removes all items from the list. List.removeItemAt() Removes the item at the specified index. List.replaceItemAt() Replaces the item at the specified index with another item. List.setPropertiesAt() Applies the specified properties to the specified item. List.sortItems() Sorts the items in the list according to the specified compare function. List.sortItemsBy() Sorts the items in the list according to a specified property.
-
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 UIObject.bottom The position of the bottom edge of the object, relative to the bottom edge of its parent. Read-only. UIObject.height The height of the object, in pixels. Read-only. UIObject.left The left edge of the object, in pixels.
-
Properties inherited from the 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 List.cellRenderer Assigns the class or symbol to use to display each row of the list. List.dataProvider The source of the list items. List.hPosition The horizontal position of the list. List.
-
Event summary for the DataGrid class The following table lists the events of the DataGrid class. Event Description DataGrid.cellEdit Broadcast when the cell value has changed. DataGrid.cellFocusIn Broadcast when a cell receives focus. DataGrid.cellFocusOut Broadcast when a cell loses focus. DataGrid.cellPress Broadcast when a cell is pressed (clicked). DataGrid.change Broadcast when an item has been selected. DataGrid.columnStretch Broadcast when a user resizes a column horizontally. DataGrid.
-
Events inherited from the List class The following table lists the events the DataGrid class inherits from the List class. Event Description List.change Broadcast whenever user interaction causes the selection to change. List.itemRollOut Broadcast when the mouse pointer rolls over and then off of list items. List.itemRollOver Broadcast when the mouse pointer rolls over list items. List.scroll Broadcast when a list is scrolled. DataGrid.addColumn() Availability Flash Player 6 (6.0.79.0).
-
Example This example shows three different ways of creating columns for a DataGrid component. With a DataGrid instance named my_dg on the Stage, paste the following code in the first frame of the main timeline (notice that it imports the DataGridColumn class first): import mx.controls.gridclasses.DataGridColumn; var my_dg:mx.controls.DataGrid; my_dg.setSize(320, 240); // Add columns to grid. my_dg.addColumn("Red"); // Add another column to grid. my_dg.
-
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 addColumnAt() and sets the column widths. With a DataGrid instance named my_dg on the Stage, paste the following code in the first frame of the main timeline (notice that it imports the DataGridColumn class first): import mx.controls.gridclasses.
-
Description Method; adds an item to the end of the grid (after the last item index). NO TE This differs from the List.addItem() method in that an object is passed rather than a string. Example This example creates one column with the heading “name” and then inserts the item_obj value for “name”. Notice that the “age” value is ignored, because only the name column has been defined. If you don’t specify a column (remove the addColumn line), DataGrid automatically creates the appropriate columns.
-
Example This example creates one column with the heading “name”, populates the column from an array, and then adds the name “Chase” in the first row. Notice that the “age” value is ignored, because only the name column has been defined. If you don’t specify a column (remove the addColumn line), DataGrid automatically creates the appropriate columns. With a DataGrid instance named my_dg on the Stage, paste the following code in the first frame of the main timeline: var my_dg:mx.controls.
-
When the event is triggered, it automatically passes an event object (eventObject) to the handler. Each event object has properties that contain information about the event. You can use these properties to write code that handles the event. The DataGrid.cellEdit event’s event object has four additional properties: columnIndex itemIndex oldValue type A number that indicates the index of the target column. A number that indicates the index of the target row. The previous value of the cell.
-
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 editCell and cellFocusOut events are broadcast.
-
Example In the following example, a handler called dgListener is defined and passed to my_dg.addEventListener() as the second parameter. When the cellFocusIn event is broadcast, a trace statement is sent to the Output panel. With a DataGrid instance named my_dg on the Stage, paste the following code in the first frame of the main timeline: // Set up sample data. var myDP_array:Array = new Array(); myDP_array.push({name:"Clark", score:3135}); myDP_array.push({name:"Bruce", score:403}); myDP_array.
-
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 the cellEdit event and before any subsequent cellFocusIn events are broadcast by the next cell.
-
// 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); N OT E The grid must be editable for this code to work, and the event is broadcast only for editable cells.
-
When the event is triggered, it automatically passes an event object (eventObject) to the handler. Each event object has properties that contain information about the event. You can use these properties to write code that handles the event. The DataGrid.cellPress event’s event object has three additional properties: columnIndex A number that indicates the index of the column that was pressed. The first position is 0. itemIndex A number that indicates the index of the row that was pressed.
-
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 change event, the event is handled by a function (also called a handler) that is attached to a listener object (listenerObject) that you create.
-
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 my_dg on the Stage, paste the following code in the first frame of the main timeline: // Add columns to grid and add data. my_dg.addColumn("a"); my_dg.addColumn("b"); my_dg.
-
Example The following example displays the column name in the Output panel when the title is clicked. With a DataGrid instance named my_dg on the Stage, paste the following code in the first frame of the main timeline: my_dg.setSize(200, 100); my_dg.columnNames = ["Name", "Description", "Price"]; var dgListener:Object = new Object(); dgListener.headerRelease = function (evt_obj:Object) { trace("You clicked on the \"" + my_dg.columnNames[evt_obj.columnIndex] + "\" column."); } my_dg.
-
When the event is triggered, it automatically passes an event object (eventObject) to the handler. Each event object has properties that contain information about the event. You can use these properties to write code that handles the event. The DataGrid.columnStretch event’s event object has two additional properties: columnIndex A number that indicates the index of the target column. The first position is 0. type The string "columnStretch". For more information, see “EventDispatcher class” on page 499.
-
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).
-
Usage myDataGrid.editable Description Property; determines whether the data grid can be edited by a user (true) or not (false). This property must be true in order for individual columns to be editable and for any cell to receive focus. The default value is false. If you want individual columns to be uneditable, use the DataGridColumn.editable property. C A U TI O N The DataGrid is not editable or sortable if it is bound directly to a WebServiceConnector component or an XMLConnector component.
-
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 colName data A string indicating the name of the column (field) that contains the target cell. The value to be stored in the target cell. This parameter can be of any data type. Returns The data that was in the cell.
-
DataGrid.focusedCell Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage myDataGrid.focusedCell Description Property; in editable mode only, an object instance that defines the cell that has focus. The object must have the fields columnIndex and itemIndex, which are both integers that indicate the index of the column and item of the cell. The origin is (0,0). The default value is undefined.
-
DataGrid.getColumnAt() Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage myDataGrid.getColumnAt(index) Parameters index The index of the DataGridColumn object to be returned. This number is zero-based. 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.
-
DataGrid.getColumnIndex() Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage myDataGrid.getColumnIndex(columnName) Parameters columnName A string that is the name of a column. Returns A number that specifies the index of the column. Description Method; returns the index of the column specified by the columnName parameter. Example The following example displays the index number of the “score” column.
-
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 my_dg on the Stage, paste the following code in the first frame of the main timeline: // Set grid attributes. my_dg.setSize(240, 100); my_dg.
-
Usage listenerObject = new Object(); listenerObject.headerRelease = function(eventObject){ // Insert your code here. } myDataGridInstance.addEventListener("headerRelease", listenerObject) Description Event; broadcast to all registered listeners when a column header has been released. You can use this event with the DataGridColumn.sortOnHeaderRelease property to prevent automatic sorting and to let you sort as you like. Version 2 components use a dispatcher/listener event model.
-
In the following example, you change the sort direction using a column. With a DataGrid instance named my_dg on the Stage, paste the following code in the first frame of the 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+" header was pressed"); trace("\t current sort order is: "+evt.target.sortDirection); trace(""); }; my_dg.
-
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}); myDP_array.push({name:"Bruce", score:403}); myDP_array.push({name:"Peter", score:25}); my_dg.dataProvider = myDP_array; my_dg.hScrollPolicy = "on"; DataGrid.
-
Example The following example removes all DataGridColumn objects from the DataGrid when the button is clicked. With a DataGrid instance named my_dg and a Button instance named clear_button on the Stage, paste the following code in the first frame of the main timeline: my_dg.setSize(140, 100); my_dg.move(10, 40); this.createClassObject(mx.controls.Button, "clear_button", 20, {label:"Clear"}); clear_button.move(10, 10); // Set up sample data. var myDP_array:Array = new Array(); myDP_array.
-
Example The following example removes the first DataGridColumn object when the button is clicked. With a DataGrid instance named my_dg and a Button instance named name_button on the Stage, paste the following code in the first frame of the main timeline: my_dg.setSize(140, 100); my_dg.move(10, 40); name_button.setSize(140, name_button.height); name_button.move(10, 10); // Set up sample data. var myDP_array:Array = new Array(); myDP_array.push({name:"Clark", score:3135}); myDP_array.
-
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 my_dg and a Button instance named replace_button on the Stage, paste the following code in the first frame of the main timeline: my_dg.setSize(140, 100); my_dg.move(10, 40); replace_button.move(10, 10); // Set up sample data. var myDP_array:Array = new Array(); myDP_array.
-
Description Property; a Boolean value that determines whether the columns of the grid can be stretched by the user (true) or not (false). This property must be true for individual columns to be resizable by the user. The default value is true. Example The following example prevents users from resizing columns. With a DataGrid instance named my_dg on the Stage, paste the following code in the first frame of the main timeline: my_dg.setSize(140, 100); // Set up sample data.
-
Example The following example prevents the grid from being selected. With a DataGrid instance named my_dg on the Stage, paste the following code in the first frame of the main timeline: my_dg.setSize(140, 100); // Set up sample data. var myDP_array:Array = new Array(); myDP_array.push({name:"Clark", score:3135}); myDP_array.push({name:"Bruce", score:403}); myDP_array.push({name:"Peter", score:25}); my_dg.dataProvider = myDP_array; my_dg.selectable = false; DataGrid.
-
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 (true) or not (false) when a user clicks the column headers. This property must be true for individual columns to be sortable, and for the headerRelease event to be broadcast. The default value is true.
-
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 my_dg when the button is clicked. With a DataGrid instance named my_dg and a Button instance named resize_button on the Stage, paste the following code in the first frame of the main timeline: my_dg.move(10, 40); my_dg.
-
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. After columns have been added or created, you can access them by calling DataGrid.getColumnAt(index).
-
Property summary for the DataGridColumn class The following table lists the properties of the DataGridColumn class. Property Description DataGridColumn.cellRenderer The linkage identifier of a symbol to be used to display the cells in this column. DataGridColumn.columnName Read-only; the name of the field associated with the column. DataGridColumn.editable A Boolean value that indicates whether a column is editable (true) or not (false). DataGridColumn.
-
Constructor for the DataGridColumn class Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage new DataGridColumn(name) Parameters name A string that indicates the name of the DataGridColumn object. This parameter is the field of each item to display. Returns Nothing. Description Constructor; creates a DataGridColumn object. Use this constructor to create columns to add to a DataGrid component.
-
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” on page 109.) The default value is undefined. Example The following example uses a linkage identifier to set a new cell renderer: myGrid.getColumnAt(3).
-
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:"; // Set up sample data. my_dg.addItem({name:"Clark", score:3135}); my_dg.
-
Description Property; determines whether the column can be edited by a user (true) or not (false). The DataGrid.editable property must be true in order for individual columns to be editable, even when DataGridColumn.editable is set to true. The default value is true. CAUTION The DataGrid is not editable or sortable if it is bound directly to a WebServiceConnector component or an XMLConnector component.
-
DataGridColumn.headerRenderer Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage myDataGrid.getColumnAt(index).headerRenderer Description Property; a string that indicates a class name to be used to display the header of this column. Any class used for this property must implement the CellRenderer API (see “CellRenderer API” on page 109). The default value is undefined. Example The following example uses a linkage identifier to set a new header renderer: myGrid.
-
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).
-
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. st_dgc.
-
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; DataGridColumn.sortable Availability Flash Player 6 (6.0.79.0).
-
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). Edition Flash MX Professional 2004. Usage myDataGrid.getColumnAt(index).
-
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). Edition Flash MX Professional 2004. Usage myDataGrid.
-
312 DataGrid component (Flash Professional only)
-
CHAPTER 11 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. Initially, the DataHolder component has a single bindable property named data. You can add more properties by using the Schema tab in the Component inspector.
-
■ You might have a data value that results from a complex indexed data binding, as shown in the following diagram. Web Service Method getMovies Results Results[movieList.selectedIndex] DataModel myDataModel UI ListBox movieList data.movieTitle UI TextField title data.movieRating UI TextField rating data.
-
3. Drag a DataGrid component to the Stage and name it namesGrid. 4. Select the DataHolder component and open the Component inspector. 5. Click the Schema tab in the Component inspector. 6. Click the Add Component Property (+) button located in the top pane of the Schema tab. 7. 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. 8.
-
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. You can add your own bindable properties, or delete the default data property, by using the Schema tab in the Component inspector.
-
12 CHAPTER 12 DataProvider API The DataProvider API is a set of methods and properties that a data source needs so that a listbased class can communicate with it. Arrays, recordsets, and data sets implement this API. You can create a DataProvider-compliant class by implementing all the methods and properties described in this section. A list-based component could then use that class as a data provider. DataProvider class ActionScript Class Name mx.controls.listclasses.
-
Method summary for the DataProvider API The following table lists the methods of the DataProvider API. Method Description DataProvider.addItem() Adds an item at the end of the data provider. DataProvider.addItemAt() Adds an item to the data provider at the specified position. DataProvider.editField() Changes one field of the data provider. DataProvider.getEditingData() Gets the data for editing from a data provider. DataProvider.getItemAt() Gets a reference to the item at a specified position.
-
DataProvider.addItem() Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage myDP.addItem(item) Parameters item An object that contains data. This constitutes an item in a data provider. Returns Nothing. Description Method; adds a new item at the end of the data provider. This method triggers the modelChanged event with the event name addItems. Example The following example adds an item to the end of the data provider myDP: myDP.
-
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 modelChanged event with the event name addItems. Example The following example adds an item to the data provider myDP at the fourth position: myDP.addItemAt(3, {label : "this is the fourth Item"}); DataProvider.editField() Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage myDP.
-
DataProvider.getEditingData() Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage myDP.getEditingData(index, fieldName) Parameters A number greater than or equal to 0 and less than DataProvider.length. This number is the index of the item to retrieve. index fieldName A string indicating the name of the field being edited. Returns The editable formatted data to be used. Description Method; retrieves data for editing from a data provider.
-
Parameters A number greater than or equal to 0 and less than DataProvider.length. This number is the index of the item to retrieve. index Returns A reference to the retrieved item; undefined if the index is out of range. Description Method; retrieves a reference to the item at a specified position. Example The following code displays the label of the fifth item: trace(myDP.getItemAt(4).label); DataProvider.getItemID() Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004.
-
DataProvider.length Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage myDP.length Description Property (read-only); the number of items in the data provider. Example This example sends the number of items in the myArray data provider to the Output panel: trace(myArray.length); DataProvider.modelChanged Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage listenerObject = new Object(); listenerObject.
-
The Menu.modelChanged event’s event object has five additional properties: ■ eventName The eventName property is used to subcategorize modelChanged events. Data-aware components use this information to avoid completely refreshing the component instance (view) that is using the data provider. The eventName property supports the following values: The entire view needs refreshing, excluding scroll position. ■ updateAll ■ addItems ■ removeItems A series of items has been deleted.
-
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(); DataProvider.removeItemAt() Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage myDP.
-
Returns Nothing. Description Method; removes the item at the specified index. The indices after the removed index collapse by one. This method triggers the modelChanged event with the event name removeItems. Example This example removes the item at the fourth position: myDP.removeItemAt(3); DataProvider.replaceItemAt() Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage myDP.replaceItemAt(index, item) Parameters index item A number greater than or equal to 0.
-
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 order. For more information, see sort (Array.sort method) in ActionScript 2.0 Language Reference.This parameter is optional.
-
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 modelChanged event with the event name sort. Example This example sorts according to uppercase labels. The items a and b are passed to the function and contain label and data fields: myList.sortItems(upperCaseFunc); function upperCaseFunc(a,b){ return a.label.toUpperCase() > b.label.toUpperCase(); } DataProvider.
-
■ Array.UNIQUESORT—if two objects in the array are identical or have identical sort fields, this method returns an error code (0) instead of a sorted array. ■ Array.RETURNINDEXEDARRAY—returns an integer index array that is the result of the sort. For example, the following array would return the second line of code and the array would remain unchanged: ["a", "d", "c", "b"] [0, 3, 2, 1] You can combine these options into one value. For example, the following code combines options 3 and 1: array.
-
330 DataProvider API
-
CHAPTER 13 CHAPTER 13 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.
-
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. See “Making data binding classes available at runtime (Flash Professional only)” on page 207.
-
Common workflow for the DataSet component The typical workflow for the DataSet component is as follows. To use a DataSet component: 1. Add an instance of the DataSet component to your application and give it an instance name. 2. Select the Schema tab for the DataSet component and create component properties to represent the persistent fields of the data set. 3. Load the DataSet component with data from an external data source.
-
To create an application using the DataSet component: 1. In Flash Professional 8, select File > New. In the Type column, select Flash Document and click OK. 2. Open the Components panel if it’s not already open. 3. Drag a DataSet component from the Components panel to the Stage. In the Property inspector, give it the instance name user_ds. 4. Drag a DataGrid component to the Stage and give it the instance name user_dg. 5.
-
15. 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. 16. In the dialog box that appears, select “selectedIndex : Number”. Click OK. 17. Double-click the Bound To field in the Component inspector to open the Bound To dialog box. 18.
-
Method summary for the DataSet class The following table lists the methods of the DataSet class. Method Description DataSet.addItem() Adds the specified item to the collection. DataSet.addItemAt() Adds an item to the data set at the specified position. DataSet.addSort() Creates a new sorted view of the items in the collection. DataSet.applyUpdates() Signals that the deltaPacket property has a value that you can access using data binding or ActionScript. DataSet.
-
Method Description DataSet.next() Moves to the next item in the current view of the collection. DataSet.previous() Moves to the previous item in the current view of the collection. DataSet.removeAll() Removes all the items from the collection. DataSet.removeItem() Removes the specified item from the collection. DataSet.removeItemAt() Removes a data set item at a specified position. DataSet.removeRange() Removes the current iterator’s range settings. DataSet.
-
Property Description DataSet.readOnly Indicates whether the collection can be modified. DataSet.schema Specifies the collection’s schema in XML format. DataSet.selectedIndex Contains the current item’s index in the collection. Event summary for the DataSet class The following table lists the events of the DataSet class. Event Description DataSet.addItem Broadcast before an item is added to the collection. DataSet.afterLoaded Broadcast after the items property is assigned. DataSet.
-
// ... }; 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 result property of the event object to false, the add operation is canceled; if you set it to true, the add operation is allowed. The event object (eventObj) contains the following properties: target The DataSet object that generated the event. type The string "addItem".
-
See also DataSet.removeItem DataSet.addItem() Availability Flash Player 7. Edition Flash MX Professional 2004. Usage dataSetInstance.addItem([obj]) Parameters obj An object to add to this collection. This parameter is optional. Returns A Boolean value: true if the item was added to the collection, false if it was not. Description Method; adds the specified record (transfer object) to the collection for management. The newly added item becomes the current item of the data set.
-
The following example demonstrates how you can accept or reject an item’s insertion into the DataSet by setting the result to true or false within the handler for the addItem event. Drag a DataSet component to the Stage, and assign it an instance name of my_ds. Drag a DataGrid component to the Stage, and give it an instance name of my_dg. Drag a CheckBox component to the Stage, and give it an instance name of my_ch. Drag a Button component to the Stage, and give it an instance name of submit_button.
-
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 insert the item; it is the index of the new item. index item An object containing the data for the item. Returns A Boolean value indicating whether the item was added: true indicates that the item was added, and false indicates that the item already exists in the data set.
-
DataSet.addSort() Availability Flash Player 7. Edition Flash MX Professional 2004. Usage dataSetInstance.addSort(name, fieldList, sortOptions) Parameters name A string that specifies the name of the sort. fieldList An array of strings that specify the field names to sort on. One or more of the following integer (constant) values, which indicate what options are used for this sort. Separate multiple values using the bitwise OR operator (|).
-
Example The following code creates a new sort named "nameSort" that performs a descending, caseinsensitive sort on the DataSet object’s "name" field. 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.
-
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.
-
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 DataSet.items property has been assigned.
-
The following example uses the afterLoaded event of the DataSet component to populate the dataProvider property for a List component on the Stage. Drag a List component and a DataSet component to the Stage, and give them instance names of my_list and my_ds, respectively. Add the following ActionScript code to Frame 1 of the main timeline: my_list.labelField = "name"; var itemsListener:Object = new Object(); itemsListener.afterLoaded = function (evt_obj:Object):Void { trace("After loaded"); my_list.
-
Example The following code calls the applyUpdates() method on the my_ds DataSet. my_ds.applyUpdates(); The following example adds four items to the my_ds DataSet instance on the Stage and displays each item in the top-level of the deltaPacket property: my_ds.addItem({name:"Thomas", age:35, gender:"M"}); my_ds.addItem({name:"Orville", age:33, gender:"M"}); my_ds.addItem({name:"Jonathan", age:48, gender:"M"}); my_ds.addItem({name:"Carol", age:31, gender:"F"}); my_ds.
-
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 calcFields event listener that you create should perform the required calculation and set the value for the calculated field.
-
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}); my_ds.addItem({name:"Frank", years:2}); my_ds.
-
Example The following example removes all items from the current view of the DataSet collection. Because the logChanges property is set to true, the removal of those items is logged. 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"]); my_ds.filtered = true; my_ds.filterFunc = function(item:Object):Boolean { return (item.
-
Description Method; creates an item that isn’t associated with the collection. You can specify the class of object created by using the DataSet.itemClassName property. If no DataSet.itemClassName value is specified and the itemData parameter is omitted, an 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 DataSet.
-
Description Property (read-only); returns the current item in the DataSet collection, or null if the collection is empty or if the current iterator’s view of the collection is empty. This property provides direct access to the item in the collection. Changes made by directly accessing this object are not tracked (in the DataSet.deltaPacket property), nor are any of the schema settings applied to any properties of this object.
-
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 dataSet collection and its items. This property is null until DataSet.applyUpdates() is called on dataSet. When DataSet.applyUpdates() is called, a transaction ID is assigned to the delta packet.
-
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 deltaPacket property has been changed and is ready to be used. See also DataSet.
-
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. To reenable events, you must call 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. Edition Flash MX Professional 2004. Usage dataSetInstance.enableEvents() Returns Nothing.
-
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"); } // Disable events for the data set. my_ds.disableEvents(); my_ds.addItem({name:"Apples", price:14}); my_ds.
-
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 false.When this property is true, the filter function specified by DataSet.filterFunc is called for each item in the collection. Example In the following example, filtering is enabled on the DataSet object named employee_ds.
-
Download a copy of the following XML document and save it to your local hard disk: http:/ This XML document will be loaded 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. Select the results property and click the “Import a schema from a sample XML file” button.
-
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. See also DataSet.filterFunc DataSet.filterFunc Availability Flash Player 7. Edition Flash MX Professional 2004. Usage dataSetInstance.
-
Example In the following example, filtering is enabled on the DataSet object named employee_ds. The specified filter function returns true if the empType field in each item is set to "management"; otherwise, it returns false. employee_ds.filtered = true; employee_ds.filterFunc = function (item:Object):Boolean { // Filter out employees who are managers. return(item.
-
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.
-
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.
-
Parameters searchValues An array that contains one or more field values to be found within the current sort. Returns Returns true if the values are found; otherwise, returns false. Description Method; searches the current view of the collection for an item with the field values specified by searchValues. Which items are in the current view depends on any current filter and range settings. If an item is found, it becomes the current item in the DataSet object.
-
DataSet.findFirst() Availability Flash Player 7. Edition Flash MX Professional 2004. Usage dataSetInstance.findFirst(searchValues) Parameters searchValues An array that contains one or more field values to be found within the current sort. Returns Returns true if the items are found; otherwise, returns false. Description Method; searches the current view of the collection for the first item with the field values specified by searchValues.
-
To test this example, drag a DataSet component to the Stage, and give it an instance name of student_ds. Add two properties, name (data type: String) and id (data type: Number) to the DataSet by using the Schema tab of the Component inspector. If you don’t already have a copy of the DataBindingClasses compiled clip in your library, drag a copy of the compiled clip from the Classes library (Window > Common Libraries > Classes). Add the following ActionScript to Frame 1 of the main timeline: student_ds.
-
Description Method; searches the current view of the collection for the last item with the field values specified by searchValues. Which items are in the current view depends on any current filter and range settings. The values specified by searchValues must be in the same order as the field list specified by the current sort (see the example below). Conversion of the data specified is based on the underlying field’s type.
-
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 inventory_ds at the first item in its collection, and then displays the value of the price property contained by that item using the DataSet.
-
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 parameter is optional. index Returns A string. Description Method; returns the identifier of the current item in the collection, or that of the item specified by index. This identifier is unique only in this collection and is assigned automatically by DataSet.addItem().
-
To test this example, drag a DataSet component to the Stage, and give it an instance name of student_ds. Add two properties, name (data type: String) and id (data type: Number) to the DataSet by using the Schema tab of the Component inspector. If you don’t already have a copy of the DataBindingClasses compiled clip in your library, drag a copy of the compiled clip from the Classes library (Window > Common Libraries > Classes). Add the following ActionScript to Frame 1 of the main timeline: student_ds.
-
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 DataSet.find() to search for an item in the current collection whose name field contain the value "Bobby".
-
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; trace ("Data set size is: " + my_ds.getLength()); //... DataSet.hasNext() Availability Flash Player 7. Edition Flash MX Professional 2004.
-
Description Method; returns false if the current iterator is at the end of its view of the collection; 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 price property of each item. my_ds.addItem({name:"item a", price:16}); my_ds.addItem({name:"item b", price:9}); my_ds.first(); while (my_ds.hasNext()) { my_ds.currentItem.price *= 0.5; // Everything's 50% off! my_ds.
-
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 price property of each item: 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; // Everything's 50% off! my_ds.previous(); } for (var i in my_ds.items) { trace(my_ds.items[i].name + ": " + my_ds.items[i].price); } See also DataSet.
-
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 DataSet.useSort(). If a sort by that name doesn’t exist, one is created by means of DataSet.addSort(). To test this example, drag a DataSet component and a List component to the Stage, and give them instance names of my_ds and my_list respectively.
-
Description Method; returns true if the specified DataSet object doesn’t contain any items (that is, if dataSet.length == 0). Example The following code disables a Delete Record button (not shown) if the DataSet object it applies to is empty: if (my_ds.isEmpty()) { delete_button.enabled = false; } See also DataSet.length DataSet.items Availability Flash Player 7. Edition Flash MX Professional 2004. Usage dataSetInstance.items Description Property; an array of items managed by my_ds.
-
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. interface mx.data.to.
-
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 (eventObj) contains the following properties: The DataSet object that generated the event. target type The string "iteratorScrolled".
-
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(); } goLast_button.
-
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 price property of each item: 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; // Everything's 50% off! my_ds.previous(); } for (var i in my_ds.items) { trace(my_ds.items[i].name + ": " + my_ds.items[i].price); } See also DataSet.first() DataSet.
-
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"); } // Disable events for the data set. my_ds.disableEvents(); my_ds.addItem({name:"Apples", price:14}); my_ds.
-
Usage dataSetInstance.loadFromSharedObj(objName, [localPath]) Parameters objName A string specifying the name of the shared object to retrieve. The name can 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 file that created the shared object.
-
DataSet.locateById() Availability Flash Player 7. Edition Flash MX Professional 2004. Usage dataSetInstance.locateById(id) Parameters id 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 id. This method returns true if the specified ID can be matched to an item in the collection; otherwise, it returns false. Example The following example uses DataSet.
-
To test this example, drag a DataSet component to the Stage, and give it an instance name of student_ds. Add two properties, name (String) and id (Number) to the DataSet by using the Schema tab of the Component inspector. If you don’t already have a copy of the DataBindingClasses compiled clip in your library, drag a copy of the compiled clip from the Classes library (Window > Common Libraries > Classes). Add the following ActionScript to Frame 1 of the main timeline: student_ds.
-
When this property is set to true, operations performed at the collection level and item level 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. Example The following example disables logging for the DataSet object named userData. user_ds.logChanges = false; See also DataSet.deltaPacket DataSet.
-
The event object (eventObj) contains the following properties: The DataSet object that generated the event. target type The string "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 change (equals firstItem if only one item was affected). lastItem fieldName undefined A string that contains the name of the field being affected.
-
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"); } // Disable events for the data set. my_ds.disableEvents(); my_ds.addItem({name:"Apples", price:14}); my_ds.
-
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 DataSet.createItem(). A listener for this event can make modifications to the item before it is added to the collection.
-
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 price property of each item: my_ds.
-
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}); my_ds.addItem({name:"item b", price:9}); my_ds.
-
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; for (i in my_ds.properties) { trace("field '" + i + "' has value " + my_ds.properties[i]); } DataSet.
-
Example The following example makes the DataSet object named my_ds read-only, and then attempts to change the value of a property that belongs to the current item in the collection. This attempt throws a DataSetError exception. import mx.data.components.datasetclasses.DataSetError; my_ds.readOnly = true; try { // This throws an exception. my_ds.addItem({name:'Joe'}); } catch (e:DataSetError) { // Sort specified 'name' doesn’t exist for DataSet 'my_ds'. trace("DataSetError >> " + e.
-
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.
-
Example In the following example, an on(removeItem) event handler cancels the deletion of the new item if a user-defined function named userHasAdminPrivs() returns false; otherwise, the deletion is allowed: on (removeItem) { if (globalObj.userHasAdminPrivs()) { // Allow the item deletion. eventObj.result = true; } else { // Don’t allow the item deletion; user doesn’t have admin privileges. eventObj.
-
DataSet.removeItem() Availability Flash Player 7. Edition Flash MX Professional 2004. Usage dataSetInstance.removeItem([item]) Parameters item The item to be removed. This parameter is optional. Returns A Boolean value. Returns true if the item was successfully removed; otherwise, returns false. Description Method; removes the specified item from the collection, or removes the current item if the item parameter is omitted. This operation is logged to DataSet.deltaPacket if DataSet.logChanges is true.
-
DataSet.removeItemAt() Availability Flash Player 7. Edition Flash MX Professional 2004. Usage dataSetInstance.removeItemAt(index) Parameters index A number greater than or equal to 0. This number is the index of the item to remove. Returns A Boolean value indicating whether the item was removed. Description Method; removes the item at the specified index. The indices after the removed index collapse by one. This method triggers the modelChanged event with the event name removeItems.
-
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.
-
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.
-
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 my_ds. With the DataSet component selected, create three new properties in the schema of the DataSet component by using the Schema tab in the Component inspector. Name the new properties name, id, and gradeLevel, and give them the data types of String, Number, and Number respectively.
-
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 DataSet.
-
Example The following example displays a form called reconcileForm (not shown) and calls a method on that form object (setReconcileData()) that allows the user to reconcile any conflicting values returned by the server: import mx.data.components.datasetclasses.*; my_ds.addEventListener("resolveDelta", onResolveDelta); function onResolveDelta(eventObj:Object) { reconcileForm.visible = true; reconcileForm.setReconcileData(eventObj.
-
Parameters objName A string that specifies the name of the shared object to create. The name can 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 file that created the shared object. This string is used to determine where the object is stored on the user’s computer. The default value is the SWF file’s full path.
-
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:
-
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” on page 333.
-
Description Method; assigns the specified iterator to this DataSet object and makes it the current iterator. The specified iterator must come from a previous call to DataSet.getIterator() on the DataSet object to which it is being assigned; otherwise; a DataSetError exception is thrown. Example import mx.data.to.ValueListIterator; myIterator:ValueListIterator = my_ds.getIterator(); myIterator.sortOn(["name"]); my_ds.setIterator(myIterator); See also DataSet.getIterator() DataSet.
-
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.
-
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}); my_ds.addItem({name:"Carrie", id:106, gradeLevel:4}); my_ds.addItem({name:"Mally", id:112, gradeLevel:3}); my_ds.
-
Example The following example uses DataSet.hasSort() to determine if a sort named "customer" exists. If it does, the code calls DataSet.useSort() to make "customer" the current sort. Otherwise, the code creates a sort by that name using DataSet.addSort(). if (my_ds.hasSort("customer")) { my_ds.useSort("customer"); } else { my_ds.addSort("customer", ["customer"], DataSetIterator.Descending); } See also DataSet.applyUpdates(), DataSet.hasSort() DataSet.
-
410 Components Dictionary
-
CHAPTER 14 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.
-
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.
-
This code assigns a value to the selectableRange property in an ActionScript object that contains two Date objects with the variable names rangeStart and rangeEnd. This defines an upper and lower end of a range in which the user can select a date. 4. 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), rangeEnd: new Date(2003, 11, 26)}]; 5.
-
A DateChooser component supports the following styles: Style Theme Description themeColor Halo The glow color for the rollover and selected dates. Possible values are "haloGreen", "haloBlue", and "haloOrange". The default value is "haloGreen". backgroundColor Both The background color. The default value is 0xEFEBEF (light gray). borderColor Both The border color. The default value is 0x919999. The DateChooser component uses a solid single-pixel line as its border.
-
Style Theme Description fontWeight Both The font weight: either "none" or "bold". The default value is "none". All components can also accept the value "normal" in place of "none" during a setStyle() call, but subsequent calls to getStyle() returns "none". textDecoration Both The text decoration: either "none" or "underline". The default value is "none". The DateChooser component uses four categories of text to display the month name, the days of the week, today’s date, and regular dates.
-
Only the month scrolling buttons can be dynamically skinned in this component. A DateChooser component uses the following skin properties: Property Description backMonthButtonUpSymbolName The month back button up state. The default value is backMonthUp. backMonthButtonDownSymbolName The month back button pressed state. The default value is backMonthDown. backMonthButtonDisabledSymbolName The month back button disabled state. The default value is backMonthDisabled.
-
8. Click the Back button to return to the main timeline. 9. Drag a DateChooser component to the Stage. 10. Select Control > Test Movie. NO TE The DateChooser Assets/States folder also contains a Day Skins folder with a single skin element, cal_todayIndicator. This element can be modified during authoring to customize the today indicator. However, it cannot be changed dynamically on a particular DateChooser instance to use a different symbol.
-
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 UIObject.createClassObject() Creates an object on the specified class. UIObject.createObject() Creates a subobject on an object. UIObject.
-
Property summary for the DateChooser class The following table lists the properties that are exclusive to the DateChooser class. Property Description DateChooser.dayNames An array indicating the names of the days of the week. DateChooser.disabledDays An array indicating the days of the week that are disabled for all applicable dates in the date chooser. DateChooser.disabledRanges A range of disabled dates or a single disabled date. DateChooser.
-
Property Description UIObject.top The position of the top edge of the object, relative to its parent. Read-only. UIObject.visible A Boolean value indicating whether the object is visible (true) or not (false). UIObject.width The width of the object, in pixels. Read-only. UIObject.x The left edge of the object, in pixels. Read-only. UIObject.y The top edge of the object, in pixels. Read-only.
-
Event Description UIObject.resize Broadcast when an object has been resized. UIObject.reveal Broadcast when an object’s state changes from invisible to visible. UIObject.unload Broadcast when the subobjects are being unloaded. Events inherited from the UIComponent class The following table lists the events the DateChooser class inherits from the UIComponent class. Event Description UIComponent.focusIn Broadcast when an object receives focus. UIComponent.
-
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 (dataChooserInstance) dispatches an event (in this case, change) and the event is handled by a function, also called a handler, on a listener object (listenerObject) that you create. You define a method with the same name as the event on the listener object; the method is called when the event is triggered.
-
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 The following example changes the value of the days of the week: my_dc.
-
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 rangeStart and rangeEnd, each of whose value must be a Date object.
-
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 the monthNames array, with 0 being the first month. The default value is the month of the current date. Example The following example sets the displayed month to December: my_dc.displayedMonth = 11; See also DateChooser.displayedYear DateChooser.
-
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 dayNames array) is displayed in the first column of the DateChooser component.
-
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: my_dc.
-
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, scroll) and the event is handled by a function, also called a handler, on a listener object (listenerObject) that you create. You define a method with the same name as the event on the listener object; the method is called when the event is triggered.
-
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 rangeStart and rangeEnd. The rangeStart and rangeEnd properties designate the boundaries of the selectable date range.
-
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)}; The following example defines the selectable range as the dates before and including June 7: my_dc.
-
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; DateChooser.
-
432 DateChooser component (Flash Professional only)
-
CHAPTER 15 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. When a user clicks anywhere inside the bounding box of the date field, a date chooser pops up and displays the dates in the month of the selected date.
-
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 is ["S", "M", "T", "W", "T", "F", "S"]. disabledDays indicates the disabled days of the week. This parameter is an array that can have up to seven values. The default value is [] (an empty array).
-
This code assigns a value to the selectableRange property in an ActionScript object that contains two Date objects with the variable names rangeStart and rangeEnd. This defines an upper and lower end of a range within which the user can select a date. 4. 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.
-
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. For more information, see “Using styles to customize component color and text” in Using Components. The DateField component supports the following styles: Style Theme Description themeColor Halo The glow color for the rollover and selected dates.
-
Style Theme Description embedFonts Both A Boolean value that indicates whether the font specified in fontFamily is an embedded font. This style must be set to true if fontFamily refers to an embedded font. Otherwise, the embedded font is not used. If this style is set to true and fontFamily does not refer to an embedded font, no text is displayed. The default value is false. fontFamily Both The font name for text. The default value is "_sans". fontSize Both The point size for the font.
-
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’ FLA files. For more information, see “About skinning components” in Using Components.
-
11. Drag a DateField component to the Stage. 12. 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.
-
Methods inherited from the UIObject class The following table lists the methods the DateField class inherits from the UIObject class. When calling these methods from the DateField object, use the form dateFieldInstance.methodName. Method Description UIObject.createClassObject() Creates an object on the specified class. UIObject.createObject() Creates a subobject on an object. UIObject.destroyObject() Destroys a component instance. UIObject.
-
Property summary for the DateField class The following table lists properties of the DateField class. Property Description DateField.dateFormatter A function that formats the date to be displayed in the text field. DateField.dayNames An array indicating the names of the days of the week. DateField.disabledDays An array indicating the disabled days of the week. DateField.disabledRanges A range of disabled dates or a single disabled date. DateField.
-
Property Description UIObject.scaleX A number indicating the scaling factor in the x direction of the object, relative to its parent. UIObject.scaleY A number indicating the scaling factor in the y direction of the object, relative to its parent. UIObject.top The position of the top edge of the object, relative to its parent. Read-only. UIObject.visible A Boolean value indicating whether the object is visible (true) or not (false). UIObject.width The width of the object, in pixels. Read-only.
-
Events inherited from the UIObject class The following table lists the events the DateField class inherits from the UIObject class. Event Description UIObject.draw Broadcast when an object is about to draw its graphics. UIObject.hide Broadcast when an object’s state changes from visible to invisible. UIObject.load Broadcast when subobjects are being created. UIObject.move Broadcast when the object has moved. UIObject.resize Broadcast when an object has been resized. UIObject.
-
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.
-
Example The following example, written on a frame of the timeline, sends a message to the Output panel when a date field called my_df is changed. The first line of code creates a listener object called dfListener. The second line defines a function for the change event on the listener object. Inside the function is a trace() statement that uses the event object that is automatically passed to the function, in this example evt_obj, to generate a message.
-
Example The following code closes the date chooser pop-up of the my_df date field instance when the button my_btn is clicked: //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). Edition Flash MX Professional 2004. Usage Usage 1: var listenerObject:Object = new Object(); listenerObject.
-
The first usage example uses a dispatcher/listener event model. A component instance (dateFieldInstance) dispatches an event (in this case, close) and the event is handled by a function, also called a handler, on a listener object (listenerObject) that you create. You define a method with the same name as the event on the listener object; the method is called when the event is triggered. When the event is triggered, it automatically passes an event object (eventObject) to the listener object method.
-
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){ return d.getFullYear()+"/ "+(d.
-
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). Edition Flash MX Professional 2004. Usage dateFieldInstance.disabledDays Description Property; an array indicating the disabled days of the week.
-
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 rangeStart and rangeEnd, each of whose value must be a Date object. The rangeStart and rangeEnd properties describe the boundaries of the date range. If either property is omitted, the range is unbounded in that direction.
-
Description Property; a number indicating which month is displayed. The number indicates an element in the monthNames array, with 0 being the first month. The default value is the month of the current date. Example The following example sets the displayed month to December: my_df.displayedMonth = 11; See also DateField.displayedYear DateField.displayedYear Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage dateFieldInstance.
-
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 dayNames array) is displayed in the first column of the DateField component. Changing this property changes the order of the day columns but has no effect on the order of the dayNames property. The default value is 0 (Sunday).
-
Example The following example sets the 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.
-
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. The first usage example uses a dispatcher/listener event model.
-
The second usage example uses an on() handler and must be attached directly to a DateField instance. The keyword this, used inside an on() handler attached to a component, refers to the component instance. For example, the following code, attached to the date field my_df, sends “_level0.my_df ” to the Output panel: on (open) { trace(this); } Example The following example, written on a frame of the timeline, sends a message to the Output panel when a date field called my_df is opened.
-
Description Property (read-only); a reference to the DateChooser component contained by the DateField component. The DateChooser subcomponent is instantiated when a user clicks on the DateField component. However, if the pullDown property is referenced before the user clicks on the component, the DateChooser is instantiated and then hidden.
-
The first usage example uses a dispatcher/listener event model. A component instance (dateFieldInstance) dispatches an event (in this case, scroll) and the event is handled by a function, also called a handler, on a listener object (listenerObject) that you create. You define a method with the same name as the event on the listener object; the method is called when the event is triggered. When the event is triggered, it automatically passes an event object (eventObject) to the listener object method.
-
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 rangeStart and rangeEnd. The rangeStart and rangeEnd properties designate the boundaries of the selectable date range. If only rangeStart is defined, all the dates after rangeStart are enabled.
-
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)}; The following example defines the selectable range as the dates before and including June 7: my_df.
-
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.
-
16 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” in Using Components), and so that you can call functions within the scope of the containing class. When you pass a function as a parameter to EventDispatcher.
-
Delegate.create() Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage Delegate.create(scopeObject, function) Parameters scopeObject function A reference to an object. This is the scope in which to run the function. A reference to a function. Description Method (static); allows you to delegate events to specific scopes and functions. Use the following syntax: import mx.utils.Delegate; compInstance.addEventListener("eventName", Delegate.
-
CHAPTER 17 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.
-
Property Description DeltaItem.name The name of the property or method that changed. This property is read-only. DeltaItem.newValue If a change was made to a property, this is the new value of the property. This property is read-only. DeltaItem.oldValue If a change was made to a property, this is the old value of the property. This property is read-only. DeltaItem.argList Availability Flash Player 7. Edition Flash MX Professional 2004. Usage deltaitem.
-
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. DeltaItem.delta Availability Flash Player 7. Edition Flash MX Professional 2004. Usage deltaitem.
-
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. DeltaItem.name Availability Flash Player 7.
-
DeltaItem.newValue Availability Flash Player 7. Edition Flash MX Professional 2004. Usage deltaitem.newValue Description Property (read-only); an object containing the new value of the property. This property applies only if the change’s kind is DeltaItem.Property. DeltaItem.oldValue Availability Flash Player 7. Edition Flash MX Professional 2004. Usage deltaitem.oldValue Description Property (read-only); an object containing the old value of the property.
-
468 DeltaItem class (Flash Professional only)
-
CHAPTER 18 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.
-
Delta.addDeltaItem() Availability Flash Player 7. Edition Flash MX Professional 2004. Usage delta.addDeltaItem(deltaitem) Parameters deltaitem DeltaItem instance to add to this delta. Returns Nothing. Description Method; adds the specified DeltaItem instance. If the specified DeltaItem instance already exists, this method replaces it. Example The following example calls the addDeltaItem() method: //... var d:Delta = new DeltaImpl("ID1345678", curItem, DeltaPacketConsts.Added, "", false); d.
-
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 getChangeList() method.: //... case mx.data.components.datasetclasses.DeltaPacketConsts.Modified: { // dpDelta is a variable of type Delta. var changes:Array = dpDelta.getChangeList(); for(var i:Number = 0; i
-
Description Method; returns the delta packet that contains this delta. This method lets you write code that can handle delta packets generically at the delta level. Example The following example uses the getDeltaPacket() method to access the delta packet’s data source: while(dpCursor.hasNext()) { dpDelta = Delta(dpCursor.next()); trace("DeltaPacket source is: " + dpDelta.getDeltaPacket().getSource()); } Delta.getId() Availability Flash Player 7. Edition Flash MX Professional 2004. Usage delta.
-
Example The following example calls the getId() method: 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 DeltaItem object. name Returns The DeltaItem object specified by name.
-
Example The following example calls the getItemByName() method: private function buildFieldTag(deltaObj:Delta, field:Object, isKey:Boolean):String { var chgItem:DeltaItem = deltaObj.getItemByName(field.name); var result:String= "
-
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. Example The following example calls the getMessage() method: //... var dpi:Iterator = dp.getIterator(); var d:Delta; while(dpi.hasNext()) { d= dpi.next(); trace(d.getMessage()); } //... Delta.
-
Example The following example calls the getOperation() method: 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.
-
Example The following example calls the getSource() method: while(dpCursor.hasNext()) { dpDelta = Delta(dpCursor.next()); op=dpDelta.getOperation(); switch(op) { case mx.data.components.datasetclasses.DeltaPacketConsts.Modified: { // the original values are trace("Unmodified source is: "); var src = dpDelta.getDeltaPacket().getSource(); for(var i in src){ if(typeof(src[i]) != "function"){ trace(i+"="+src[i]); } } } } Delta.
-
478 Delta interface (Flash Professional only)
-
CHAPTER 19 19 DeltaPacket interface (Flash Professional only) ActionScript Interface Name mx.data.components.datasetclasses.DeltaPacket The DeltaPacket interface is provided by the deltaPacket property of the DataSet component, which is part of the data management functionality in Flash MX Professional 2004. (For more information, see Chapter 16, “Data Integration (Flash Professional Only),” in Using Flash). Typically the delta packet is used internally by resolver components.
-
Method summary for the DeltaPacket interface The following table lists the methods of the DeltaPacket interface. Method Description DeltaPacket.getConfigInfo() Returns configuration information that is specific to the implementation of the DeltaPacket interface. DeltaPacket.getIterator() Returns the iterator for the delta packet that iterates through the delta packet’s list of deltas. DeltaPacket.getSource() Returns the source of the delta packet.
-
Description Method; returns configuration information that is specific to the implementation of the DeltaPacket interface. This method allows implementations of the DeltaPacket interface to access custom information. Example The following example calls the getConfigInfo() method: // ... new DeltaPacketImpl(source, getTransactionId(), null, logChanges(), getConfigInfo()); // ... DeltaPacket.getIterator() Availability Flash Player 7. Edition Flash MX Professional 2004. Usage deltaPacket.
-
Example The following example uses the getIterator() method to access the iterator for the deltas in a delta packet and uses a while statement to loop through the deltas: var deltapkt:DeltaPacket = _parent.myDataSet.deltaPacket; trace("*** Test deltapacket. Trans ID is: " + deltapkt.getTransactionId() + " ***"); var OPS:Array = new Array("added", "removed", "modified"); var dpCursor:Iterator = deltapkt.getIterator(); var dpDelta:Delta; var op:Number; var changeMsg:String; while(dpCursor.
-
Example The following example calls the getSource() method: // ... 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.
-
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.
-
DeltaPacket.logChanges() Availability Flash Player 7. Edition Flash MX Professional 2004. Usage deltaPacket.logChanges() Parameters None. Returns A Boolean value; true if the consumer of the delta packet should log changes found in the delta packet. Description Method; returns true if the consumer of this delta packet should log the changes it specifies. 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.
-
486 DeltaPacket interface (Flash Professional only)
-
20 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 _root. It also lets you manage reserved depths in a special highest-depth clip on _root for system-level services such as the pointer and tooltips. In general, Depth Manager manages components automatically, using its own “shuffling” algorithm.
-
Method summary for the DepthManager class The following table lists the methods of the DepthManager class. Method Description DepthManager.createChildAtDepth() Creates a child of the specified symbol at the specified depth. DepthManager.createClassChildAtDepth() Creates an object of the specified class at the specified depth. DepthManager.createClassObjectAtDepth() Creates an instance of the specified class at a specified depth in the special highest-depth clip. DepthManager.
-
Property Description DepthManager.kTop A static property with the constant value 201. DepthManager.kTopmost A static property with the constant value 203. DepthManager.createChildAtDepth() Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage movieClipInstance.createChildAtDepth(linkageName, depthFlag[, initObj]) Parameters linkageName A linkage identifier. This parameter is a string. One of the following values: DepthManager.kTop, DepthManager.
-
DepthManager.createClassChildAtDepth() Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage movieClipInstance.createClassChildAtDepth(className, depthFlag[, initObj]) Parameters className A class name. This parameter is a of type Function. One of the following values: DepthManager.kTop, DepthManager.kBottom, All depth flags are static properties of the DepthManger class. You must either reference the DepthManager package (for example, mx.managers.DepthManager.
-
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 depthSpace One of the following values: DepthManager.kCursor, DepthManager.kTooltip. All depth flags are static properties of the DepthManger class. You must either reference the DepthManager package (for example, mx.managers.DepthManager.
-
DepthManager.createObjectAtDepth() Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage DepthManager.createObjectAtDepth(linkageName, depthSpace[, initObj]) Parameters linkageName A linkage identifier. This parameter is of type String. One of the following values: DepthManager.kCursor, DepthManager.kTooltip. All depth flags are static properties of the DepthManger class. You must either reference the DepthManager package (for example, mx.managers.DepthManager.
-
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() and DepthManager.createChildAtDepth() to place content behind other content. DepthManager.kCursor Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage DepthManager.
-
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() and DepthManager.createChildAtDepth() to request removal from the topmost layer. DepthManager.kTooltip Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage DepthManager.kTooltip Description Property (static); a property with the constant value 102.
-
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() and DepthManager.createChildAtDepth() to request placement on top of other content, including DepthManager.kTop objects. DepthManager.setDepthAbove() Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage movieClipInstance.
-
DepthManager.setDepthBelow() Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004 and Flash MX Professional 2004. Usage movieClipInstance.setDepthBelow(instance) Parameters instance An instance name. This parameter is of type MovieClip. Returns Nothing. Description Method; sets the depth of a movie clip or component instance below the depth of the specified instance and moves other objects if necessary.
-
Parameters One of the following values: DepthManager.kTop, DepthManager.kBottom, All depth flags are static properties of the DepthManger class. You must either reference the DepthManager package (for example, mx.managers.DepthManager.kTopmost) or use the import statement to import the DepthManager package. depthFlag DepthManager.kTopmost, DepthManager.kNotopmost. Returns Nothing. Description Method; sets the depth of movieClipInstance to the value specified by depthFlag.
-
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. NO TE 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.
-
21 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. For example, you use the EventDispatcher.addEventListener() method to register a listener with a component instance.
-
Some event object properties are defined in the W3C specification (www.w3.org/TR/DOMLevel-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. Property Description type A string indicating the name of the event.
-
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 event A string that is the name of the event. listener A reference to a listener object or function. Returns Nothing. Description Method; registers a listener object with a component instance that is broadcasting an event. When the event occurs, the listener object or function is notified.
-
You can register multiple listeners to a single component instance, but you must use a separate call to addEventListener() for each listener. Also, you can register one listener to multiple component instances, but you must use a separate call to addEventListener() for each instance. For example, the following code defines one listener object and assigns it to two Button component instances, whose label properties are button1 and button2, respectively: lo = new Object(); lo.click = function(evt){ trace(evt.
-
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 type property that is a string indicating the name of the event. Generally, the event object also has a target property that is the name of the instance broadcasting the event.
-
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 listener A reference to a listener object or function. Returns Nothing. Description Method; unregisters a listener object from a component instance that is broadcasting an event.
-
CHAPTER 22 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).
-
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.
-
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” on page 698. Using the FLVPlayback component Using the FLVPlayback component basically consists of putting it on the Stage and specifying an FLV file for it to play.
-
5. Click the magnifying-glass icon to open the Select Skin dialog box. 6. 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. ■ Select None, and drag individual FLV Playback Custom UI components to the Stage to add playback controls.
-
6. 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 for the component, select Custom Skin URL from the pop-up menu, and enter the URL for the SWF file that contains the skin in the URL text box. Select None, and drag individual FLV Playback Custom UI components to the Stage to add playback controls.
-
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 true, the component plays the FLV file immediately when it is loaded. If false, the component loads the first frame and pauses. The default value is true for the default video player (0) and false for others.
-
isLive A Boolean value that, if true, specifies that the FLV file is streaming live from Flash Communication Server. One example of a live stream is a video of news events as they are taking place. The default value is false. For more information, see FLVPlayback.isLive on page 601.
-
Specifying the contentPath parameter The contentPath parameter lets you specify the name and location of the FLV file, both of 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.
-
You can also specify the name and location of the FLV file using the ActionScript FLVPlayback.contentPath property and the FLVPlayback.play() and FLVPlayback.load() methods. These three alternatives take precedence over the contentPath parameter in the Component inspector. For more information, see FLVPlayback.contentPath on page 579, FLVPlayback.play() on page 620 and FLVPlayback.load() on page 603. The FLV file options The Content Path dialog box also has two options.
-
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 cuePoint event. An event cue point enables you to synchronize a point in time within the FLV file with an external event on the web page.
-
Using the Flash Video Cue Points dialog box Open the Flash Video Cue Points dialog box by double-clicking the Value cell of the cuePoints parameter in the Component inspector. The dialog box looks like the 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. You can also enable or disable embedded cue points. However, you cannot add, change, or delete embedded cue points.
-
5. 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. 6. To add more ActionScript cue points, repeat steps 2 through 5 for each one. 7. Click OK to save your changes. To delete an ActionScript cue point: 1. Double-click the value cell of the cuePoints parameter in the Component inspector to open the Flash Cue Points dialog box. 2.
-
Adding ActionScript cue points You can add ActionScript cue points to an FLV file using the addASCuePoint() method. The 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. The second call specifies the time and name using the method’s time and name parameters. import mx.video.*; my_FLVPlybk.contentPath = "http://www.helpexamples.
-
The ready event handler in the following example calls the findCuePoint() method to find the cue point ASpt1 and then calls the findNearestCuePoint() method to find the 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" var rtn_obj:Object = new Object(); //create cue point object my_FLVPlybk.addASCuePoint(2.
-
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. When the cuePoint event occurs, the example calls the seekToPrevNavCuePoint() method to seek to the first cue point.
-
You can test whether an embedded FLV file cue point is enabled using the isFLVCuePointEnabled() method. The following example disables the embedded cue points point2 and point3 when the video is ready to play. When the first cuePoint event occurs, however, the event handler tests to see if cue point point3 is disabled and, if so, enables it. import mx.video.*; my_FLVPlybk.contentPath = "http://www.helpexamples.com/flash/video/ cuepoints.flv"; var listenerObject:Object = new Object(); listenerObject.
-
Playing multiple FLV files You can play FLV files sequentially in an FLVPlayback instance simply by loading a new URL in the contentPath property when the previous FLV file finishes playing. For example, the following ActionScript code listens for the complete event, which occurs when an FLV file finishes playing. When this event occurs, the code sets the name and location of a new FLV file in the contentPath property and calls the play() method to play the new video. import mx.video.*; my_FLVPlybk.
-
The following ActionScript code loads the contentPath property to play an FLV file in the default video player and adds a cue point for it. When the ready event occurs, the event handler opens a second video player by setting the activeVideoPlayerIndex property to the number 1. It specifies an FLV file and a cue point for the second video player and then makes the default player (0) the active video player again.
-
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; my_FLVPlybk.visibleVideoPlayerIndex = 1; my_FLVPlybk.play(); } else { my_FLVPlybk.
-
Streaming FLV files from a FCS If you use a FCS to stream FLV files to the FLVPlayback component, you must add the main.asc file to your Flash Communication Server FLV application. You can find the main.asc file in your Flash 8 application folder under Flash 8/Samples and Tutorials/Samples/ Components/FLVPlayback/main.asc. To set up your FCS for streaming FLV files: 1. Create a folder in your FCS application folder, and give it a name such as my_application. 2. Copy the main.
-
Selecting a predesigned skin You can select a skin for the FLVPlayback component by clicking the value cell for the 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. Skins that are listed in the Skin pop-up menu are located in the Flash 8 Configuration/Skins folder or in the user’s local Configuration/Skins folder.
-
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. After you open the components, you can see that each one is set up a little differently from the others. Button components The button components have a similar structure.
-
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 configure it.
-
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. This rectangle with alpha set to 0 is not necessary for any other reason and, generally, you can replace the inside of the handle with any image you want.
-
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.
-
The progress or fullness movie clip is scaled horizontally based on the percentage. At 0%, the instance’s _xscale is set to 0, making it invisible. As the percentage grows, the _xscale is adjusted until, at 100%, the clip is the same size it was on the Stage when it was created. Again, this is not necessarily _xscale = 100 because the clip instance might have been scaled when it was created.
-
5. In the Library panel, open the FLVPlayback Skins folder, and then open the SquareButton folder below it. 6. Select the SquareBgDown movie clip, and double-click it to open it on the Stage. 7. Right-click (Windows) or Control-click (Macintosh), select Select All from the menu, and delete the symbol. 8. Select the oval tool, draw an oval in the same location, and set the fill to blue #(0033FF). 9. In Property inspector, set the width (W:) to 40 and the height (H:) to 20.
-
22.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; my_FLVPlybk.muteButton = my_mutebttn; my_FLVPlybk.seekBar = my_seekbar; 23.Press Control+Enter to test the movie.
-
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. All the other controls are laid out relative to video_mc.
-
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. // minimum width and height of video recommended to use this skin, // leave as undefined or <= 0 if there is no minimum layout_mc.minWidth = 270; layout_mc.
-
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.
-
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. The bufferingBar_mc clip has 9-slice scaling applied to it, so the borders won’t distort when it scales.
-
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. These dimensions are, by default, equal and based on the difference between the x (horizontal) positions of seekBar_mc and seekBarProgress_mc.
-
ActionScript The seek bar and volume bar support the following additional properties: Property Description handle_mc:MovieClip The movie clip for the handle. Defaults to seekBarHandle_mc or volumeBarHandle_mc progress_mc:MovieClip The movie clip for progress. Defaults to seekBarProgress_mc or volumeBarProgress_mc. fullness_mc:MovieClip The movie clip for fullness. Defaults to seekBarFullness or volumeBarFullness.
-
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.
-
Method Description FLVPlayback.findNextCuePointWithName() Finds the next cue point with the same name as a cue point returned by the findCuePoint() or findNearestCuePoint() methods. FLVPlayback.getVideoPlayer() Gets the video player specified by the index parameter. FLVPlayback.isFLVCuePointEnabled() Returns false if the FLV file embedded cue point is disabled by ActionScript. FLVPlayback.load() Begins loading the FLV file with the autoPlay property set to false. FLVPlayback.
-
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 FLVPlayback.ACTIONSCRIPT "actionscript" Can use as type parameter for findCuePoint() and findNearestCuePoint() methods. FLVPlayback.
-
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. Property Description FLVPlayback.activeVideoPlayerIndex A number that specifies which FLV file stream is affected by other methods, properties, and events.
-
Property Description FLVPlayback.bytesLoaded A number that indicates the extent of downloading in number of bytes for an HTTP download. Read only. FLVPlayback.bytesTotal A number that specifies the total number of bytes downloaded for an HTTP download. Read-only. FLVPlayback.contentPath A string that specifies the URL of an FLV file to load. FLVPlayback.cuePoints An array that describes ActionScript cue points and disabled embedded FLV file cue points.
-
Property Description FLVPlayback.ncMgr An INCManager object that provides access to an instance of the class implementing INCManager. Read-only. FLVPlayback.pauseButton A MovieClip object that is the PauseButton control. FLVPlayback.paused A Boolean value that is true if the FLV file is in a paused state. Read-only. FLVPlayback.playButton A MovieClip object that is the PlayButton control. FLVPlayback.
-
Property Description FLVPlayback.seekBar A MovieClip object that is the SeekBar control. FLVPlayback.seekBarInterval A number that specifies, in milliseconds, how often to check the seekBar handle when scrubbing. The default value is 250. FLVPlayback.seekBarScrubTolerance A number (percentage) that specifies how far a user can move the scrubBar handle before an update occurs. The value is specified as a percentage, ranging from 1 to 100. FLVPlayback.
-
Property Description FLVPlayback.visibleVideoPlayerIndex A number that you can use to manage multiple FLV file streams. Sets which video player instance is visible and audible. Default is 0. FLVPlayback.volume A number in the range of 0 to 100 that indicates the volume control setting. FLVPlayback.volumeBar A MovieClip object that is the VolumeBar control. FLVPlayback.volumeBarInterval A number that specifies, in milliseconds, how often to check the volumeBar handle when scrubbing.
-
Event Description FLVPlayback.paused Dispatched when the pause state is entered. FLVPlayback.playheadUpdate Dispatched every .25 seconds by default while the FLV file is playing. You can specify frequency with the playheadUpdateInterval property. FLVPlayback.playing Dispatched when the playing state is entered. FLVPlayback.progress Dispatched every .25 seconds, starting when the load() method is called and ending when all bytes are loaded or there is a network error.
-
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 type property with the findCuePoint() and findNearestCuePoint() methods. Example The following example uses the ACTIONSCRIPT constant to set the type property of the findCuePoint() method.
-
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; use the visibleVideoPlayerIndex property to do that.
-
APIs that control volume, positioning, dimensions, visibility, and UI controls are always global, and their behavior is not affected by setting activeVideoPlayerIndex. Specifically, setting the activeVideoPlayerIndex property does not affect the following properties and methods.
-
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.*; // specify name and location of FLV for default player my_FLVPlybk.contentPath = "http://www.helpexamples.com/flash/video/ clouds.flv"; var listenerObject:Object = new Object(); listenerObject.
-
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 name:String and time:Number (in seconds) properties, which describe the cue point. It also might have a parameters:Object property that holds name/ value pairs. It may have type:String set to "actionscript".
-
Example The following example adds two ActionScript cue points to an FLV file. The example adds the first one using a CuePoint parameter and the second one using the time and name parameters. When each cue point occurs while playing, a listener for cuePoint events shows the value of the playheadTime property in a text area. Drag an FLVPlayback component to the Stage, and give it an instance name of my_FLVPlybk.
-
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 the listener is an object, this is also the name of the listener object function to call. event listener The name of the listener object or function that you are registering for the event. Returns Nothing.
-
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!"; my_ta.visible = true; }; my_FLVPlybk.
-
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.*; my_FLVPlybk.contentPath = "http://www.helpexamples.com/flash/video/ cuepoints.flv"; // create cue point object var listenerObject = new Object(); listenerObject.
-
Description Property; a Boolean value that, if set to true, causes the FLV file to play immediately when the contentPath property is set. If set to false, the component waits for the play command. Even if autoPlay is set to false, the component loads the content immediately. The default value is true. If you set the property to true between the loading of new FLV files, it has no effect until contentPath is set.
-
Description Property; a Boolean value that, if true, causes the FLV file to rewind to Frame 1 when play stops, either because the player reached the end of the stream or the stop() method was called. This property is meaningless for live streams. The default value is true. Example The following example sets the autoRewind property to false to prevent the FLV file from automatically rewinding when it finishes playing. Drag an FLVPlayback component to the Stage, and give it an instance name of my_FLVPlybk.
-
Example The following example first show the source dimensions of the FLV file (preferredWidth and preferredHeight) when the FLV file is ready to play. Then it calls the setSize() to change the dimensions of the FLVPlayback instance, triggering a resize event. Next, it sets the autoSize property to true, triggering another resize event that restores the size to the dimensions of the source FLV file.
-
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 rewind event.
-
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. When streaming video from a FCS, you can provide a SMIL file that describes how to switch between multiple streams based on bandwidth.
-
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 contentPath property, replace the italicized text with the name and location of your SMIL file. /** Requires: - FLVPlayback component in the Library - RadioButton component in the Library - Label component in the Library */ import mx.
-
FLVPlayback.bringVideoPlayerToFront() Availability Flash Player 8. Edition Flash Professional 8. Usage my_FLVPlybk.bringVideoPlayerToFront(index:Number) Parameters index A number that is the index of the video player to move to the front Description Method; brings a video player to the front of the stack of video players. Useful for custom transitions between video players.
-
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"); var listenerObject:Object = new Object(); listenerObject.ready = function(eventObject:Object) { if (eventObject.target.contentPath == "http://www.helpexamples.
-
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.
-
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.*; var listenerObject:Object = new Object(); listenerObject.buffering = function(eventObject:Object) { trace("The state property has a value of " + eventObject.target.state); trace("The video player number is: " + eventObject.
-
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.*; var listenerObject:Object = new Object(); listenerObject.stateChange = function(eventObject:Object):Void { if(eventObject.state == FLVPlayback.BUFFERING) trace(FLVPlayback.BUFFERING); }; my_FLVPlybk.
-
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.*; var listenerObject:Object = new Object(); listenerObject.stateChange = function(eventObject:Object):Void { if(my_FLVPlybk.buffering){ trace("The video is buffering"); } }; my_FLVPlybk.
-
Example The following example attaches individual FLV Playback Custom UI controls to an FLVPlayback component by setting the following properties: playPauseButton, stopButton, backButton, forwardButton, and bufferingBar. The buffering bar appears 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 skin parameter to None in the Component inspector.
-
FLVPlayback.bufferingBarHidesAndDisablesOthers Availability Flash Player 8. Edition Flash Professional 8. Usage my_FLVPlybk.bufferingBarHidesAndDisablesOthers Description Property; if set to true, hides the SeekBar control and disables the Play, Pause, PlayPause, BackButton and ForwardButton controls while the FLV file is in the buffering state.
-
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.
-
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. The returned value is useful only for an HTTP download. Read-only.
-
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. The returned value is useful only for an HTTP download. Read-only.
-
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.
-
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.
-
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 complete event calls the closeVideoPlayer() method to close the second player.
-
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.
-
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 "connectionError". You can compare this property to the state property to determine if a connection error state has occurred.
-
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. If you set this property through the Component inspector or the Property inspector, the FLV file begins loading and playing at the next MovieClip.onEnterFrame event.
-
Drag an FLVPlayback component to the Stage, and give it an instance name of my_FLVPlybk. Do not assign a value to the contentPath parameter in the Component 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.*; my_FLVPlybk.contentPath = "http://www.helpexamples.com/flash/video/ water.flv"; var listenerObject:Object = new Object(); listenerObject.
-
Example The following example adds two ActionScript cue points to an FLV file. The example adds the first one using a cuePoint parameter and the second one using the time and name parameters. When each cue point occurs, a listener for cuePoint events shows the value of the playheadTime property in a text area. Drag an FLVPlayback component to the Stage, and give it an instance name of my_FLVPlybk. Drag a TextArea component to the Stage below the FLVPlayback instance, and give it an instance name of my_ta.
-
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.
-
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 state property to determine if a disconnected state exists. The FLVPlayback instance is in a disconnected state until you set the contentPath property.
-
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, "event". You can use this property as the type parameter for the findCuePoint() and findNearesstCuePoint() methods. Example The following example uses the FLVPlayback.EVENT property to specify that it wants to find a cue point named myCue that is of the event type.
-
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.
-
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.*; var listenerObject:Object = new Object(); listenerObject.ready = function(eventObject:Object):Void { my_FLVPlybk.seekPercent(35); }; my_FLVPlybk.addEventListener("ready", listenerObject); listenerObject.
-
Parameters A number that is the time, in seconds, of the cue point for which to search. The 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. It returns null if it does not find a match. time name A string that is the name of the cue point for which to search.
-
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 findCuePoint() method three times. The first call looks for a navigation cue point with a time of 7.748. The second call looks for cue point "ASCue1", using only a name value. The third call uses a cue point object that specifies both a time, 10, and a name, "ASCue2".
-
// 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, FLVPlayback.findNearestCuePoint(), FLVPlayback.findNextCuePointWithName(), FLVPlayback.isFLVCuePointEnabled(), FLVPlayback.removeASCuePoint(), FLVPlayback.seekToNavCuePoint(), FLVPlayback.
-
An object that is a cue point object containing time and name properties for which to search. If you provide a time and the name property has no value or is null, the search behaves as if the parameter is a number representing the time for which to search. If you provide a name and the time property has no value, is null, or is less than zero, the search behaves as if the parameter is a string containing a name for which to search.
-
Example The following example creates an ActionScript cue point for the FLV file at 4.07 seconds. When this cue point occurs, the cuePoint event handler calls the 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. Drag an FLVPlayback component to the Stage, and give it an instance name of my_FLVPlybk.
-
FLVPlayback.findNextCuePointWithName() Availability Flash Player 8. Edition Flash Professional 8. Usage my_FLVplybk.findNextCuePointWithName(my_cuePoint:Object) Parameters my_cuePoint A cue point object that has been returned by either the findCuePoint() method, the findNearestCuePoint() method, or a previous call to this method. Returns An object that is a copy of the found cue point object with the following additional properties: The array of cue points searched.
-
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.*; my_FLVPlybk.contentPath = "http://www.helpexamples.com/flash/video/ cuepoints.flv"; var cuePt:Object = new Object(); //create cue point object cuePt.time = 6.27; cuePt.name = "transition"; cuePt.type = "actionscript"; my_FLVPlybk.
-
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, "flv". You can use this property as the type parameter for the findCuePoint() and findNearestCuePoint() methods. Example The following example looks for a cue point named point2 with a time of 7.748 among FLV file cue points and displays the type and time found.
-
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” on page 525.
-
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 index. When possible, it is best to access VideoPlayer methods and properties using FLVPlayback methods and properties. Each VideoPlayer._name property is its index.
-
//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.
-
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.*; my_FLVPlybk.maintainAspectRatio = false; my_FLVPlybk.width = 300; my_FLVPlybk.height = 350; my_FLVPlybk.contentPath = "http://www.helpexamples.com/flash/video/ water.flv"; See also FLVPlayback.preferredHeight, FLVPlayback.
-
Example The following example assumes playing a streaming FLV file from a FCS or FVSS. The example sets the idleTimeout property to a low value of 10 milliseconds, which triggers a timeout and, consequently, a close event on the RTMP connection. The listener for the close event shows the index number of the video player for which the event occurred. Drag an FLVPlayback component to the Stage, and give it an instance name of my_FLVPlybk.
-
A cue point object with time and name properties for the cue point. The method does not check any other properties on the incoming cue point object. If time or name is undefined, the method uses only the property that is defined. cuePoint Returns A Boolean value that is false if the cue point or cue points are found and are disabled, and true if the cue point is not disabled or does not exist.
-
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.
-
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 contentPath property, replace the italicized text with the name and location of an FLV file on your FCS. /** Requires: - FLVPlayback component on the Stage with an instance name of my_FLVPlybk */ import mx.video.*; var listenerObject:Object = new Object(); listenerObject.
-
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 contentPath property, replace the italicized text with the name and location of an FLV file on your FCS. /** Requires: - FLVPlayback component on the Stage with an instance name of my_FLVPlybk */ import mx.video.*; my_FLVPlybk.
-
Returns Nothing. Description Method; begins loading the FLV file and provides a shortcut for setting the autoPlay property to false and setting the contentPath, totalTime, and isLive properties, if given. If the totalTime and isLive properties are undefined, they are not set. If the contentPath property is undefined, null, or an empty string, this method does nothing. Example The following example calls the load() method to load an FLV file that is specified by the contentPath parameter.
-
Description A read-only FLVPlayback class property that contains the string constant, "loading". You can compare this property to the state property to determine whether the component is in the loading state. Example The following example displays the value of the FLVPlayback.LOADING property if the FLV file is in the loading state. Drag an FLVPlayback component to the Stage, and give it an instance name of my_FLVPlybk.
-
Description Property; a Boolean value that, if true, maintains the video aspect ratio. If this property is changed from false to true and the autoSize property is false after an FLV file has been loaded, an automatic resize of the video starts immediately. The default value is true. Example The following example calls the setSize() method to change the size of the FLVPlayback instance, causing a resize event.
-
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 NetSteam.onMetaData() callback function, if available. Read only. If the FLV file is encoded with the Flash 8 encoder, the metadata property contains the following information. Older FLV files contain only the height, width, and duration values.
-
Parameter Description framerate A number that is the frame rate of the FLV file. videodatarate A number that is the video data rate of the FLV file. height A number that is the height of the FLV file. width A number that is the width of the FLV file. duration A number that specifies the duration of the FLV file in seconds. Example The following example shows in the Output panel a sampling of metadata values from the FLV file cuepoints.flv.
-
Edition Flash Professional 8. Usage my_FLVPlybk.metadataLoaded Description Property; a Boolean value that is true if a metadata packet has been encountered and processed or if the FLV file was encoded without the metadata packet. In other words, the value is true if the metadata is received, or if you are never going to get any metadata. So, you know if you have the metadata; and if you don’t have the metadata, you know not to wait around for it.
-
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 info property that contains the info object received by the NetStream.onMetaData callback.
-
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.*; var listenerObject:Object = new Object(); listenerObject.metadataReceived = function(eventObject:Object):Void { var i:Number = 0; trace("This FLV contains the following cue points:"); while(i < my_FLVPlybk.metadata.cuePoints.
-
Example The following example uses the backButton, forwardButton, playPauseButton, stopButton, and muteButton properties to attach individual FLV Custom UI controls to an FLVPlayback component. Drag an FLVPlayback component to the Stage, and give it an instance name of my_FLVPlybk and set the skin parameter to None in the Component inspector.
-
Description A read-only FLVPlayback class property that contains the string constant, "navigation". You can use this property for the type parameter of the findCuePoint() and findNearestCuePoint() methods. Example The following example uses the FLVPlayback.NAVIGATION property to specify the type of cue point to find. Drag an FLVPlayback component to the Stage, and give it an instance name of my_FLVPlybk.
-
Description Property; an INCManager object that provides access to an instance of the class implementing INCManager, which is an interface to the NCManager class. 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 DEFAULT_TIMEOUT property when the ready event occurs. Drag an FLVPlayback component to the Stage, and give it an instance name of my_FLVPlybk.
-
Parameters None. Returns Nothing. Description Method; pauses playing the video stream. Example The following example creates a listener for the playheadUpdate event. When it occurs, the event handler checks to see whether the playhead time is between 5 and 5.05 seconds. If it is, the event handler calls the pause() method to suspend playing the FLV file. The paused event handler prompts you to push the Play button to continue.
-
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.
-
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, "paused". You can compare this property to the state property to see if the component is in the paused state. Example The following example uses the FLVPlayback.PAUSED property to show the state of the FLV file when the user clicks the Pause button.
-
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.
-
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.*; my_FLVPlybk.playheadUpdateInterval = 5; var listenerObject:Object = new Object(); listenerObject.playheadUpdate = function(eventObject:Object):Void { if ((eventObject.playheadTime >= 5) && (eventObject.playheadTime < 5.
-
Example The following example creates a listener for the stateChange event. When the event occurs, it checks the paused property to determine whether the component is in the paused state. If 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. Drag an FLVPlayback component to the Stage, and give it an instance name of my_FLVPlybk.
-
totalTime A number that is the total playing time for the video. Optional. isLive A Boolean value that is true if the video stream is live. This value is effective only when streaming from a FCS or FVSS. The value of this property is ignored for an HTTP download. Optional. Returns Nothing. Description Method; plays the video stream. With no parameters, the method simply takes the FLV file from a paused or stopped state to the playing state.
-
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.
-
FLVPlayback.playheadPercentage Availability Flash Player 8. Edition Flash Professional 8. Usage my_FLVPlybk.playheadPercentage Description Property; a number that specifies the current playheadTime as a percentage of the totalTime property. If you access this property, it contains the percentage of playing time that has elapsed. If you set this property, it causes a seek operation to the point representing that percentage of the FLV file’s playing time.
-
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.*; my_FLVPlybk.contentPath = "http://www.helpexamples.com/flash/video/ cuepoints.flv"; var listenerObject:Object = new Object(); listenerObject.cuePoint = function(eventObject:Object):Void { if(eventObject.info.
-
For several reasons, the playheadTime property might not have the expected value immediately after calling one of the seek methods or setting playheadTime to cause seeking. 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. (When streaming, a seek always goes to the precise specified time even if the source FLV file doesn’t have a keyframe there.
-
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 playheadUpdateInterval property. The default is .25 seconds. The component does not dispatch this event when the video player is paused or stopped unless a seek occurs.
-
Usage my_FLVPlybk.playheadUpdateInterval Description Property; a number that is the amount of time, in milliseconds, between each playheadUpdate event. Setting this property while the FLV file is playing restarts the timer. 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.
-
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, "playing". You can compare this property to the state property to determine if the component is in the playing state. Example The following example uses the FLVPlayback.PLAYING property to see if the state equals "playing" when a stateChange event occurs.
-
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.
-
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 true if the FLV file is in the playing state. Read-only. Example The following example listens for occurrences of the stateChange event as it occurs while the FLV file plays.
-
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.
-
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 play() or load() methods. It is valid when the ready event starts. If the value of the autoSize property or maintainAspectRatio property is true, it is best to read the value when the resize event starts. Read-only.
-
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.
-
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.*; var listenerObject:Object = new Object(); listenerObject.resize = function(eventObject:Object):Void { trace("width is: " + my_FLVPlybk.width); trace("height is: " + my_FLVPlybk.height); }; my_FLVPlybk.
-
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 progressInterval property, starting when the load begins and ending when all bytes are loaded or there is a network error. Default is every .25 seconds. Dispatched only for a progressive HTTP download.
-
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.
-
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 play() or load() method.
-
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 time and name properties for the cue point to remove.
-
Example The following example adds an ActionScript cue point to the FLV file, and then calls the removeASCuePoint() method to remove it. It shows the name of the removed cue point in the Output panel. 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.*; my_FLVPlybk.
-
Returns Nothing. Description Method; removes an event listener from a component instance. Example The following example removes the listener for a cuePoint event when the first cue point 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.
-
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 visibleVideoPlayerIndex property and switch to a video player with different dimensions.
-
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.*; // turn off autoSize and maintainAspectRatio my_FLVPlybk.autoSize = false; my_FLVPlybk.maintainAspectRatio = false; // play this FLV my_FLVPlybk.contentPath = "http://www.helpexamples.com/flash/video/ clouds.
-
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() or when an automatic rewind completes. The event object has the properties auto, state, and playheadTime.
-
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.*; my_FLVPlybk.autoRewind = true; var listenerObject:Object = new Object(); listenerObject.rewind = function(eventObject:Object) { trace("Video player is #" + eventObject.vp); trace("State is: " + eventObject.
-
Example The following example creates a listener for the stateChange event and uses the FLVPlayback.REWINDING property to determine whether the component is in the rewinding state. 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.
-
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.*; my_FLVPlybk.scaleX = 150; my_FLVPlybk.scaleY = 150; my_FLVPlybk.contentPath = "http://www.helpexamples.com/flash/video/ water.flv"; See also FLVPlayback.setScale(), FLVPlayback.scaleY FLVPlayback.scaleY Availability Flash Player 8.
-
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.*; my_FLVPlybk.scaleX = 150; my_FLVPlybk.scaleY = 150; my_FLVPlybk.contentPath = "http://www.helpexamples.com/flash/video/ water.flv"; See also FLVPlayback.scaleX, FLVPlayback.setScale() FLVPlayback.
-
/** 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.
-
Example The following example listens for the scrubFinish event and shows the time at which 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: N OT E You must grab the handle of the SeekBar, drag it, and release it to cause the event. /** Requires: - FLVPlayback component on the Stage with an instance name of my_FLVPlybk */ import mx.video.*; my_FLVPlybk.
-
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. The event object has the properties state and playheadTime. The component also dispatches the stateChange event with the state property equal to “seeking”.
-
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 seek(), by setting the playheadTime property or by using the seekBar control. The playheadTime property is the destination time.
-
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.*; var listenerObject:Object = new Object(); listenerObject.seek = function(eventObject:Object) { trace("A seek event occurred at " + eventObject.playheadTime); }; my_FLVPlybk.addEventListener("seek", listenerObject); listenerObject.
-
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 playheadTime property might not have the expected value immediately after calling one of the seek methods or setting playheadTime to cause seeking. 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.
-
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” on page 525.
-
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.
-
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.
-
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, "seeking". You can compare this property to the state property to determine whether the component is in the seeking state. Example The following example uses the FLVPlayback.
-
FLVPlayback.seekPercent() Availability Flash Player 8. Edition Flash Professional 8. Usage my_FLVplybk.seekPercent(percent:Number) Parameters percent A number that specifies a percentage of the length of the FLV file at which to place 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.
-
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.*; my_FLVPlybk.autoPlay = false; my_FLVPlybk.contentPath = "http://www.helpexamples.com/flash/video/ water.flv"; var listenerObject:Object = new Object(); listenerObject.ready = function(eventObject:Object) { my_FLVPlybk.
-
For several reasons, the playheadTime property might not have the expected value immediately after calling one of the seek methods or setting playheadTime to cause seeking. 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. (When streaming, a seek always goes to the precise specified time even if the source FLV file doesn’t have a keyframe there.
-
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 the first three decimal places and rounds any additional decimal places. time name A string that is the name of the cue point to seek. cuePoint A cue point object in which you set the time and name properties to specify the cue point to seek.
-
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.*; var listenerObject:Object = new Object(); listenerObject.ready = function(eventObject:Object):Void { my_FLVPlybk.seekToNavCuePoint("point2"); } my_FLVPlybk.
-
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 playheadTime property might not have the expected value immediately after calling one of the seek methods or setting playheadTime to cause seeking.
-
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 navigation cue point. The default is the current value of the playheadTime property. Optional. time Returns Nothing. Description Method; seeks to the previous navigation cue point, based on the current value of the playheadTime property.
-
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.*; my_FLVPlybk.contentPath = "http://www.helpexamples.com/flash/video/ cuepoints.flv"; var listenerObject:Object = new Object(); listenerObject.cuePoint = function(eventObject:Object) { if(eventObject.info.name == "point2") my_FLVPlybk.
-
Example The following example initially sets the seekToPrevOffset property to 10, causing the first call to the seekToPrevNavCuePoint() method to hit cue point point1. When the initial cuePoint event for point3 occurs, however, the example lowers the seekToPrevOffset property to 1 second, causing subsequent calls to the seekToPrevNavCuePoint() method to reach cue point point2. Drag an FLVPlayback component to the Stage, and give it an instance name of my_FLVPlybk.
-
Usage my_FLVplybk.setFLVCuePointEnabled(enabled:Boolean, time:Number) my_FLVplybk.setFLVCuePointEnabled(enabled:Boolean, name:String) my_FLVplybk.setFLVCuePointEnabled(enabled:Boolean, cuePoint:Object) Parameters enabled A Boolean value that specifies whether to enable (true) or disable (false) an FLV file cue point. time A number that is the time, in seconds, of the cue point to set. name The name of the cue point to set.
-
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.*; function ready(eventObject:Object) { my_FLVPlybk.setFLVCuePointEnabled(false, "point2"); my_FLVPlybk.setFLVCuePointEnabled(false, 16.02); } my_FLVPlybk.
-
Description Method; sets the scaleX and scaleY properties simultaneously. Because setting either one, individually, can cause automatic resizing, setting them simultaneously can be more efficient than setting the scaleX and scaleY properties, individually. If autoSize is true, this method has no effect because the player sets its own dimensions. If the maintainAspectRatio property is true and autoSize is false, then changing scaleX or scaleY causes automatic resizing.
-
Parameters w A number that specifies the width of the video player. h 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 the width and height properties individually. If autoSize is true, this method has no effect because the player sets its own dimensions.
-
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. Example The following example applies the skin ArcticExternal.swf to an instance of the FLVPlayback component.
-
FLVPlayback.skinAutoHide Availability Flash Player 8. Edition Flash Professional 8. Usage my_FLVplybk.skinAutoHide Description Property; a Boolean value that, if true, hides the component skin when the mouse is not over the video. This property affects only skins that are loaded by setting the skin property and not a skin that you create from the FLV Playback Custom UI components. Defaults to false.
-
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.
-
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 ready and skinLoaded (or skinError) events have both started.
-
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(), play(), stop(), pause(), and seek() methods. Read-only. The possible values for the state property are: "buffering", "connectionError", "disconnected", "loading", "paused", "playing", "rewinding", "seeking", and "stopped". You can use the FLVPlayback class properties to test for these states.
-
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 and playheadTime.
-
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.*; var listenerObject:Object = new Object(); listenerObject.stateChange = function(eventObject:Object):Void { trace(my_FLVPlybk.state); }; my_FLVPlybk.addEventListener("stateChange", listenerObject); my_FLVPlybk.contentPath = "http://www.
-
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.*; var listenerObject:Object = new Object(); listenerObject.stateChange = function(eventObject:Object):Void { trace(my_FLVPlybk.state + "; responsive: " + my_FLVPlybk.stateResponsive); }; my_FLVPlybk.
-
Example The following example listens for the playheadUpdate event, and when the elapsed playheadTime is greater than or equal to 5 seconds, the listener calls the stop() method to stop playing the FLV file. A second listener listens for the stopped event and displays the values of the playheadTime and state properties. Drag an FLVPlayback component to the Stage, and give it an instance name of my_FLVPlybk.
-
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, pauseButton, and stopButton properties to attach individual FLV Playback Custom UI controls to an FLVPlayback component.
-
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, "stopped". You can compare this property to the state property to determine whether the component is in the stopped state. Example The following example displays the value of the FLVPlayback.STOPPED property when the component enters a stopped state.
-
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 stopButton control.
-
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.*; var listenerObject:Object = new Object(); listenerObject.stopped = function(eventObject:Object):Void { trace(my_FLVPlybk.state + ": playhead time is: " + eventObject.playheadTime); }; my_FLVPlybk.
-
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.*; var listenerObject:Object = new Object(); listenerObject.stateChange = function(eventObject:Object):Void { trace(my_FLVPlybk.state + ": stopped property is: " + my_FLVPlybk.stopped); }; my_FLVPlybk.
-
When you set this property, the value takes effect for the next FLV file that is loaded by setting contentPath. It has no effect on an FLV file that has already loaded. Also, this property does 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.
-
Description Property; an object that provides direct access to the Sound.setTransform() and Sound.getTransform() methods to provide sound control. You must set this property to an 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. The default value is undefined. Example The following example sets the transform property to play the sound for the FLV file from the left speaker only.
-
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.*; trace(FLVPlayback.version); FLVPlayback.visible Availability Flash Player 8. Edition Flash Professional 8.
-
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.*; var listenerObject:Object = new Object(); listenerObject.complete = function(eventObject:Object):Void { my_FLVPlybk.visible = false; }; my_FLVPlybk.addEventListener("complete", listenerObject); my_FLVPlybk.contentPath = "http://www.
-
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. The default is 0.
-
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.*; // specify name and location of FLV for default player my_FLVPlybk.contentPath = "http://www.helpexamples.com/flash/video/ clouds.flv" var listenerObject:Object = new Object(); listenerObject.
-
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.
-
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.
-
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.
-
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.
-
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 volume property in ActionScript. The event object has a volume property.
-
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. Use the FLVPlayback width property and not the MovieClip._width property because the _width property might give a different value if a skin SWF file is loaded.
-
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.
-
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. Use the FLVPlayback y property, not the MovieClip.
-
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 VideoError.code A numeric error code. VideoError.
-
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: " + err.code) ... } VideoError.DELETE_DEFAULT_PLAYER Availability Flash Player 8. Edition Flash Professional 8. Usage mx.video.VideoError.
-
Example The following code checks for the DELETE_DEFAULT_PLAYER error code: 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.
-
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 contentPath value was found. Example The following code checks for the INVALID_CONTENT_PATH error code: import mx.video.*; try { ... } catch (err:VideoError) { if (err.code == INVALID_CONTENT_PATH) { ... } } See also FLVPlayback.contentPath VideoError.INVALID_SEEK Availability Flash Player 8.
-
Description A value of 1003, indicating an invalid seek was attempted. Example The following code checks for the INVALID_SEEK error code: 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. Usage mx.video.VideoError.INVALID_XML Description A value of 1005, indicating invalid XML was encountered.
-
Example The following code checks for the INVALID_XML error code: 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. Occurs only when downloading and parsing a SMIL file.
-
Example The following code checks for the NO_BITRATE_MATCH error code: 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.
-
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 NO_CUE_POINT_MATCH error code: import mx.video.*; try { ... } catch (err:VideoError) { if (err.code == NO_CUE_POINT_MATCH) { ... } } See also FLVPlayback.
-
VideoPlayer class Inheritance MovieClip > VideoPlayer class ActionScript Class Name mx.video.VideoPlayer 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.
-
Method summary for the VideoPlayer class The following table lists the methods of the VideoPlayer class: Method Description VideoPlayer.addEventListener() Creates a listener for a specified event. VideoPlayer.close() Closes the video stream and FCS connection. VideoPlayer.load() Loads the FLV file but does not begin playing. After resizing (if needed) the FLV file is paused. VideoPlayer.pause() Pauses playing the video stream. VideoPlayer.play() Begins playing the video stream. VideoPlayer.
-
Property Value Description VideoPlayer.DEFAULT_INCMANAGER “mx.video.NCManager” Name of the default (mx.video.NCManager) or custom implementation of the INCManager interface. VideoPlayer.DISCONNECTED "disconnected" Possible value for the state property. Indicates that the FLV file stream is disconnected. VideoPlayer.LOADING "loading" Possible value for the state property. Indicates that the FLV file is loading. VideoPlayer.PAUSED "paused" Possible value for the state property.
-
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 VideoPlayer.autoRewind A Boolean value that, if true, causes the FLV file to rewind to the first frame when play stops. VideoPlayer.autoSize A Boolean value that, if true, causes the video to automatically size to the source dimensions. VideoPlayer.
-
Property Description VideoPlayer.playheadUpdateInterval A number that is the amount of time, in milliseconds, between each playheadUpdate event. VideoPlayer.progressInterval A number that is the amount of time, in milliseconds, between each progress event. VideoPlayer.scaleX A number that specifies the horizontal scale. VideoPlayer.scaleY A number that specifies the vertical scale. VideoPlayer.state A string that specifies the state of the component.
-
Event summary for the VideoPlayer class The following table lists the events of the VideoPlayer class: Event Description VideoPlayer.close Dispatched when the video stream is closed, whether through timeout or a call to the close() method. VideoPlayer.complete Dispatched when playing completes by reaching the end of the FLV file. VideoPlayer.cuePoint Dispatched when a cue point is reached. VideoPlayer.metadataReceived Dispatched the first time the FLV file metadata is reached. VideoPlayer.
-
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. It can also be used to specify the bit rate and duration of the FLV file.
-
The following example shows a progressive download for a single FLV file that does not use bandwidth detection: Availability Flash Professional 8. Usage ... child tags ... Attributes None. Child tags , Parent tag None. Description Top level tag, which identifies a SMIL file.
-
Example The following example shows a SMIL file specifying three FLV files:
Availability Flash Professional 8. Usage ... child tags ...
-
Description Supporting the and tags, specifies the location and default layout (height and width) of the source FLV files. Example The following example sets the root layout to 240 pixels by 180 pixels: Availability Flash Professional 8. Usage Attributes base Child tags Parent tag None.
-
Availability Flash Professional 8. Usage ... child tags ... Attributes None. Child tags Parent tag Description Specifies the width and height of the FLV file. Example The following example specified the layout of 240 pixels by 180 pixels: Availability Flash Professional 8. Usage Attributes Width, height Child tags None.
-
Parent tag Description Specifies the width and height of the FLV file. Example The following example specified the layout of 240 pixels by 180 pixels: Availability Flash Professional 8. Usage ... child tags ... Attributes None.
-
Example The following example specified three FLV files, two using the video tag, and one using the ref tag:
Availability Flash Professional 8. Usage
-
[ Availability Flash Professional 8. Usage Attributes src, system-bitrate, dur Child tags None Parent tag Description Synonymous with tag. Supports the src and dur attributes, which specify the name of the source FLV file and its duration. The dur attribute supports the full (00:03:00:01) and partial (03:00:01) time formats. Example The following example sets the source and duration for a video: ][PAGE 723
] Availability Flash Professional 8. Usage ... child tags ... Attributes None Child tags , [ Parent tag Description Used with either the or ][ child tags to list the FLV files for multiple bandwidth video streaming. The tag supports the system-bitrate attribute, which specifies the minimum bandwidth as well as the src and dur attributes.]
-
722 FLVPlayback Component (Flash Professional Only)
-
23 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). For example, when users fill out a form, they should be able to tab between fields and press Enter (Windows) or Return (Macintosh) to submit the form.
-
The Focus Manager handles focus changes caused by mouse clicks. If the user clicks a component, that component is given focus. NO T E 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. Also, tabbing and keyboard shortcuts are used by the authoring environment by default.
-
To create a button that receives focus when a user presses Enter (Windows) or Return (Macintosh), set the FocusManager.defaultPushButton property to the instance name of the desired button, as shown here: focusManager.defaultPushButton = okButton; NO TE The Focus Manager is sensitive to when objects are placed on the Stage (the depth order of objects) and not their relative positions on the Stage. This is different from the way Flash Player handles tabbing.
-
// 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); If your movie clip doesn’t have an onPress or onRelease method or a tabEnabled property, it won’t be seen by the Focus Manager unless you set focusEnabled to true.
-
6. Select Control > Test Movie. 7. 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. Also, you have to select the Disable Keyboard Shortcuts menu option for focus to work properly in test mode.
-
Method summary for the FocusManager class The following table lists the methods of the FocusManager class. Method Description FocusManager.getFocus() Returns a reference to the object that has focus. FocusManager.sendDefaultPushButtonEvent() Sends a click event to listener objects registered to the default push button. Sets focus to the specified object. FocusManager.
-
Methods inherited from the UIComponent class The following table lists the methods the FocusManager class inherits from the UIComponent class. Method Description UIComponent.getFocus() Returns a reference to the object that has focus. UIComponent.setFocus() Sets focus to the component instance. Property summary for the FocusManager class The following table lists the properties of the FocusManager class. Property Description FocusManager.
-
Property Description UIObject.top The position of the top edge of the object, relative to its parent. Read-only. UIObject.visible A Boolean value indicating whether the object is visible (true) or not (false). UIObject.width The width of the object, in pixels. Read-only. UIObject.x The left edge of the object, in pixels. Read-only. UIObject.y The top edge of the object, in pixels. Read-only.
-
Events inherited from the UIComponent class The following table lists the events the FocusManager class inherits from the UIComponent class. Event Description UIComponent.focusIn Broadcast when an object receives focus. UIComponent.focusOut Broadcast when an object loses focus. UIComponent.keyDown Broadcast when a key is pressed. UIComponent.keyUp Broadcast when a key is released. FocusManager.defaultPushButton Availability Flash Player 6 (6.0.79.0).
-
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 (true) or not (false). Setting defaultPushButtonEnabled to false allows a component to receive the Return or Enter key and handle it internally.
-
Description Property; a Boolean value that determines if tab handling is turned on (true) or not (false) for a particular group of focus objects. (For example, another pop-up window could have its own Focus Manager.) Setting enabled to false allows a component to receive the tab handling keys and handle them internally. You must re-enable the Focus Manager handling by watching the component’s onKillFocus() method (see onKillFocus (MovieClip.onKillFocus handler) in ActionScript 2.
-
See also FocusManager.setFocus() FocusManager.nextTabIndex Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage FocusManager.nextTabIndex Description Property; the next available tab index number. Use this property to dynamically set an object’s tabIndex property. Example The following code gives the mycheckbox instance the next highest tabIndex value: mycheckbox.tabIndex = focusManager.nextTabIndex; See also UIComponent.tabIndex FocusManager.
-
Returns Nothing. Description Method; sends a click event to listener objects registered to the default push button. Use this method to programmatically send a click event. Example The following code triggers the default push button click event and fills in the user name and password fields when a user selects the CheckBox instance chb (the check box would be labeled “Automatic Login”): name_txt.tabIndex = 1; password_txt.tabIndex = 2; chb.tabIndex = 3; submit_ib.tabIndex = 4; focusManager.
-
FocusManager.setFocus() Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004 and Flash MX Professional 2004. Usage focusManager.setFocus(object) Parameters object A reference to the object to receive focus. Returns Nothing. Description Method; sets focus to the specified object. If the object to which you want to set focus is not on the main timeline, use the following code: _root.focusManager.setFocus(object); Example The following code sets focus to myOKButton: focusManager.
-
CHAPTER 24 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, for example—as well as application states.
-
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 Form.visible property), while simultaneously toggling the visibility of other forms, as well.
-
Method summary for the Form class The following table lists methods of the Form class. Method Description Form.getChildForm() Returns the child form at a specified index. 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 Description UIObject.createClassObject() Creates an object on the specified class. UIObject.
-
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 Loader.load() Loads the content specified by the contentPath property. Methods inherited from the Screen class The following table lists the methods the Form class inherits from the Screen class. When calling these methods from the Form object, use the syntax formInstance.
-
Properties inherited from the UIObject class The following table lists the properties the Form class inherits from the UIObject class. When accessing these properties from the Form object, use the syntax formInstance.propertyName. Property Description UIObject.bottom The position of the bottom edge of the object, relative to the bottom edge of its parent. Read-only. UIObject.height The height of the object, in pixels. Read-only. UIObject.left The left edge of the object, in pixels. Read-only.
-
Properties inherited from the Loader class The following table lists the properties the Form class inherits from the Loader class. When accessing these properties from the Form object, use the syntax formInstance.propertyName. Property Description Loader.autoLoad A Boolean value that indicates whether the content loads automatically (true) or you must call Loader.load() (false). Loader.bytesLoaded A read-only property that indicates the number of bytes that have been loaded. Loader.
-
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 UIObject.draw Broadcast when an object is about to draw its graphics. UIObject.hide Broadcast when an object’s state changes from visible to invisible. UIObject.load Broadcast when subobjects are being created. UIObject.move Broadcast when the object has moved. UIObject.
-
Events inherited from the Screen class The following table lists the events the Form class inherits from the Screen class. Event Description Screen.allTransitionsInDone Broadcast when all “in” transitions applied to a screen have finished. Screen.allTransitionsOutDone Broadcast when all “out” transitions applied to a screen have finished. Screen.mouseDown Broadcast when the mouse button was pressed over an object (shape or movie clip) directly owned by the screen. Screen.
-
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 null if there is no current focus. Example The following code, attached to a button (not shown), displays the name of the form with the current focus. trace("The form with the current focus is: " + mx.screens.Form.currentFocusedForm); Form.getChildForm() Availability Flash Player 6 (6.0.79.0).
-
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 myForm in its parent’s list of child forms. If the parent object of myForm is a screen but not a form (for example, if it is a slide), indexInParentForm is always 0. Example var myIndex:Number = myForm.indexInParent; if (myForm == myForm._parent.
-
Description Property (read-only); the number of child forms contained by myForm that are derived directly from the class mx.screens.Form. This property does not include any slides that are contained by myForm; it contains only forms. NO T E When using a custom ActionScript 2.0 class that extends mx.screens.Form, the form isn't counted in the numChildForms property. Example The following code iterates over all the child forms contained in myForm and displays their names in the Output panel.
-
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 myForm that is a child of the default form1 screen created when you select Flash Form Application from the New Document dialog box. onClipEvent(keyDown){ var parentForm:mx.screens.Form = this.parentForm; trace(parentForm); } // output: _level0.application.
-
Example In the following example, a reference to the root form of myForm is placed in a variable named root. If the value assigned to root refers to myForm, then myForm is at the top of its form tree. var root:mx.screens.Form = myForm.rootForm; if(root == myForm) { trace("myForm is the top form in its tree"); } Form.visible Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage myForm.
-
748 Form class (Flash Professional only)
-
CHAPTER 25 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 Iterator.hasNext() Indicates whether the iterator has more items. Iterator.next() Returns the next item in the iteration. Iterator.hasNext() Availability Flash Player 7.
-
Example The following example uses the hasNext() method to control looping through the iterator of 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; trace("Title: "+title+" Artist: "+artist); } } Iterator.next() Availability Flash Player 7.
-
26 CHAPTER 26 Label component A Label component is a single line of text. You can specify that a label be formatted with HTML. You can also control the alignment and size of a label. Label components don’t have borders, cannot be focused, and don’t broadcast any events. A live preview of each Label instance reflects changes made to parameters in the Property inspector or Component inspector during authoring.
-
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: ■ none, which specifies that the label is not resized or aligned to fit the text.
-
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: 1. Drag a Label component from the Components panel to the Stage. 2. In the Component inspector, enter Expiration Date for the label parameter. To create a Label component instance using ActionScript: 1.
-
A Label component supports the following styles: Style Theme Description color Both The text color. The default value is 0x0B333C for the Halo theme and blank for the Sample theme. disabledColor Both The color for text when the component is disabled. The default color is 0x848384 (dark gray). embedFonts Both A Boolean value that indicates whether the font specified in fontFamily is an embedded font. This style must be set to true if fontFamily refers to an embedded font.
-
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. Setting a property of the Label class with ActionScript overrides the parameter of the same name set in the Property inspector or Component inspector.
-
Method Description UIObject.doLater() Calls a function when parameters have been set in the Property and Component inspectors. UIObject.getStyle() Gets the style property from the style declaration or object. UIObject.invalidate() Marks the object so it is redrawn on the next frame interval. UIObject.move() Moves the object to the requested position. UIObject.redraw() Forces validation of the object so it is drawn in the current frame. UIObject.
-
Property Description UIObject.scaleX A number indicating the scaling factor in the x direction of the object, relative to its parent. UIObject.scaleY A number indicating the scaling factor in the y direction of the object, relative to its parent. UIObject.top The position of the top edge of the object, relative to its parent. Read-only. UIObject.visible A Boolean value indicating whether the object is visible (true) or not (false). UIObject.width The width of the object, in pixels. Read-only.
-
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: "none", "left", "center", and "right". The default value is "none". The label is not resized or aligned to fit the text. ■ none ■ left ■ center The left and right sides of the label resize to fit the text.
-
Usage labelInstance.html Description Property; a Boolean value that indicates whether the label can be formatted with HTML (true) or not (false). The default value is false. Label components with the html property set to true cannot be formatted with styles. To retrieve plain text from HTML-formatted text, set the HTML property to false and then access the text property.
-
760 Label component
-
27 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 List.addItem() and List.addItemAt() methods to add items to the list. The List component uses a zero-based index, where the item with index 0 is the top item displayed.
-
A live preview of each List instance on the Stage reflects changes made to parameters in the Property inspector or Component inspector during authoring. When you add the List component to an application, you can use the Accessibility panel to make it accessible to screen readers. First, you must add the following line of code to enable accessibility: mx.accessibility.ListAccImpl.enableAccessibility(); You enable accessibility for a component only once, regardless of how many instances the component has.
-
■ 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” mode. Also, measuring thousands of strings would be too intensive. The compromise is the maxHPosition property, which, when vScrollPolicy is set to "on", gives the list extra buffer space for scrolling.
-
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). There is no equivalent runtime property. labels is an array of text values that populate the label values of the list. The default value is [] (an empty array). There is no equivalent runtime property.
-
To populate a List instance with a data provider: 1. Drag a List component from the Components panel to the Stage. 2. Select the Free Transform tool and resize the component to fit your application. 3. In the Property inspector, enter the instance name my_list. 4. Select Frame 1 of the Timeline and, in the Actions panel, enter the following: my_list.dataProvider = myDP; If you have defined a data provider named myDP, the list fills with data. (For more information about data providers, see List.
-
To create a List component instance using ActionScript: 1. 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. 2. 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); my_list.addItem({label:"One", data:dt1}); my_list.addItem({label:"Two", data:dt2}); This script uses the method UIObject.
-
A List component uses the following styles: Style Theme Description themeColor Halo The base color scheme of a component. Possible values are "haloGreen", "haloBlue", and "haloOrange". The default value is "haloGreen". alternatingRowColors Both Specifies colors for rows in an alternating pattern. The value can be an array of two or more colors, for example, 0xFF00FF, 0xCC6699, and 0x996699.
-
Style Theme Description fontWeight Both textAlign Both The font weight: either "none" or "bold". The default value is "none". All components can also accept the value "normal" in place of "none" during a setStyle() call, but subsequent calls to getStyle() return "none". The text alignment: either "left", "right", or "center". The default value is "left". textDecoration Both The text decoration: either "none" or "underline". The default value is "none".
-
Style Theme Description selectionDisabledColor Both The background color of a selected row. The default value is a 0xDDDDDD (medium gray). Because the default value for this property is the same as the default for backgroundDisabledColor, the selection is not visible when the component is disabled unless one of these style properties is changed. selectionEasing Both A reference to the easing equation used to control the transition between selection states.
-
When creating a new class-level style declaration, you lose all default values provided by the ScrollSelectList declaration. This includes backgroundColor, which is required for supporting mouse events. To create a class-level style declaration and preserve defaults, use a for..in loop to copy the old settings to the new declaration. var source = _global.styles.ScrollSelectList; var target = _global.styles.List; for (var style in source) { target.setStyle(style, source.
-
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.
-
Method Description List.sortItems() Sorts the items in the list according to the specified compare function. List.sortItemsBy() Sorts the items in the list according to a specified property. 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 Description UIObject.createClassObject() Creates an object on the specified class. UIObject.
-
Property summary for the List class The following table lists properties of the List class. Property Description List.cellRenderer Assigns the class or symbol to use to display each row of the list. List.dataProvider The source of the list items. List.hPosition The horizontal position of the list. List.hScrollPolicy Indicates whether the horizontal scroll bar is displayed ("on") or not ("off"). List.iconField A field in each item to be used to specify icons. List.
-
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 UIObject.bottom The position of the bottom edge of the object, relative to the bottom edge of its parent. Read-only. UIObject.height The height of the object, in pixels. Read-only. UIObject.left The left edge of the object, in pixels. Read-only. UIObject.
-
Event summary for the List class The following table lists events that of the List class. Event Description List.change Broadcast whenever user interaction causes the selection to change. List.itemRollOut Broadcast when the pointer rolls over and then off of list items. List.itemRollOver Broadcast when the pointer rolls over list items. List.scroll Broadcast when a list is scrolled.
-
List.addItem() Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage listInstance.addItem(label[, data]) listInstance.addItem(itemObject) Parameters label data A string that indicates the label for the new item. The data for the item. This parameter is optional and can be of any data type. itemObject An item object that usually has label and data properties. Returns The index at which the item was added. Description Method; adds a new item to the end of the list.
-
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 index A number greater than or equal to 0 that indicates the position of the item. label A string that indicates the label for the new item. data The data for the item. This parameter is optional and can be of any data type. itemObject An item object that usually has label and data properties.
-
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. Example The following example uses a linkage identifier to set a new cell renderer: my_list.cellRenderer = "ComboBoxCell"; List.
-
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 (listInstance) dispatches an event (in this case, change) and the event is handled by a function, also called a handler, on a listener object (listenerObject) that you create.
-
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 []. For more information, see “DataProvider API” on page 317.
-
This example creates a data provider array and assigns it to the dataProvider property, as in 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. myDP_array.addItem({label:accounts_array[i].
-
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; my_list.addItem({data:'flash', label:'Flash'}); my_list.addItem({data:'dreamweaver', label:'Dreanweaver'}); my_list.addItem({data:'coldfusion', label:'ColdFusion'}); trace(my_list.getItemAt(2).label); List.hPosition Availability Flash Player 6 (6.0.79.0).
-
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 be "on" or "off". The default value is "off".
-
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 undefined, the default icon specified by the defaultIcon style is used. If the defaultIcon style is undefined, no icon is used. Example The following example sets the iconField property to the icon property of each item.
-
List.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, item, which is the item being rendered, and must return a string representing the icon’s symbol identifier. Example The following example adds icons that indicate whether a file is an image or a text document. If the data.
-
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(); listenerObject.
-
The first usage example uses a dispatcher/listener event model. A component instance (listInstance) dispatches an event (in this case, itemRollOut) and the event is handled by a function, also called a handler, on a listener object (listenerObject) that you create. You define a method with the same name as the event on the listener object; the method is called when the event is triggered. When the event is triggered, it automatically passes an event object (eventObject) to the listener object method.
-
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.
-
The second usage example uses an on() handler and must be attached directly to a List instance. The keyword this, used inside an on() handler attached to a component, refers to the component instance. For example, the following code, attached to the List instance my_list, sends “_level0.my_list” to the Output panel: on (itemRollOver) { trace(this); } Example The following example sends a message to the Output panel that indicates which item index number has been rolled over: var my_list:mx.controls.
-
Example The following example sets the labelField property to be the "name" field of each item. “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 Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage listInstance.
-
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; // Add data to list. my_list.addItem({data:"flash", label:"Flash"}); my_list.addItem({data:"dreamweaver", label:"Dreamweaver"}); my_list.
-
Description Property; specifies the number of pixels the list can scroll when List.hScrollPolicy is set to "on". The list doesn’t precisely measure the width of text that it contains. You must set maxHPosition to indicate the amount of scrolling that the list requires. The list does not scroll horizontally if this property is not set. Example The following example creates a list with 200 pixels of horizontal scrolling: var my_list:mx.controls.List; my_list.setSize(150, 100); my_list.
-
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. Add the following code to Frame 1 in the timeline: var my_list:mx.controls.List; my_list.addItem({data:"flash", label:"Flash"}); my_list.
-
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; var remove_button:mx.controls.Button; remove_button.label = "Remove"; my_list.addItem({data:"flash", label:"Flash"}); my_list.
-
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. To try this code, drag a List component to the Stage and give it the instance name my_list.
-
Parameters index A number greater than 0 and less than List.length that indicates the position at which to insert the item (the index of the new item). label data A string that indicates the label for the new item. The data for the item. This parameter is optional and can be of any type. itemObject An object to use as the item, usually containing label and data properties. Returns Nothing. Description Method; replaces the content of the item at the specified index.
-
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. The code my_list.rowCount = num is equivalent to the code my_list.setSize(my_list.
-
The following example resizes the list using the setSize() method and then sets a row count 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). Edition Flash MX 2004. Usage listInstance.
-
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 scroll event has one additional property, direction. It is a string with two possible values, "horizontal" or "vertical".
-
The second usage example uses an on() handler and must be attached directly to a List instance. The keyword this, used inside an on() handler attached to a component, refers to the component instance. For example, the following code, attached to the List instance my_list, sends “_level0.my_list” to the Output panel: on (scroll) { trace(this); } Example The following example sends the direction and position of the list every time the list items are scrolled: var my_list:mx.controls.List; my_list.
-
Description Property; a Boolean value that indicates whether the list is selectable (true) or not (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; my_list.addItem({data:"flash", label:"Flash"}); my_list.addItem({data:"dreamweaver", label:"Dreamweaver"}); my_list.addItem({data:"coldfusion", label:"ColdFusion"}); my_list.selectable = false; List.
-
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; var listListener:Object = new Object(); listListener.
-
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; my_list.addItem({data:"flash", label:"Flash"}); my_list.addItem({data:"dreamweaver", label:"Dreamweaver"}); my_list.
-
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(); listListener.
-
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. Add the following code to Frame 1 in the timeline: this.createClassObject(mx.controls.
-
Parameters index A number greater than 0 or less than List.length indicating the index of the item to change. styleObj An object that enumerates the properties and values to set. Returns Nothing. Description Method; applies the specified properties to the specified item. The supported properties are icon and backgroundColor. Example The following example changes the background color of the third item to red and gives it an icon.
-
Parameters A reference to a function. This function is used to compare two items to determine their sort order. compareFunc 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. Example The following example sorts the items according to uppercase labels.
-
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 usually "label" or "data". fieldName order A string that specifies whether to sort the items in ascending order ("ASC") or descending order ("DESC"). optionsFlag Lets you perform multiple sorts of different types on a single array without having to replicate the entire array or resort it repeatedly.
-
Description Method; sorts the items in the list in the specified order, using the specified field name. If the fieldName items are a combination of text strings and integers, the integer items are listed first. The fieldName parameter is usually "label" or "data", but you can specify any primitive data value. This is the fastest way to sort data in a component. It also maintains the component’s selection state. The sortItemsBy() method is fast because it doesn’t run any ActionScript while sorting.
-
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.
-
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.
-
812 List component
-
28 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). A Loader component can’t receive focus.
-
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 _lockroot property when calling loadMovie() or loading into the Loader component. If you’re using the Loader component, add the following code: myLoaderComponent.content.
-
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 (true), or the loader scales to fit the content (false). The default value is true.
-
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 setSize() method (see UIObject.setSize()). The sizing behavior of the Loader component is controlled by the scaleContent property.
-
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. Each component class has a version property, which is a class property.
-
Method Description UIObject.redraw() Forces validation of the object so it is drawn in the current frame. UIObject.setSize() Resizes the object to the requested size. UIObject.setSkin() Sets a skin in the object. UIObject.setStyle() Sets the style property on the style declaration or object. Methods inherited from the UIComponent class The following table lists the methods the Loader class inherits from the UIComponent class.
-
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 UIObject.bottom The position of the bottom edge of the object, relative to the bottom edge of its parent. Read-only. UIObject.height The height of the object, in pixels. Read-only. UIObject.left The left edge of the object, in pixels. Read-only.
-
Event summary for the Loader class The following table lists events of the Loader class. Event Description Loader.complete Triggered when the content finished loading. Loader.progress Triggered while content is loading. Events inherited from the UIObject class The following table lists the events the Loader class inherits from the UIObject class. Event Description UIObject.draw Broadcast when an object is about to draw its graphics. UIObject.
-
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 (true), or wait until Loader.load() is called (false). The default value is true. Example The following code sets up the loader component to wait for a Loader.load() call: loader.autoload = false; Loader.bytesLoaded Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage loaderInstance.
-
When you create an instance with createClassObject(), you have to position it on the Stage with move(). See 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.
-
Example The following code creates a progress bar and a Loader component. It then creates a load listener object with a progress event handler that shows the progress of the load. The listener is registered with the my_ldr instance, as follows: import mx.controls.Loader; import mx.controls.ProgressBar; this.createClassObject(ProgressBar, "my_pb", 998); this.createClassObject(Loader, "my_ldr", 999); my_pb.move(1, 1); my_ldr.move(1, 50); my_pb.
-
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 (loaderInstance) dispatches an event (in this case, complete) and the event is handled by a function, also called a handler, on a listener object (listenerObject) that you create. You define a method with the same name as the event on the listener object; the method is called when the event is triggered.
-
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 undefined until the load begins. Set properties for the content within an event handler function for the Loader.
-
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.
-
Parameters path An optional parameter that specifies the value for the contentPath property before the load begins. If a value is not specified, the current value of contentPath is used as is. Returns Nothing. Description Method; tells the loader to begin loading its content. Example The following example creates a Loader instance, my_ldr, and a Button instance and sets the loader autoload property to false so that loading does not begin until a call to the load() method is made.
-
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.
-
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 autoload parameter or by a call to Loader.load().
-
Example The following code creates a Loader instance and then creates a listener object with an event handler for the progress event that sends a message to the Output panel telling what percent of the content has loaded: //Create loader instance. this.createClassObject(mx.controls.Loader, "my_ldr", 10); //Create listener object. var loaderListener:Object = new Object(); loaderListener.progress = function(evt_obj:Object){ // evt_obj.
-
CHAPTER 29 29 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. You can use this component with video and audio data.
-
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 Mouse rollover of a given controller The button is highlighted.
-
Target Navigation Playback controller Tab, Shift+Tab navigation A given control button Description Moves the focus from button to button within the 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. Shift+Tab moves focus from right to left and bottom to top.
-
The streaming media components broadcast several related events. The following broadcast events can be used to set other items in motion: ■ A change event is broadcast continuously by the MediaDisplay and MediaPlayback components while media is playing. (See Media.change.) ■ A progress event is continuously broadcast by the MediaDisplay and MediaPlayback components while media is loading. (See Media.progress.
-
For FLV files, when Media.autoSize is set to true, the media is displayed at its preferred size, regardless of the size of the component. This means that if the size of the MediaDisplay instance is different from the size of the media, the media either spills out of the instance boundaries or does not fill the instance size. When Media.autoSize is set to false, Flash uses the instance size as much as possible, while honoring the aspect ratio. If both Media.autoSize and Media.
-
The MediaController component has an orientation setting, Media.horizontal, which you 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. You can associate the MediaDisplay and MediaController components with each other by using the Media.associateDisplay() and Media.associateController() methods.
-
To create a Flash document that displays a CD or DVD preview: 1. Select File > New; then select Flash Document. 2. Open the Components panel and double-click the MediaPlayback component to place an instance of it on the Stage. 3. Select the MediaPlayback component instance and enter the instance name myMedia in the Property inspector. 4. In the Component inspector, set your media type according to the type of media that will be streaming (MP3 or FLV). 5.
-
14. 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. var saleListener:Object = new Object(); saleListener.cuePoint = function(eventObj:Object) { var saleWin:MovieClip = PopUpManager.
-
To create a Flash document that displays a CD or DVD preview: 1. In Flash, select File > New; then select Flash Document. 2. From the Components panel, drag a MediaController and a MediaDisplay component to the Stage. 3. Select the MediaDisplay instance and enter the instance name myDisplay in the Property inspector. 4. Select the MediaController instance and enter the instance name myController in the Property inspector. 5.
-
Using the Component inspector with media components The Component inspector makes it easy to set media component parameters, properties, and so on. To use this panel, click the desired component on the Stage and, with the Property inspector open, click Launch Component Inspector. The Component inspector can be used for the following purposes: ■ To automatically play the media (see Media.activePlayControl and Media.autoPlay) ■ To keep or ignore the media’s aspect ratio (see Media.
-
■ 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. When Milliseconds is unselected, the FPS control is enabled and the playbar time is formatted as HH:MM:SS.
-
To associate a MediaDisplay component with a MediaController component: 1. Place a MediaDisplay instance and a MediaController instance on the Stage. 2. Select the MediaDisplay instance and, using the Property inspector, enter the instance name myMediaDisplay. 3. Select the MediaController instance that will trigger the behavior. 4. In the Behaviors panel, click the Add (+) button and select Media > Associate Display. 5.
-
To use a Slide CuePoint Navigation behavior: 1. Open your new document as a Flash slide presentation. 2. Place a MediaDisplay or MediaPlayback component instance on the Stage. 3. In the Screen Outline pane to the left of the Stage, click the Insert Screen (+) button to add a second slide; then select the second slide and rename it mySlide. 4. Select your MediaDisplay or MediaController instance. 5.
-
Name Type Default value Description Cue Points (Media.cuePoints) Array Undefined An array of cue point objects, each with a name and position in time in a valid HH:MM:SS:FF (Milliseconds option selected) or HH:MM:SS:mmm format. FLV or MP3 (Media.mediaType) FLV or MP3 FLV Designates the type of media to be played. Milliseconds Boolean Unselected Determines whether the playbar uses frames or milliseconds, and whether the cue points use seconds or frames.
-
Name Type Default value Description horizontal (Media.horizontal) Boolean true Determines whether the controller portion of the instance is vertically or horizontally oriented. A true value indicates that the component has a horizontal orientation. enabled Boolean true Determines whether this control can be modified by the user. A true value indicates that the control can be modified. visible Boolean true Determines whether this control is viewable by the user.
-
Name Type Default value Description FLV or MP3 (Media.mediaType) String: FLV or MP3 FLV Designates the type of media to be played. 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. URL (Media.contentPath) String undefined A string that holds the path and filename of the media to be played. Video Length (Media.
-
Customizing media components (Flash Professional only) If you want to change the appearance of your media components, you can use skinning. For a complete guide to component customization, see Chapter 5, “Customizing Components” in Using Components. Using styles with media components The media components do not use styles.
-
Method summary for the Media class The following table lists methods of the Media class. Method Components Description Media.addCuePoint() MediaDisplay, Adds a cue point object to the MediaPlayback component instance. Media.associateController() MediaDisplay Associates a MediaDisplay instance with a MediaController instance. Media.associateDisplay() MediaController Associates a MediaController instance with a MediaDisplay instance. Media.
-
Property summary for the Media class The following table lists properties of the Media class. Property Components Description Media.activePlayControl MediaController Determines the component state when loaded at runtime. Media.aspectRatio MediaDisplay, Determines if the component instance MediaPlayback maintains its video aspect ratio. Media.autoPlay MediaDisplay, Determines if the component instance MediaPlayback immediately starts to buffer and play. Media.
-
Property Components Description Media.playing MediaDisplay, For MediaDisplay and MediaPlayback, this 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. Media.preferredHeight MediaDisplay, The default value of the height of a FLV file. MediaPlayback Media.
-
Event Components Description Media.scrubbing MediaController, Generated when the playhead is dragged. MediaPlayback Media.volume MediaController, Broadcast when the user adjusts the 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.
-
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 cuePointName A string that names the cue point. cuePointTime A number, in seconds, that indicates when a cuePoint event is broadcast. Returns Nothing. Description Method; adds a cue point object to a MediaPlayback or MediaDisplay instance.
-
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 true value indicates that the aspect ratio should be maintained; a false value indicates that the aspect ratio can change during playback. The default value is true.
-
Parameters instanceName A string that specifies the instance name of the MediaController component to associate. Returns Nothing. Description Method; associates a MediaDisplay instance with a MediaController instance. If you use Media.associateDisplay() to associate a MediaController instance with a MediaDisplay instance, you do not need to use Media.associateController(). Example The following code associates myMedia with myController: myMedia.associateController(myController); See also Media.
-
Description Method; associates a MediaController instance with a MediaDisplay instance. If you associate a MediaDisplay instance with a MediaController instance by using Media.associateController(), you do not need to use Media.associateDisplay(). Example The following code associates myMedia with myDisplay: myMedia.associateDisplay(myDisplay); See also Media.associateController() Media.autoPlay Applies to MediaDisplay, MediaPlayback. Availability Flash Player 7. Edition Flash MX Professional 2004.
-
Media.autoSize Applies to MediaDisplay, MediaPlayback. Availability Flash Player 7. Edition Flash MX Professional 2004. Usage myMedia.autoSize Description Property; a Boolean value that determines the size of the media-viewing portion of the MediaDisplay or MediaPlayback component. For the MediaDisplay component, the property behaves as follows: ■ If you set this property to true, Flash displays the media at its preferred size, regardless of the size of the component.
-
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.
-
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 PlaybackLoad that is set with the number of bytes loaded. The variable is then used in a for loop.
-
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. Availability Flash Player 7. Edition Flash MX Professional 2004. Usage listenerObject = new Object(); listenerObject.change = function(eventObject){ // Insert your code here.
-
Example The following example uses an object listener to determine the playhead position (Media.playheadTime), from which the percentage complete can be calculated: 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); See also Media.playing, Media.pause() Media.
-
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); Media.complete Applies to MediaDisplay, MediaPlayback. Availability Flash Player 7.
-
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. Usage myMedia.
-
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.
-
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 "top", "bottom", "left", and "right". The default value is "bottom". Example For the following example, the controller portion of the MediaPlayback component is on the right side: myMedia.
-
Description Event; notification that the playhead has reached the cue point. The Media.cuePoint event object has the following properties: cuePointName A string that indicates the name of the cue point. cuePointTime A number, expressed in frames or seconds, that indicates when the cue point was reached. target A reference to the MediaPlayback object if there is one, or to the MediaDisplay object itself. type The string "cuePoint".
-
Description Property; an array of cue point objects that have been assigned to a MediaPlayback or MediaDisplay instance. In the array, each cue point object can have a name, a time in seconds or frames, and a player property (which is the instance name of the component it is associated with). The default value is an empty array ([]). Example The following example deletes the third cue point if playing an action preview: if (myVariable == actionPreview) { myMedia.removeCuePoint(myMedia.
-
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 Media.displayFull() method has been used.
-
Media.getCuePoint() Applies to MediaDisplay, MediaPlayback. Availability Flash Player 7. Edition Flash MX Professional 2004. Usage myMedia.getCuePoint(cuePointName) Parameters cuePointName The string that was provided when Media.addCuePoint() was used. Returns A cue point object. Description Method; returns a cue point object based on its cue point name. Example The following code retrieves a cue point named myCuePointName. myMedia.removeCuePoint(myMedia.
-
Usage myMedia.horizontal Description Property; determines whether the MediaController component displays itself in a vertical or horizontal orientation. A true value indicates that the component is displayed in a horizontal orientation; a false value indicates a vertical orientation. When set to false, the playbar and playback slider move from bottom to top. The default value is true. Example The following example displays the MediaController component in a vertical orientation: myMedia.
-
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. Edition Flash MX Professional 2004. Usage myMedia.
-
Parameters A non-negative integer that indicates the starting point (in seconds) at which the media should begin playing. startingPoint Returns Nothing. Description Method; plays the media associated with the component instance at the given starting point. The default value is the current value of playheadTime. Example The following code indicates that the media component should start playing at 120 seconds: myMedia.play(120); See also Media.pause() Media.
-
Description Event; broadcast by the MediaController or MediaPlayback component when the user moves the playback slider or clicks the Go to Beginning or Go to End button. The Media.playheadChange event object has the following properties: A number that indicates the percentage of the media that has played. detail type The string "playheadChange".
-
Media.playing Applies to MediaDisplay, MediaPlayback, MediaController. Availability Flash Player 7. Edition Flash MX Professional 2004. Usage myMedia.playing Description Property; returns a Boolean value that indicates whether the media is playing (true) or paused (false). This property is read-only for the MediaDisplay and MediaPlayback components, and read/write for the MediaController component. Example The following code determines if the media is playing or paused: if(myMedia.
-
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 undefined if no FLV media is set.
-
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 Media.progress event object has the following properties: target type A reference to the MediaDisplay or MediaPlayback instance.
-
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); } // Listen for progress. var myListener:Object = new Object(); myListener.progress = function(eventObj:Object) { setInterval(callback, timeOut, "Experiencing Network Delay"); }; md.
-
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.
-
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 Media.addCuePoint(). cuePoint Returns Nothing. Description Method; deletes a cue point associated with a component instance. Example The following code deletes a cue point named myCuePoint: myMedia.
-
Media.setMedia() Applies to MediaDisplay, MediaPlayback. Availability Flash Player 7. Edition Flash MX Professional 2004. Usage myMedia.setMedia(contentPath [, mediaType]) Parameters contentPath A string that indicates the URL of the media to be played. The default value is undefined. A string used to set the media type to either FLV or MP3. This parameter is optional. The default value is FLV. mediaType Returns Nothing.
-
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 MediaDisplay, MediaPlayback. Availability Flash Player 7. Edition Flash MX Professional 2004. Usage myMedia.
-
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 Media.totalTime manually so that the playbar can accurately reflect the actual play time of the media. The default value for MP3 files is the play time of the media. For FLV files, the default value is undefined. You cannot set this property for MP3 files, because the information is contained in the Sound object.
-
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 Media.volume event object has the following properties: detail type An integer between 0 and 100 that represents the volume level.
-
CHAPTER 30 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 buttonlike menu activator. You can also script a Menu component to open when a user presses a certain key. Menu components are always created dynamically at runtime.
-
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. Clicking selects a menu item, except with the following types of menu items: Disabled items or separators Rollovers and clicks have no effect (the menu remains visible).
-
When a Menu instance has focus either from clicking or tabbing, you can use the following keys to control it: Key Description Down Arrow Up Arrow Moves the selection down and up the rows of the menu. The selection 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).
-
Understanding the Menu component: view and data Conceptually, the Menu component consists of a data model and a view that displays the data. The Menu class provides the view and contains the visual configuration methods. The MenuDataProvider class adds methods to the global XML prototype object (much like the DataProvider API does to the Array object); these methods let you externally construct data providers and add them to multiple menu instances.
-
About menu item XML attributes The attributes of a menu item XML element determine what is displayed, how the menu item behaves, and how it is exposed to ActionScript. The following table describes the attributes of an XML menu item: Attribute name Type Default Description label String undefined The text that is displayed to represent a menu item. This attribute is required for all item types, except separator.
-
About menu item types (Flash Professional only) There are four kinds of menu items, specified by the type attribute:
Normal menu items The Normal Item menu item doesn’t have a type attribute, which means that the type attribute defaults to normal.
-
The following example defines three check box menu items:
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.
-
When the user selects one of the items, the current selection automatically changes, and a change event is broadcast to all listeners on the root menu. The currently selected item in a radio group is available in ActionScript through the selection property, as follows: var selectedMenuItem = myMenu.alignment_group.selection; myMenu.alignment_group = myMenu.center_item; Each groupName value must be unique within the scope of the root menu instance.
-
About initialization object properties (Flash Professional only) The initObject (initialization object) parameter is a fundamental concept in creating the layout for the Menu component. This parameter is an object with properties. Each property represents one of the possible the XML attributes of a menu item. (For a description of the properties allowed in the initObject parameter, see “About menu item XML attributes” on page 887.) The initObject parameter is used in the following methods: ■ Menu.
-
You should treat the instanceName, groupName, and type attributes of a menu item as readonly. You should set them only while creating an item (for example, in a call to addMenuItem()). Modifying these attributes after creation may produce unpredictable results. Menu parameters (Flash Professional only) You can set the following authoring parameter for each Menu component instance in the Property inspector: rowHeight indicates the height of each row, in pixels.
-
4. In the Actions panel, on the first frame, enter the following code to add an event listener to listen for click events on the button. The code also listens for a change event on the menu and displays the name of the selected menu item in the Output panel: /** Requires: - Menu component in library - Button component in library */ import mx.controls.Button; import mx.controls.Menu; this.createClassObject(Button, "menu_button", 10, {label:"Launch Menu"}); // Create a menu. var my_menu:Menu = Menu.
-
To use XML data from a server to create and populate a menu: 1. Select File > New and create a Flash document. 2. Drag the Menu component from the Components panel to the library. Menus are created dynamically through ActionScript. 3. In the Actions panel, add the following code to the first frame to create a menu, and use the dataProvider property to load menu items from a web page: /** Requires: - Menu component in library */ import mx.controls.Menu; var my_menu:Menu = Menu.
-
To use a well-formed XML string to create and populate a menu: 1. Select File > New and create a Flash document. 2. Drag the Menu component from the Components panel to the library. Menus are created dynamically through ActionScript. 3. In the Actions panel, add the following code to the first frame to create a menu and add some items: /** Requires: - Menu component in library */ import mx.controls.Menu; // Create an XML object to act as a factory.
-
To use the MenuDataProvider class to create and populate a menu: 1. Select File > New and create a Flash document. 2. Drag the Menu component from the Components panel to the library. Menus are created dynamically through ActionScript. 3. In the Actions panel, add the following code to the first frame to create a menu and add some items: /** Requires: - Menu component in library */ import mx.controls.Menu; // Create an XML object to act as a factory.
-
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 setStyle() method to change the style of the menu, its items, and its submenus.The Menu component supports the following styles: Style n Description themeColor Halo The base color scheme of a component.
-
Style n Description embedFonts Both A Boolean value that indicates whether the font specified in fontFamily is an embedded font. This style must be set to true if fontFamily refers to an embedded font. Otherwise, the embedded font is not used. If this style is set to true and fontFamily does not refer to an embedded font, no text is displayed. The default value is false. fontFamily Both The font name for text. The default value is "_sans". fontSize Both The point size for the font.
-
Style n Description selectionColor Both The background color of a selected row. The default value is a 0xCDFFC1 (light green) with the Halo theme and 0xEEEEEE (very light gray) with the Sample theme. When themeColor is changed through a setStyle() call, the framework sets selectionColor to a value related to the themeColor chosen. selectionDuration Both The length of the transition from a normal to selected state, in milliseconds. The default value is 200.
-
To set a style property on the Menu components only, you can create a new CSSStyleDeclaration and store it in _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 ScrollSelectList declaration.
-
5. Open the symbols that you want to customize for editing. For example, open the MenuCheckEnabled symbol. 6. Customize the symbol as desired. For example, change the image to be an X instead of a check mark. 7. Repeat steps 6-7 for all symbols that you want to customize. 8. Click the Back button to return to the main timeline. 9. Drag a Menu component from the Components panel to the current document’s library. This adds the Menu component to the library and makes it available at runtime. 10.
-
Method summary for the Menu class The following table lists methods of the Menu class. Method Description Menu.addMenuItem() Adds a menu item to the menu. Menu.addMenuItemAt() Adds a menu item to the menu at a specific location. Menu.createMenu() Creates an instance of the Menu class. This is a static method. Menu.getMenuItemAt() Gets a reference to a menu item at a specified location. Menu.hide() Closes a menu. Menu.indexOf() Returns the index of a given menu item. Menu.
-
Method Description UIObject.redraw() Forces validation of the object so it is drawn in the current frame. UIObject.setSize() Resizes the object to the requested size. UIObject.setSkin() Sets a skin in the object. UIObject.setStyle() Sets the style property on the style declaration or object. Methods inherited from the UIComponent class The following table lists the methods the Menu class inherits from the UIComponent class.
-
Property Description UIObject.scaleX A number indicating the scaling factor in the x direction of the object, relative to its parent. UIObject.scaleY A number indicating the scaling factor in the y direction of the object, relative to its parent. UIObject.top The position of the top edge of the object, relative to its parent. Read-only. UIObject.visible A Boolean value indicating whether the object is visible (true) or not (false). UIObject.width The width of the object, in pixels. Read-only.
-
Events inherited from the UIObject class The following table lists the events the Menu class inherits from the UIObject class. Event Description UIObject.draw Broadcast when an object is about to draw its graphics. UIObject.hide Broadcast when an object’s state changes from visible to invisible. UIObject.load Broadcast when subobjects are being created. UIObject.move Broadcast when the object has moved. UIObject.resize Broadcast when an object has been resized. UIObject.
-
Usage 2: menuInstance.addMenuItem(childMenuItem) Parameters initObject An object containing properties that initialize a menu item’s attributes. See “About menu item XML attributes” on page 887. childMenuItem An XML node object. Returns A reference to the added XML node. Description Method; Usage 1 adds a menu item at the end of the menu. The menu item is constructed from the values supplied in the initObject parameter.
-
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 is added. index initObject An object containing properties that initialize a menu item’s attributes. See “About menu item XML attributes” on page 887. childMenuItem An XML node object.
-
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"}); // First usage method first_menu.
-
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 change event, the event is handled by a function (also called a handler) that is attached to a listener object (listenerObject) that you create. You call the addEventListener() method and pass it the name of the handler as a parameter.
-
// 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.
-
Example The following example creates a menu with a submenu for the New menu item. It creates the menu by creating an XML object, my_xml, and adding menu items to it with calls to addMenuItem(). It then creates the menu with a call to createMenu(), passing the XML object as the data provider. 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.
-
Description Property; the data source for items in a Menu component. Menu.dataProvider is an XML node object. Setting this property replaces the existing data source of the menu. The default value is undefined. NO TE All XML or XMLNode instances are automatically given the methods and properties of the MenuDataProvider class when they are used with the Menu component.
-
Menu.getMenuItemAt() Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage menuInstance.getMenuItemAt(index) Parameters index An integer indicating the index of the node in the menu. 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.
-
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 closeMenu() function calls the menu.hide() method to close the menu.
-
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.
-
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. Next, it calls the indexOf() method by using the reference to obtain the index of the item and display it in the Output panel.
-
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; broadcast to all registered listeners whenever a menu closes. Version 2 components use a dispatcher-listener event model.
-
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 menuHide event, menuListener, displays “Menu closed” in the Output panel. You first drag a Menu component and a Button component to the library and then add the following code to Frame 1: /** Requires: - Menu component in library - Button component in library */ import mx.
-
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.
-
When the event is triggered, it automatically passes an event object (eventObject) to the handler. Each event object has properties that contain information about the event. You can use these properties to write code that handles the event. The Menu.menuShow event’s event object has two additional properties: ■ menuBar A reference to the MenuBar instance that is the parent of the target menu. When the target menu does not belong to a MenuBar instance, this value is undefined.
-
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."); }; // Add listener. my_menu.
-
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. // The createMenu() method call (below) expects to // 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.
-
Returns A reference to the returned menu item (XML node). This value is undefined if there is no 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).
-
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 index The index of the menu item to remove. Returns A reference to the returned menu item (XML node). This value is undefined if there is no item in that position. Description Method; removes the menu item and all its children at the specified index.
-
// 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"}); // Create the Menu object. var my_menu:Menu = Menu.createMenu(this, menuDP_obj); // Show and position the menus. my_menu.
-
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 rollOut event, the event is handled by a function (also called a handler) that is attached to a listener object (listenerObject) that you create. You call the addEventListener() method and pass it the name of the handler as a parameter.
-
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.
-
When the event is triggered, it automatically passes an event object (eventObject) to the handler. Each event object has properties that contain information about the event. You can use these properties to write code that handles the event. The Menu.rollOver event’s event object has one additional property: menuItem, which is a reference to the menu item (XML node) that the pointer rolled over. For more information, see “EventDispatcher class” on page 499.
-
Menu.setMenuItemEnabled() Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage menuInstance.setMenuItemEnabled(item, enable) Parameters item An XML node; the target menu item’s node in the data provider. enable A Boolean value indicating whether the item is enabled (true) or not (false). Returns Nothing. Description Method; changes the target item’s enabled attribute to the state specified in the enable parameter.
-
// 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); See also Menu.setMenuItemSelected() Menu.setMenuItemSelected() Availability Flash Player 6 (6.0.79.0).
-
Description Method; changes the selected attribute of the item to the state specified by the 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 type attribute is set to "radio" or "check", because it causes their dot or check to appear or disappear. If you call this method on an item whose type is "normal" or "separator", it has no effect.
-
Menu.show() Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage menuInstance.show(x, y) Parameters x The x coordinate. y The y coordinate. Returns Nothing. Description Method; opens a menu at a specific location. The menu is automatically resized so that all of its top-level items are visible, and the upper left corner is placed at the specified location in the coordinate system provided by the component’s parent.
-
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 Menu.
-
Method summary for the MenuDataProvider class The following table lists the methods of the MenuDataProvider class. Method Description MenuDataProvider.addMenuItem() Adds a child item. MenuDataProvider.addMenuItemAt() Adds a child item at a specified location. MenuDataProvider.getMenuItemAt() Gets a reference to a menu item at a specified location. MenuDataProvider.indexOf() Returns the index of a specified menu item. MenuDataProvider.removeMenuItem() Removes a menu item. MenuDataProvider.
-
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. Any node or menu item in a MenuDataProvider instance can call the methods of the MenuDataProvider class. Example The following example creates a menu from an XML data provider.
-
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 index An integer. An object containing the specific attributes that initialize a Menu item’s attributes. For more information, see “About menu item XML attributes” on page 887. initObject childMenuItem An XML node.
-
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. // The createMenu() method call (below) expects to // 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.
-
MenuDataProvider.getMenuItemAt() Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage myMenuDataProvider.getMenuItemAt(index) Parameters index An integer indicating the position of the menu. 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.
-
// 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); // Retrieve the submenu item from the 1st menu item.
-
Example The following example adds a menu item to a menu and calls the indexOf() method to 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; // 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.
-
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); undefined if an error occurs. 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.
-
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(); d // The item created next does not appear in the menu. // The createMenu() method call (below) expects to // 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.
-
MenuDataProvider.removeMenuItemAt() Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage myMenuDataProvider.removeMenuItemAt(index) Parameters index The index of the menu item. Returns A reference to the removed menu item. This value is undefined if there is no item in that position. Description Method; removes the child item of the menu item specified by the index parameter. If there is no menu item at that index, calling this method has no effect.
-
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. // The createMenu() method call (below) expects to // 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.
-
CHAPTER 31 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. The MenuBar component lets you create an application menu in a few steps.
-
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: Key Description Down Arrow Moves the selection down a menu row. Up Arrow Moves the selection up a menu row. Right Arrow Moves the selection to the next button.
-
visible is a Boolean value that indicates whether the object is visible (true) or not (false). The default value is true. NO T E 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. Otherwise, setting these properties in the Component inspector has no visible effect.
-
6. 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; case "closeInstance": trace("Close menu item"); break; } trace(menuItem_obj); }; //Add listener. my_menu.
-
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 themeColor Halo The base color scheme of a component. Possible values are "haloGreen", "haloBlue", and "haloOrange". The default value is "haloGreen". color Both The text color.
-
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” on page 900. The MenuBar component supports the following skin properties.
-
11. Select Control > Test Movie. N OT E 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. However, the symbol name cannot be modified, and you cannot use a different symbol for different MenuBar instances in a single document.
-
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 UIObject.createClassObject() Creates an object on the specified class. UIObject.createObject() Creates a subobject on an object. UIObject.destroyObject() Destroys a component instance. UIObject.
-
Property summary for the MenuBar class The following table lists properties of the MenuBar class. Property Description MenuBar.dataProvider The data model for a menu bar. MenuBar.labelField A string that determines which attribute of each XMLNode to use as the label text of the menu. MenuBar.labelFunction A function that determines what to display in each menu’s label.
-
Properties inherited from the UIComponent class The following table lists the properties the MenuBar class inherits from the UIComponent class. When calling these properties from the MenuBar object, use the form MenuBar.propertyName. Property Description UIComponent.enabled Indicates whether the component can receive focus and input. UIComponent.tabIndex A number indicating the tab order for a component in a document.
-
Event Description UIObject.resize Broadcast when an object has been resized. UIObject.reveal Broadcast when an object’s state changes from invisible to visible. UIObject.unload Broadcast when the subobjects are being unloaded. Events inherited from the UIComponent class The following table lists the events the MenuBar class inherits from the UIComponent class. When calling these events from the MenuBar object, use the form MenuBar.eventName. Event Description UIComponent.
-
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 menuDataProvider parameter. Example Usage 1: The following example adds a File menu and then uses Menu.addMenuItem() to add the menu items New and Open.
-
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 position is 0. To append to the end of the menu, call MenuBar.addMenu(label). index label A string indicating the label of the new menu. An XML or XMLNode instance that describes the menu.
-
Drag an instance of the MenuBar component onto the Stage, and enter the instance name my_mb in the Property inspector. Add the following code to Frame 1 of the timeline: /** 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.
-
Usage menuBarInstance.dataProvider Description Property; the data model for items in a MenuBar component. MenuBar.dataProvider is an XML node object. Setting this property replaces the existing 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. The default value is undefined.
-
MenuBar.getMenuAt() Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage menuBarInstance.getMenuAt(index) Parameters index An integer indicating the position of the menu. Returns A reference to the menu at the specified index. This value is undefined if there is no menu at that position. Description Method; returns a reference to the menu at the specified index. Because getMenuAt() returns a reference, it is possible to add items to a menu at the specified index.
-
MenuBar.getMenuEnabledAt() Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage menuBarInstance.getMenuEnabledAt(index) Parameters index The index of the menu in the menu bar. Returns A Boolean value that indicates whether this menu can be chosen (true) or not (false). Description Method; returns a Boolean value that indicates whether this menu can be chosen (true) or not (false).
-
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. The default value is "label". After the dataProvider property is set, this property is read-only.
-
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. This property is passed to any menus created from the menu bar. The default value is undefined.
-
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 removeAll() to remove the menu items.
-
MenuBar.removeMenuAt() Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage menuBarInstance.removeMenuAt(index) Parameters index The index of the menu to be removed from the menu bar. Returns A reference to the menu at the specified index in the menu bar. This value is undefined if there is no menu in that position in the menu bar. Description Method; removes the menu at the specified index. If there is no menu item at that index, calling this method has no effect.
-
Drag an instance of the MenuBar component onto the Stage, and enter the instance name my_mb in the Property inspector. Add the following code to Frame 1 of the timeline: /** Requires: - MenuBar component on Stage (instance name: my_mb) */ import mx.controls.Menu; import mx.controls.MenuBar; var my_mb:MenuBar; var file_menu:Menu = my_mb.addMenu("File"); file_menu.addMenuItem({label:"New", instanceName:"newInstance"}); file_menu.
-
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. Drag an instance of the MenuBar component onto the Stage, and enter the instance name my_mb in the Property inspector.
-
968 MenuBar component (Flash Professional only)
-
32 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 stepSize parameter, until the user releases the buttons or until the maximum or minimum value is reached.
-
For more information about controlling focus, see “FocusManager class” on page 721 or “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.
-
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 (true) or not (false). The default value is true. NO TE The minHeight and minWidth properties are used by internal sizing routines.
-
5. 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. var nstepListener:Object = new Object(); nstepListener.change = function(evt_obj:Object) { my_label.text = "value = " + evt_obj.target.
-
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” in Using Components. A NumericStepper component supports the following styles: Style Theme Description themeColor Halo The base color scheme of a component.
-
Style Theme Description repeatInterval Both symbolColor Sample The color of the arrows. The default value is 0x2B333C (dark gray). The number of milliseconds between automatic clicks when a user holds the mouse button down on a button. The default value is 35. Using skins with the NumericStepper component The NumericStepper component uses skins to represent its up and down button states.
-
To create movie clip symbols for NumericStepper skins: 1. Create a new FLA file. 2. Select File > Import > Open External Library and select the HaloTheme.fla file. This file is located in the application-level configuration folder. For the exact location on your operating system, see “About themes” in Using Components. 3. In the theme’s Library panel, expand the Flash UI Components 2/Themes/MMDefault folder and drag the Stepper Assets folder to the library of your document. 4.
-
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 version property, which is a class property. Class properties are available only on the class itself. The version property returns a string that indicates the version of the component.
-
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 UIComponent.getFocus() Returns a reference to the object that has focus. UIComponent.setFocus() Sets focus to the component instance.
-
Property Description UIObject.scaleX A number indicating the scaling factor in the x direction of the object, relative to its parent. UIObject.scaleY A number indicating the scaling factor in the y direction of the object, relative to its parent. UIObject.top The position of the top edge of the object, relative to its parent. Read-only. UIObject.visible A Boolean value indicating whether the object is visible (true) or not (false). UIObject.width The width of the object, in pixels. Read-only.
-
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 UIObject.draw Broadcast when an object is about to draw its graphics. UIObject.hide Broadcast when an object’s state changes from visible to invisible. UIObject.load Broadcast when subobjects are being created. UIObject.
-
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.
-
Drag an instance of the NumericStepper component onto the Stage, and enter the instance name my_nstep in the Property inspector. Add the following code to Frame 1 of the timeline: /** Requires: - NumericStepper component on Stage (instance name: my_nstep) */ var my_nstep:mx.controls.NumericStepper; // Create listener object. var nstepListener:Object = new Object(); nstepListener.change = function(evt_obj:Object){ // evt_obj.target is the component that generated the change event, // i.e.
-
Drag an instance of the NumericStepper component onto the Stage, and enter the instance name my_nstep in the Property inspector. Add the following code to Frame 1 of the timeline: /** Requires: - NumericStepper component on Stage (instance name: my_nstep) */ var my_nstep:mx.controls.NumericStepper; my_nstep.maximum = 20; See also NumericStepper.minimum NumericStepper.minimum Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage numericStepperInstance.
-
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 stepSize property to 3. It then displays the value of the nextValue property in the Output panel.
-
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. It sets the stepSize value to 3 and creates a listener object for a change event.
-
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.
-
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. This property can contain a number of up to three decimal places.
-
33 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. Method Description PopUpManager.createPopUp() Creates a pop-up window.
-
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 class A reference to the class of object you want to create. modal A Boolean value indicating whether the window is modal (true) or not (false). initobj An object containing initialization properties. This parameter is optional.
-
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 PopUpManager.deletePopUp() when the window is being destroyed.
-
990 PopUpManager class
-
34 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. An indeterminate progress bar is used when the amount of content to load is unknown.
-
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. The default value is 1. direction indicates the direction toward which the progress bar fills. This value can be right or left; the default value is right.
-
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 progress and complete events that the progress bar uses to display progress. (These events are emitted by the Loader component. For more information, see “Loader component” on page 813.
-
To create an application with the ProgressBar component in polled mode: 1. Drag a ProgressBar component from the Components panel to the Stage. 2. In the Property inspector, enter the instance name my_pb. 3. Select Frame 1 in the Timeline, open the Actions panel, and enter the following code, which creates a Sound object called my_sound and calls loadSound() to load a sound into the Sound object: /** Requires: - ProgressBar component on Stage (instance name: my_pb) */ System.security.
-
To create an application with the ProgressBar component in manual mode: 1. Drag a ProgressBar component from the Components panel to the Stage. 2. In the Property inspector, do the following: 3. ■ Enter the instance name my_pb. ■ Select Manual for the mode parameter.
-
To create an application with the ProgressBar component in manual mode (example 3): 1. Drag a ProgressBar component onto the Stage and give it an instance name my_pb. 2. Select the my_pb ProgressBar on the Stage and, in the Property inspector, set the component's mode parameter to "manual". 3. Select Frame 1 in the Timeline, and add the following ActionScript in the Actions panel: var img_mcl:MovieClipLoader = new MovieClipLoader(); var mclListener:Object = new Object(); mclListener.
-
A ProgressBar component supports the following styles: Style Theme Description themeColor Halo The base color scheme of a component. Possible values are "haloGreen", "haloBlue", and "haloOrange". The default value is "haloGreen". color Both The text color. The default value is 0x0B333C for the Halo theme and blank for the Sample theme. disabledColor Both The color for text when the component is disabled. The default color is 0x848384 (dark gray).
-
Using skins with the ProgressBar component The ProgressBar component uses skins to represent the progress bar track, the completed bar, and an indeterminate bar. To skin the ProgressBar component while authoring, modify symbols in the Flash UI Components 2/Themes/MMDefault/ProgressBar Elements folder. For more information, see “About skinning components” in Using Components. The track and bar graphics are each made up of three skins corresponding to the left and right caps and the middle.
-
6. Customize the symbol as desired. For example, flip the track horizontally. 7. Repeat steps 5-6 for all symbols you want to customize. 8. Click the Back button to return to the main timeline. 9. Drag a ProgressBar component to the Stage. To view the skins modified in this example, use ActionScript to set the indeterminate property to true. 10. Select Control > Test Movie. ProgressBar class Inheritance MovieClip > UIObject class > ProgressBar ActionScript Class Name mx.controls.
-
Methods inherited from the UIObject class The following table lists the methods the ProgressBar class inherits from the UIObject class. When calling these methods from the ProgressBar object, use the form ProgressBar.methodName. Method Description UIObject.createClassObject() Creates an object on the specified class. UIObject.createObject() Creates a subobject on an object. UIObject.destroyObject() Destroys a component instance. UIObject.
-
Property Description ProgressBar.percentComplete Read-only; a number indicating the percent loaded. ProgressBar.source The content to load. ProgressBar.value Read-only; indicates the amount of progress that has been made. Properties inherited from the UIObject class The following table lists the properties the ProgressBar class inherits from the UIObject class. When calling these properties from the ProgressBar object, use the form ProgressBar.propertyName. Property Description UIObject.
-
Event summary for the ProgressBar class The following table lists events of the ProgressBar class. Event Description ProgressBar.complete Triggered when loading is complete. ProgressBar.progress Triggered as content loads in manual or polled mode. Events inherited from the UIObject class The following table lists the events the ProgressBar class inherits from the UIObject class. When calling these events from the ProgressBar object, use the form ProgressBar.eventName. Event Description UIObject.
-
ProgressBar.complete Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage Usage 1: var listenerObject:Object = new Object(); listenerObject.complete = function(eventObject:Object) { // ... }; progressBarInstance.addEventListener("complete", listenerObject); Usage 2: on (complete) { // ... } Event object In addition to the standard event object properties, there are two additional properties defined for the ProgressBar.
-
The second usage example uses an on() handler and must be attached directly to a ProgressBar instance. The keyword this, used inside an on() handler attached to a component, refers to the component instance. For example, the following code, attached to the instance progressBarInstance, sends “_level0.
-
ProgressBar.conversion Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage progressBarInstance.conversion Description Property; a number that sets a conversion value for the incoming values. It divides the current and total values, floors them, and displays the converted value in the label property. The default value is 1. N OT E The floor is the closest integer value that is less than or equal to the specified value. For example, the number 4.6 becomes 4.
-
ProgressBar.direction Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage progressBarInstance.direction Description Property; indicates the fill direction for the progress bar. A value of right specifies that the bar will fill from left to right. A value of left specifies that the bar will fill from right to left. The default value is right. Example The following code loads a sound object and marks the progress with a progress bar that fills to the left.
-
ProgressBar.indeterminate Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage progressBarInstance.indeterminate Description Property; a Boolean value that indicates whether the progress bar has a striped fill and a loading source of unknown size (true), or a solid fill and a loading source of a known size (false). For example, you might use this property if you are loading a large data set into a SWF file and do not know the size of the data you are loading.
-
my_pb.indeterminate = true; my_pb.source = my_ldr; //Set loader settings my_ldr.autoLoad = false; my_ldr.scaleContent = false; my_ldr.move(100, 100) my_ldr.load("http://www.helpexamples.com/flash/images/image1.jpg"); ProgressBar.label Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage progressBarInstance.label Description Property; text that indicates the loading progress. This property is a string in the format "%1 out of %2 loaded (%3%%)".
-
System.security.allowDomain("http://www.helpexamples.com"); this.createClassObject(mx.controls.ProgressBar, "my_pb", 10); this.createClassObject(mx.controls.Loader, "my_ldr", 20); my_ldr.move(0, 30); //Set progress bar settings my_pb.mode = "polled"; my_pb.source = my_ldr; my_pb.label = "%1 of %2 KB loaded"; my_pb.conversion = 1024; // 1024 bytes in a KB //Set loader settings my_ldr.autoLoad = false; my_ldr.scaleContent = false; my_ldr.load("http://www.helpexamples.com/flash/images/image1.
-
You must first drag a Loader component and a ProgressBar component from the Components panel to the current document’s library; then add the following code to Frame 1 of the main timeline: /** Requires: - ProgressBar component in library - Loader component in library */ System.security.allowDomain("http://www.helpexamples.com"); this.createClassObject(mx.controls.ProgressBar, "my_pb", 10); this.createClassObject(mx.controls.Loader, "my_ldr", 20); my_ldr.move(0, 30); // Set progress bar settings my_pb.
-
Description Property; the largest value for the progress bar when the ProgressBar.mode property is set to "manual". Example The following example increments a ProgressBar component manually up to a maximum value of 200, at which point it stops. It displays the increment in the Output panel as the value increases. Drag an instance of the ProgressBar component onto the Stage, and enter the instance name my_pb in the Property inspector.
-
ProgressBar.minimum Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage progressBarInstance.minimum Description Property; the smallest value for the progress bar when the ProgressBar.mode property is set to "manual". Example The following example manually increments a ProgressBar component, starting with a minimum value of 100. It displays the increment in the Output panel as the value increases.
-
trace(increment_num); } else { delete this.onEnterFrame; } }; See also ProgressBar.maximum, ProgressBar.mode ProgressBar.mode Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage progressBarInstance.mode Description Property; the mode in which the progress bar loads content. This value can be "event", "polled", or "manual". Event mode and polled mode are the most common modes.
-
You must first drag a Loader component and a ProgressBar component from the Components panel to the current document’s library; then add the following code to Frame 1 of the main timeline: /** Requires: - ProgressBar component in library - Loader component in library */ System.security.allowDomain("http://www.helpexamples.com"); this.createClassObject(mx.controls.ProgressBar, "my_pb", 10); this.createClassObject(mx.controls.
-
Description Property (read-only); tells what percentage of the content has been loaded. This value is floored. (The floor is the closest integer value that is less than or equal to the specified value. For example, the number 7.8 becomes 7.) The following formula is used to calculate the percentage: 100 * (value - minimum) / (maximum - minimum) Example The following example loads an image into a loader that is associated with a progress bar.
-
ProgressBar.progress Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage Usage 1: var listenerObject:Object = new Object(); listenerObject.progress = function(eventObject:Object) { // ... }; progressBarInstance.addEventListener("progress", listenerObject); Usage 2: on (progress) { // ... } Event object In addition to the standard event object properties, there are two additional properties defined for the ProgressBar.
-
The second usage example uses an on() handler and must be attached directly to a ProgressBar instance. The keyword this, used inside an on() handler attached to a component, refers to the component instance. For example, the following code, attached to the instance progressBarInstance, sends “_level0.progressBarInstance” to the Output panel: on (progress) { trace(this); } Example This example loads an image into a loader with an associated progress bar and creates a listener for the progress event.
-
See also EventDispatcher.addEventListener() ProgressBar.setProgress() Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage progressBarInstance.setProgress(completed, total) Parameters A number indicating the amount of progress that has been made. You can use the ProgressBar.label and ProgressBar.conversion properties to display the number in percentage form or any units you choose, depending on the source of the progress bar.
-
Example The following example sets the progress bar mode to manual and calls setProgress() from the onEnterFrame() function, which is invoked repeatedly at the frame rate of the SWF file. The example sets the minimum value for the progress bar to 100 and the maximum to 200 and marks the progress in increments of 1. Drag an instance of the ProgressBar component onto the Stage, and enter the instance name my_pb in the Property inspector.
-
ProgressBar.source Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage progressBarInstance.source Description Property; a reference to the instance to be loaded whose loading process will be displayed. The loading content should emit a progress event from which the current and total values are retrieved. This property is used only when ProgressBar.mode is set to "event" or "polled". The default value is undefined.
-
You must first drag a Loader component and a ProgressBar component from the Components panel to the current document’s library; then add the following code to Frame 1 of the main timeline: /** Requires: - ProgressBar component in library - Loader component in library */ System.security.allowDomain("http://www.helpexamples.com"); this.createClassObject(mx.controls.ProgressBar, "my_pb", 10); this.createClassObject(mx.controls.
-
Description Property (read-only); indicates the amount of progress that has been made. This property is a number between the value of ProgressBar.minimum and ProgressBar.maximum. The default value is 0. Example The following example loads an image into a Loader component and marks the progress with the a progress bar. When the loading is complete, the example displays the minimum, maximum, and current values for the progress bar.
-
35 CHAPTER 35 RadioButton component The RadioButton component lets you force a user to make a single choice within a set of choices. This component must be used in a group of at least two RadioButton instances. Only one member of the group can be selected at any given time. Selecting one radio button in a group deselects the currently selected radio button in the group. You set the groupName parameter to indicate which group a radio button belongs to. A radio button can be enabled or disabled.
-
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 RadioButton component A radio button is a fundamental part of any form or web application. You can use radio buttons wherever you want a user to make one choice from a group of options. For example, you would use radio buttons in a form to ask which credit card a customer wants to use.
-
To create an application with the RadioButton component: 1. Drag two RadioButton components from the Components panel to the Stage. 2. Select one of the radio buttons. In the Component inspector, do the following: 3. ■ Enter Yes for the label parameter. ■ Enter Flashist for the data parameter. Select the other radio button. In the Component inspector, do the following: ■ Enter No for the label parameter. ■ Enter Anti-Flashist for the data parameter. 4.
-
Using styles with the RadioButton component You can set style properties to change the appearance of a RadioButton. 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” in Using Components. A RadioButton component uses the following styles: Style Theme Description themeColor Halo The base color scheme of a component.
-
Style Theme Description symbolBackgroundColor Sample The background color of the radio button. The default value is 0xFFFFFF (white). symbolBackgroundDisabledColor Sample The background color of the radio button when disabled. The default value is 0xEFEEEF (light gray). symbolBackgroundPressedColor Sample The background color of the radio button when pressed. The default value is 0xFFFFFF (white). symbolColor Sample The color of the dot in the radio button.
-
Name Description falseDisabledIcon The disabled-unselected state. The default value is RadioFalseDisabled. trueUpIcon The selected state. The default value is RadioTrueUp. trueDisabledIcon The disabled-selected state. The default value is RadioTrueDisabled. Each of these skins corresponds to the icon indicating the RadioButton state. The RadioButton does not have a border or background. To create movie clip symbols for RadioButton skins: 1. Create a new FLA file. 2.
-
RadioButton class Inheritance MovieClip > UIObject class > UIComponent class > SimpleButton class > Button component > RadioButton ActionScript Package Name mx.controls.RadioButton The properties of the RadioButton class allow you at runtime to create a text label and position it in relation to the radio button. You can also assign data values to radio buttons, assign them to groups, and select them based on data value or instance name.
-
Method Description UIObject.getStyle() Gets the style property from the style declaration or object. UIObject.invalidate() Marks the object so it is redrawn on the next frame interval. UIObject.move() Moves the object to the requested position. UIObject.redraw() Forces validation of the object so it is drawn in the current frame. UIObject.setSize() Resizes the object to the requested size. UIObject.setSkin() Sets a skin in the object. UIObject.
-
Property Description RadioButton.selectedData Selects the radio button with the specified data value in a radio button group. RadioButton.selection A reference to the currently selected radio button in a radio button group. This property can be used with a RadioButton instance or a RadioButtonGroup instance. Properties inherited from the UIObject class The following table lists the properties the RadioButton class inherits from the UIObject class.
-
Properties inherited from the UIComponent class The following table lists the properties the RadioButton class inherits from the UIComponent class. When accessing these properties from the RadioButton object, use the form RadioButtonInstance.propertyName. Property Description UIComponent.enabled Indicates whether the component can receive focus and input. UIComponent.tabIndex A number indicating the tab order for a component in a document.
-
Properties inherited from the Button class The following table lists the properties the RadioButton class inherits from the Button class. When accessing these properties from the RadioButton object, use the form RadioButtonInstance.propertyName. Property Description Button.icon Specifies an icon for a button instance. Button.label Specifies the text that appears in a button. Button.labelPlacement Specifies the orientation of the label text in relation to an icon.
-
Events inherited from the UIComponent class The following table lists the events the RadioButton class inherits from the UIComponent class. Event Description UIComponent.focusIn Broadcast when an object receives focus. UIComponent.focusOut Broadcast when an object loses focus. UIComponent.keyDown Broadcast when a key is pressed. UIComponent.keyUp Broadcast when a key is released.
-
RadioButton.click Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage Usage 1: var listenerObject:Object = new Object(); listenerObject.click = function(eventObj:Object) { // ... }; radioButtonGroup.addEventListener("click", listenerObject); Usage 2: on (click) { // ... } Description Event; broadcast to all registered listeners when the mouse is clicked (pressed and released) over the radio button or if the radio button is selected by means of the arrow keys.
-
The second usage example uses an on() handler and must be attached directly to a RadioButton instance. The keyword this, used inside an on() handler attached to a component, refers to the component instance. For example, the following code, attached to the radio button myRadioButton, sends “_level0.myRadioButton” to the Output panel: on (click) { trace(this); } Example The following example creates three radio buttons, positions them on the Stage, and creates a listener for the click event.
-
RadioButton.data Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage radioButtonInstance.data Description Property; specifies the data to associate with a RadioButton instance. Setting this property overrides the data parameter value set during authoring. The data property can be of any data type. Example The following example assigns the data value 0xFF00FF and the label #FF00FF to the radio button instance my_rb.
-
RadioButton.groupName Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage radioButtonInstance.groupName radioButtonGroup.groupName Description Property; sets the group name for a radio button instance or group. You can use this property to get or set a group name for a radio button instance or for a radio button group. Calling this method overrides the groupName parameter value set during authoring. The default value is "radioGroup".
-
// Create listener object. var rbListener:Object = new Object(); rbListener.click = function(evt_obj:Object){ trace("The selected radio button group name is " + evt_obj.target.groupName); } // Add listener. myrbGroup.addEventListener("click", rbListener); RadioButton.label Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage radioButtonInstance.label Description Property; specifies the text label for the radio button. By default, the label appears to the right of the radio button.
-
Example The following example creates a radio button and assigns it a label of “Remove from list.” You first add a RadioButton component from the Components panel to the current document’s library, and then add the following code to Frame 1 of the main timeline. /** Requires: - RadioButton component in library */ this.createClassObject(mx.controls.RadioButton, "my_rb", 10); // Resize RadioButton component. my_rb.setSize(200, my_rb.height); my_rb.label = "Remove from list"; RadioButton.
-
■ The label is placed above the radio button. The radio button and label grouping are centered horizontally and vertically. If the bounding box of the radio button isn’t large enough, the label is clipped. "top" Example The following code creates three radio buttons and uses the labelPlacement property to place the label for the second button on the left of the button.
-
Description Property; a Boolean value that sets the state of the radio button to selected (true) and deselects the previously selected radio button, or sets the radio button to deselected (false). Example The following example creates three radio buttons in a radio group, positions the buttons, and sets the selected property to true to put it in the selected state.
-
Description Property; selects the radio button with the specified data value and deselects the previously selected radio button. If the data property is not specified for a selected instance, the label value of the selected instance is selected and returned. The selectedData property can be of any data type. Example The following example creates three radio buttons in a radio group, positions the buttons, and selects the button that has a data value of 10, which is the second button.
-
Description Property; behaves differently depending on whether you get or set the property. If you get the property, it returns the object reference of the currently selected radio button in a radio button group. If you set the property, it selects the specified radio button (passed as an object reference) in a radio button group and deselects the previously selected radio button.
-
CHAPTER 36 RadioButtonGroup component 36 For information about the RadioButtonGroup class, see RadioButton component.
-
1046 RadioButtonGroup component
-
CHAPTER 37 37 RDBMSResolver component (Flash Professional only) Resolver components are used with the DataSet component (part of the data management functionality in the Flash data architecture) to save changes to an external data source. Resolvers include both the RDBMSResolver component and the XUpdateResolver component. Resolvers take a delta packet (returned by DataSet.deltaPacket) and convert it to an update packet in a format appropriate to the type of resolver.
-
Using the RDBMSResolver component (Flash Professional only) You use the RDBMSResolver component only when your Flash application contains a DataSet component and must send an update back to the data source. This component resolves data that you want to return to a relational database.
-
The FieldInfo parameter lets you use properties to designate fields that require special handling. Each item in the collection contains three properties: Name of a field. This should match a field name in the DataSet component. ■ FieldName ■ OwnerName ■ IsKey Boolean property that you should set to true so that all key fields for the table are updated. Optional value used to identify fields not “owned” by the same table defined in the RDBMSResolver component’s TableName parameter.
-
Common workflow for the RDBMSResolver component The following steps describe the typical workflow for the RDBMSResolver component. To use an RDBMSResolver component: 1. Add two instances of the WebServiceConnector component and one instance of the DataSet and RDBMSResolver components to your application, and give them instance names. 2. Select the first WebServiceConnector component.
-
RDBMSResolver class (Flash Professional only) Inheritance MovieClip > RDBMSResolver ActionScript Package Name mx.data.components.RDBMSResolver The methods, properties, and events of the RDBMSResolver class allow you to connect to a DataSet component and make changes to external data sources. Method summary for the RDBMSResolver component The following table lists the method of the RDBMSResolver class. Method Description RDBMSResolver.
-
Property Description RDBMSResolver.updatePacket The XML packet produced by this resolver that contains the changes from the data set’s delta packet. RDBMSResolver.updateResults A delta packet that contains the results of an update returned from the server through a connector. Event summary for the RDBMSResolver component The following table lists the events of the RDBMSResolver class. Event Description RDBMSResolver.
-
RDBMSResolver.addFieldInfo() Availability Flash Player 7. Edition Flash MX Professional 2004. Usage resolveData.addFieldInfo("fieldName", "ownerName", "isKey") Parameters fieldName String; provides the name of the field that this information object describes. String; provides the name of the table that owns this field. If this name is the same as the RDBMSResolver instance’s tableName property, you can leave this parameter blank ("").
-
RDBMSResolver.beforeApplyUpdates Availability Flash Player 7. Edition Flash MX Professional 2004. Usage resolveData.beforeApplyUpdates(eventObject) Parameters Resolver event object; describes the customizations to the XML packet before the update is sent though the connector to the database. This event object should contain the following properties: eventObject Property Description target Object; the resolver producing this event. type String; the name of the event.
-
Example The following example adds the user authentication data to the XML packet: on (beforeApplyUpdates) { // Add user authentication data. var userInfo = new XML("" + getUserId() + ""+getPassword() + ""); updatePacket.firstChild.appendChild(userInfo); } RDBMSResolver.deltaPacket Availability Flash Player 7. Edition Flash MX Professional 2004. Usage resolveData.deltaPacket Description Property; a property of type deltaPacket.
-
Description Property; specifies a collection of an unlimited number of fields with properties that identify DataSet fields that require special handling, either because they are key fields or because they cannot be updated (for information about adding a field, see RDBMSResolver.addFieldInfo()). Each fieldInfo item in the collection contains three properties: Property Description fieldName Name of the special-case field. This field name should match a field name in the DataSet component.
-
RDBMSResolver.reconcileResults Availability Flash Player 7. Edition Flash MX Professional 2004. Usage resolveData.reconcileResults(eventObject) Parameters Resolver event object; describes the event object used to compare two update packets. This event object should contain the following properties: eventObject Property Description target Object; the resolver broadcasting this event. type String; the name of the event. Returns Nothing.
-
Example The following example reconciles two update packets and returns and clears the updates on success: on (reconcileResults) { // Examine results. if (examine(updateResults)) { myDataSet.purgeUpdates(); } else { displayErrors(results); } } RDBMSResolver.reconcileUpdates Availability Flash Player 7. Edition Flash Professional 8. Usage resolveData.
-
Description Event; broadcast by the RDBMSResolver component when results have been received from the server after the updates from a delta packet were applied. A single updateResults packet can contain results of operations that were in the delta packet, as well as information about updates that were performed by other clients. When a new update packet is received, the operation results and database updates are split into two delta packets, which are placed separately in the deltaPacket property.
-
Description Property; a string that represents the table name in the XML for the database table to be updated. This property also determines which fields to send in the update packet. To make this determination, the RDBMSResolver component compares the value of this property with the value provided for the fieldInfo.ownerName property. If a field has no entry in the fieldInfo collection property, the field is placed in the update packet.
-
Value Description "umUsingModified" Uses the old values of all of the fields modified to identify the record to be updated. This value guarantees that another user has not modified the same fields in the record since you retrieved it. "umUsingKey" The default value. This setting uses the old value of the key fields. This implies an “optimistic concurrency” model, which most database systems today employ, and guarantees that you are modifying the same record that you retrieved from the database.
-
RDBMSResolver.updateResults Availability Flash Player 7. Edition Flash MX Professional 2004. Usage resolveData.updateResults Description Property; a delta packet that contains the results of an update returned from the server through a connector. Use this property to transmit errors and updated data from the server to a data set—for example, when the server assigns new IDs for an auto-assigned field.
-
38 CHAPTER 38 RectBorder class The RectBorder class is used as the border of most components. A separate implementation of this class is provided by each theme, which has its own set of border styles and properties that it supports. You interact with the RectBorder class primarily by setting styles on other components.
-
Using styles with the RectBorder class You can set style properties to change the appearance of a RectBorder instance. A RectBorder instance uses the following styles: ■ borderCapColor ■ borderColor ■ buttonColor ■ highlightColor ■ shadowCapColor ■ shadowColor ■ themeColor The styles available on a particular RectBorder instance depend on the theme in use and the border style set on the component.
-
To set multiple border styles as parameters of the createClassObject method: 1. Select File > New and create a new Flash document. 2. In the first frame of the main timeline, add the following ActionScript to the Actions panel: createClassObject(mx.controls.TextArea, "my_ta", 1, {borderStyle: "menuBorder", themeColor: "0x990000"}); For more information, see UIObject.createClassObject().
-
6. In the first frame of the main timeline, add the following ActionScript to the Actions panel: my_btn.setStyle("buttonColor", "0xFFFFFF"); my_btn.setStyle("borderStyle", "solid"); my_btn.
-
Creating a custom RectBorder implementation The RectBorder class is used as a border skin in most ActionScript 2.0 components. The default implementations in both the Halo and Sample themes use ActionScript to draw the border. A custom implementation must use ActionScript to register itself as the RectBorder implementation and provide sizing functionality, but can use either ActionScript or graphic elements to represent the visuals.
-
To create a custom RectBorder implementation: 1. Create a new folder in the Classes/mx/skins folder corresponding to the custom package name that you will use for the custom border. For this example, use myTheme. 2. Create a new AS file in the new folder and save it as RectBorder.as. 3. Copy the following ActionScript code to the new AS file: import mx.core.ext.UIObjectExtensions; class mx.skins.myTheme.RectBorder extends mx.skins.
-
5. Create a new FLA file. 6. Use Insert > New Symbol to create a new movie clip symbol. 7. Set the name to RectBorder. 8. If the advanced fields are not displayed, click Advanced. 9. Select Export for ActionScript The identifier is automatically filled in as RectBorder. 10. Set the AS 2.0 class to the full class name of the custom border implementation. This example uses mx.skins.myTheme.RectBorder. 11. Make sure that Export in First Frame is selected and then click OK. 12. Open 13.
-
1070 RectBorder class
-
CHAPTER 39 39 Screen class (Flash Professional only) The Screen class is the base class for screens that you create in the Screen Outline pane in Flash Professional 8. Screens are high-level containers for creating applications and presentations. For an overview of working with screens, see Chapter 14, “Working with Screens (Flash Professional Only),” in Using Flash. The Screen class has two primary subclasses: Slide and Form. The Slide class provides the runtime behavior for slide presentations.
-
Loading external content into screens (Flash Professional only) The Screen class extends the Loader class (see “Loader component” on page 813), which lets you easily manage and load external SWF and JPEG files. The Loader class contains a contentPath property, which specifies the URL of an external SWF or JPEG file, or the linkage identifier of a movie clip in the library. Using this feature, you can load an external screen tree (or any external SWF file) as a child of any screen node.
-
By default, when you set a slide’s contentPath property while authoring in the Property inspector, or using ActionScript (as shown above), the specified SWF file loads as soon as the “master presentation” SWF file has loaded. To reduce initial load time, consider setting the contentPath property in an on(reveal) handler attached to each slide. // Attached to Speaker_1 slide on(reveal) { this.contentPath="speaker_1.swf"; } Alternatively, you could set the slide’s autoLoad property to false.
-
At runtime, when the Speaker 1 SWF file is loaded into the placeholder slide, the overall slide presentation would have the following structure: Inserted at runtime by Loader class Structure of “master” and “speaker” presentation (runtime) The properties and methods of the Screen, Slide, and Form classes “ignore” this contentHolder node as much as possible.
-
Methods inherited from the UIObject class The following table lists the methods the Screen class inherits from the UIObject class. When calling these methods from the Screen object, use the form ScreenInstance.methodName. Method Description UIObject.createClassObject() Creates an object on the specified class. UIObject.createObject() Creates a subobject on an object. UIObject.destroyObject() Destroys a component instance. UIObject.
-
Property summary for the Screen class The following table lists properties of the Screen class. Property Description Screen.currentFocusedScreen Read-only; returns the screen that contains the global current focus. Screen.indexInParent Read-only; returns the screen’s index (zero-based) in its parent screen’s list of child screens. Screen.numChildScreens Read-only; returns the number of child screens contained by the screen. Screen.
-
Property Description UIObject.visible A Boolean value indicating whether the object is visible (true) or not (false). UIObject.width The width of the object, in pixels. Read-only. UIObject.x The left edge of the object, in pixels. Read-only. UIObject.y The top edge of the object, in pixels. Read-only. Properties inherited from the UIComponent class The following table lists the properties the Screen class inherits from the UIComponent class.
-
Property Description Loader.percentLoaded A number that indicates the percentage of loaded content. This property is read-only. Loader.scaleContent A Boolean value that indicates whether the content scales to fit the loader (true), or the loader scales to fit the content (false). Event summary for the Screen class The following table lists events of the Screen class. Event Description Screen.allTransitionsInDone Broadcast when all “in” transitions applied to a screen have finished. Screen.
-
Events inherited from the UIObject class The following table lists the events the Screen class inherits from the UIObject class. Event Description UIObject.draw Broadcast when an object is about to draw its graphics. UIObject.hide Broadcast when an object’s state changes from visible to invisible. UIObject.load Broadcast when subobjects are being created. UIObject.move Broadcast when the object has moved. UIObject.resize Broadcast when an object has been resized. UIObject.
-
Screen.allTransitionsInDone Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage on(allTransitionsInDone) { // Your code here. } listenerObject = new Object(); listenerObject.allTransitionsInDone = function(eventObject){ // Insert your code here. } screenObj.addEventListener("allTransitionsInDone", listenerObject) Description Event; broadcast when all “in” transitions applied to this screen have finished.
-
Screen.allTransitionsOutDone Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage on(allTransitionsOutDone) { // Your code here. } listenerObject = new Object(); listenerObject.allTransitionsOutDone = function(eventObject){ // Insert your code here. } screenObj.addEventListener("allTransitionsOutDone", listenerObject) Description Event; broadcast when all “out” transitions applied to the screen have finished.
-
Description Static property (read-only); returns a reference to the “leafmost” Screen object that contains the global current focus. Leafmost refers to the screen that is furthest away from the root screen in the screen hierarchy. The focus may be on the screen itself, or on a movie clip, text object, or component inside that screen. This property defaults to null if there is no current focus.
-
Description Method; returns the child screen of myScreen whose index is childIndex. Example The following example sends the names of all the child screens belonging to the root screen named Presentation to the Output panel. for (var i:Number = 0; i < _root.Presentation.numChildScreens; i++) { var childScreen:mx.screens.Screen = _root.Presentation.getChildScreen(i); trace(childScreen._name); } Screen.indexInParent Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004.
-
Screen.mouseDown Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage on(mouseDown) { // Your code here. } listenerObject = new Object(); listenerObject.mouseDown = function(eventObj){ // Insert your code here. } screenObj.addEventListener("mouseDown", listenerObject) Description Event; broadcast when the mouse button is pressed over an object (for example, a shape or a movie clip) directly owned by the screen.
-
Screen.mouseDownSomewhere Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage on(mouseDownSomewhere) { // Your code here. } listenerObject = new Object(); listenerObject.mouseDownSomewhere = function(eventObject){ // Insert your code here. } screenObj.addEventListener("mouseDownSomewhere", listenerObject) Description Event; broadcast when the mouse button is pressed, but not necessarily over the specified screen.
-
Usage on(mouseMove) { // Your code here. } listenerObject = new Object(); listenerObject.mouseMove = function(eventObject){ // Insert your code here. } screenObj.addEventListener("mouseMove", listenerObject) Description Event; broadcast when the mouse moves while over the screen. This event is sent only when the mouse is over the bounding box of this screen. When the event is triggered, it automatically passes an event object (eventObj) to the handler.
-
Description Event; broadcast when the mouse moves from inside the screen’s bounding box to outside its bounding box. When the event is triggered, it automatically passes an event object (eventObj) to the handler. Each event object has properties that contain information about the event. You can use these properties to write code that handles the event. For more information, see “EventDispatcher class” on page 499. NO T E This event may affect system performance and should be used judiciously. Screen.
-
Screen.mouseUp Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage on(mouseUp) { // Your code here. } listenerObject = new Object(); listenerObject.mouseUp = function(eventObject){ // Insert your code here. } screenObj.addEventListener("mouseUp", listenerObject) Description Event; broadcast when the mouse is released over the screen. When the event is triggered, it automatically passes an event object (eventObj) to the handler.
-
Description Event; broadcast when the mouse button is released, but not necessarily over the specified screen. When the event is triggered, it automatically passes an event object (eventObj) to the handler. Each event object has properties that contain information about the event. You can use these properties to write code that handles the event. For more information, see “EventDispatcher class” on page 499. Screen.numChildScreens Availability Flash Player 6 (6.0.79.0).
-
Screen.parentIsScreen Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage myScreen.parentIsScreen Description Property (read-only): returns a Boolean value indicating whether the specified screen’s parent object is also a screen (true) or not (false). If this property is false, myScreen is at the root of its screen hierarchy. Example The following code determines if the parent object of the screen myScreen is also a screen. If myScreen.
-
Screen.parentScreen Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage myScreen.parentScreen Description Property (read-only); returns the screen that contains myScreen. Returns null if myScreen is the root screen. Example The following example displays the name of the screen that contains the screen myScreen. var myParent:mx.screens.Screen = myScreen.rootScreen; Screen.rootScreen Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004.
-
1092 Screen class (Flash Professional only)
-
40 CHAPTER 40 ScrollPane component The ScrollPane component displays movie clips, JPEG files, and SWF files in a scrollable area. By using a scroll pane, you can limit the amount of screen area occupied by these media types. The scroll pane can display content that is loaded from a local disk or from the Internet. You can set this content while authoring and at runtime by using ActionScript. Once the scroll pane has focus, if its content has valid tab stops, those markers receive focus.
-
Using the ScrollPane component You can use a scroll pane to display any content that is too large for the area into which it is loaded. For example, if you have a large image and only a small space for it in an application, you could load it into a scroll pane. You can set up a scroll pane to allow users to drag the content within the pane by setting the scrollDrag parameter to true; a pointing hand appears on the content.
-
vLineScrollSize indicates the number of units a vertical scroll bar moves each time a scroll arrow is clicked. The default value is 5. vPageScrollSize indicates the number of units a vertical scroll bar moves each time the scroll bar track is clicked. The default value is 20. vScrollPolicy displays the vertical scroll bars. The value can be on, off, or auto. The default value is auto.
-
3. Select Frame 1 in the main Timeline, open the Actions panel, and enter the following code: /** Requires: - ScrollPane in library */ System.security.allowDomain("http://www.helpexamples.com"); this.createClassObject(mx.containers.ScrollPane, "my_sp", 10); my_sp.setSize(320, 240); // Create listener object for scroll vertical position. var scrollListener:Object = new Object(); scrollListener.scroll = function(evt_obj:Object) { trace("hPosition: " + my_sp.hPosition + ", vPosition = " + my_sp.
-
Bear in mind these points about the ScrollPane component: ■ The ScrollPane places the registration point of its content in the upper-left corner of the pane. ■ When the horizontal scroll bar is turned off, the vertical scroll bar is displayed from top to bottom along the right side of the scroll pane. When the vertical scroll bar is turned off, the horizontal scroll bar is displayed from left to right along the bottom of the scroll pane. You can also turn off both scroll bars.
-
ScrollPane class Inheritance MovieClip > UIObject class > UIComponent class > View > ScrollView > ScrollPane ActionScript Class Name mx.containers.ScrollPane The properties of the ScrollPane class let you do the following at runtime: set the content, monitor the loading progress, and adjust the scroll amount. Setting a property of the ScrollPane class with ActionScript overrides the parameter of the same name set in the Property inspector or Component inspector.
-
Methods inherited from the UIObject class The following table lists the methods the ScrollPane class inherits from the UIObject class. When calling these methods from the ScrollPane object, use the form ScrollPaneInstance.methodName. Method Description UIObject.createClassObject() Creates an object on the specified class. UIObject.createObject() Creates a subobject on an object. UIObject.destroyObject() Destroys a component instance. UIObject.
-
Property summary for the ScrollPane class The following table lists properties of the ScrollPane class. Method Description ScrollPane.content A reference to the content loaded into the scroll pane (readonly). ScrollPane.contentPath A string that indicates an absolute or relative URL of the SWF or JPEG file to load into the scroll pane, or that is the linkage identifier of a movie clip in the current document’s library panel. ScrollPane.
-
Properties inherited from the UIObject class The following table lists the properties the ScrollPane class inherits from the UIObject class. When accessing these properties from the ScrollPane object, use the form ScrollPaneInstance.propertyName. Property Description UIObject.bottom Read-only; the position of the bottom edge of the object, relative to the bottom edge of its parent. UIObject.height Read-only; the height of the object, in pixels. UIObject.
-
Event summary for the ScrollPane class The following table lists events of the ScrollPane class. Event Description ScrollPane.complete Broadcast when the scroll pane content is loaded. ScrollPane.progress Broadcast while the scroll pane content is loading. ScrollPane.scroll Broadcast when the scroll bar is clicked. Events inherited from the UIObject class The following table lists the events the ScrollPane class inherits from the UIObject class. Event Description UIObject.
-
ScrollPane.complete Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage Usage 1: var listenerObject:Object = new Object(); listenerObject.complete = function(eventObject:Object) { // ... }; scrollPaneInstance.addEventListener("complete", listenerObject); Usage 2: on (complete) { //... } Description Event; broadcast to all registered listeners when the content finishes loading. The first usage example uses a dispatcher/listener event model.
-
The second usage example uses an on() handler and must be attached directly to a ScrollPane instance. The keyword this, used inside an on() handler attached to a component, refers to the component instance. For example, the following code, attached to the ScrollPane instance myScrollPaneComponent, sends “_level0.myScrollPaneComponent” to the Output panel: on (complete) { trace(this); } Example The following example creates a listener object with a complete event handler for the scrollPane instance.
-
Usage scrollPaneInstance.content Description Read-only property; a reference to the content of the scroll pane. The value is undefined until the load begins. Example This example sets the contentPath property to load a scroll pane with a picture (or technically, a movie clip containing a JPEG image). It also creates a numeric stepper that the user can increment or decrement by 10, up to a value of 100. When the user changes the value in the NumericStepper, a listener sets the transparency (content.
-
ScrollPane.contentPath Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage scrollPaneInstance.contentPath Description Property; a string that indicates an absolute or relative URL of the SWF or JPEG file to load into the scroll pane. A relative path must be relative to the SWF file that loads the content. If you load content using a relative URL, the loaded content must be relative to the location of the SWF file that contains the scroll pane.
-
// method 2: Symbol in library my_sp.contentPath ="movieClip_Name"; // method 3: SWF file my_sp.contentPath ="logo.swf"; See also ScrollPane.content ScrollPane.getBytesLoaded() Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage scrollPaneInstance.getBytesLoaded() Parameters None. Returns The number of bytes loaded in the scroll pane. Description Method; returns the number of bytes loaded in the ScrollPane instance.
-
You first drag the ScrollPane component from the Components panel to the current document’s library and then add the following code to Frame 1: /** Requires: - ScrollPane component in library */ this.createClassObject(mx.containers.ScrollPane, "my_sp", 10); my_sp.setSize(360, 280); var loadListener:Object = new Object(); loadListener.progress = function(evt_obj:Object) { trace(my_sp.getBytesLoaded() + " of " + my_sp.getBytesTotal() + " bytes loaded."); }; my_sp.
-
Example This example creates a ScrollPane instance called my_sp and defines a listener object called loadListener with a progress event handler. The event handler calls the getBytesLoaded() getBytesTotal() functions to display the progress of the load in the Output panel. You first drag the ScrollPane component from the Components panel to the current document’s library and then add the following code to Frame 1: /** Requires: - ScrollPane component in library */ this.createClassObject(mx.containers.
-
Example This example creates a ScrollPane instance called my_sp, loads it with an image, and sets the hLineScrollSize property to scroll 100 pixels when the user clicks an arrow on the horizontal scroll bar. You first drag the ScrollPane component from the Components panel to the current document’s library and then add the following code to Frame 1: /** Requires: - ScrollPane component in library */ this.createClassObject(mx.containers.ScrollPane, "my_sp", 10); my_sp.setSize(360, 280); System.security.
-
You first drag the ScrollPane component from the Components panel to the current document’s library and add the following code to Frame 1: /** Requires: - ScrollPane component in library */ this.createClassObject(mx.containers.ScrollPane, "my_sp", 10); my_sp.setSize(360, 280); System.security.allowDomain("http://www.helpexamples.com"); my_sp.contentPath = "http://www.helpexamples.com/flash/images/image1.jpg"; // Scroll 100 pixels when clicking on horizontal bar. my_sp.hPageScrollSize = 100; ScrollPane.
-
You first drag the ScrollPane component from the Components panel to the current document’s library and then add the following code to Frame 1: /** Requires: - ScrollPane component in library */ this.createClassObject(mx.containers.ScrollPane, "my_sp", 10); my_sp.setSize(360, 280); System.security.allowDomain("http://www.helpexamples.com"); my_sp.contentPath = "http://www.helpexamples.com/flash/images/image1.jpg"; // Scroll 100 pixels when clicking on horizontal bar. my_sp.
-
You first drag the ScrollPane component from the Components panel to the current document’s library and then add the following code to Frame 1: /** Requires: - ScrollPane component in library */ this.createClassObject(mx.containers.ScrollPane, "my_sp", 10); my_sp.setSize(360, 280); my_sp.hScrollPolicy = "off"; System.security.allowDomain("http://www.helpexamples.com"); my_sp.contentPath = "http://www.helpexamples.com/flash/images/image1.jpg"; ScrollPane.progress Availability Flash Player 6 (6.0.79.0).
-
The first usage example uses a dispatcher/listener event model. A component instance (scrollPaneInstance) dispatches an event (in this case, progress) and the event is handled by a function, also called a handler, on a listener object (listenerObject) that you create. You define a method with the same name as the event on the listener object; the method is called when the event is triggered. When the event is triggered, it automatically passes an event object (eventObject) to the listener object method.
-
ScrollPane.refreshPane() Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage scrollPaneInstance.refreshPane() Parameters None. Returns Nothing. Description Method; refreshes the scroll pane after content is loaded. This method reloads the content, but does not reset the scroll bar. You could use this method if, for example, you’ve loaded a form into a scroll pane and an input property (for example, a text field) has been changed by ActionScript.
-
You first drag the ScrollPane component from the Components panel to the current document’s library and then add the following code to Frame 1: /** Requires: - ScrollPane component in library */ this.createClassObject(mx.controls.Button, "my_button", 10, {label:"Refresh"}); this.createClassObject(mx.containers.ScrollPane, "my_sp", 20); my_sp.move(0, 30); my_sp.setSize(360, 280); var buttonListener:Object = new Object(); buttonListener.click = function(evt_obj:Object) { my_sp.refreshPane(); } my_button.
-
Event object In addition to the standard event object properties, there are two additional properties defined for the scroll event: a type property whose value is "scroll", and a direction property whose value can be "vertical" or "horizontal". In addition to the standard event object properties, there are two additional properties defined for the ProgressBar.progress event: current (the loaded value equals total), and total (the total value).
-
You first drag the ScrollPane component from the Components panel to the current document’s library and then add the following code to Frame 1: /** Requires: - ScrollPane component in library */ this.createClassObject(mx.containers.ScrollPane, "my_sp", 10); my_sp.setSize(360, 280); System.security.allowDomain("http://www.helpexamples.com"); my_sp.contentPath = "http://www.helpexamples.com/flash/images/image1.jpg"; // Scroll 100 pixels when clicking on horizontal bar. my_sp.
-
Example This example creates a ScrollPane instance called my_sp, loads it with an image, and sets the scrollDrag property to true, allowing the user to scroll by dragging the image within the scroll pane. You first drag the ScrollPane component from the Components panel to the current document’s library and then add the following code to Frame 1: /** Requires: - ScrollPane component in library */ this.createClassObject(mx.containers.ScrollPane, "my_sp", 10); my_sp.setSize(360, 280); System.security.
-
You first drag the ScrollPane component from the Components panel to the current document’s panel and then add the following code to Frame 1: /** Requires: - ScrollPane component in library */ this.createClassObject(mx.containers.ScrollPane, "my_sp", 10); my_sp.setSize(360, 280); System.security.allowDomain("http://www.helpexamples.com"); my_sp.contentPath = "http://www.helpexamples.com/flash/images/image1.jpg"; // Scroll 20 pixels when clicking on vertical bar arrows. my_sp.
-
You first drag the ScrollPane component from the Components panel to the current document’s library and then add the following code to Frame 1: /** Requires: - ScrollPane component in library */ this.createClassObject(mx.containers.ScrollPane, "my_sp", 10); my_sp.setSize(360, 280); System.security.allowDomain("http://www.helpexamples.com"); my_sp.contentPath = "http://www.helpexamples.com/flash/images/image1.jpg"; // Scroll 30 pixels when clicking on vertical bar. my_sp.vPageScrollSize = 30; ScrollPane.
-
You first drag the ScrollPane component from the Components panel to the current document’s library and then add the following code to Frame 1: /** Requires: - ScrollPane component in library */ this.createClassObject(mx.containers.ScrollPane, "my_sp", 10); my_sp.setSize(360, 280); System.security.allowDomain("http://www.helpexamples.com"); my_sp.contentPath = "http://www.helpexamples.com/flash/images/image1.jpg"; // Scroll 100 pixels when clicking on horizontal bar. my_sp.
-
Example The following example creates an instance of a ScrollPane called my_sp, sets vScrollPolicy to off to prevent a vertical scroll bar from appearing, and loads the ScrollPane with an image. You first drag the ScrollPane component from the Components panel to the current document’s library and then add the following code to Frame 1: /** Requires: - ScrollPane component in library */ import mx.containers.ScrollPane; this.createClassObject(ScrollPane, "my_sp", 30); my_sp.setSize(360, 280); my_sp.
-
1124 ScrollPane component
-
41 CHAPTER 41 SimpleButton class Inheritance MovieClip > UIObject class > UIComponent class > SimpleButton ActionScript Class Name mx.controls.
-
Method Description UIObject.setSize() Resizes the object to the requested size. UIObject.setSkin() Sets a skin in the object. UIObject.setStyle() Sets the style property on the style declaration or object. Methods inherited from the UIComponent class The following table lists the methods the SimpleButton class inherits from the UIComponent class. When calling these methods from the SimpleButton object, use the form buttonInstance.methodName. Method Description UIComponent.
-
Properties inherited from the UIObject class The following table lists the properties the SimpleButton class inherits from the UIObject class. When accessing these properties from the SimpleButton object, use the form buttonInstance.propertyName. Property Description UIObject.bottom The position of the bottom edge of the object, relative to the bottom edge of its parent. Read-only. UIObject.height The height of the object, in pixels. Read-only. UIObject.left The left edge of the object, in pixels.
-
Event summary for the SimpleButton class The following table lists the event of the SimpleButton class. Event Description SimpleButton.click Broadcast when a button is clicked. Events inherited from the UIObject class The following table lists the events the SimpleButton class inherits from the UIObject class. Event Description UIObject.draw Broadcast when an object is about to draw its graphics. UIObject.hide Broadcast when an object’s state changes from visible to invisible. UIObject.
-
SimpleButton.click Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage Usage 1: var listenerObject:Object = new Object(); listenerObject.click = function(eventObj:Object){ // ... }; buttonInstance.addEventListener("click", listenerObject); Usage 2: on (click) { // ... } Description Event; broadcast to all registered listeners when the mouse is clicked (released) over the button or if the button has focus and the Spacebar is pressed.
-
The second usage example uses an on() handler and must be attached directly to a Button component instance. The keyword this, used inside an on() handler attached to a component, refers to the component instance. For example, the following code, attached to the Button component instance myButtonComponent, sends “_level0.
-
The following code also sends a message to the Output panel when buttonInstance is clicked. The on() handler must be attached directly to buttonInstance. on (click) { trace("button component was clicked"); } SimpleButton.emphasized Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage buttonInstance.emphasized Description Property; indicates whether the button is in an emphasized state (true) or not (false). The emphasized state is equivalent to the appearance of a default push button.
-
SimpleButton.emphasizedStyleDeclaration Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage buttonInstance.emphasizedStyleDeclaraion Description Property (static); a string indicating the style declaration that formats a button when the emphasized property is set to true. The emphasizedStyleDeclaration property is a static property of the SimpleButton class. Therefore, you must access it directly from SimpleButton, rather than from a buttonInstance, as in the following: SimpleButton.
-
SimpleButton.toggle Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage buttonInstance.toggle Description Property; a Boolean value that indicates whether the button acts as a toggle switch (true) or not (false). The default value is false. If a button acts as a toggle switch, it stays pressed until you click it again to release it. SimpleButton.
-
1134 SimpleButton class
-
CHAPTER 42 42 Slide class (Flash Professional only) The Slide class corresponds to a node in a hierarchical slide presentation. In Flash Professional 8, you can create slide presentations using the Screen Outline pane. For an overview of working with screens, see Chapter 14, “Working with Screens (Flash Professional Only),” in Using Flash.
-
Also note that child slides “inherit” the visual appearance (graphics and other content) of their parent slides. For example, in the above illustration, in addition to the content on the Finance slide, the user would also see any content on the Intro and Presentation slides. NO TE The Slide class inherits from the Loader class, which lets you easily load external SWF or JPEG files into a given slide. This provides a way to make your slide presentations modular and reduce initial download time.
-
Using the Slide class to create a slide presentation You use the methods and properties of the Slide class to control slide presentations you create in the Screen Outline pane for a Flash Slide Presentation in the Flash authoring environment. (The Behaviors panel also contains several behaviors for creating slide navigation.) In this example, you write your own ActionScript to create Next and Previous buttons for a slide presentation. To create a slide presentation with navigation: 1.
-
Slide class (API) (Flash Professional only) Inheritance MovieClip > UIObject class > UIComponent class > View > Loader component > Screen class (Flash Professional only) > Slide ActionScript Class Name mx.screens.Slide The methods, properties, and events of the Slide class allow you to manage and manipulate slides. Method summary for the Slide class The following table lists methods of the Slide class: Method Description Slide.getChildSlide() Returns the specified child slide. Slide.
-
Method Description UIObject.move() Moves the object to the requested position. UIObject.redraw() Forces validation of the object so it is drawn in the current frame. UIObject.setSize() Resizes the object to the requested size. UIObject.setSkin() Sets a skin in the object. UIObject.setStyle() Sets the style property on the style declaration or object. Methods inherited from the UIComponent class The following table lists the methods the Slide class inherits from the UIComponent class.
-
Property summary for the Slide class The following table lists properties of the Slide class: Property Description Slide.autoKeyNav Determines whether the slide uses default keyboard handling to navigate to the next/previous slide. Slide.currentChildSlide Read-only; returns the immediate child of the specified slide that contains the currently active slide. Slide.
-
Properties inherited from the UIObject class The following table lists the properties the Slide class inherits from the UIObject class. When accessing these properties from the Slide object, use the form SlideInstance.propertyName. Property Description UIObject.bottom The position of the bottom edge of the object, relative to the bottom edge of its parent. Read-only. UIObject.height The height of the object, in pixels. Read-only. UIObject.left The left edge of the object, in pixels. Read-only.
-
Properties inherited from the Loader class The following table lists the properties the Slide class inherits from the Loader class. When accessing these properties from the Slide object, use the form SlideInstance.propertyName. Property Description Loader.autoLoad A Boolean value that indicates whether the content loads automatically (true) or you must call Loader.load() (false). Loader.bytesLoaded A read-only property that indicates the number of bytes that have been loaded. Loader.
-
Property Description Screen.parentIsScreen Read-only; returns a Boolean (true or false) value that indicates whether the screen’s parent object is itself a screen. Screen.rootScreen Read-only; returns the root screen of the tree or subtree that contains the screen. Event summary for the Slide class The following table lists events of the Slide class. Event Description Slide.hideChild Broadcast each time a child of a slide changes from visible to invisible. Slide.
-
Events inherited from the UIComponent class The following table lists the events the Slide class inherits from the UIComponent class. Event Description UIComponent.focusIn Broadcast when an object receives focus. UIComponent.focusOut Broadcast when an object loses focus. UIComponent.keyDown Broadcast when a key is pressed. UIComponent.keyUp Broadcast when a key is released. Events inherited from the Loader class The following table lists the events the Slide class inherits from the Loader class.
-
Event Description Screen.mouseUp Broadcast when the mouse button was released over an object (shape or movie clip) directly owned by the screen. Screen.mouseUpSomewhere Broadcast when the mouse button was released somewhere on the Stage, but not necessarily over an object owned by this screen. Slide.autoKeyNav Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage mySlide.
-
Example This example turns off automatic keyboard navigation for the slide named loginSlide. _root.Presentation.loginSlide.autoKeyNav = "false"; See also Slide.defaultKeydownHandler Slide.currentChildSlide Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage mySlide.currentChildSlide Description Property (read-only); returns the immediate child of mySlide that contains the currently active slide; returns null if no child slide contained by mySlide has the current focus.
-
Slide.currentFocusedSlide Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage mx.screens.Slide.currentFocusedSlide Description Property (read-only); returns the “leafmost” slide (the slide farthest from the root of the slide tree) that contains the current global focus. The actual focus may be on the slide itself, or on a movie clip, text object, or component inside that slide; the method returns null if there is no current focus. Example var focusedSlide = mx.screens.
-
Example The following code, attached to a button on the root presentation slide, advances the slide presentation to the next slide each time the button is clicked. // Attached to button instance contained by presentation slide: on(press) { _parent.currentSlide.gotoNextSlide(); } See also Slide.gotoNextSlide() Slide.defaultKeydownHandler Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage mySlide.defaultKeyDownHandler = function (eventObj) { // Your code here.
-
Description Callback function; lets you override the default keyboard navigation with a custom keyboard handler that you create. For example, instead of having the Left and Right Arrow keys navigate to the previous and next slides in a presentation, respectively, you could have the Up and Down Arrow keys perform those functions. For a discussion of the default keyboard handling behavior, see Slide.autoKeyNav.
-
Example In the hierarchy of slides shown below, the following statements are both true: Presentation.Intro.firstSlide == Intro_bullet_1_1; Presentation.Intro_bullet_1.firstSlide == Intro_bullet_1_1; Slide.getChildSlide() Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage mySlide.getChildSlide(childIndex) Parameters childIndex The zero-based index of the child slide to return. Returns A slide object.
-
Example The following code causes the Output panel to display the names of all the child slides of the root presentation slide. var numSlides = _root.Presentation.numChildSlides; for(var slideIndex=0; slideIndex < numSlides; slideIndex++) { var childSlide = _root.Presentation.getChildSlide(slideIndex); trace(childSlide._name); } See also Slide.numChildSlides Slide.gotoFirstSlide() Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage mySlide.
-
Example In the slide hierarchy illustrated below, the following method calls would all navigate to the slide named Intro_bullet_1_1: Presentation.gotoFirstSlide(); Presentation.Intro.gotoFirstSlide(); Presentation.Intro.Intro_bullet_1.gotoFirstSlide(); This method call would navigate to the slide named Intro_bullet_2_1: Presentation.Intro.Intro_bullet_2.gotoFirstSlide(); See also Slide.firstSlide, Slide.revealChild Slide.gotoLastSlide() Availability Flash Player 6 (6.0.79.0).
-
Returns Nothing. Description Method; navigates to the last leaf slide in the tree of child slides beneath mySlide. This method is ignored when called from within a slide’s on(hide) or on(reveal) event handler if that event was a result of another slide navigation. Example In the slide hierarchy illustrated below, the following method calls would navigate to the slide named Intro_bullet_1_2: Presentation.Intro.gotoLastSlide(); Presentation.Intro.Intro_bullet_1.
-
Slide.gotoNextSlide() Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage mySlide.gotoNextSlide() Parameters None. Returns A Boolean value, or null. The method returns true if it successfully navigated to the next slide; it returns false if the presentation is already at the last slide when the method is invoked (that is, if currentSlide.nextSlide is null). The method returns null if invoked on a slide that doesn’t contain the current slide.
-
Example Suppose that, in the following slide hierarchy, the slide named Intro_bullet_1_1 is the current slide being viewed (that is, _root.Presentation.currentSlide._name == Intro_bullet_1_1). In this case, calling Intro_bullet_1_1.gotoNextSlide() would navigate to which is a sibling slide of Intro_bullet_1_1. Intro_bullet_1_2, However, calling Intro_bullet_1.
-
Slide.gotoPreviousSlide() Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage mySlide.gotoPreviousSlide() Parameters None. Returns A Boolean value, or null. The method returns true if it successfully navigated to the previous slide; it returns false if the presentation is at the first slide when the method is invoked (that is, if currentSlide.nextSlide is null). The method returns null if invoked on a slide that doesn’t contain the current slide.
-
Example Suppose that, in the following slide hierarchy, the slide named Intro_bullet_1_2 is the current slide being viewed (that is, _root.Presentation.currentSlide._name == Intro_bullet_1_2). In this case, calling Intro_bullet_1_2.gotoPreviousSlide() would navigate to which is the previous sibling slide of Intro_bullet_1_2. Intro_bullet_1_1, However, calling Intro_bullet_2.
-
Slide.gotoSlide() Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage mySlide.gotoSlide(newSlide) Parameters newSlide The slide to navigate to. Returns A Boolean value indicating if the navigation succeeded (true) or not (false). Description Method; navigates to the slide specified by newSlide. For the navigation to succeed, the following must be true: ■ The current slide must be a child slide of mySlide.
-
Also consider the following screen hierarchy, where a form object is the parent screen of two separate slide trees: Form_1 Slide1 Slide1_1 Slide1_2 Slide2 Slide2_1 Slide2_2 If the current slide is Slide1_2, the following method call also fails, because Slide1 and Slide2 are in different slide subtrees: Slide1_2.gotoSlide(Slide2_2); Example The following code, attached to a Button component, uses the Slide.currentSlide property and the gotoSlide() method to display the next slide in the presentation.
-
Description Event; broadcast each time a child of a slide changes from visible to invisible. This event is broadcast only by slides, not forms. The main use of the hideChild event is to apply “out” transitions to all the children of a slide. Example When attached to the root slide (for example, the presentation slide), this code displays the name of each child slide that belongs to the root slide, as the child slide is hidden. on(hideChild) { var child = eventObj.target.
-
Example The following code uses the indexInParentSlide and Slide.numChildSlides properties to display the index of the current slide being viewed and the total number of slides contained by its parent slide. To use this code, attach it to a parent slide that contains one or more child slides. on (revealChild) { trace("Displaying "+(currentSlide.indexInParentSlide+1)+" of "+currentSlide._parent.
-
Example The following statements are all true concerning the slide hierarchy shown below: Presentation.lastSlide._name == Results_bullet_1; Intro.lastSlide._name == Intro_bullet_1_2; Intro_bullet_1.lastSlide._name == Intro_bullet_1_2; Results.lastSlide.
-
Slide.nextSlide Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage mySlide.nextSlide Description Property (read-only); returns the slide you would reach if you called mySlide.gotoNextSlide(), but does not actually navigate to that slide. For example, you can use this property to display the name of the next slide in a presentation and let users select whether they want to navigate to that slide.
-
Slide.numChildSlides Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage mySlide.numChildSlides Description Property (read-only); returns the number of child slides that mySlide contains. A slide can contain either forms or other slides; if mySlide contains both slides and forms, this property only returns the number of slides, and does not count forms. Example This example uses Slide.numChildSlides and the Slide.
-
Slide.overlayChildren Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage mySlide.overlayChildren Description Property; determines whether child slides of mySlide remain visible when navigating from one child slide to the next. When this property is true, the previous slide remains visible when control passes to its next sibling slide; when this property is false, the previous slide is invisible when control passes to its next sibling slide.
-
Slide.parentIsSlide Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage mySlide.parentIsSlide Description Property (read-only); a Boolean value indicating whether the parent object of mySlide is also a slide. If the parent object of mySlide is a slide, or belongs to a subclass of Slide, this property returns true; otherwise, it returns false.
-
Usage mySlide.parentSlide Description Property (read-only); a reference to the slide containing the current slide. Slide.playHidden Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage mySlide.playHidden Description Property; a Boolean value that specifies whether mySlide should continue to play when it is hidden. When this property is true, mySlide continues to play when hidden.
-
Example In this example, the label of a Button component named previousButton displays the name of the previous slide in the presentation. If there is no previous slide—that is, if mySlide.previousSlide is null—the button’s label is updated to indicate that the user is at the beginning of this slide presentation. if (mySlide.previousSlide != null) { previousButton.label = "Previous slide: " + mySlide.previous._name + " > "; } else { previousButton.
-
See also Slide.hideChild Slide.rootSlide Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage mySlide.rootSlide Description Property (read-only); returns the root slide of the slide tree, or slide subtree, that contains mySlide. Example Suppose you have a movie clip on a slide that, when clicked, goes to the first slide in the presentation. To accomplish this, you would attach the following code to the movie clip: on(press) { _parent.rootSlide.
-
1170 Slide class (Flash Professional only)
-
43 CHAPTER 43 StyleManager class ActionScript Class Name mx.styles.StyleManager The StyleManager class keeps track of known inheriting styles and colors. You need to use this class only if you are creating components and want to add a new inheriting style or color. To determine which styles are inheriting, see the W3C web site at www.w3.org/Style/CSS/. Method summary for the StyleManager class The following table lists methods of the StyleManager class. Method Description StyleManager.
-
StyleManager.registerColorName() Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage StyleManager.registerColorName(colorName, value) Parameters colorName A string indicating the name of the color (for example, "gray", "darkGrey", and so on). A hexadecimal number indicating the color (for example, 0x808080, 0x404040, and value so on). Returns Nothing. Description Method; associates a color name with a hexadecimal value and registers it with the Style Manager.
-
StyleManager.registerColorStyle() Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage StyleManager.registerColorStyle(colorStyle) Parameters A string indicating the name of the color (for example, "highlightColor", "shadowColor", "disabledColor", and so on). colorStyle Returns Nothing. Description Method; adds a new color style to the Style Manager. Example The following example registers "highlightColor" as a color style: StyleManager.
-
StyleManager.registerInheritingStyle() Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage StyleManager.registerInheritingStyle(propertyName) Parameters A string indicating the name of the style property (for example, "newProp1", "newProp2", and so on). propertyName Returns Nothing. Description Method; marks this style property as inheriting. Use this method to register style properties that aren’t listed in the CSS specification.
-
44 CHAPTER 44 SystemManager class ActionScript Class Name mx.managers.SystemManager The SystemManager class works automatically with the FocusManager class to handle which top-level window is activated in an application that contains version 2 components. It also provides a screen property that allows components and movie clips to access Stage coordinates. Property summary for the SystemManager class The following table lists the property of the SystemManager class.
-
SystemManager.screen Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage SystemManager.screen Description Property; an object with x, y, width, and height properties that indicate the size and position of the Stage. Example If Stage.align is set to something other than "LT", it is difficult to know what coordinates are actually viewable. Suppose you want to place a watermark movie clip in the lower-right corner of the Stage (similar to the watermarks many television channels use).
-
45 CHAPTER 45 TextArea component The TextArea component wraps the native ActionScript TextField object. You can use styles to customize the TextArea component; when an instance is disabled, its contents display in a color represented by the disabledColor style. A TextArea component can also be formatted with HTML, or as a password field that disguises the text. See “Applying a style sheet to a TextArea component” in Learning ActionScript 2.0 in Flash.
-
Using the TextArea component You can use a TextArea component wherever you need a multiline text field. If you need a single-line text field, use the TextInput component. For example, you could use a TextArea component as a comment field in a form. You could set up a listener that checks if the field is empty when a user tabs out of the field. That listener could display an error message indicating that a comment must be entered in the field.
-
visible is a Boolean value that indicates whether the object is visible (true) or not (false). The default value is true. NO T E 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. Otherwise, setting these properties in the Component inspector has no visible effect.
-
Customizing the TextArea component You can transform a TextArea 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 UIObject.setSize() or any applicable properties and methods of the TextArea class. When a TextArea component is resized, the border is resized to the new bounding box.
-
Style Theme Description embedFonts Both A Boolean value that indicates whether the font specified in fontFamily is an embedded font. This style must be set to true if fontFamily refers to an embedded font. Otherwise, the embedded font is not used. If this style is set to true and fontFamily does not refer to an embedded font, no text is displayed. The default value is false. fontFamily Both The font name for text. The default value is "_sans". fontSize Both The point size for the font.
-
You can make the background of TextArea components transparent by setting the backgroundColor style globally to a value of undefined. You then need to set the backgroundColor style to a color individually for all TextArea components that you do not want to be transparent. // Give all TextArea components transparent backgrounds. _global.styles.TextArea.backgroundColor = undefined; //Make this specific component instance have a white background. myTextArea2.
-
Setting a property of the TextArea class with ActionScript overrides the parameter of the same name set in the Property inspector or Component inspector. The TextArea component overrides the default Flash Player focus rectangle and draws a custom focus rectangle with rounded corners. The TextArea component supports CSS styles and any additional HTML styles supported by Flash Player. Each component class has a version property, which is a class property.
-
Method Description UIObject.setSkin() Sets a skin in the object. UIObject.setStyle() Sets the style property on the style declaration or object. Methods inherited from the UIComponent class The following table lists the methods the TextArea class inherits from the UIComponent class. When calling these methods from the TextArea object, use the form TextAreaInstance.methodName. Method Description UIComponent.getFocus() Returns a reference to the object that has focus. UIComponent.
-
Property Description TextArea.vPosition A number indicating the vertical scrolling position. TextArea.vScrollPolicy Indicates whether the vertical scroll bar is always on ("on"), is never on ("off"), or turns on when needed ("auto"). TextArea.wordWrap A Boolean value indicating whether the text wraps (true) or not (false). Properties inherited from the UIObject class The following table lists the properties the TextArea class inherits from the UIObject class.
-
Properties inherited from the UIComponent class The following table lists the properties the TextArea class inherits from the UIComponent class. When accessing these properties from the TextArea object, use the form TextAreaInstance.propertyName. Property Description UIComponent.enabled Indicates whether the component can receive focus and input. UIComponent.tabIndex A number indicating the tab order for a component in a document.
-
Events inherited from the UIComponent class The following table lists the events the TextArea class inherits from the UIComponent class. Event Description UIComponent.focusIn Broadcast when an object receives focus. UIComponent.focusOut Broadcast when an object loses focus. UIComponent.keyDown Broadcast when a key is pressed. UIComponent.keyUp Broadcast when a key is released. TextArea.change Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004.
-
The first usage example uses a dispatcher/listener event model. A component instance (textAreaInstance) dispatches an event (in this case, change) and the event is handled by a function, also called a handler, on a listener object (listenerObject) that you create. You define a method with the same name as the event on the listener object; the method is called when the event is triggered. When the event is triggered, it automatically passes an event object (eventObject) to the listener object method.
-
// Define a listener object. var taListener:Object = new Object(); // Define a function that is executed whenever the listener receives // notification of a change in the TextArea component. taListener.change = function(evt_obj:Object) { changeCount_num++; trace("Text has changed " + changeCount_num + " times now!"); trace("It now contains: " + evt_obj.target.text); trace(""); }; // Register the listener object with the TextArea component instance. my_ta.
-
You must first add an instance of the TextArea component to the Stage and name it my_ta; then add the following code to Frame 1. /** Requires: - TextArea instance on Stage (instance name: my_ta) */ var my_ta:mx.controls.TextArea; my_ta.setSize(320, 240); my_ta.editable = false; // Load text to display and define onData handler. var my_lv:LoadVars = new LoadVars(); my_lv.onData = function(src:String) { if (src != undefined) { my_ta.text = src; } else { my_ta.text = "Error loading text."; } }; my_lv.
-
You must first add an instance of the TextArea component to the Stage and name it my_ta; then add the following code to Frame 1. /** Requires: - TextArea instance on Stage (instance name: my_ta) */ var my_ta:mx.controls.TextArea; my_ta.setSize(320, 240); my_ta.wordWrap = false; var taListener:Object = new Object(); taListener.scroll = function(evt_obj:Object) { trace("hPosition = " + my_ta.hPosition); } my_ta.addEventListener("scroll", taListener); // Load text to display and define onData handler.
-
Example The following example turns off the hScrollPolicy property, causing the TextArea instance to not have a scroll bar. You must first add an instance of the TextArea component to the Stage and name it my_ta; then add the following code to Frame 1. /** Requires: - TextArea instance on Stage (instance name: my_ta) */ var my_ta:mx.controls.TextArea; my_ta.setSize(320, 240); my_ta.wordWrap = false; my_ta.hScrollPolicy = "off"; // Load text to display and define onData handler.
-
Example The following example makes the TextArea called my_ta an HTML text area and then formats the text with HTML tags. You must first add an instance of the TextArea component to the Stage and name it my_ta; then add the following code to Frame 1: /** Requires: - TextArea instance on Stage (instance name: my_ta) */ var my_ta:mx.controls.TextArea; my_ta.setSize(320, 240); my_ta.html = true; my_ta.text = "The Royal Nonesuch"; TextArea.length Availability Flash Player 6 (6.0.79.0).
-
You must first add an instance of the TextArea component to the Stage and name it my_ta; then add the following code to Frame 1. /** Requires: - TextArea instance on Stage (instance name: my_ta) */ var my_ta:mx.controls.TextArea; // Define a listener object. var taListener:Object = new Object(); taListener.change = function(evt_obj:Object) { trace("my_ta.length is now: " + my_ta.length + " characters"); }; my_ta.addEventListener("change", taListener); TextArea.maxChars Availability Flash Player 6 (6.0.79.
-
You must first add an instance of the TextArea component to the Stage and name it my_ta; then add the following code to Frame 1. /** Requires: - TextArea instance on Stage (instance name: my_ta) */ var my_ta:mx.controls.TextArea; my_ta.maxChars = 24; // Define a listener object. var taListener:Object = new Object(); taListener.change = function(evt_obj:Object) { trace("my_ta.length is now: " + my_ta.length + " characters"); }; my_ta.addEventListener("change", taListener); TextArea.
-
You must first add an instance of the TextArea component to the Stage and name it my_ta; then add the following code to Frame 1. /** Requires: - TextArea instance on Stage (instance name: my_ta) */ var my_ta:mx.controls.TextArea; my_ta.setSize(320, 240); my_ta.wordWrap = false; var taListener:Object = new Object(); taListener.scroll = function(evt_obj:Object) { trace("hPosition = " + my_ta.hPosition); } my_ta.addEventListener("scroll", taListener); // Load text to display and define onData handler.
-
Description Read-only property; indicates the maximum value of TextArea.vPosition. The default value is 0. Example The following example accesses the maxVPosition property to set the initial vertical position of the TextArea called my_ta to the bottom. It also traces the current vertical position as the user scrolls up and down. You must first add an instance of the TextArea component to the Stage and name it my_ta; then add the following code to Frame 1.
-
TextArea.password Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage textAreaInstance.password Description Property; a Boolean value indicating whether the text area is a password field (true) or not (false). If password is true, the text area is a password text area and hides the input characters with asterisks. If password is false, the text area is not a password text area. The default value is false.
-
TextArea.restrict Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage textAreaInstance.restrict Description Property; indicates the set of characters that users can enter in the text area. The default value is undefined. If this property is null, users can enter any character. If this property is an empty string, no characters can be entered. If this property is a string of characters, users can enter only characters in the string; the string is scanned from left to right.
-
You must first add an instance of the TextArea component to the Stage and name it my_ta; then add the following code to Frame 1. Use only one setting for the restrict property at a time. /** Requires: - TextArea instance on Stage (instance name: my_ta) */ var my_ta:mx.controls.TextArea; my_ta.wordWrap = true; // Limit control to uppercase letters, numbers, and spaces. my_ta.restrict = "A-Z 0-9"; // Allow all characters, except lowercase letters // characters to uppercase my_ta.restrict = "^a-z"; TextArea.
-
Description Event; broadcast to all registered listeners when the mouse button is clicked (released) over the scroll bar. The UIScrollBar.scrollPosition property and the scroll bar’s onscreen image are updated before this event is broadcast. The first usage example uses a dispatcher/listener event model, in which the script is placed on a frame in the that contains the component instance.
-
You first add an instance of the TextArea component to the Stage and name it my_ta; then add the following code to Frame 1: /** Requires: - TextArea instance on Stage (instance name: my_ta) */ my_ta.setSize(320, 240); my_ta.move(10, 10); var lorem_lv:LoadVars = new LoadVars(); lorem_lv.onData = function(src:String):Void { my_ta.text = src; } lorem_lv.load("http://www.helpexamples.com/flash/lorem.txt"); my_ta.
-
The style sheet associated with a TextArea component may be changed at any time. If the style sheet in use is changed, the TextArea component is redrawn with the new style sheet. The style sheet may be set to null or undefined to remove the style sheet. If the style sheet in use is removed, the TextArea component is redrawn without a style sheet. The formatting done by a style sheet is not retained if the style sheet is removed.
-
TextArea.text Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage textAreaInstance.text Description Property; the text contents of a TextArea component. The default value is "" (an empty string). Example The following example places a string in the text property of the my_ta TextArea instance, and then traces that string to the Output panel. You must first add an instance of the TextArea component to the Stage and name it my_ta; then add the following code to Frame 1.
-
TextArea.vPosition Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage textAreaInstance.vPosition Description Property; defines the vertical scroll position of text in a text area. This property is useful for directing users to a specific paragraph in a long passage, or creating scrolling text areas. You can get and set this property. The default value is 0.
-
TextArea.vScrollPolicy Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage textAreaInstance.vScrollPolicy Description Property; determines whether the vertical scroll bar is always present ("on"), is never present ("off"), or appears automatically according to the size of the field ("auto"). The default value is "auto".
-
TextArea.wordWrap Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage textAreaInstance.wordWrap Description Property; a Boolean value that indicates whether the text wraps (true) or not (false). The default value is true. N OT E If you create a TextArea instance using the createClassObject() method, the default for wordWrap is false.
-
1208 TextArea component
-
46 CHAPTER 46 TextInput component The TextInput component is a single-line text component that is a wrapper for the native ActionScript TextField object. You can use styles to customize the TextInput component; when an instance is disabled, its contents appear in a color represented by the disabledColor style. A TextInput component can also be formatted with HTML, or as a password field that disguises the text. A TextInput component can be enabled or disabled in an application.
-
Using the TextInput component You can use a TextInput component wherever you need a single-line text field. If you need a multiline text field, use the TextArea component. For example, you could use a TextInput component as a password field in a form. You could also set up a listener that checks if the field has enough characters when a user tabs out of the field. That listener could display an error message indicating that the proper number of characters must be entered.
-
Creating an application with the TextInput component The following procedure explains how to add a TextInput component to an application while authoring. In this example, the component is a password field with an event listener that determines if the proper number of characters has been entered. To create an application with the TextInput component: 1. Drag a TextInput component from the Components panel to the Stage. 2. In the Property inspector, do the following: 3. ■ Enter the instance name my_ti.
-
Customizing the TextInput component You can transform a TextInput component horizontally 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 UIObject.setSize() or any applicable properties and methods of the TextInput class. When a TextInput component is resized, the border is resized to the new bounding box.
-
Style Theme Description embedFonts Both A Boolean value that indicates whether the font specified in fontFamily is an embedded font. This style must be set to true if fontFamily refers to an embedded font. Otherwise, the embedded font is not used. If this style is set to true and fontFamily does not refer to an embedded font, no text is displayed. The default value is false. fontFamily Both The font name for text. The default value is "_sans". fontSize Both The point size for the font.
-
Using skins with the TextInput component The TextArea component uses an instance of RectBorder for its border. For more information about skinning these visual elements, see “RectBorder class” on page 1063. TextInput class Inheritance MovieClip > UIObject class > UIComponent class > TextInput ActionScript Class Name mx.controls.TextInput The properties of the TextInput class let you set the text content, formatting, and horizontal position at runtime.
-
Method summary for the TextInput class There are no methods exclusive to the TextInput class. Methods inherited from the UIObject class The following table lists the methods the TextInput class inherits from the UIObject class. When calling these methods from the TextInput object, use the form TextInputInstance.methodName. Method Description UIObject.createClassObject() Creates an object on the specified class. UIObject.createObject() Creates a subobject on an object. UIObject.
-
Property summary for the TextInput class The following table lists properties of the TextInput class. Property Description TextInput.editable A Boolean value indicating whether the field is editable (true) or not (false). TextInput.hPosition The horizontal scrolling position of the text in the field. TextInput.length Read-only; the number of characters in a TextInput component. TextInput.maxChars The maximum number of characters that a user can enter in the text field. TextInput.
-
Properties inherited from the UIObject class The following table lists the properties the TextInput class inherits from the UIObject class. When accessing these properties from the TextInput object, use the form TextInputInstance.propertyName. Property Description UIObject.bottom Read-only; the position of the bottom edge of the object, relative to the bottom edge of its parent. UIObject.height Read-only; the height of the object, in pixels. UIObject.
-
Event summary for the TextInput class The following table lists events of the TextInput class. Event Description TextInput.change Broadcast when the TextInput field changes. TextInput.enter Broadcast when the Enter key is pressed. Events inherited from the UIObject class The following table lists the events the TextInput class inherits from the UIObject class. Event Description UIObject.draw Broadcast when an object is about to draw its graphics. UIObject.
-
TextInput.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) { //... }; textInputInstance.addEventListener("change", listenerObject) Usage 2: on (change){ //... } Description Event; notifies listeners that text has changed. This event is broadcast after the text has changed.
-
The second usage example uses a dispatcher/listener event model. A component instance (textInputInstance) dispatches an event (in this case, change) and the event is handled by a function, also called a handler, on a listener object (listenerObject) that you create. You define a method with the same name as the event on the listener object; the method is called when the event is triggered. When the event is triggered, it automatically passes an event object (eventObject) to the listener object method.
-
TextInput.editable Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage textInputInstance.editable Description Property; a Boolean value that indicates whether the component is editable (true) or not (false). The default value is true. Example This example sets the editable property to a value of false for the my_ti TextInput instance. This prevents the user from entering text in the instance. You can set the property to true to make the make the TextInput instance editable.
-
TextInput.enter Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage Usage 1: var listenerObject:Object = new Object(); listenerObject.enter = function(eventObject:Object) { //... }; textInputInstance.addEventListener("enter", listenerObject); Usage 2: on (enter) { //... } Description Event; notifies listeners that the Enter key has been pressed. The first usage example uses an on() handler and must be attached directly to a TextInput instance.
-
For more information, see “EventDispatcher class” on page 499. Example This example creates a listener for an enter event on a TextInput instance called my_ti. When the enter event occurs, if the user entered fewer than eight characters, the example displays: You must enter at least 8 characters. Otherwise, it displays Thanks! You must first drag a TextInput component to the Stage and give it an instance name of my_ti; then add the following code to Frame 1.
-
TextInput.hPosition Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage textInputInstance.hPosition Description Property; specifies how many pixels have been scrolled to accommodate the user’s entry in the TextInput box. The default value is 0. N OT E The value changes for the same text on different computers because of monitor, screen size, and font characteristics. Example The following example creates a listener for a change event on the TextInput instance called my_ti.
-
TextInput.length Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage textInputInstance.length Description Read-only property; a number that indicates the number of characters in a TextInput component. A character such as tab ("\t") counts as one character. The default value is 0. Example The following example creates a listener for the change event on the TextInput instance my_ti.
-
TextInput.maxChars Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage textInputInstance.maxChars Description Property; the maximum number of characters that the text field can contain. A script may insert more text than the maxChars property allows; this property indicates only how much text a user can enter. If this property is null, there is no limit to the amount of text a user can enter. The default value is null.
-
TextInput.maxHPosition Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage textInputInstance.maxHPosition Description Read-only property; the value of maxHPosition is the pixel position of the character that is visible when the pointer has been moved to the very right of the text. It’s not the last character’s pixel position. Rather, it’s the pixel position all the way to the right of the last character in the TextInput field. The default value is 0.
-
TextInput.password Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage textInputInstance.password Description Property; a Boolean value indicating whether the text field is a password field (true) or not (false). If this property is true, the text field is a password text field and hides the input characters. If this property is false, the text field is not a password text field. The default value is false.
-
TextInput.restrict Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage textInputInstance.restrict Description Property; indicates the set of characters that a user can enter in the text field. The default value is undefined. If this property is null or an empty string (""), a user can enter any character. If this property is a string of characters, the user can enter only characters in the string; the string is scanned from left to right. You can specify a range by using a dash (-).
-
Because you must enter this expression within double quotation marks, you must not only provide the expression for the restrict interpreter, but you must also escape the Actions panel’s built-in interpreter for double quotation marks. To send the value 0-9\-\^\\ to the restrict interpreter, you must enter the following code: myText.restrict = "0-9\\-\\^\\\\"; The restrict property restricts only user interaction; a script may put any text into the text field.
-
TextInput.text Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage textInputInstance.text Description Property; the text contents of a TextInput component. The default value is "" (an empty string). Example The following code places a string in the TextInput instance called my_ti, and then traces that string to the Output panel. You must first drag a TextInput component to the Stage and give it an instance name of my_ti; then add the following code to Frame 1.
-
1232 TextInput component
-
47 CHAPTER 47 TransferObject interface ActionScript Class Name mx.data.to.TransferObject The TransferObject interface defines a set of methods that items managed by the DataSet component must implement. The DataSet.itemClassName property specifies the name of the transfer object class that is instantiated each time a new item is needed. You can also specify this property for a selected DataSet component using the Property inspector.
-
TransferObject.clone() Availability Flash Player 7. Edition Flash MX Professional 2004. Usage class itemClass implements mx.data.to.TransferObject { function clone() { // Your code here. } } Parameters None. Returns A copy of the transfer object. Description Method; creates an instance of the transfer object. The implementation of this method creates a copy of the existing transfer object and its properties and then returns that object.
-
TransferObject.getPropertyData() Availability Flash Player 7. Edition Flash MX Professional 2004. Usage class itemClass implements mx.data.to.TransferObject { function getPropertyData() { // Your code here. } } Parameters None. Returns An object. Description Method; returns the data for this transfer object. The implementation of this method can return an anonymous ActionScript object with properties and corresponding values.
-
TransferObject.setPropertyData() Availability Flash Player 7. Edition Flash MX 2004. Usage class yourClass implements TransferObject { function setPropertyData(propData) { // Your code here. } } Parameters propData An object that contains the data assigned to this transfer object. Returns Nothing. Description Method; sets the data for this transfer object. The propData parameter is an object whose fields contain the data assigned by the DataSet component to this transfer object.
-
48 CHAPTER 48 TransitionManager class ActionScript Class Name mx.transitions.TransitionManager The TransitionManager class and the effect-defining transition-based classes allow you to quickly apply impressive transition animation effects to slides and movie clips. As its name implies, the TransitionManager class manages transitions. It allows you to apply one of ten animation effects to slides and movie clips.
-
You can also create a new instance of the TransitionManager class by using the new operator. You then designate the transition properties and start the transition effect in a second step by calling the TransitionManager.startTransition() method. The following code uses the TransitionManager.startTransition() method: var myTransitionManager:mx.transitions.TransitionManager = new mx.transitions.TransitionManager(myMovieClip_mc); myTransitionManager.startTransition({type:mx.transitions.
-
TransitionManager class summary The following sections list the methods, properties, and events for the TransitionManager class. Method summary for the TransitionManager class The following table lists the methods of the TransitionManager class. Method Description TransitionManager.start() Creates a new TransitionManager instance, designates the target object, applies a transition, and starts the transition. TransitionManager.startTransition() Creates a transition instance and starts it.
-
TransitionManager.allTransitionsInDone Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage var listenerObject:Object = new Object(); listenerObject.allTransitionsInDone = function(eventObj:Object) { // ... }; transitionManagerInstance.addEventListener("allTransitionsInDone", listenerObject); Description Event; notifies listeners that the TransitionManager instance has completed all transitions that have a direction property of mx.transitions.Transition.
-
Example The following code assigns an object to listen for the allTransitionsInDone event and specifies the method to act as the handler for the event. When that method is called to handle the event, a transition with a direction property of mx.transitions.Transition.IN has already been completed. import mx.transitions.*; import mx.transitions.easing.*; var myTransitionManager:TransitionManager = new TransitionManager(img1_mc); myTransitionManager.startTransition({type:Iris, direction:Transition.
-
The usage example uses a dispatcher or listener event model. A TransitionManager instance (transitionManagerInstance) dispatches an event (in this case, allTransitionsOutDone) and the event is handled by a function, also called a handler, on a listener object (listenerObject) that you create. You define a method with the same name as the event on the listener object; the method is called when the event is triggered.
-
TransitionManager.content Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage transitionManagerInstance.content Description Property; the movie clip instance to which TransitionManager is to apply a transition. Example The following example returns the movie clip object currently targeted by a TransitionManager instance: import mx.transitions.*; import mx.transitions.easing.
-
Description Property (read-only); an object that contains a snapshot of the properties of the target movie clip of a TransitionManager instance before the transition is applied. This object is helpful for obtaining information about what property values you can expect the movie clip to return to after the transition completes. The object returned from TransitionManager.
-
transParams A collection of parameters that are passed within an object. The transParams object should contain a type parameter that indicates the transition effect class to be applied, followed by direction, duration, and easing parameters. In addition, you must include any parameters required by that transition effect class. For example, the mx.transitions.Iris transition effect class requires additional startPoint and shape parameters.
-
Example The following code uses the TransitionManager.start() method to create an instance of TransitionManager and assigns an Iris transition to a movie clip called img1_mc. The TransitionManager.start() method contains two parameters. The first parameter, content, is the MovieClip object that the transition effect will be applied to. The second parameter for the TransitionManager.start() method, transParam, contains an object that holds a parameter collection.
-
The transParams object should contain a type parameter that indicates the transition effect class to apply, followed by direction, duration, and easing parameters. In addition, you must include any parameters required by the specified transition effect class. For example, the mx.transitions.Iris transition effect class requires additional startPoint and shape parameters.
-
Example The following code imports the TransitionManager class and creates a new TransitionManager instance. Next, the TransitionManager.startTransition() method designates a mx.transitions.Zoom transition in its type parameter. The direction parameter indicates that the transition should move in the out direction by designating mx.transitions.Transition.OUT. The duration of the transition is 3 seconds. The easing is calculated by using the mx.transitions.Bounce.easeOut() method of the Bounce class.
-
Transition-based classes Inheritance (Root class) ActionScript Class Name mx.transitions.Transition The Transition class is the base class for all transition classes. You do not use or access this class directly. It allows transition-based classes to share some common behaviors and properties that are accessed by an instance of the TransitionManager class. Transition-based classes define an effect that is applied over time to a movie clip or a slide.
-
Flash includes the following transitions: Transition Description Blinds transition Reveals the movie clip object by using appearing or disappearing rectangles. Fade transition Fades the movie clip object in or out. Fly transition Slides the movie clip object in from a specified direction. Iris transition Reveals or hides the movie clip object by using an animated mask of a square shape or a circle shape that zooms in or out.
-
Example The following code creates an instance of TransitionManager that applies the Blinds transition with ten numStrips and a dimension integer specified as vertical (0). The content target of the transition is the movie clip img1_mc. The TransitionManager instance applies a direction of mx.transitions.Transition.IN over a duration of 2 seconds with no easing. import mx.transitions.*; import mx.transitions.easing.*; TransitionManager.start(img1_mc, {type:Blinds, direction:Transition.
-
Description A transition effect: Slides the movie clip object in from a specified direction. This class is used by specifying mx.transitions.Fly as a transObject.type parameter for the TransitionManager class. Example The following code creates an instance of TransitionManager that applies the Fly transition with a startPoint set to the bottom right (9). The content target of the transition is the movie clip img1_mc. The TransitionManager instance applies a direction of mx.transitions.Transition.
-
Example The following code creates an instance of TransitionManager that applies the Iris transition with a startPoint from the center (5) and a masking shape of mx.transitions.Iris.CIRCLE. The content target of the transition is the movie clip img1_mc. The TransitionManager applies a direction of mx.transitions.Transition.IN over a duration of 2 seconds with an easing of Strong with an emphasis on the easeOut by specifying the mx.transitions.easing.Strong.easeOut easing calculation method. import mx.
-
Description A transition effect: Reveals the movie clip object by using randomly appearing or disappearing rectangles in a checkerboard pattern. This class is used by specifying mx.transitions.PixelDissolve as a transObject.type parameter for the TransitionManager class. Example The following code creates an instance of TransitionManager that applies the PixelDissolve transition with ten xSections and ten ySections. The content target of the transition is the movie clip img1_mc.
-
Example The following code creates an instance of TransitionManager that applies the Rotate transition clockwise 720 degrees (two full revolutions). The content target of the transition is the movie clip img1_mc. The TransitionManager instance applies a direction of mx.transitions.Transition.IN over a duration of 3 seconds with an easing set to Strong.easeInOut so that the transition starts slowly, speeds up, and then ends slowly. import mx.transitions.*; import mx.transitions.easing.*; TransitionManager.
-
Top Left, 1; Top Center, 2; Top Right, 3; Left Center, 4; Right Center, 6; Bottom Left, 7; Bottom Center, 8; Bottom Right, 9. Description A transition effect: Reveals or hides the movie clip object by using an animated mask of a shape that moves horizontally. This class is used by specifying mx.transitions.Wipe as a transObject.type parameter for the TransitionManager class.
-
CHAPTER 49 49 TreeDataProvider interface (Flash Professional only) The TreeDataProvider interface is a set of properties and methods and does not need to be instantiated to be used. If a Tree class is packaged in a SWF file, all XML instances in the SWF file contain the TreeDataProvider interface. All nodes in a tree are XML objects that contain the TreeDataProvider interface. It’s best to use the TreeDataProvider methods to create XML for the Tree.
-
Property summary for the TreeDataProvider interface The following table lists the properties of the TreeDataProvider interface. Property Description TreeDataProvider.attributes.data Specifies the data to associate with a node. TreeDataProvider.attributes.label Specifies the text to be displayed next to a node. TreeDataProvider.addTreeNode() Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage Usage 1: someNode.addTreeNode(label, data) Usage 2: someNode.
-
Example The first line of code in the following example locates the node to which to add a child. The second line adds a new node to a specified node. var myTreeNode = myTreeDP.firstChild.firstChild; myTreeNode.addTreeNode("Inbox", 3); The following code moves a node from one tree to the root of another tree: myTreeNode.addTreeNode(mySecondTree.getTreeNodeAt(3)); TreeDataProvider.addTreeNodeAt() Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage Usage 1: someNode.
-
Description Method; adds a child node at the specified location in the parent node. The node is constructed either from the information supplied in the label and data parameters (Usage 1), or from the prebuilt child node, which is an XMLNode object (Usage 2). Adding a preexisting node removes the node from its previous location. Calling this method refreshes the display of the tree.
-
TreeDataProvider.attributes.label Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage someNode.attributes.label Description Property; a string that specifies the text displayed for the node. This is written to an attribute of the XMLNode object. Setting this property does not refresh any tree displays. Example The following code locates the node to adjust and sets its label property. The result of the following code is . var myTreeNode = myTreeDP.
-
Description Method; returns the specified child node of the node. Example The following code locates a node and then retrieves the second child of myTreeNode: var myTreeNode = myTreeDP.firstChild.firstChild; myTreeNode.getTreeNodeAt(1); TreeDataProvider.removeTreeNode() Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage someNode.removeTreeNode() Parameters None. Returns The removed XML node, or undefined if an error occurs.
-
TreeDataProvider.removeTreeNodeAt() Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage someNode.removeTreeNodeAt(index) Parameters index An integer indicating the position of the node to be removed. Returns The removed XML node, or undefined if an error occurs. Description Method; removes a node (and all of its descendants) specified by the current node and index position of the child node. Calling this method refreshes the view.
-
1264 TreeDataProvider interface (Flash Professional only)
-
CHAPTER 50 50 Tree component (Flash Professional only) The Tree component allows a user to view hierarchical data. The tree appears in a box like the List component, but each item in a tree is called a node and can be either a leaf or a branch. By default, a leaf is represented by a text label beside a file icon, and a branch is represented by a text label beside a folder icon with an expander arrow (disclosure triangle) that a user can open to display child nodes.
-
Using the Tree component (Flash Professional only) The Tree component can be used to represent hierarchical data such as e-mail client folders, file browser panes, or category browsing systems for inventory. Most often, the data for a tree is retrieved from a server in the form of XML, but it can also be well-formed XML that is created during authoring in Flash. The best way to create XML for the tree is to use the TreeDataProvider interface.
-
Nodes in the XML data source can have any name. Notice in the previous example that each node is named with the generic name node. The tree reads through the XML and builds the display hierarchy according to the nested relationship of the nodes. Each XML node can be displayed as one of two types in the tree: branch or leaf. Branch nodes can contain multiple child nodes and appear as a folder icon with an expander arrow that allows users to open and close the folder.
-
Flash Player wraps the XML nodes in an extra document node, which is passed to the tree. When the tree tries to display the XML, it tries to display , which doesn’t have a label, so it doesn’t display correctly. To avoid this problem, the data provider for the Tree component should point at the XMLDocumentObject’s first child, as shown here: myTree.dataProvider = myXML.
-
4. Select the Tree instance. In the Property inspector, enter the instance name menuTree. 5. Select the Tree instance and press F8. Select Movie Clip, and enter the name TreeNavMenu. 6. Click the Advanced button, and select Export for ActionScript. 7. Type TreeNavMenu in the AS 2.0 Class text box and click OK. 8. Select File > New and select ActionScript File. 9. Save the file as TreeNavMenu.as in the same directory as treeMenu.fla. 10.
-
This ActionScript sets up styles for the tree. An XML object is created to load the XML file that creates the tree’s nodes. Then the onLoad event handler is defined to set the data provider to the contents of the XML file. 11. Create a new file called TreeNavMenu.xml in a text editor. 12. Enter the following code in the file: PAGE 1275
6. Enter the following code in the file: 7. Select Control > Test Movie. In the SWF file, you can see the XML structure displayed in the tree.
-
This code creates an XML object called myTreeDP. Any XML object on the same frame as a Tree component automatically receives all the properties and methods of the TreeDataProvider interface. The second line of code creates a single root node called Local Folders. For detailed information about the rest of the code, see the comments (lines preceded with //) throughout the code. 5. Select Control > Test Movie. In the SWF file, you can see the XML structure displayed in the tree.
-
5. Select Control > Test Movie. In the SWF file, you can see the XML structure displayed in the tree. Click items in the tree to see the trace() statements in the change event handler send the data values to the Output panel. To use a well-formed string to create XML in Flash while authoring: 1. In Flash, select File > New and select Flash Document. 2. Drag an instance of the Tree component onto the Stage. 3. Select the Tree instance. In the Property inspector, enter the instance name myTree. 4.
-
Using styles with the Tree component A Tree component uses the following styles: Style Theme Description themeColor Halo The base color scheme of a component. Possible values are "haloGreen", "haloBlue", and "haloOrange". The default value is "haloGreen". backgroundColor Both The background color of the list. The default color is white and is defined on the class style declaration. This style is ignored if alternatingRowColors is specified.
-
Style Theme Description fontStyle Both The font style: either "normal" or "italic". The default value is "normal". fontWeight Both The font weight: either "none" or "bold". The default value is "none". All components can also accept the value "normal" in place of "none" during a setStyle() call, but subsequent calls to getStyle() return "none". textAlign Both The text alignment: either "left", "right", or "center". The default value is "left".
-
Style Theme Description openEasing Both A reference to a tweening function that controls the expand and collapse animations. Defaults to sine in/ out. For more information, see “Customizing component animations” in Using Components. repeatDelay Both The number of milliseconds of delay between when a user first presses a button in the scrollbar and when the action begins to repeat. The default value is 500 (half a second).
-
Style Theme Description selectionEasing Both A reference to the easing equation used to control the transition between selection states. Applies only for the transition from a normal to a selected state. The default equation uses a sine in/out formula. For more information, see “Customizing component animations” in Using Components. textRollOverColor Both The color of text when the pointer rolls over it. The default value is 0x2B333C (dark gray).
-
Setting styles for all Tree components in a document The Tree 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 the new settings are reflected in all affected components. _global.styles.ScrollSelectList.
-
Method summary for the Tree class The following table lists methods of the Tree class. Method Description Tree.addTreeNode() Adds a node to a Tree instance. Tree.addTreeNodeAt() Adds a node at a specific location in a Tree instance. Tree.getDisplayIndex() Returns the display index of a given node. Tree.getIsBranch() Specifies whether the folder is a branch (has a folder icon and an expander arrow). Tree.getIsOpen() Indicates whether a node is open or closed. Tree.
-
Method Description UIObject.invalidate() Marks the object so it is redrawn on the next frame interval. UIObject.move() Moves the object to the requested position. UIObject.redraw() Forces validation of the object so it is drawn in the current frame. UIObject.setSize() Resizes the object to the requested size. UIObject.setSkin() Sets a skin in the object. UIObject.setStyle() Sets the style property on the style declaration or object.
-
Property summary for the Tree class The following table lists properties of the Tree class. Property Description Tree.dataProvider Specifies an XML data source. Tree.firstVisibleNode Specifies the first node at the top of the display. Tree.selectedNode Specifies the selected node in a Tree instance. Tree.selectedNodes Specifies the selected nodes in a Tree instance.
-
Properties inherited from the UIComponent class The following table lists the properties the Tree class inherits from the UIComponent class. When accessing these properties from the Tree object, use the form TreeInstance.propertyName. Property Description UIComponent.enabled Indicates whether the component can receive focus and input. UIComponent.tabIndex A number indicating the tab order for a component in a document.
-
Property Description List.selectedIndex The index of a selection in a single-selection list. List.selectedIndices An array of the selected items in a multiple-selection list. List.selectedItem The selected item in a single-selection list. This property is read-only. List.selectedItems The selected item objects in a multiple-selection list. This property is read-only. List.vPosition Scrolls the list so the topmost visible item is the number assigned. List.
-
Events inherited from the UIComponent class The following table lists the events the Tree class inherits from the UIComponent class. Event Description UIComponent.focusIn Broadcast when an object receives focus. UIComponent.focusOut Broadcast when an object loses focus. UIComponent.keyDown Broadcast when a key is pressed. UIComponent.keyUp Broadcast when a key is released. Events inherited from the List class The following table lists the events the Tree class inherits from the List class.
-
Tree.addTreeNode() Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage Usage 1: treeInstance.addTreeNode(label [, data]) Usage 2: treeInstance.addTreeNode(child) Parameters A string that displays the node, or an object with a label field (or whatever label field name is specified by the labelField property). label An object of any type that is associated with the node. This parameter is optional. data child Any XMLNode object. Returns The added XML node.
-
/** Requires: - Tree component in library */ import mx.controls.Tree; this.createClassObject(Tree, "first_tr", 10); first_tr.setSize(200, 100); this.createClassObject(Tree, "second_tr", 20); second_tr.setSize(200, 100); second_tr.move(0, 120); var trDP_xml:XML = new XML(""); first_tr.
-
Parameters index The zero-based index position (among the child nodes) at which the node should be added. label A string that contains the name of the node to add. An object of any type that is associated with the node. This parameter is optional. data child Any XMLNode object. Returns The added XML node. Description Method; adds a node at the specified location in the tree.
-
/** Requires: - Tree component in library */ import mx.controls.Tree; this.createClassObject(Tree, "first_tr", 10); first_tr.setSize(200, 100); this.createClassObject(Tree, "second_tr", 20); second_tr.setSize(200, 100); second_tr.move(0, 120); var trDP_xml:XML = new XML(""); first_tr.
-
You can either load XML from an external source at runtime or create it in Flash while authoring. To create XML, you can use either the TreeDataProvider methods, or the built-in ActionScript XML class methods and properties. You can also create a string that contains XML. XML objects that are on the same frame as a Tree component automatically contain the TreeDataProvider methods and properties. You can use the ActionScript XML or XMLNode object.
-
Tree.firstVisibleNode Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage treeInstance.firstVisibleNode = someNode Description Property; indicates the first node that is visible at the top of the tree display. Use this property to scroll the tree display to a desired position. If the specified node someNode is within a node that hasn’t been expanded, setting firstVisibleNode has no effect. The default value is the first visible node or undefined if there is no visible node.
-
You must first add an instance of the Tree component to the Stage and name it my_tr; then add the following code to Frame 1. /** Requires: - Tree component on Stage (instance name: my_tr) */ var my_tr:mx.controls.Tree; my_tr.
-
Description Method; returns the display index of the node specified in the node parameter. The display index indicates the item’s position in the list of items that are visible in the tree window. For example, any children of a closed node are not in the display index. The list of display indices starts with 0 and proceeds through the visible items regardless of parent. In other words, the index is the row number, starting with 0, of the displayed rows.
-
Tree.getIsBranch() Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage treeInstance.getIsBranch(node) Parameters node An XMLNode object. Returns A Boolean value that indicates whether the node is a branch (true) or not (false). Description Method; indicates whether the specified node has a folder icon and expander arrow (and is therefore a branch). This is set automatically when children are added to the node. You only need to call Tree.
-
See also Tree.setIsBranch() Tree.getIsOpen() Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage treeInstance.getIsOpen(node) Parameters node An XMLNode object. Returns A Boolean value that indicates whether the tree is open (true) or closed (false). Description Method; indicates whether the specified node is open or closed. NO T E Display indices change every time nodes open and close.
-
var trDP_xml:XML = new XML(""); my_tr.dataProvider = trDP_xml; my_tr.setIsOpen(my_tr.getTreeNodeAt(1), true); var isOpen:Boolean = my_tr.getIsOpen(my_tr.getTreeNodeAt(1)); trace("2nd node is a open: " + isOpen); Tree.getNodeDisplayedAt() Availability Flash Player 6 (6.0.79.0).
-
Example The following example adds a node to a Tree instance called my_tr and then calls the getNodeDisplayedAt() method to retrieve the node at display position 0 (zero). The example calls the trace() function to display the node. You must first add an instance of the Tree component to the Stage and name it my_tr; then add the following code to Frame 1. /** Requires: - Tree component on Stage (instance name: my_tr) */ var my_tr:mx.controls.Tree; my_tr.
-
Example The following example adds a node to the Tree instance my_tr, and then calls the getTreeNodeAt() method to return the first node in the tree. You must first add an instance of the Tree component to the Stage and name it my_tr; then add the following code to Frame 1. /** Requires: - Tree component on Stage (instance name: my_tr) */ var my_tr:mx.controls.Tree; my_tr.
-
When the event is triggered, it automatically passes an event object (eventObject) to the handler. Each event object has properties that contain information about the event. You can use these properties to write code that handles the event. The Tree.nodeClose event’s event object has one additional property: node (the XML node that closed). For more information, see “EventDispatcher class” on page 499.
-
Tree.nodeOpen Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage var listenerObject:Object = new Object(); listenerObject.nodeOpen = function(eventObject:Object) { // Insert your code here. }; treeInstance.addEventListener("nodeOpen", listenerObject); Description Event; broadcast to all registered listeners when a user opens a node on a Tree component. Version 2 components use a dispatcher/listener event model.
-
You must first add an instance of the Tree component to the Stage and name it my_tr; then add the following code to Frame 1. /** Requires: - Tree component on Stage (instance name: my_tr) */ var my_tr:mx.controls.Tree; my_tr.setSize(200, 100); var trDP_xml:XML = new XML(""); my_tr.
-
Returns Nothing. Description Method; updates the tree. Example The following example adds a node to a Tree instance called my_tr and creates listeners for a Refresh button and a Remove All button. Assuming the XML source for the data provider has changed, the user can click the Refresh button, and the code calls the refresh() method to update the tree contents. You must first add an instance of the Tree component to the Stage and name it my_tr. Then add a button called refresh_button.
-
Tree.removeAll() Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage treeInstance.removeAll() Parameters None. Returns Nothing. Description Method; removes all nodes and refreshes the tree. Example The following example adds a node to a Tree instance called my_tr and creates a listener for a Remove All button. When the user clicks the Remove All button, the code calls the removeAll() method to remove all nodes from the tree.
-
var trDP_xml:XML = new XML(); trDP_xml.ignoreWhite = true; trDP_xml.onLoad = function() { my_tr.dataProvider = this.firstChild; }; trDP_xml.load("http://www.flash-mx.com/mm/xml/tree.xml"); function removeAllListener(evt_obj:Object):Void { my_tr.removeAll(); } removeAll_button.addEventListener("click", removeAllListener); Tree.removeTreeNodeAt() Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage treeInstance.
-
You first add an instance of the Tree component to the Stage and name it my_tr and then add the following code to Frame 1. /** Requires: - Tree component on Stage (instance name: my_tr) */ var my_tr:mx.controls.Tree; my_tr.setSize(200, 100); var trDP_xml:XML = new XML(""); my_tr.
-
You must first add an instance of the Tree component to the Stage and name it my_tr; then add the following code to Frame 1: /** Requires: - Tree component on Stage (instance name: my_tr) */ var my_tr:mx.controls.Tree; my_tr.setSize(200, 100); var trDP_xml:XML = new XML(""); my_tr.
-
You must first add an instance of the Tree component to the Stage and name it my_tr; then add the following code to Frame 1: /** Requires: - Tree component on Stage (instance name: my_tr) */ var my_tr:mx.controls.Tree; my_tr.
-
linkID2 For a branch node, the linkage identifier of a symbol to be used as an icon that represents the open state of the node. This parameter is optional. Returns Nothing. Description Method; specifies an icon for the specified node. This method takes one ID parameter (linkID) for leaf nodes and two ID parameters (linkID and linkID2) for branch nodes (the closed and open icons). For leaf nodes, the second parameter is ignored.
-
Tree.setIsBranch() Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage treeInstance.setIsBranch(node, isBranch) Parameters node An XML node. isBranch A Boolean value indicating whether the node is (true) or is not (false) a branch. Returns Nothing. Description Method; specifies whether the node has a folder icon and expander arrow and either has children or can have children.
-
You must first add an instance of the Tree component to the Stage and name it my_tr; then add the following code to Frame 1. /** Requires: - Tree component on Stage (instance name: my_tr) */ var my_tr:mx.controls.Tree; my_tr.setSize(200, 100); var trDP_xml:XML = new XML(""); my_tr.dataProvider = trDP_xml; // Set 1st node to be branch. my_tr.setIsBranch(my_tr.getTreeNodeAt(0), true); Tree.setIsOpen() Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004.
-
Description Method; opens or closes a node. Example The following example creates two nodes in a Tree instance called my_tr and calls the setIsOpen() method to open the second node. /** Requires: - Tree component on Stage (instance name: my_tr) */ var my_tr:mx.controls.Tree; my_tr.
-
51 CHAPTER 51 Tween class Inheritance (Root class) ActionScript Class Name mx.transitions.Tween The Tween class lets you use ActionScript to move, resize, and fade movie clips easily on the Stage by specifying a property of the target movie clip to be tween animated over a number of frames or seconds. The Tween class also lets you specify a variety of easing methods. Easing refers to gradual acceleration or deceleration during an animation, which helps your animations appear more realistic.
-
Method Description Tween.resume() Resumes a tweened animation from its stopped point in the animation. Tween.rewind() Rewinds a tweened animation to the beginning of the tweened animation. Tween.start() Starts the tweened animation from the beginning. Tween.stop() Stops the tweened animation at its current position. Tween.toString() Returns the class name, “[Tween]”. Tween.yoyo() Instructs the tweened animation to play in reverse from its last direction of tweened property increments.
-
Event Description Tween.onMotionResumed Event handler; invoked when the Tween.resume() method is called, causing the tweened animation to resume. Tween.onMotionStarted Event handler; invoked when the Tween.start() method is called, causing the tweened animation to start. Tween.onMotionStopped Event handler; invoked when the Tween.stop() method is called, causing the tweened animation to stop.
-
duration A number indicating the length of time of the tween motion. If omitted, the duration is set to infinity by default. useSeconds A Boolean value indicating to use seconds if true or frames if false in relation to the value specified in the duration parameter. About easing classes and methods When you create an instance of the Tween class, you use the func parameter to specify a function or method that provides an easing calculation.
-
These six easing calculation classes each have three easing methods, which indicate at what part of the animation to apply the easing effect. In addition, the None easing class has a fourth easing method: easeNone. The easing methods are described in the following table: Method Description easeIn Provides the easing effect at the beginning of the transition. easeOut Provides the easing effect at the end of the transition.
-
5. Add the following ActionScript to Frame 1 of the actions layer: import mx.core.View; import mx.transitions.easing.*; my_acc.createChild(View, "studio_view", {label:"Studio"}); my_acc.createChild(View, "dreamweaver_view", {label:"Dreamweaver"}); my_acc.createChild(View, "flash_view", {label:"Flash"}); my_acc.createChild(View, "coldfusion_view", {label:"ColdFusion"}); my_acc.createChild(View, "contribute_view", {label:"Contribute"}); my_acc.setStyle("openEasing", Bounce.easeOut); my_acc.
-
3. Insert a new layer and rename it actions. Make sure the actions layer is above Layer 1. 4. Add the following ActionScript to Frame 1 of the actions layer: import mx.transitions.easing.*; this.createClassObject(mx.controls.ComboBox, "my_cb", 20); var product_array:Array = new Array("Studio", "Dreamweaver", "Flash", "ColdFusion", "Contribute", "Breeze", "Director", "Flex"); my_cb.dataProvider = product_array; my_cb.move(10, 10); my_cb.setSize(140, 22); my_cb.setStyle("openDuration", 2000); my_cb.
-
To add easing to the DataGrid component: 1. Create a new Flash document and save it as datagrid.fla. 2. Drag an instance of the DataGrid component onto the Stage, and give it the name my_dg. 3. Insert a new layer and rename it actions. Make sure you place the actions layer above Layer 1. 4. Add the following ActionScript to the actions layer: import mx.transitions.easing.*; my_dg.setSize(320, 240); my_dg.addColumn("product"); my_dg.getColumnAt(0).width = 304; my_dg.rowHeight = 60; my_dg.
-
Tween.continueTo() Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage tweenInstance.continueTo(finish, duration) Parameters A number indicating the ending value of the target object property that is to be tweened. finish duration A number indicating the length of time or number of frames for the tween motion; duration is measured in length of time if the Tween.start() useSeconds parameter is set to true, or measured in frames if it is set to false.
-
Tween.duration Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage tweenInstance.duration Description Property (read-only); a number indicating the duration of the tweened animation in frames or seconds. This property is set as a parameter when creating a new Tween instance or when calling the Tween.yoyo() method. Example The following example traces the current duration setting of a Tween object by getting the Tween.duration property.
-
Description Method; forwards the tweened animation directly to the final value of the tweened animation. Example In this example, Tween.fforward() is called to forward a tweened animation directly to its final value, immediately triggering the onMotionFinished event. A handler for the Tween.onMotionFinished event calls the Tween.yoyo() method. The tweened animation therefore visibly starts with the reversing effect of the Tween.yoyo() method, since the initial animation was skipped to its end.
-
Example The following example returns the current finish setting of a Tween instance. A movie clip instance named img1_mc is required on the Stage for this example: import mx.transitions.Tween; var myTween:Tween = new Tween(img1_mc, "_y", mx.transitions.easing.Strong.easeOut,0, Stage.height - img1_mc._height, 50, false); var myFinish:Number = myTween.finish; trace(myFinish); Tween.FPS Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage tweenInstance.
-
Example The following example creates two tweened animations set at two different FPS settings. The current FPS settings of both Tween instances are displayed. A movie clip instance named img1_mc, and a movie clip instance named img2_mc are required on the Stage for this example: import mx.transitions.Tween; var myTween1:Tween = new Tween(img1_mc, "_y", mx.transitions.easing.Strong.easeOut,0, Stage.height - img1_mc._height, 400, false); myTween1.FPS = 1; var myFPS1:Number = myTween1.FPS; trace("myTween1.
-
Example This example applies a tweened animation to the img1_mc movie clip. The animation is looped to play repeatedly from its starting point by calling the Tween.start() method from within a handler triggered by the Tween.onMotionFinished event. Clicking a button called forwardByFrame_btn calls the Tween.stop() method to stop the animation, followed by calling the Tween.nextFrame() method.
-
Description Event handler; invoked with each change in the tweened object property that is being animated. Handling this event allows your code to react as the target movie clip’s property that is being tweened increments to the next value. Example In this example, a tween is applied to the img1_mc movie clip. With each increment of the tween to the _x property of the movie clip, the onMotionChanged event handler is invoked and displays a trace message indicating the tweened movie clip’s new position.
-
Example In the following example, a tween is applied to the img1_mc movie clip. When the tween reaches the end of its animation, it invokes the onMotionFinished event handler which calls the Tween.yoyo()method. The tween is therefore able to complete its animation before the Tween.yoyo() method is called to reverse the animation. A movie clip instance named img1_mc is required on the Stage for this example: import mx.transitions.Tween; var myTween:Tween = new Tween(img1_mc, "_x", mx.transitions.easing.
-
Example The following example applies a tweened animation to the img1_mc movie clip. The animation is looped to play repeatedly from its starting point by calling the Tween.start() method from within an onMotionFinished event handler. Clicking a button called stopTween_btn calls the Tween.stop() method to stop the tweened animation at its current value. Clicking a button called resumeTween_btn calls the Tween.resume() method to resume the tweened animation from its stopping point. When the Tween.
-
Description Event handler; invoked when the animation starts again during or after completing its animation. This event handler is not invoked at the initial start of a tweened animation. Calling the Tween.start(), Tween.yoyo() or Tween.yoyo()method to restart a finished animation or restart during an animation invokes the onMotionStarted event handler. Handling this event allows your code to react at the point at which the tweened animation was started again sometime after its initial start.
-
Description Event handler; invoked when the tweened animation completes to the end of its animation or when the Tween.stop() method is called. Handling this event allows your code to react at the point at which the tweened animation was stopped. Example The following example applies a tweened animation to the img1_mc movie clip. When the Tween instance finishes its animation, the Tween instance invokes the Tween.onMotionStopped event handler.
-
Example The following example traces a Tween object’s current Tween.position and the Tween.position value that the tween position ends with at the last frame of the tweened animation. A movie clip instance named img1_mc is required on the Stage for this example: import mx.transitions.Tween; var myTween:Tween = new mx.transitions.Tween(img1_mc, "_x", mx.transitions.easing.None.easeNone, 0, Stage.width-img1_mc._width, 3, true); myTween.onMotionChanged = function() { var myPosition:Number = myTween.
-
Example This example applies a tweened animation to the img1_mc movie clip. The animation is looped to play repeatedly from its starting point by calling the Tween.start() method from within a handler triggered by the onMotionFinished event. Clicking a button called forwardByFrame_btn calls the Tween.stop() method to stop the animation, followed by calling the Tween.prevFrame() method. Clicking the button during the tweened animation stops the animation and then reverses it by only a single frame.
-
Returns Nothing. Description Method; resumes the play of a tweened animation that has been stopped. Use this method to continue a tweened animation after you have stopped it by using the Tween.stop() method. N OT E This method may be used only on frame-based tweens. A tween is set to be frame based at its creation by setting the useSeconds parameter to false. Example This example applies a tweened animation to the img1_mc movie clip.
-
Tween.rewind() Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage tweenInstance.rewind() Parameters None. Returns Nothing. Description Method; moves the play of a tweened animation back to its starting value. If Tween.rewind() is called while the tweened animation is still playing, the animation rewinds to its starting value and continues playing. If Tween.
-
Example The following example applies a tweened animation to the img1_mc movie clip. The animation is looped to play repeatedly from its starting point by calling the Tween.start() method from within a handler triggered by the Tween.onMotionFinished event. Clicking the rewindTween_btn button calls the Tween.rewind() method to rewind the tweened animation to its starting point.
-
Description Method; starts the play of a tweened animation from its starting point. This method is used for re-starting a Tween from the beginning of its animation after it stops or has completed its animation. Example This example creates a new Tween object that animates the _x property of the img1_mc movie clip. After the tweened animation is complete and calls the Tween.onMotionFinished event handler, the tween is played again by calling the Tween.start() method.
-
Example The following example applies a tweened animation to the _x property of the img1_mc movie clip. A stopTween_btn movie clip’s onRelease() handler calls the Tween.stop() method to stop the tweened animation and a resumeTween_btn movie clip’s onRelease() handler calls the Tween.resume() method to resume the animation from a stopped position.
-
Example The following example returns the time value of a Tween instance. A movie clip instance named img1_mc, is required on the Stage for this example: import mx.transitions.Tween; var myTween:Tween = new mx.transitions.Tween(img1_mc, "_x", mx.transitions.easing.None.easeNone, 0, Stage.width-img1_mc._width, 10, false); myTween.onMotionChanged = function() { var myCurrentTime:Number = myTween.time; var myCurrentDuration:Number = myTween.
-
Tween.yoyo() Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage tweenInstance.yoyo() Returns Nothing. Description Method; instructs the tweened animation to play in reverse from its last direction of tweened property increments. If this method is called before a Tween object’s animation is complete, the animation abruptly jumps to the end of its play and then plays in a reverse direction from that point.
-
52 CHAPTER 52 UIComponent class The UIComponent class does not represent a visual component; it contains methods, properties, and events that allow Macromedia components to share some common behavior. All version 2 Macromedia Component Architecture components extend UIComponent.
-
Method summary for the UIComponent class The following table lists methods of the UIComponent class. Method Description UIComponent.getFocus() Returns a reference to the object that has focus. UIComponent.setFocus() Sets focus to the component instance. Methods inherited from the UIObject class The following table lists the methods the UIComponent class inherits from the UIObject class. When calling these methods from the UIComponent object, use the form UIComponentInstance.methodName.
-
Property summary for the UIComponent class The following table lists properties of the UIComponent class. Property Description UIComponent.enabled Indicates whether the component can receive focus and input. UIComponent.tabIndex A number indicating the tab order for a component in a document. Properties inherited from the UIObject class The following table lists the properties the UIComponent class inherits from the UIObject class.
-
Event summary for the UIComponent class The following table lists events of the UIComponent class. Event Description UIComponent.focusIn Broadcast when an object receives focus. UIComponent.focusOut Broadcast when an object loses focus. UIComponent.keyDown Broadcast when a key is pressed. UIComponent.keyUp Broadcast when a key is released. Events inherited from the UIObject class The following table lists the events the UIComponent class inherits from the UIObject class.
-
UIComponent.enabled Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage componentInstance.enabled Description Property; indicates whether the component can (true) or cannot (false) accept focus and mouse input. The default value is true. Example The following example sets the enabled property of a CheckBox component to false: checkBoxInstance.enabled = false; UIComponent.focusIn Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004.
-
Description Event; notifies listeners that the object has received keyboard focus. The first usage example uses a dispatcher/listener event model. A component instance (componentInstance) dispatches an event (in this case, focusIn), and the event is handled by a function, also called a handler, on a listener object (listenerObject) that you create. You define a method with the same name as the event on the listener object; the method is called when the event is triggered.
-
UIComponent.focusOut Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage on(focusOut){ ... } listenerObject = new Object(); listenerObject.focusOut = function(eventObject){ ... } componentInstance.addEventListener("focusOut", listenerObject) Description Event; notifies listeners that the object has lost keyboard focus. The first usage example uses an on() handler and must be attached directly to a component instance. The second usage example uses a dispatcher/listener event model.
-
Example The following code disables a Button component, btn, while a user types the TextInput component, txt, and enables the button when the user clicks it: var txt:mx.controls.TextInput; var btn:mx.controls.Button; var txtListener:Object = new Object(); txtListener.focusOut = function() { _root.btn.enabled = true; } txt.addEventListener("focusOut", txtListener); var txtListener2:Object = new Object(); txtListener2.focusIn = function() { _root.btn.enabled = false; } txt.
-
Example The following code returns a reference to the object that has focus and assigns it to the tmp variable: var tmp = checkbox.getFocus(); UIComponent.keyDown Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage on(keyDown){ ... } listenerObject = new Object(); listenerObject.keyDown = function(eventObject){ ... } componentInstance.addEventListener("keyDown", listenerObject) Description Event; notifies listeners when a key is pressed.
-
Example The following code makes an icon blink when a key is pressed:v formListener.handleEvent = function(eventObj) { form.icon.visible = !form.icon.visible; } form.addEventListener("keyDown", formListener); UIComponent.keyUp Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage on(keyUp){ ... } listenerObject = new Object(); listenerObject.keyUp = function(eventObject){ ... } componentInstance.
-
Example The following code makes an icon blink when a key is released: formListener.handleEvent = function(eventObj) { form.icon.visible = !form.icon.visible; } form.addEventListener("keyUp", formListener); UIComponent.setFocus() Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage componentInstance.setFocus(); Parameters None. Returns Nothing. Description Method; sets the focus to this component instance. The instance with focus receives all keyboard input.
-
UIComponent.tabIndex Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage instance.tabIndex Description Property; a number indicating the tabbing order for a component in a document. Example The following code sets the value of tmp to the tabIndex property of the checkbox instance: var tmp = checkbox.
-
53 CHAPTER 53 UIEventDispatcher class ActionScript Class Name Inheritance mx.events.UIEventDispatcher EventDispatcher class > UIEventDispatcher The UIEventDispatcher class is mixed in to the UIComponent class and allows components to emit certain events. If you want an object that doesn’t inherit from UIComponent to dispatch certain events, you can use UIEventDispatcher. Method summary for the UIEventDispatcher class The following table lists the method of the UIEventDispatcher class.
-
Event summary for the UIEventDispatcher class The following table lists events of the UIEventDispatcher class. Method Description UIEventDispatcher.keyDown Broadcast when a key is pressed. UIEventDispatcher.keyUp Broadcast when a pressed key is released. UIEventDispatcher.load Broadcast when a component loads into Flash Player. UIEventDispatcher.mouseDown Broadcast when the mouse is pressed. UIEventDispatcher.mouseOut Broadcast when the mouse is moved off a component instance. UIEventDispatcher.
-
UIEventDispatcher.keyUp Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage listenerObject = new Object(); listenerObject.keyUp = function(eventObject){ // Insert your code here. } componentInstance.addEventListener("keyUp", listenerObject) Description Event; broadcast to all registered listeners when a key that was pressed is released and the Flash application has focus. When the event is triggered, it automatically passes an event object (eventObject) to the handler.
-
Description Event; broadcast to all registered listeners when a component is loaded into Flash Player. When the event is triggered, it automatically passes an event object (eventObject) to the handler. Each event object has properties that contain information about the event. You can use these properties to write code that handles the event. UIEventDispatcher.mouseDown Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage listenerObject = new Object(); listenerObject.
-
Usage listenerObject = new Object(); listenerObject.mouseOut = function(eventObject){ // Insert your code here. } componentInstance.addEventListener("mouseOut", listenerObject) Description Event; broadcast to all registered listeners when a Flash application has focus and the mouse is moved off a component instance. When the event is triggered, it automatically passes an event object (eventObject) to the handler. Each event object has properties that contain information about the event.
-
UIEventDispatcher.mouseUp Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage listenerObject = new Object(); listenerObject.mouseUp = function(eventObject){ // Insert your code here. } componentInstance.addEventListener("mouseUp", listenerObject) Description Event; broadcast to all registered listeners when a Flash application has focus and the mouse is pressed and released. When the event is triggered, it automatically passes an event object (eventObject) to the handler.
-
Description Method; unregisters a listener object from a component instance that is broadcasting an event. This method overrides the EventDispatcher.removeEventListener() event found in the EventDispatcher base class. UIEventDispatcher.unload Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage listenerObject = new Object(); listenerObject.unload = function(eventObject){ // Insert your code here. } componentInstance.
-
1358 UIEventDispatcher class
-
54 CHAPTER 54 UIObject class Inheritance MovieClip > UIObject ActionScript Class Name mx.core.UIObject UIObject is the base class for all version 2 of the Macromedia Component Architecture components; it is not a visual component. The UIObject class wraps the ActionScript MovieClip object and contains functions and properties that allow version 2 components to share some common behavior.
-
Method summary for the UIObject class The following table lists methods of the UIObject class. Method Description UIObject.createClassObject() Creates an object on the specified class. UIObject.createLabel() Creates a TextField subobject, for use when creating components. UIObject.createObject() Creates a subobject on an object. UIObject.destroyObject() Destroys a component instance. UIObject.doLater() Calls a function when parameters have been set in the Property and Component inspectors.
-
Property Description UIObject.top The position of the top edge of the object, relative to its parent. Read-only. UIObject.visible A Boolean value indicating whether the object is visible (true) or not (false). UIObject.width The width of the object, in pixels. Read-only. UIObject.x The left edge of the object, in pixels. Read-only. UIObject.y The top edge of the object, in pixels. Read-only. Event summary for the UIObject class The following table lists events of the UIObject class.
-
UIObject.bottom Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage componentInstance.bottom Description Property (read-only); a number indicating the bottom position of the object, in pixels, relative to its parent’s bottom. To set this property, call UIObject.move(). Example This example moves the check box so it aligns under the bottom edge of the list box: myCheckbox.move(myCheckbox.x, form.height - listbox.bottom); UIObject.createClassObject() Availability Flash Player 6 (6.0.
-
Description Method; creates an instance of a component at runtime. Use the import statement and specify the class package name before you call this method. In addition, the component must be in the FLA file’s library. Example The following code imports the assets of the Button component and then makes a subobject of the Button component: import mx.controls.Button; createClassObject(Button,"button2",5,{label:"Test Button"}); The following example creates a CheckBox object: import mx.controls.
-
Description Method; creates a TextField subobject. Used by most components to get a lightweight text object to display text in the component while inheriting sizing and style methods and properties of the component. This method is used to create new components. The TextField that is created is the same as a TextField object created using MovieClip.createTextField(), but has the added benefit of inheriting useful properties and methods from the parent UIObject. A TextField that uses UIObject.
-
UIObject.createObject() Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage componentInstance.createObject(linkageName, instanceName, depth, initObject) Parameters linkageName A string indicating the linkage identifier of a symbol in the library. A string indicating the instance name of the new instance. instanceName depth A number indicating the depth of the new instance. initObject An object containing initialization properties for the new instance.
-
Parameters instanceName A string indicating the instance name of the object to be destroyed. Returns Nothing. Description Method; destroys a component instance. Example The following example removes the TextInput instance my_ti when the button is clicked. With a Button and a TextInput component in the current document’s library, add the following code to the first frame of the main timeline: //Create textinput and button instances this.createClassObject(mx.controls.
-
Parameters target A reference to a timeline that contains the specified function. A string indicating a function name to be called after a frame within the component movie clip has passed (so the component’s properties set in the Property or Component inspector are available). function Returns Nothing. Description Method; calls a user-defined function only after the component has finished setting all of its properties from the Property inspector or Component inspector.
-
UIObject.draw Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage Usage 1: var listenerObject:Object = new Object(); listenerObject.draw = function(eventObject:Object) { // ... }; componentInstance.addEventListener("draw", listenerObject); Usage 2: on (draw) { // ... } Description Event; notifies listeners that the object is about to draw its graphics. This is a low-level event that you should not use unless necessary because it can affect system performance.
-
Example The following code redraws the object form2 when the form object is drawn: formListener.draw = function(eventObj:Object) { form2.redraw(true); } form.addEventListener("draw", formListener); See also EventDispatcher.addEventListener() UIObject.getStyle() Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage componentInstance.getStyle(propertyName) Parameters A string indicating the name of the style property (for example, "fontWeight", "borderStyle", and so on).
-
UIObject.height Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage componentInstance.height Description Property (read-only); a number indicating the height of the object, in pixels. To change the height property, call UIObject.setSize(). Example The following example increases the check box height: myCheckbox.setSize(myCheckbox.width, myCheckbox.height + 10); UIObject.hide Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004.
-
Description Event; broadcast when the object’s visible property is changed from true to false. Example The following handler displays a message in the Output panel when the object it’s attached to becomes invisible. on (hide) { trace("I’ve become invisible."); } See also UIObject.reveal UIObject.invalidate() Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage componentInstance.invalidate() Returns Nothing.
-
All operations that change the component’s appearance can call invalidate() instead of redrawing the component themselves. This has some advantages: code isn’t duplicated unnecessarily, and multiple changes can easily be batched up into one redraw, instead of causing multiple, redundant redraws. Example The following example marks the ProgressBar instance pBar for redrawing: pBar.invalidate(); UIObject.left Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage componentInstance.
-
Usage 2: on (load) { //... } Description Event; notifies listeners that the subobject for this object is being created. The first usage example uses a dispatcher/listener event model. A component instance (componentInstance) dispatches an event (in this case, load) and the event is handled by a function, also called a handler, on a listener object (listenerObject) that you create. You define a method with the same name as the event on the listener object; the method is called when the event is triggered.
-
Usage Usage 1: var listenerObject:Object = new Object(); listenerObject.move = function(eventObject:Object):Void { // ... }; componentInstance.addEventListener("move", listenerObject); Usage 2: on (move) { // ... } Description Event; notifies listeners that the object has moved. The first usage example uses a dispatcher/listener event model.
-
UIObject.move() Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage componentInstance.move(x, y, noEvent) Parameters x A number that indicates the position of the object’s upper left corner, relative to its parent. y A number that indicates the position of the object’s upper left corner, relative to its parent. noEvent A Boolean value that indicates whether the move event should be dispatched. Returns Nothing. Description Method; moves the object to the requested position.
-
UIObject.redraw() Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage componentInstance.redraw(always) Parameters A Boolean value. If true, the method draws the object, even if invalidate() wasn’t called. If false, the method draws the object only if invalidate() was called. always Returns Nothing. Description Method; forces validation of the object so that it is drawn in the current frame.
-
Usage Usage 1: var listenerObject:Object = new Object(); listenerObject.resize = function(eventObject:Object) { // ... }; componentInstance.addEventListener("resize", listenerObject); Usage 2: on (resize) { // ... } Description Event; notifies listeners that an object has been resized. The first usage example uses a dispatcher/listener event model.
-
The following example calls the setSize() method to resize a Button component, my_button, to 200 pixels wide by 100 pixels high: var my_button:mx.controls.Button; my_button.addEventListener("resize", doSize); function doSize(evt_obj:Object):Void { trace(evt_obj.target + " resized from {oldWidth:" + evt_obj.oldWidth + ", oldHeight:" + evt_obj.oldHeight + "} to {width:" + evt_obj.target.width + ", height:" + evt_obj.target.height + "}"); } my_button.setSize(200, 100); UIObject.
-
Example The following handler displays a message in the Output panel when the object it’s attached to becomes visible. on (reveal) { trace("I’ve become visible."); } See also UIObject.hide UIObject.right Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage componentInstance.right Description Property (read-only); a number indicating the right edge of the object, in pixels, relative to its parent’s right edge. To set this property, call UIObject.move().
-
Description Property; a number indicating the scaling factor in the x direction of the object, relative to its parent. Example The following example makes the check box twice as wide and sets the tmp variable to the horizontal scale factor: checkbox.scaleX = 200; var tmp:Number = checkbox.scaleX; UIObject.scaleY Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage componentInstance.
-
UIObject.setSize() Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage componentInstance.setSize(width, height, noEvent) Parameters width A number that indicates the width of the object, in pixels. height A number that indicates the height of the object, in pixels. noEvent A Boolean value that indicates whether the resize event should be dispatched. Returns Nothing. Description Method; resizes the object to the requested size. You should pass only integer values to UIObject.
-
The following example calls the setSize() method to resize the my_button Button component to 200 pixels wide by 100 pixels high: var my_button:mx.controls.Button; my_button.addEventListener("resize", doSize); function doSize(evt_obj:Object):Void { trace(evt_obj.target + " resized from {oldWidth:" + evt_obj.oldWidth + ", oldHeight:" + evt_obj.oldHeight + "} to {width:" + evt_obj.target.width + ", height:" + evt_obj.target.height + "}"); } my_button.setSize(200, 100); UIObject.
-
Example This example is a code snippet from the class file of a new component, called Shape. It creates a variable, themeShape and sets it to the Linkage identifier of the skin.
-
Parameters A string indicating the name of the style property. Supported styles vary depending on the component. Each component has a different set of styles that you can set. For example, “Customizing the TextArea component” on page 1180 shows a table of styles, including fontWeight. So, for a TextArea component, you can use fontWeight as the propertyName parameter. propertyName The value of the property. If the value is a string, it must be enclosed in quotation marks. value Returns Nothing.
-
UIObject.top Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage componentInstance.top Description Property (read-only); a number indicating the top edge of the object, in pixels, relative to its parent. To set this property, call UIObject.move(). UIObject.unload Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage Usage 1: var listenerObject:Object = new Object(); listenerObject.unload = function(eventObject:Object):Void { // ... }; componentInstance.
-
The first usage example uses a dispatcher/listener event model. A component instance (componentInstance) dispatches an event (in this case, unload) and the event is handled by a function, also called a handler, on a listener object (listenerObject) that you create. You define a method with the same name as the event on the listener object; the method is called when the event is triggered. When the event is triggered, it automatically passes an event object (eventObject) to the listener object method.
-
UIObject.width Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage componentInstance.width Description Property (read-only); a number indicating the width of the object, in pixels. To change the width, call UIObject.setSize(). Example The following example makes the check box wider: myCheckbox.setSize(myCheckbox.width + 10, myCheckbox.height); UIObject.x Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage componentInstance.
-
UIObject.y Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage componentInstance.y Description Property (read-only); a number indicating the top edge of the object, in pixels. To set this property, call UIObject.move(). Example The following example moves the check box down 10 pixels: myCheckbox.move(myCheckbox.x, myCheckbox.
-
55 CHAPTER 55 UIScrollBar Component The UIScrollBar component allows you to add a scroll bar to a text field. You can add a scroll bar to a text field while authoring, or at runtime with ActionScript. The UIScrollBar component functions like any other scroll bar. It contains arrow buttons at either end and a scroll track and scroll box (thumb) in between. It can be attached to any edge of a text field and used both vertically and horizontally.
-
UIScrollBar parameters You can set the following authoring parameters for each UIScrollBar instance in the Property inspector or in the Component inspector (Window > Component Inspector menu option): _targetInstanceName indicates the name of the text field instance that the UIScrollBar component is attached to. horizontal indicates whether the scroll bar is oriented horizontally (true) or vertically (false). The default value is false.
-
To create an application with the UIScrollBar component: 1. Create a dynamic text field and give it an instance name myText in the Property inspector. 2. In the Property inspector, set the Line Type of the text input field to Multiline or to Multiline No Wrap if you plan to use the scroll bar horizontally. 3. In Frame 1, use ActionScript to add enough text to the field so that users have to scroll to view it all. You could write the following code: myText.
-
The following code creates a vertically oriented UIScrollBar instance and attaches it to the right side of a text field instance named my_txt and sets the size of the scroll bar to match the size of the text field: /** Requires: - UIScrollBar component in library */ // Create text field. this.createTextField("my_txt", 10, 10, 20, 200, 100); my_txt.wordWrap = true; this.createClassObject(mx.controls.UIScrollBar, "my_sb", 20); // Set the target text field for the scroll bar. my_sb.
-
Customizing the UIScrollBar component You can transform a UIScrollBar component horizontally and vertically while authoring and at runtime. However, a vertical UIScrollBar does not allow you to modify the width, and a horizontal UIScrollBar does not allow you to modify the height. While authoring, select the component on the Stage and use the Free Transform tool or any of the Modify > Transform commands. At runtime, use the setSize() method (see UIObject.
-
Using skins with the UIScrollBar component The UIScrollBar component uses 13 skins for the track, scroll box (thumb), and buttons. To customize these skin elements, edit the symbols in the Flash UI Components 2/Themes/ MMDefault/ScrollBar Assets/States folder. For more information, see “About skinning components” in Using Components. Both horizontal and vertical scroll bars use the same vertical skins, and when displaying a horizontal scroll bar the UIScrollBar component rotates the skins as appropriate.
-
The following example demonstrates how to put a thin blank line in the middle of the scroll track. To create movie clip symbols for UIScrollBar skins: 1. Create a new FLA file. 2. Select File > Import > Open External Library, and select the HaloTheme.fla file. This file is located in the application-level configuration folder. For the exact location on your operating system, see “About themes” in Using Components. 3.
-
Each component class has a version property, which is a class property. Class properties are available only on the class itself. The version property returns a string that indicates the version of the component. To access this property, use the following code: trace(mx.controls.UIScrollBar.version); NO TE The code trace(myUIScrollBarInstance.version); returns undefined. Method summary for the UIScrollBar class The following table lists the method of the UIScrollBar class. Method Description UIScrollBar.
-
Method Description UIObject.setSkin() Sets a skin in the object. UIObject.setStyle() Sets the style property on the style declaration or object. Methods inherited from the UIComponent class The following table lists the methods the UIScrollBar class inherits from the UIComponent class. When calling these methods from the UIScrollBar object, use the form UIScrollBarInstance.methodName. Method Description UIComponent.getFocus() Returns a reference to the object that has focus. UIComponent.
-
Properties inherited from the UIObject class The following table lists the properties the UIScrollBar class inherits from the UIObject class. When accessing these properties from the UIScrollBar object, use the form UIScrollBarInstance.propertyName. Property Description UIObject.bottom Read-only; the position of the bottom edge of the object, relative to the bottom edge of its parent. UIObject.height Read-only; the height of the object, in pixels. UIObject.
-
Event summary for the UIScrollBar class The following table lists the event of the UIScrollBar class. Event Description UIScrollBar.scroll Broadcast when any part of the scroll bar is clicked. Events inherited from the UIObject class The following table lists the events the UIScrollBar class inherits from the UIObject class. Event Description UIObject.draw Broadcast when an object is about to draw its graphics. UIObject.hide Broadcast when an object’s state changes from visible to invisible.
-
UIScrollBar.horizontal Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage scrollBarInstance.horizontal Description Property; indicates whether the scroll bar is oriented vertically (false) or horizontally (true). This property can be tested and set. The default value is false.
-
UIScrollBar.lineScrollSize Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage scrollBarInstance.lineScrollSize Description Property; gets or sets the number of lines or pixels scrolled when the user clicks the arrow buttons of the UIScrollBar component. If the scroll bar is oriented vertically, the value is a number of lines. If the scroll bar is oriented horizontally, the value is a number of pixels. The default value is 1.
-
// Load text to display and define onData handler. var my_lv:LoadVars = new LoadVars(); my_lv.onData = function(src:String) { if (src != undefined) { my_txt.text = src; } else { my_txt.text = "Error loading text."; } }; my_lv.load("http://www.helpexamples.com/flash/lorem.txt"); UIScrollBar.pageScrollSize Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage scrollBarInstance.
-
my_sb.setScrollTarget(my_txt); // Size it to match the text field. my_sb.setSize(16, my_txt._height); // Move it next to the text field. my_sb.move(my_txt._x + my_txt._width, my_txt._y); // Scroll 2 lines per click of scroll arrow. my_sb.lineScrollSize = 2; // Scroll 5 lines per click of scroll track. my_sb.pageScrollSize = 5; // Load text to display and define onData handler. var my_lv:LoadVars = new LoadVars(); my_lv.onData = function(src:String) { if (src != undefined) { my_txt.
-
Description Event; broadcast to all registered listeners when the mouse is clicked (released) over the scroll bar. The UIScrollBar.scrollPosition property and the scroll bar’s onscreen image are updated before this event is broadcast. The first usage example uses a dispatcher/listener event model, in which the script is placed on a frame in the timeline that contains the component instance.
-
Example The following example implements Usage 1 and creates a listener object called sbListener with a scroll event handler: /** Requires: - UIScrollBar component in library */ this.createTextField("my_txt", 10, 10, 20, 200, 100); my_txt.wordWrap = true; this.createClassObject(mx.controls.UIScrollBar, "my_sb", 20); // Set the target text field. my_sb.setScrollTarget(my_txt); // Size it to match the text field. my_sb.setSize(16, my_txt._height); // Move it next to the text field. my_sb.move(my_txt.
-
UIScrollBar.scrollPosition Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage scrollBarInstance.scrollPosition Description Property; gets or sets the current scroll position of the scroll box (thumb) when a new scrollPosition value is set. The value of scrollPosition depends on whether the UIScrollBar instance is being used for vertical or horizontal scrolling. Set the scrolling of the scroll bar target instance separately, using the following syntax: my_scrollbar._targetInstanceName.
-
Example The following example sets the text to position 20: /** Requires: - UIScrollBar and Button components in library */ this.createTextField("my_txt", 10, 10, 20, 200, 100); this.createClassObject(mx.controls.UIScrollBar, "my_sb", 20); this.createClassObject(mx.controls.Button, "my_bt", 30, {label: "Scroll"}); my_txt.wordWrap = true; my_bt.move(300, 100); // Set the target text field. my_sb.setScrollTarget(my_txt); // Move it next to the text field. my_sb.move(my_txt._x + my_txt._width, my_txt.
-
UIScrollBar.setScrollProperties() Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage scrollBarInstance.setScrollProperties(pageSize, minPos, maxPos) Parameters The number of items that can be viewed in the display area. This parameter sets the size of the text field’s bounding box. If the scroll bar is vertical, this value is a number of lines of text; if the scroll bar is horizontal, this value is a number of pixels.
-
UIScrollBar.setScrollTarget() Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage scrollBarInstance.setScrollTarget(textInstance) Parameters textInstance The text field to assign to the scroll bar. Description Method; assigns a UIScrollBar component to a text field instance. If you need to associate a text field and a UIScrollBar component at runtime, use this method. Example The following example creates a scroll bar to scroll text in a text field, which it loads from a web page.
-
my_sb.pageScrollSize = 5; // Load text to display and define onData handler. var my_lv:LoadVars = new LoadVars(); my_lv.onData = function(src:String) { if (src != undefined) { my_txt.text = src; } else { my_txt.text = "Error loading text."; } }; my_lv.load("http://www.helpexamples.com/flash/lorem.txt"); UIScrollBar._targetInstanceName Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage scrollBarInstance.
-
Example The following example creates a scroll bar to scroll text in a text field, which it loads from a web page. The example calls the trace() function to display the value of the targetInstanceName property. /** Requires: - UIScrollBar component in library */ this.createTextField("my_txt", 10, 10, 20, 200, 100); my_txt.wordWrap = true; this.createClassObject(mx.controls.UIScrollBar, "my_sb", 20); // Set the target text field. my_sb.setScrollTarget(my_txt); trace(my_sb.
-
1412 UIScrollBar Component
-
56 CHAPTER 56 Web service classes (Flash Professional only) The web service classes, which are found in the mx.services package, let you access web services that use Simple Object Access Protocol (SOAP). This API is not the same as the WebServiceConnector component API. The web service API is a set of classes that can you use only in ActionScript code, and is common to various Macromedia products.
-
Making web service classes available at runtime (Flash Professional only) In order to make the web service classes available at runtime, the WebServiceConnector component must be in your FLA file’s library. This component contains the runtime classes that let you work with web services. For details on adding these classes to your FLA file, see Chapter 16, “Data Integration (Flash Professional Only),” in Using Flash.
-
Method summary for the Log class The following table lists methods of the PendingCall class. Method Description Log.getDateString() Returns the current date and time as a string in the following format: mm/dd hh:mm:ss used by Log messages. Log.logInfo() Generates a Log.onLog event with a designated log level and a designated message. Log.logDebug() Generates a Log.onLog event with a log level of Log.DEBUG and a designated message.
-
Constructor for the Log class Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage myWebSrvcLog = new Log([logLevel] [, logName]); Parameters A level to indicate the category of information that you want to record in the log. Four log levels are available: logLevel ■ The log records primary life-cycle event and error notifications. This is the Log.BRIEF default value. ■ Log.VERBOSE ■ Log.DEBUG ■ Log.
-
You then pass this Log object as a parameter to the WebService constructor: myWebSrvc = new WebService("http://www.myco.com/info.wsdl", myWebSrvcLog); As the web services code executes and messages are sent to the Log object, the onLog() function of your Log object is called. This is the only place to put code that displays the log messages if you want to see them in real time.
-
Example The following example creates a new Log object, passes it to a new WebService object, and handles the log messages, using Log.getDateString() to get the time of the log. import mx.services.*; // Creates a new Log object. myWebSrvcLog = new Log(Log.BRIEF, "myLog"); // Passes the Log object to the web service. myWebService = new WebService(wsdlURI, myWebSrvcLog); // Handles incoming log messages. myWebSrvcLog.
-
Description Function; generates a log message set by the msg parameter at a log level set by the level parameter. This method provides a way to create your own log events with any log level. Example The following example creates a new Log object. An onLog event with a message indicating the start of a new log is generated by calling Log.logDebug(). import mx.services.*; // Creates a new Log object. myWebSrvcLog = new Log(Log.VERBOSE, "myLog"); // Handles incoming log messages. myWebSrvcLog.
-
Description Function; generates a log message containing msg and the message type indicator of [debug]. This method provides a way to create your own log events with [debug] in the log message, which will be viewable only with a log level setting of Log.DEBUG. The following string is an examples of a debug level log message generated by Log.logDebug(): 12/18 23:20:17 [DEBUG] myLog: My log message Example The following example creates a new Log object.
-
Description Property; indicates the category of information that you want to record in the log. Four log levels are available: The log records primary life-cycle event and error notifications. This is the default value. A Log.level property set to Log.BRIEF returns the number 0. ■ Log.BRIEF ■ Log.VERBOSE ■ Log.DEBUG ■ Log.NONE The log records all life-cycle event and error notifications. A Log.level property set to Log.VERBOSE returns the number 1.
-
Description Property; a string identifying the Log instance; included in every Log.onLog event message. This property can be both get and set. It is usually set when creating a new Log object. See “Log class (Flash Professional only)” on page 1414.) Example The following example creates a new Log object with a Log.level property of Log.VERBOSE The current Log.name property is traced. Then the Log object’s Log.name property is set to "myNewLogName". and a name of “myLog”. import mx.services.
-
Example The following example creates a new Log object, passes it to a new WebService object, and handles the log messages: import mx.services.*; // Creates a new Log object. myWebSrvcLog = new Log(); // Passes the Log object to the web service. myWebService = new WebService(wsdlURI, myWebSrvcLog); // Handles incoming log messages. myWebSrvcLog.onLog = function(message : String) : Void { mytrace("myWebSrvcLog.message: " + message); } PendingCall class (Flash Professional only) ActionScript Class Name mx.
-
The PendingCall object also gives you access to multiple output parameters when the web service method returns more than one result. The “return value” referred to in this API is simply the first (or only) result; to gain access to all of the results, you can use the “get output” functions.
-
Callback summary for the PendingCall object The following table lists the callbacks of the PendingCall class. Callback Description PendingCall.onFault Called by Flash Player when a web service method has failed and returned an error. PendingCall.onResult Called when a method has succeeded and returned a result. PendingCall.getOutputParameter() Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage myPendingCall.
-
Example Given the SOAP descriptor file below, getOutputParameter(1) would return a SOAPParameter object with value="Hi there!" and element=the XMLNode. ... 54 Hi there! true ... See also PendingCall.getOutputParameterByName(), PendingCall.getOutputParameters(), PendingCall.getOutputValue(), PendingCall.
-
Description Function; gets any output parameter as a SOAPParameter object, which contains the value and the XML element. SOAP RPC calls may return multiple output parameters. The first (or only) return value is always delivered in the result parameter of the onResult callback function, but to get access to the other return values, you must use functions such as getOutputParameterByName(). This function returns the output parameter with the name localName.
-
Returns A SOAPParameter object with two properties: value (the output parameter’s ActionScript value) and element (the output parameter’s XML value). Description Function; gets additional output parameters of the SOAPParameter object, which contains the values and the XML elements. SOAP RPC calls may return multiple output parameters.
-
Example Given the SOAP descriptor file below, getOutputValue(2) would return true. ... 54 Hi there! true ... See also PendingCall.getOutputParameterByName(),PendingCall.getOutputParameter(), PendingCall.getOutputParameters(), PendingCall.getOutputValues() PendingCall.getOutputValues() Availability Flash Player 6 (6.0.
-
See also PendingCall.getOutputParameterByName(), PendingCall.getOutputParameter(), PendingCall.getOutputParameters(), PendingCall.getOutputValue() PendingCall.myCall Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage PendingCall.myCall Description Property; the SOAPCall object corresponding to the PendingCall operation. The SOAPCall object contains information about the web service operation, and provides control over certain behaviors.
-
Usage myPendingCallObj.onFault = function(fault) { // Your code here. } Parameters fault Decoded ActionScript object version of the SOAPFault object with properties. If the error information came from a server in the form of XML, the SOAPFault object is the decoded ActionScript version of that XML. The type of error object returned to PendingCall.onFault is a SOAPFault object. It is not constructed directly by you, but is returned as the result of a failure.
-
Example The following example handles errors returned from the web service method. // Handles any error returned from the use of a web service method. myPendingCallObj = myWebService.methodName(params) myPendingCallObj.onFault = function(fault) { // Catches the SOAP fault. DebugOutputField.text = fault.faultstring; // Add code to handle any faults, for example, by telling the // user that the server isn’t available or to contact technical // support. } PendingCall.onResult Availability Flash Player 6 (6.
-
Example The following example handles results returned from the web service method. // Handles results returned from the use of a web service method. myPendingCallObj = myWebService.methodName(params) myPendingCallObj.onResult = function(result) { // Catches the result and handles it for this application. ResultOutputField.text = result; } See also PendingCall.response PendingCall.request Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage rawXML = myPendingCallback.
-
Usage rawXML = myPendingCallback.response; Description Property; contains the raw XML form of the response to the most recent web service method call sent with myPendingCallback = myWebService.methodName(). Normally, you would not have any use for PendingCall.response, but you can use it if you are interested in the SOAP communications that are sent over the network. To get the corresponding ActionScript version of the results of the request, use myPendingCallback.onResult.
-
Property summary for the SOAPCall object The following table lists the properties of the SOAPCall object. Property Description SOAPCall.concurrency The number of concurrent requests. SOAPCall.doDecoding Turns the decoding of the XML response on or off. SOAPCall.doLazyDecoding Turns “lazy decoding” (the delay of turning SOAP arrays into ActionScript objects) on or off. SOAPCall.concurrency Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage SOAPCall.
-
SOAPCall.doDecoding Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage SOAPCall.doDecoding Description Property; turns decoding of the XML response on (true) or off (false). By default, the XML response is converted (decoded) into ActionScript objects. If you want just the XML, set SOAPCall.doDecoding to false. SOAPCall.doLazyDecoding Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage SOAPCall.
-
WebService class (Flash Professional only) ActionScript Class Name mx.services.WebService The WebService class is part of the mx.services package and is used with the Log, PendingCall, and SOAPCall classes. For an overview of the classes in the mx.services package, see “Web service classes (Flash Professional only)” on page 1413. NO TE The WebService class is not the same as the WebServiceConnector class.
-
To make the web service classes available at runtime, you must have the WebServiceConnector component in your FLA file’s library. If you’re using ActionScript only to access a web service at runtime, you must add this component manually to your document’s library. For information on how to add this component to your document, see Chapter 16, “Data Integration (Flash Professional Only),” in Using Flash. Method summary for the WebService object The following table lists methods of the WebService object.
-
Numeric Simple types XML schema type ActionScript binding decimal Number integer Number negativeInteger Number nonNegativeInteger Number positiveInteger Number long Number int Number short Number byte Number unsignedLong Number unsignedShort Number unsignedInt Number unsignedByte Number float Number double Number Date and Time Simple types XML schema type ActionScript binding date Date object datetime Date object duration Date object gDay Date object gMonth Date ob
-
Name and String Simple types XML schema type ActionScript binding string ActionScript string normalizedString ActionScript string QName mx.services.
-
WebService security (Flash Professional only) The methods and callbacks of the WebService class conform to the Flash Player security model. For more information on the Flash Player security model, see “Understanding Security” in Learning ActionScript 2.0 in Flash. User authentication and authorization The authentication and authorization rules are the same for the WebService API as they are for any XML network operation from Flash. SOAP itself does not specify any means of authentication and authorization.
-
Parameters wsdlURI The URI of the web service WSDL file. An optional parameter specifying the name of the Log object for this web service. If this parameter is used, the Log object must be created first. For more information, see “Log class (Flash Professional only)” on page 1414. logObject Returns Nothing. Description Constructor function; creates a WebService object. When you call new WebService(), you provide a WSDL URL, and Flash Player returns a WebService object.
-
Handling the PendingCall object This callback object is a PendingCall object that you use for handling the results and errors from the web service method that was called (see “PendingCall class (Flash Professional only)” on page 1423). Here is an example: MyPendingCallObject = myWebServiceObject.myMethodName(param1, ..., paramN); MyPendingCallObject.onResult = function(result) { OutputField.text = result } MyPendingCallObject.onFault = function(fault) { DebugField.text = fault.faultCode + "," + fault.
-
Description Function; when you create a new WebService object, it contains the methods corresponding to operations in the WSDL URL you pass in. Behind the scenes, a SOAPCall object is created for each operation in the WSDL as well. The SOAPCall object is the descriptor of the operation, and as such contains all the information about that operation (how the XML should look on the network, the operation style, and so on). It also provides control over certain behaviors.
-
The callback invoked when the response comes back from the WebService method is PendingCall.onResult or PendingCall.onFault. By uniquely identifying your callback objects, you can manage multiple onResult callbacks, as in the following example: myWebService = new WebService("http://www.myCompany.com/myService.wsdl"); callback1 = myWebService.getWeather("02451"); callback1.onResult = function(result) { // do something } callback2 = myWebService.getDetailedWeather("02451"); callback2.
-
The type of error object returned to WebService.onFault methods is a SOAPFault object. This object is not constructed directly by you, but returned as the result of a failure. This object is an ActionScript mapping of the SOAPFault XML type. SOAPFault property Description faultcode String; the short standard QName describing the error. faultstring String; the human-readable description of the error.
-
WebService.onLoad Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage myService.onLoad = function(wsdlDocument) { // Your code here. } Parameters wsdlDocument The WSDL XML document. Returns Nothing. Description Callback function; called by Flash Player when the WebService object has successfully loaded and parsed its WSDL file.
-
1448 Web service classes (Flash Professional only)
-
CHAPTER 57 57 WebServiceConnector component (Flash Professional only) The WebServiceConnector component lets you access remote methods exposed by a server using the industry-standard Simple Object Access Protocol (SOAP). A web service method can accept parameters and return a result. Using the Flash Professional 8 authoring tool and the WebServiceConnector component, you can inspect, access, and bind data between a remote web service and your Flash application.
-
WebServiceConnector parameters You can set the following authoring parameters for each WebServiceConnector component instance by using the Parameters tab of the Component inspector: multipleSimultaneousAllowed is a Boolean value that indicates whether multiple calls can take place at the same time; the default value is false. If this parameter is false, the trigger() method does not perform a call if a call is already in progress. A status event is emitted, with the code CallAlreadyInProgress.
-
To use a WebServiceConnector component: 1. Use the Web Services panel to enter the URL for a web service WSDL file. 2. Add a call to a method of the web service by selecting the method, right-clicking (Windows) or Control-clicking (Macintosh), and selecting Add Method Call from the context menu. This creates a WebServiceConnector component instance in your application. The schema for the component can then be found on the Schema tab of the Component inspector.
-
Method summary for the WebServiceConnector class The following table lists the method of the WebServiceConnector class. Method Description WebServiceConnector.trigger() Initiates a call to a web service. Property summary for the WebServiceConnector class The following table lists properties of the WebServiceConnector class. Property Description WebServiceConnector.multiple Indicates whether multiple calls can take place at the same time. SimultaneousAllowed WebServiceConnector.
-
Event summary for the WebServiceConnector class The following table lists events of the WebServiceConnector class. Event Description WebServiceConnector.result Broadcast when a call to a web service completes successfully. WebServiceConnector.send Broadcast when the trigger() method is in process, after the parameter data has been gathered but before the data is validated and the call to the web service is initiated. WebServiceConnector.
-
When multiple calls are simultaneously in progress, there is no guarantee that they will be completed in the order in which they were triggered. Also, the browser and/or operating system may place limits on the number of simultaneous network operations. The most likely limit you may encounter is the browser enforcing a maximum number of URLs that can be downloaded simultaneously. This is something that is often configurable in a browser.
-
var wsConn:WebServiceConnector = new WebServiceConnector(); wsConn.addEventListener("result", wscListener); wsConn.addEventListener("send", wscListener); wsConn.WSDLURL = "http://www.flash-mx.com/mm/tips/tips.cfc?wsdl"; wsConn.operation = "getTipByProduct"; wsConn.params = ["Flash"]; wsConn.suppressInvalidCalls = true; wsConn.multipleSimultaneousAllowed = false; wsConn.trigger(); WebServiceConnector.params Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004.
-
WebServiceConnector.result Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage componentInstance.addEventListener("result", myListenerObject) Description Event; broadcast when a call to a web service completes successfully.
-
WebServiceConnector.results Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage componentInstance.results Description Property; identifies data that was received from the server as a result of a trigger() operation. Each WebServiceConnector component defines how this data is fetched, and what the valid types are. This data appears when the RPC operation has successfully completed, as signaled by the result event.
-
Description Event; broadcast during the processing of a trigger() operation, after the parameter data has been gathered but before the data is validated and the call to the web service is initiated. This is a good place to put code that modifies the parameter data before the call.
-
The following are the codes and associated data available for the status event: Code Data Description StatusChange {callsInProgress:nnn} This event is emitted whenever a web service call starts or finishes. The item nnn gives the number of calls currently in progress. CallAlreadyInProgress No data This event is emitted if trigger() is called, multipleSimultaneousAllowed is false, and a call is already in progress.
-
faultcode faultstring detail Client.Disconnected Could not load WSDL Unable to load WSDL, if currently online, please verify the URI and/or format of the WSDL xxx Server Faulty WSDL format Definitions must be the first element in a WSDL document Server.NoServicesInWSDL Could not load WSDL No elements found in WSDL at xxx WSDL.UnrecognizedNamespace The WSDL parser had no registered document for the namespace xxxx WSDL.
-
faultcode faultstring Unknown.Call.Failure WebService invocation failed for unknown reasons Client.Disconnected Could not load imported schema detail Unable to load schema; if currently online, please verify the URI and/or format of the schema at (XXXX) Example The following example defines a function fault for the status event and assigns the function to the addEventListener event handler.
-
Edition Flash MX Professional 2004. Usage componentInstance.suppressInvalidCalls Description Property; indicates whether to suppress a call if parameters are invalid. If this property is true, the trigger() method does not perform a call if the bound parameters fail the validation. A status event is emitted, with the code InvalidParams. If this property is false, the call takes place, using the invalid data as required.
-
WebServiceConnector.trigger() Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage componentInstance.trigger(); Description Method; initiates a call to a web service. Each web service defines exactly what this involves. If the operation is successful, the results of the operation appear in the results property for the web service. The trigger() method performs the following steps: 1.
-
WebServiceConnector.WSDLURL Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage componentInstance.WSDLURL Description Property; the URL of the WSDL file that defines the web service operation. When you set this URL while authoring, the WSDL file is immediately fetched and parsed. The resulting parameters and results appear in the Schema tab of the Component inspector. The service description also appears in the Web Service panel.
-
58 CHAPTER 58 Window component A Window component displays the contents of a movie clip inside a window with a title bar, a border, and an optional close button. A Window component can be modal or nonmodal. A modal window prevents mouse and keyboard input from going to other components outside the window. The Window component also supports dragging; a user can click the title bar and drag the window and its contents to another location. Dragging the borders doesn’t resize the window.
-
If you use the Popup Manager to add a Window component to a document, the Window instance will have its own Focus Manager, distinct from the rest of the document. If you don’t use the Popup Manager, the window’s contents participate in focus ordering with the other components in the document. For more information about controlling focus, see “FocusManager class” on page 721 or “Creating custom focus navigation” in Using Components.
-
You can set the following additional parameters for each Window 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 (true) or not (false). The default value is true. NO TE For more information about the following five skin parameters, see “Using skins with the Window component” on page 1470.
-
3. Open the Actions panel, and enter the following click handler in Frame 1: /** Requires: - Button component on Stage (instance name: my_button) - Window component in library */ import mx.containers.Window; var my_button:mx.controls.Button; System.security.allowDomain("http://www.helpexamples.com"); // Create listener object. var buttonListener:Object = new Object(); buttonListener.click = function(evt_obj:Object) { // Instantiate Window. var my_win:MovieClip = mx.managers.PopUpManager.
-
Using styles with the Window component A Window component supports the following styles: Style Theme Description themeColor Halo The base color scheme of a component. Possible values are "haloGreen", "haloBlue", and "haloOrange". The default value is "haloGreen". backgroundColor Both The background color. The default value is white for the Halo theme and 0xEFEBEF (light gray) for the Sample theme.
-
Style Theme Description textDecoration Both The text decoration: either "none" or "underline". The default value is "none". textIndent Both A number indicating the text indent. The default value is 0. Text styles can be set on the Window component itself, or they can be set on the _global.styles.windowStyles class style declaration (text styles, only, not other styles like themeColor or backgroundColor, which come from the _global.styles.Window class style declaration).
-
Property Description skinCloseDown The close button in its down state. The default value is CloseButtonDown. skinCloseDisabled The close button in its disabled state. The default value is CloseButtonDisabled. skinCloseOver The close button in its over state. The default value is CloseButtonOver. The following example demonstrates how to create a new movie clip symbol to use as the title background. To set the title of a Window component to a custom movie clip symbol: 1. Create a new FLA file. 2.
-
Window class Inheritance MovieClip > UIObject class > UIComponent class > View > ScrollView > Window ActionScript Class Name mx.containers.Window The properties of the Window class let you do the following at runtime: set the title caption, add a close button, and set the display content. Setting a property of the Window class with ActionScript overrides the parameter of the same name set in the Property inspector or Component Inspector panel.
-
Each component class has a version property, which is a class property. Class properties are available only on the class itself. The version property returns a string that indicates the version of the component. To access this property, use the following code: trace(mx.containers.Window.version); NO TE The code trace(myWindowInstance.version); returns undefined. Method summary for the Window class The following table lists the method of the Window class. Method Description Window.
-
Methods inherited from the UIComponent class The following table lists the methods the Window class inherits from the UIComponent class. When calling these methods from the Window object, use the form WindowInstance.methodName. Method Description UIComponent.getFocus() Returns a reference to the object that has focus. UIComponent.setFocus() Sets focus to the component instance. Property summary for the Window class The following table lists properties of the Window class.
-
Property Description UIObject.scaleY A number indicating the scaling factor in the y direction of the object, relative to its parent. UIObject.top Read-only; the position of the top edge of the object, relative to its parent. UIObject.visible A Boolean value indicating whether the object is visible (true) or not (false). UIObject.width Read-only; the width of the object, in pixels. UIObject.x Read-only; the left edge of the object, in pixels. UIObject.
-
Events inherited from the UIObject class The following table lists the events the Window class inherits from the UIObject class. Event Description UIObject.draw Broadcast when an object is about to draw its graphics. UIObject.hide Broadcast when an object’s state changes from visible to invisible. UIObject.load Broadcast when subobjects are being created. UIObject.move Broadcast when the object has moved. UIObject.resize Broadcast when an object has been resized. UIObject.
-
Usage Usage 1: var listenerObject:Object = new Object(); listenerObject.click = function(eventObject:Object) { // ... }; windowInstance.addEventListener("click", listenerObject); Usage 2: on (click) { // ... } Description Event; broadcast to all registered listeners when the mouse is clicked (released) over the close button. The first usage example uses a dispatcher/listener event model.
-
Example The following example creates a modal window with a close button. It defines a click handler that calls the click() method to delete the window when the user clicks the button. You drag a Window component from the Components panel to the current document’s library; then add the following code to Frame 1: /** Requires: - Window component in library */ import mx.managers.PopUpManager; import mx.containers.Window; System.security.allowDomain("http://www.flash-mx.
-
Clicking the close button broadcasts a click event, but doesn’t close the window. You must write a handler that calls Window.deletePopUp() to explicitly close the window. For more information about the click event, see Window.click. Example The following example creates a pop-up window and sets the closeButton property to add a close button to it.
-
A component instance (windowInstance) dispatches an event (in this case, complete) and the event is handled by a function, also called a handler, on a listener object (listenerObject) that you create. You define a method with the same name as the event on the listener object; the method is called when the event is triggered. When the event is triggered, it automatically passes an event object (eventObject) to the listener object method.
-
Window.content Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage windowInstance.content Description Read-only property; a reference to the content (root movie clip) of the window. This property returns a MovieClip object. When you attach a symbol from the library, the default value is an instance of the attached symbol. When you load content from a URL, the default value is undefined until the load operation has started.
-
Window.contentPath Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage windowInstance.contentPath Description Property; sets the name of the content to display in the window. This value can be the linkage identifier of a movie clip in the library, or the absolute or relative URL of a SWF or JPEG file to load. The default value is "" (an empty string).
-
Window.deletePopUp() Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage windowInstance.deletePopUp() Parameters None. Returns Nothing. Description Method; deletes the window instance and removes the modal state. This method can be called only on Window instances that were created by PopUpManager.createPopUp(). Example The following example creates a modal window and then defines a click handler that calls the deletePopUp() function to delete the window.
-
Window.mouseDownOutside Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage Usage 1: var listenerObject:Object = new Object(); listenerObject.mouseDownOutside = function(eventObject:Object) { // ... }; windowInstance.addEventListener("mouseDownOutside", listenerObject); Usage 2: on (mouseDownOutside) { // ... } Description Event; broadcast to all registered listeners when the mouse is clicked (released) outside the modal window.
-
The second usage example uses an on() handler and must be attached directly to a Window instance. The keyword this, used inside an on() handler attached to a component, refers to the component instance. For example, the following code, attached to the Window instance myWindowComponent, sends “_level0.
-
Window.title Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage windowInstance.title Description Property; a string indicating the text of the title bar. The default value is "" (an empty string). Example The following example creates a pop-up window and uses the title property to set the title to “Hello World”.
-
Window.titleStyleDeclaration Availability Flash Player 6 (6.0.79.0). Edition Flash MX 2004. Usage windowInstance.titleStyleDeclaration Description Property; a string indicating the style declaration that formats the title bar of a window. The default value is undefined, which indicates bold, white text. Example The following example creates a CSS style declaration to make text 14 points in size, italicized and underlined.
-
// Set window attributes. my_win.title = "Testing Styles"; my_win.setSize(200, 100); my_win.move(20, 20); // Create listener object. var winListener:Object = new Object(); winListener.click = function(evt_obj:Object) { trace("closing window"); evt_obj.target.deletePopUp(); }; // Add listener. my_win.addEventListener("click", winListener); For more information about styles, see “Using styles to customize component color and text” in Using Components.
-
CHAPTER 59 59 XMLConnector component (Flash Professional only) The XMLConnector component lets you read or write XML documents using HTTP GET and POST operations. It acts as a connector between other components and external XML data sources. The XMLConnector component communicates with other components in your application using either ActionScript code or data binding features in the Flash authoring environment.
-
A value of "send" means that the XML data is sent (via HTTP POST) to the URL, but Flash ignores any data that comes back. The XMLConnector.results property is never set to anything, and no result event occurs. A value of "receive" means that no data is sent out to the XML URL. Flash accesses the URL via HTTP GET, and expects valid XML data to come back. A value of "send/receive" means that Flash sends the XML data via HTTP POST, and expects valid XML data to come back.
-
4. Use the Bindings tab of the Component inspector to bind data elements (params and results) from the XML document to properties of the visual components in your application. For example, you can connect to an XML document that provides weather data and bind the Location and Temperature data elements to label components in your application. The name and temperature of a specified city appears in the application at runtime. 5.
-
Property summary for the XMLConnector class The following table lists properties of the XMLConnector class. Property Description XMLConnector.direction Indicates whether data is being sent, received, or both. XMLConnector.ignoreWhite Indicates whether text nodes containing only white space are discarded during the parsing process. XMLConnector.multipleSimultaneousAllowed Indicates whether multiple calls can take place at the same time. XMLConnector.
-
XMLConnector.direction Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage componentInstance.direction Description Property; indicates whether data is being sent, received, or both. The values are the following: ■ XML data for the params property is sent by HTTP POST method to the URL for the XML document. Any data that is returned is ignored. The results property is not set to anything, and there is no result event.
-
Usage componentInstance.ignoreWhite Description Property; a Boolean value. When this parameter is set to true, the text nodes that contain only white space are discarded during the parsing process. Text nodes with leading or trailing white space are unaffected. The default setting is false. Example The following code sets the ignoreWhite property to true: myXMLConnector.ignoreWhite = true; XMLConnector.multipleSimultaneousAll owed Availability Flash Player 6 (6.0.79.0).
-
Example This example retrieves a remote XML file using the XMLConnector component by setting the direction property to receive. Drag an XMLConnector component into your library, and enter the following code on Frame 1 of the timeline: import mx.data.components.XMLConnector; var xmlListener:Object = new Object(); xmlListener.result = function(evt:Object) { trace("results:"); trace(evt.target.results); trace(""); }; xmlListener.status = function(evt:Object) { trace("status::"+evt.
-
Description Property; specifies data that will be sent to the server when the next trigger() operation is executed. Each RPC component defines how this data is used, and what the valid types are. Example The following example defines name and city parameters for myXMLConnector: myXMLConnector.params = new XML("BobOakland city>"); XMLConnector.result Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage componentInstance.
-
XMLConnector.results Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage componentInstance.results Description Property; identifies data that was received from the server as a result of a trigger() operation. Each RPC component defines how this data is fetched, and what the valid types are. This data appears when the RPC operation has successfully completed, as signaled by the result event. It is available until the component is unloaded, or until the next RPC operation.
-
Description Event; broadcast when the trigger() operation is in process, after the parameter data has been gathered but before the data is validated and the remote procedure call is initiated. This is a good place to put code that modifies the parameter data before the call.
-
The code field for the status event is set to Fault if problems occur with the call, as follows: Code Data Description Fault {faultcode: code, faultstring: string, detail: detail, element: element, faultactor: actor} This event is emitted if other problems occur during the processing of the call. The data is a SOAPFault object. After this event occurs, the attempted call is considered complete, and there is no result or send event.
-
FaultCode FaultString XMLConnector.Results.Parse.Error received data had an XML parsing error NN XMLConnector.Params.Missing Notes The received XML was not valid, as determined by the Flash Player built-in XML parser. To see the possible errors NN, see XML.status in ActionScript 2.0 Language Reference. Direction is 'send' or 'send/receive', but params are null.
-
Example This example displays an error because the required parameters are not being passed. Drag an XMLConnector component into your library, and enter the following code on Frame 1 of the timeline: import mx.data.components.XMLConnector; var xmlListener:Object = new Object(); xmlListener.result = function(evt:Object) { trace("results:"); trace(evt.target.results); trace(""); }; xmlListener.status = function(evt:Object) { switch (evt.code) { case 'Fault' : trace("ERROR! ["+evt.data.
-
XMLConnector.trigger() Availability Flash Player 6 (6.0.79.0). Edition Flash MX Professional 2004. Usage componentInstance.trigger() Description Method; initiates a remote procedure call by the XMLConnector component. This can be either getting or posting to the specified XML file. If the operation is successful, the results of the operation appear in the RPC component’s results property. The trigger() method performs the following steps: 1.
-
Example This example retrieves a remote XML file using the XMLConnector by setting the direction property to receive. Drag an XMLConnector component into your library, and enter the following code on Frame 1 of the timeline: import mx.data.components.XMLConnector; var xmlListener:Object = new Object(); xmlListener.result = function(evt:Object) { trace("results:"); trace(evt.target.results); trace(""); }; xmlListener.status = function(evt:Object) { trace("status::"+evt.
-
Description Property; the URL that this component uses when carrying out HTTP operations. This URL may be an absolute or relative URL. The URL is subject to all the standard Flash Player security protections (for more information about Flash Player security protections, see “Understanding Security” in Learning ActionScript 2.0 in Flash). Example This example retrieves a remote XML file using the XMLConnector component by setting the direction property to receive.
-
60 CHAPTER 60 XPathAPI class ActionScript Class Name mx.xpath.XPathAPI The XPathAPI class allows you to do simple XPath searches within Macromedia Flash. This can be very useful for searching XML packets based on node names and attribute values. In other words, you can quickly find nodes and attributes in an XML document using the XpathAPI methods.
-
1506 XPathAPI class
-
CHAPTER 61 61 XUpdateResolver component (Flash Professional only) Resolver components are used with the DataSet component (part of the data management functionality in the Flash data architecture) to save changes to an external data source. Resolvers take a DataSet.deltaPacket object and convert it to an update packet in a format appropriate to the type of resolver. The update packet can then be transmitted to the external data source by one of the connector components.
-
Using the XUpdateResolver component (Flash Professional only) The XUpdateResolver component is used only when your Flash application contains a DataSet component and must send an update back to an external data source. The XUpdateResolver component communicates with the DataSet component by using the DataSetDeltaToXUpdateDelta encoder. This encoder creates XPath statements that uniquely identify nodes within an XML file according to the information contained in the DataSet component’s delta packet.
-
The following is an example of an XML update packet when the includeDeltaPacketInfo parameter is set to true: Common workflow for the XUpdateResolver component The following procedure outlines the typical workflow for the XUpdateResolver component.
-
8. Select Encoder Options and enter the rowNodeKey value that uniquely identifies the row node within the XML file. NO T E 9. The rowNodeKey value combines an XPath statement with a field parameter to define how unique XPath statements should be generated for the update data contained within the delta packet. See information on the DataSetDeltaToXUpdateDelta encoder in “Schema encoders” in Using Flash.
-
XUpdateResolver class (Flash Professional only) Inheritance MovieClip > XUpdateResolver ActionScript Class Name mx.data.components.XUpdateResolver The properties and events of the XUpdateResolver class allow you to work with the DataSet component to save changes to external data sources. Property summary for the XUpdateResolver class The following table lists properties of the XUpdateResolver class. Property Description XUpdateResolver.
-
XUpdateResolver.beforeApplyUpdates Availability Flash Player 7. Edition Flash MX Professional 2004. Usage resolveData.beforeApplyUpdates(eventObject) Parameters Resolver event object; describes the customizations to the XML packet before the update is sent through the connector to the database. This event object should contain the following properties: eventObject Property Description target Object; the resolver generating this event. type String; the name of the event.
-
XUpdateResolver.deltaPacket Availability Flash Player 7. Edition Flash MX Professional 2004. Usage resolveData.deltaPacket Description Property; contains a description of the changes to the DataSet component. This property is of type deltaPacket and receives a delta packet to be translated into an XUpdate packet, and outputs a delta packet from any server results placed in the updateResults property.
-
XUpdateResolver.includeDeltaPacketInfo Availability Flash Player 7. Edition Flash MX Professional 2004. Usage resolveData.includeDeltaPacketInfo Description Property; a Boolean property that, if true, includes additional information from the delta packet in attributes on the XUpdate nodes. This information consists of the transaction ID and operation ID. For an example of the resulting XML, see “XUpdateResolver component parameter” on page 1508. XUpdateResolver.
-
Description Event; called by the resolver component to compare two packets. Use this callback to insert any code after the results have been received from the server and immediately before the transmission, through data binding, of the delta packet that contains operation results. This is a good place to put code that handles messages from the server. Example The following example reconciles two update packets and clears the updates on success: on (reconcileResults) { // Examine results.
-
XUpdateResolver.xupdatePacket Availability Flash Player 7. Edition Flash MX Professional 2004. Usage resolveData.xupdatePacket Description Property; property of type xml that contains the XUpdate translation of the changes to the DataSet component. Bind this property to the connector component’s property that transmits the translated update packet of changes back to the DataSet component.
-
Index A Accordion component applying easing methods to 1315 creating applications 37 customizing 40 events 50 inheritance 47 methods 47 package 47 parameters 36 properties 49 using skins 42 using styles 41 activators, menu 945 Alert component creating applications 66 customizing 67 events 74 inheritance 71 methods 71 package 71 parameters 66 properties 73 using skins 69 using styles 67 authentication and WebService class 1441 B behaviors and video playback 841 Binding class about 208 methods 209 borders.
-
CheckBox 135 ComboBox 165 ComponentMixins 226 CustomFormatter 212 CustomValidator 216 data binding 207 DataGrid 262 DataGridColumn 300 DataHolder 315 DataSet 335 DataType 233 DateChooser 417 DateField 439 Delegate 461 DeltaItem 463 DepthManager 487 EndPoint 220 EventDispatcher 499 FLVPlayback 539 FocusManager 721 Form 735 Label 755 List 770 Loader 817 Log 1414 Media 847 Menu 883 MenuBar 951 MenuDataProvider 933 NumericStepper 975 PendingCall 1423 PopUpManager 987 ProgressBar 999 RadioButton 1029 RDBMSResolv
-
D data binding classes about 207 Binding class 208 ComponentMixins class 226 CustomValidator class 216 DataType class 233 EndPoint class 220 package 208 TypedValue class 245 using at runtime 207 data components 31 data models DataGrid component 252 Menu component 886 data sets.
-
Delta interface about 469 methods 469 DeltaItem class about 463 properties 463 DeltaPacket interface about 479 methods 480 DepthManager class 487 methods 488 detail property PendingCall.onFault 1431 WebService.onFault 1446 E easing classes and methods, Tween class 1314 element PendingCall.onFault 1431 WebService.onFault 1446 EndPoint class about 220 methods 221 event object 499 EventDispatcher class about 499 methods 500 package 500 events event object 499 I F faultactor property PendingCall.
-
L Label component about 751 creating applications 753 customizing 753 events 757 inheritance 755 methods 755 package 755 parameters 752 properties 756 using styles 753 List component about 761 creating applications 764 customizing 766 design 109 events 775 inheritance 770 methods 771 package 770 parameters 764 properties 773 scrolling behavior 110 using skins 770 using styles 766 Loader component about 813 creating applications 815 customizing 816 events 820 inheritance 817 methods 817 package 817 parameter
-
MenuDataProvider class about 933 events 934 methods 934 multipleSimultaneousAllowed parameter 1450 N NumericStepper component about 969 creating applications 971 customizing 972 events 978 methods 976 parameters 970 properties 977 using skins 974 using styles 973 O onFault callback function 1446 operation parameter 1450 P PendingCall class about 1423 callbacks 1425 methods 1424 properties 1424 PopUpManager class 987 ProgressBar component about 991 creating applications 993 customizing 996 events 1002 met
-
inheritance 1138 methods 1138 package 1138 parameters 1136 properties 1140 SOAPCall class about 1434 properties 1435 SOAPFault object 1446 StyleManager class about 1171 methods 1171 styles RectBorder class 1064 See also individual component names suppressInvalidCalls parameter 1450 SystemManager class about 1175 properties 1175 T tab order, for components 721 tables.
-
U W UI components 30 UIComponent class about 1339 events 1342 inheritance 1339 methods 1340 package 1339 properties 1341 UIEventDispatcher class about 1351 events 1352 methods 1351 UIObject class 1359 about 1311, 1359 events 1312, 1361 inheritance 1359 methods 1311, 1360 package 1359 properties 1312, 1360 UIScrollBar component about 1389 creating applications 1390 customizing 1393 events 1399 inheritance 1395 methods 1396 package 1395 parameters 1390 properties 1397 using skins 1394 using styles 1393 user
-
XUpdateResolver component about 1507 common workflow 1509 events 1511 parameters 1508 properties 1511 Index 1525
-
1526 Index