MACROMEDIA DIRECTOR MX 2004-USING DIRECTOR Using Manual

Other manuals for DIRECTOR MX 2004-USING DIRECTOR: Using Manual, Using Manual, Using Manual, Using Manual, Using Manual

Summary of DIRECTOR MX 2004-USING DIRECTOR

  • Page 1

    Using components.

  • Page 2

    Trademarks add life to the web, afterburner, aftershock, andromedia, allaire, animation powerpack, aria, attain, authorware, authorware star, backstage, bright tiger, clustercats, coldfusion, contribute, design in motion, director, dream templates, dreamweaver, drumbeat 2000, edje, ejipt, extreme 3d...

  • Page 3: Contents

    3 contents introduction: getting started with components . . . . . . . . . . . . . . . . . . . . . . . 7 intended audience . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 system requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . ....

  • Page 4

    4 contents deleting components from flash documents. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50 using code hints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50 creating custom focus navigation . . . . . . . . . . . . . . . . . ....

  • Page 5

    Contents 5 loader component . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 484 media components (flash professional only) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 497 menu component (flash professional only) . . . . . . . . . . . . . . . ...

  • Page 6

    6 contents appendix: collection properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 959 defining a collection property . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 960 simple collection example . . . . . . . . . . . . . . . . . . . . . ...

  • Page 7: Introduction

    7 introduction getting started with components macromedia flash mx 2004 and macromedia flash mx professional 2004 are the professional standard authoring tools for producing high-impact web experiences. Components are the building blocks for the rich internet applications that provide those experien...

  • Page 8

    8 introduction: getting started with components if you are less experienced with writing actionscript, you can add components to a document, set their parameters in the property inspector or component inspector, and use the behaviors panel to handle their events. For example, you could attach a go t...

  • Page 9

    Additional resources 9 terms used in this manual the following terms are used in this manual: at runtime when the code is running in flash player. While authoring while you are working in the flash authoring environment. Additional resources for the latest information on flash, plus advice from expe...

  • Page 10

    10 introduction: getting started with components.

  • Page 11: Chapter 1

    11 chapter 1 about components components are movie clips with parameters that allow you to modify their appearance and behavior. A component can be a simple user interface control, such as a radio button or a check box, or it can contain content, such as a scroll pane; a component can also be non-vi...

  • Page 12

    12 chapter 1: about components about version 2 component architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 what’s new in version 2 components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 about compiled clip...

  • Page 13

    Where component files are stored 13 • rdbmsresolver component (flash professional only) • screen class (flash professional only) • slide class (flash professional only) • tree component (flash professional only) • webserviceconnector class (flash professional only) • xmlconnector component (flash pr...

  • Page 14

    14 chapter 1: about components if you’ve added components, you’ll need to refresh the components panel. To refresh the contents of the components panel: • select reload from the components panel menu. To remove a component from the components panel: • remove the mxp or fla file from the configuratio...

  • Page 15

    About version 2 component architecture 15 categories of components components included with flash mx 2004 and flash mx professional 2004 fall into the following five categories (the locations of their actionscript source files roughly correspond to these categories as well and are listed in parenthe...

  • Page 16

    16 chapter 1: about components version 2 components are included in the components panel as compiled clip (swc) symbols. A compiled clip is a component movie clip whose code has been compiled. Compiled clips cannot be edited, but you can change their parameters in the property inspector and componen...

  • Page 17

    About compiled clips and swc files 17 the halo theme provides a ready-made, responsive, and flexible user interface for applications. Halo is the default theme that the version 2 components use. (see “about themes” on page 77 .) manager classes provide an easy way to handle focus and depth in a appl...

  • Page 18

    18 chapter 1: about components accessibility and components a growing requirement for web content is that it should be accessible; that is, usable for people with a variety of disabilities. Visual content in flash applications can be made accessible to the visually impaired with the use of screen re...

  • Page 19: Chapter 2

    19 chapter 2 creating an application with components (flash professional only) components in flash are prebuilt elements that you can use when creating flash applications, to add user interface controls, data connectivity, and other functionality. Components can save you work when you’re building an...

  • Page 20

    20 chapter 2: creating an application with components (flash professional only) you can modify the appearance and behavior of components by setting component parameters in the authoring environment, using the parameters tab in either the property inspector or the component inspector. You can also co...

  • Page 21

    View the application 21 if you are experienced with building application architecture in flash, you may want to skip the first section of the tutorial and read the second and third sections while referring to the finished fla file of the sample application, to learn about the procedures used to bind...

  • Page 22

    22 chapter 2: creating an application with components (flash professional only) on the checkout screen, click the billing information, shipping information, and credit card information headers to view the form fields for each of these items. To place an order, you can add the appropriate information...

  • Page 23

    Build the application architecture 23 • the webservice class is part of a set of web service classes, which provides a set of methods, events, and properties that enable you to connect to a web service. The webservice class is different from the webserviceconnector component. (the webserviceconnecto...

  • Page 24

    24 chapter 2: creating an application with components (flash professional only) 4. Make sure the form layer is selected. In the components panel (window > development panels > components), locate the combobox component in the ui components folder. Drag an instance of combobox onto the stage. Place i...

  • Page 25

    Build the application architecture 25 create a movie clip with component instances to display product details in the application, a pop-up window appears when a user clicks on a product in the gift ideas section. The pop-up window contains component instances that display information for the product...

  • Page 26

    26 chapter 2: creating an application with components (flash professional only) 7. Drag an instance of the label component from the ui components folder in the components panel onto the stage. Place it below the loader component. Set the x, y coordinates to 5, 145. Enter price_lbl for the instance n...

  • Page 27

    Build the application architecture 27 next, the code populates the textarea and label instances by using the description , price , and pricequalifier properties of the thisproduct object. These properties correspond to elements in the products.Xml file that you linked to the products_xmlcon xmlconne...

  • Page 28

    28 chapter 2: creating an application with components (flash professional only) later in the tutorial, you’ll create movie clips to use as children in the accordion instance, to display the billing, shipping, and credit card information panes. 1. In the main timeline for the application, move the pl...

  • Page 29

    Build the application architecture 29 8. In the create new symbol dialog box, enter checkout1_sub_mc for name and select movie clip for behavior. 9. Click the advanced button. Under linkage, select export for actionscript, leave export in first frame selected, and click ok. A document window for the...

  • Page 30

    30 chapter 2: creating an application with components (flash professional only) 14. In the tools panel, select the rectangle tool. Set the stroke color to none and the fill color to white. Click the stroke color control in the tools panel and click the none button—the white swatch with a red line th...

  • Page 31

    Bind components to display product information from an external source 31 2. Drag four instances of the label component onto the stage. Name and position the instances as follows: ■ for the first instance, enter ccname_lbl for the instance name and set the x and y coordinates to 5, 5. Click the para...

  • Page 32

    32 chapter 2: creating an application with components (flash professional only) specify a schema for the xml data source when you connect to an external xml data source with the xmlconnector component, you need to specify a schema—a schematic representation which identifies the structure of the xml ...

  • Page 33

    Add actionscript to the main timeline 33 8. On the stage, select the products_ds instance. In the bindings tab of the component inspector, notice that the component’s data provider appears in the binding list (the top pane of the bindings tab). In the binding attributes pane, the bound to parameter ...

  • Page 34

    34 chapter 2: creating an application with components (flash professional only) ui components controls package this package contains classes for the user interface control components, including combobox, datagrid, loader, textinput, label, numericstepper, button, and checkbox. A package is a directo...

  • Page 35

    Add actionscript to the main timeline 35 add an instance of the cart class and initialize it the next code that you’ll add creates an instance of the custom cart class and then initializes the instance. • in the actions panel, add the following code: var mycart:cart = new cart(this); mycart.Init(); ...

  • Page 36

    36 chapter 2: creating an application with components (flash professional only) add columns to the gift ideas section now you’re ready to add columns to the data grid in the gift ideas section of the application, for displaying product information and price. • in the actions panel, add the following...

  • Page 37

    Add actionscript to the main timeline 37 }; // if you are unable to connect to the remote web service, display the // error messages in the output panel. Myproblems.Onfault = function(error:object) { trace("error:"); for (var prop in error) { trace(" "+prop+" -> "+error[prop]); } }; load the externa...

  • Page 38

    38 chapter 2: creating an application with components (flash professional only) resetting the filtered property (setting it to false and then to true ) at the beginning of the change() function ensures that the function will work properly if the user changes the what did you do? Selection repeatedly...

  • Page 39

    Add actionscript to the main timeline 39 add an event listener to the checkout button now you’ll add code to display the checkout screen when the user clicks the checkout button. • in the actions panel, add the following code: // when the checkout button is clicked, go to the "checkout" frame label ...

  • Page 40

    40 chapter 2: creating an application with components (flash professional only) checkboxlistener.Click = function(evt:object) { if (evt.Target.Selected) { thischild2.Shippingfirstname_ti.Text = thischild1.Billingfirstname_ti.Text; thischild2.Shippinglastname_ti.Text = thischild1.Billinglastname_ti.T...

  • Page 41

    Test the application 41 var response_lv:loadvars = new loadvars(); var checkout_lv:loadvars = new loadvars(); checkout_lv.Billingfirstname = thischild1.Billingfirstname_ti.Text; checkout_lv.Billinglastname = thischild1.Billinglastname_ti.Text; checkout_lv.Billingcountry = thischild1.Billingcountry_t...

  • Page 42

    42 chapter 2: creating an application with components (flash professional only).

  • Page 43: Chapter 3

    43 chapter 3 working with components in this chapter, you’ll use several macromedia flash (fla) files and actionscript class files to learn how to add components to a document and set their properties. This chapter also explains a few advanced topics such as using code hints, creating custom focus n...

  • Page 44

    44 chapter 3: working with components the components panel all components in the user-level configuration/components directory are displayed in the components panel. (for more information about this directory, see “where component files are stored” on page 13 .) to display the components panel: • se...

  • Page 45

    Adding components to flash documents 45 3. If the component is a fla (all installed version 2 components are swc files) and if you have edited skins for another instance of the same component, or for a component that shares skins with the component you are adding, do one of the following: ■ select d...

  • Page 46

    46 chapter 3: working with components adding components at runtime with actionscript use the createclassobject() method (which most components inherit from the uiobject class) to add components to a flash application dynamically. For example, you could add components that create a page layout based ...

  • Page 47

    Setting component parameters 47 alternatively, you can import the class package, as in this example: import mx.Controls.Checkbox; createclassobject(checkbox, "cb", 5, {label:"check me"}); for more information, see uiobject.Createclassobject() on page 810 and chapter 4, “handling component events,” o...

  • Page 48

    48 chapter 3: working with components you can set parameters for a component instance using the component inspector or the property inspector (it doesn’t matter which panel you use). To enter an instance name for a component in the property inspector: 1. Select window > properties. 2. Select an inst...

  • Page 49

    Sizing components 49 sizing components use the free transform tool or the setsize() method to resize component instances. Resizing the menu component on the stage with the free transform tool you can call the setsize() method from any component instance (see uiobject.Setsize() on page 823 ) to resiz...

  • Page 50

    50 chapter 3: working with components deleting components from flash documents to delete a component’s instances from a flash document, you must delete the component from the library by deleting the compiled clip icon. It isn’t enough to delete the component from the stage. To delete a component fro...

  • Page 51

    Managing component depth in a document 51 comment.Tabindex = 1; okbutton.Tabindex = 2; you can also use the accessibility panel to assign a tab index value. If nothing on the stage has a tab index value, the focus manager uses the depth levels (z-order). The depth levels are set up primarily by the ...

  • Page 52

    52 chapter 3: working with components components in live preview the live preview feature, enabled by default, lets you view components on the stage as they will appear in the published flash content; the components appear at their approximate size. The live preview reflects different parameters for...

  • Page 53

    Upgrading version 1 components to version 2 architecture 53 upgrading version 1 components to version 2 architecture the version 2 components were written to comply with several web standards (regarding events [ www.W3.Org/tr/dom-level-3-events/events.Html ], styles, getter/setter policies, and so o...

  • Page 54

    54 chapter 3: working with components.

  • Page 55: Chapter 4

    55 chapter 4 handling component events every component has events that are broadcast when a user interacts with it (for example, the click and change events) or when something significant happens to the component (for example, the load event). To handle an event, you write actionscript code that exe...

  • Page 56

    56 chapter 4: handling component events the keyword this , used inside an on() handler attached to a component, refers to the component instance. For example, the following code, attached to the button component instance mybutton , sends “_level0.Mybutton” to the output panel: on(click){ trace(this)...

  • Page 57

    Using listeners to handle events 57 • to register a listener to a broadcaster, call the addeventlistener() method from the broadcaster. Use the following syntax: componentinstance.Addeventlistener("eventname", listenerobjectorfunction); • you can register multiple listeners to one component instance...

  • Page 58

    58 chapter 4: handling component events // your code here }; tip: the evtobj parameter is an object that is automatically generated when an event is triggered and passed to the callback function. The event object has properties that contain information about the event. For details, see “about the ev...

  • Page 59

    Using listeners to handle events 59 8. In the actions panel, enter the following code: var mybutton:mx.Controls.Button; var mytext:mx.Controls.Textinput; function click(evt){ mytext.Text = evt.Target; } mybutton.Addeventlistener("click", this); the target property of the event object, evt , is a ref...

  • Page 60

    60 chapter 4: handling component events function handleevent(evt){ // check if the event was a click if (evt.Type == "click"){ // do something if the event was click } else if (evt.Type == "change"){ // do something else if the event was change } }; // register the listener object to // two differen...

  • Page 61

    Using listeners to handle events 61 4. Select frame 1 in the timeline. 5. Select window > development panels > actions. 6. In the actions panel, enter the following code: // declare variables var mylist:mx.Controls.List; var myhandler:function; // add items to the list mylist.Additem("bird"); mylist...

  • Page 62

    62 chapter 4: handling component events as discussed earlier, you register a listener with a component instance by calling addeventlistener() . This method takes two parameters: a string indicating the name of the event, and a reference to either an object or a function. The following table lists th...

  • Page 63

    Delegating events 63 trace("this: " + this); trace("mygrid: " + mygrid); } } // register the myhandler function with mybutton // when the button is clicked, myhandler executes function onload():void{ mybutton.Addeventlistener("click", myhandler); } } delegating events you can import the delegate cla...

  • Page 64

    64 chapter 4: handling component events var mybutton_btn:button; function onload() { mycheckbox_chb.Addeventlistener("click", this); mybutton_btn.Addeventlistener("click", this); } function click(eventobj:object) { switch(eventobj.Target) { case mybutton_btn: // sends the broadcaster instance name /...

  • Page 65

    Delegating events 65 delegating the scope of a function the addeventlistener() method requires two parameters: the name of an event and a reference to a listener. The listener can either be an object or a function. If you pass an object, the callback function assigned to the object is invoked in the...

  • Page 66

    66 chapter 4: handling component events // from the chb_onclick function var i:number = 10 function onload() { mycheckbox_chb.Addeventlistener("click", delegate.Create(this, chb_onclick)); } function chb_onclick(eventobj:object) { // sends 10 to the output panel // because the function is scoped to ...

  • Page 67: Chapter 5

    67 chapter 5 customizing components you might want to change the appearance of components as you use them in different applications. There are three ways to accomplish this in macromedia flash mx 2004 and macromedia flash mx professional 2004: • use the setstyle() method of each component and style ...

  • Page 68

    68 chapter 5: customizing components you can use styles to customize a component in the following ways: • set styles on a component instance. You can change color and text properties of a single component instance. This is effective in some situations, but it can be time consuming if you need to set...

  • Page 69

    Using styles to customize component color and text 69 setting styles on a component instance you can write actionscript code to set and get style properties on any component instance. The uiobject.Setstyle() and uiobject.Getstyle() methods can be called directly from any component. The following syn...

  • Page 70

    70 chapter 5: customizing components custom style settings have priority over class, inherited, and global style settings. For a list of the styles that each component supports, see the component entries in chapter 6, “components dictionary,” on page 91 . To create a custom style declaration for a g...

  • Page 71

    Using styles to customize component color and text 71 another option in setting custom style declarations is you can assign the cssstyledeclaration instance directly to the component instance’s stylename property and bypass storing the declaration in _global.Styles . To use this approach, modify the...

  • Page 72

    72 chapter 5: customizing components the style manager tells flash whether a style inherits its value. Additional styles can also be added at runtime as inheriting styles. For more information, see “stylemanager class” on page 721 . Note: the css inherit value is not supported. Inherited styles take...

  • Page 73

    Using styles to customize component color and text 73 notice that the fontstyle setting on the accordion component affects not only the accordion text itself but also the text associated with the textinput and button components inside the accordion component. Setting global styles the global style d...

  • Page 74

    74 chapter 5: customizing components 4. If the style is one of the inheriting styles, flash looks through the parent hierarchy for an inherited value. 5. Flash looks for the style in the global style declaration. 6. If the property is still not defined, the property has the value undefined . About c...

  • Page 75

    Using styles to customize component color and text 75 you can use class style declarations and color names to easily control the colors of text and symbols on the screen. For example, if you want to provide a display configuration screen that looks like microsoft windows, you would define color name...

  • Page 76

    76 chapter 5: customizing components each of the classes in the mx.Transitions.Easing package provides the following three easing methods: because the easing methods are static methods of the easing classes, you never need to instantiate the easing classes. The methods are used in calls to setstyle(...

  • Page 77

    About themes 77 about themes themes are collections of styles and skins. The default theme for flash mx 2004 and flash mx professional 2004 is called halo (halotheme.Fla). The halo theme lets you provide a responsive, expressive experience for your users. Flash mx 2004 and flash mx professional 2004...

  • Page 78

    78 chapter 5: customizing components 4. Double-click any skin symbol you want to modify to open it in symbol-editing mode. The skins are located in the flash ui components 2/themes/mmdefault/component assets folder (this example uses radiobutton assets). 5. Modify the symbol or delete the graphics a...

  • Page 79

    About themes 79 9. Modify all references to the source theme’s package to the new theme’s package. For example, change all occurrences of “halo” to “mytheme”. 10. Save the changed focusrect class file. 11. Open the fla file for your custom theme. This example uses mytheme.Fla. 12. Open the library (...

  • Page 80

    80 chapter 5: customizing components 3. Select file > import > open external library, and select the fla file of the theme you want to apply to your document. If you haven’t created a new theme, you can use the sample theme. 4. In the theme’s library panel, select flash ui components 2/themes/mmdefa...

  • Page 81

    About skinning components 81 the as file that defines each component class contains code that loads specific skins for the component. Each component skin corresponds to a skin property that is assigned to a skin symbol’s linkage identifier. For example, the pressed (down) state of the down arrow of ...

  • Page 82

    82 chapter 5: customizing components the procedure described below is very similar to creating and applying a new theme (see “about themes” on page 77 ). The primary difference is that this procedure describes copying symbols directly from the theme already in use to a single document and editing on...

  • Page 83

    About skinning components 83 creating new component skins if you want to use a particular skin for one instance of a component, but another skin for another instance of the component, you must open a theme fla file and create a new skin symbol. Components are designed to make it easy to use differen...

  • Page 84

    84 chapter 5: customizing components to link a skin to a style property: 1. If you already applied the sample theme to a document, skip to step 5. 2. Select file > import > open external library, and select the halotheme.Fla file. This file is located in the application-level configuration folder. F...

  • Page 85

    About skinning components 85 11. Drag an instance of the component to the stage. For this example, drag two radiobutton components to the stage, set one to selected, and use actionscript to set both to disabled in order to see the changes. 12. Add actionscript code to the document to set the new sty...

  • Page 86

    86 chapter 5: customizing components 5. Select the radiobutton component on the stage and open the actions panel. 6. Attach the following code to the radiobutton instance: onclipevent(initialize){ trueupicon = "myradiotrueup"; } 7. Select control > test movie. Applying new skins to a subcomponent in...

  • Page 87

    About skinning components 87 ■ if you want to change a specific scroll bar in a document, enter the following code in the actions panel on frame 1 of the timeline: import mx.Controls.List import mx.Controls.Scrollclasses.Scrollbar var oldname = scrollbar.Prototype.Downarrowdownname; scrollbar.Protot...

  • Page 88

    88 chapter 5: customizing components the following example explains how to skin something that’s already on the stage. This example skins only list scroll bars; any textarea or scrollpane scroll bars would not be skinned. To use #initclip to apply an edited skin to specific components in a document:...

  • Page 89

    About skinning components 89 changing skin properties in the prototype if a component does not directly support skin variables, you can subclass the component and replace its skins. For example, the combobox component doesn’t directly support skinning its drop-down list, because the combobox compone...

  • Page 90

    90 chapter 5: customizing components 13. Enter the following code: import mx.Controls.Combobox import mx.Controls.Scrollclasses.Scrollbar class mycombobox extends combobox{ function getdropdown():object{ var oldname = scrollbar.Prototype.Downarrowdownname; scrollbar.Prototype.Downarrowdownname = "my...

  • Page 91: Chapter 6

    91 chapter 6 components dictionary this reference chapter describes each component and its application programming interface (api). Each component description contains information about the following: • keyboard interaction • live preview • accessibility • setting the component parameters • using th...

  • Page 92

    92 chapter 6: components dictionary data handling checkbox component allows users to make a boolean (true or false) choice. Combobox component allows users to select one option from a scrolling list of choices. This component can have an selectable text field at the top of the list that allows users...

  • Page 93

    Types of components 93 media components for more information on these components, see “media components (flash professional only)” on page 497 . Managers dataprovider api the model for linear-access lists of data; it provides simple array- manipulation capabilities that broadcast data changes. Datas...

  • Page 94

    94 chapter 6: components dictionary screens other listings in this chapter this chapter also describes several classes and apis that don’t fall into the above categories of components. They are listed in the following table. Class description form class (flash professional only) lets you manipulate ...

  • Page 95

    Other listings in this chapter 95 treedataprovider interface (flash professional only) a set of properties and methods used to create xml for the tree.Dataprovider property. Uicomponent class provides methods, properties, and events that allow components to share some common behavior. Uieventdispatc...

  • Page 96: Chapter 6

    96 chapter 6: components dictionary accordion component (flash professional only) the accordion component is a navigator that contains a sequence of children that it displays one at a time. The children must be objects that inherit from the uiobject class (which includes all components and screens b...

  • Page 97

    Accordion component (flash professional only) 97 using the accordion component (flash professional only) you can use the accordion component to present multipart forms. For example, a three-child accordion might present forms where the user fills out her shipping address, billing address, and paymen...

  • Page 98

    98 chapter 6: components dictionary 5. Repeat steps 2-4 to create a screen named checkoutform. 6. Create a new screen named accordionform. 7. Drag an accordion component from the components panel to the accordionform form, and name it myaccordion. 8. With myaccordion selected, in the property inspec...

  • Page 99

    Accordion component (flash professional only) 99 ■ for the childnames property, enter shippingaddress, billingaddress, and checkout. These strings are the actionscript names of the accordion’s children. ■ for the childlabels property, enter shipping address, billing address, and checkout. These stri...

  • Page 100

    100 chapter 6: components dictionary if the headers are too small to contain their label text, the labels are clipped. If the content area of an accordion is smaller than a child, the child is clipped. Using styles with the accordion component you can set style properties to change the appearance of...

  • Page 101

    Accordion component (flash professional only) 101 using skins with the accordion component the accordion component uses skins to represent the visual states of its header buttons. To skin the buttons and title bar while authoring, modify skin symbols in the flash ui components 2/ themes/mmdefault/ac...

  • Page 102

    102 chapter 6: components dictionary to create an actionscript class to use as the skin and provide different states, the skin can read the borderstyle style property of the skin to determine the state. The following table shows the border style that is set for each skin: to create an actionscript c...

  • Page 103

    Accordion component (flash professional only) 103 clear(); linestyle(0, 0, 100); beginfill(c, 100); drawrect(0, 0, __width, __height); endfill(); } // required for skins static function classconstruct():boolean { uiobjectextensions.Extensions(); _global.Skinregistry["accordionheaderskin"] = true; re...

  • Page 104

    104 chapter 6: components dictionary 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 ...

  • Page 105

    Accordion component (flash professional only) 105 accordion class (flash professional only) inheritance movieclip > uiobject class > uicomponent class > view > accordion actionscript class name mx.Containers.Accordion an accordion component contains children that are displayed one at a time. Each ch...

  • Page 106

    106 chapter 6: components dictionary methods inherited from uicomponent class the following table lists the methods the accordion class inherits from the uicomponent class. When calling these methods from the accordion object, use the form accordioninstance.Methodname . Property summary for the acco...

  • Page 107

    Accordion component (flash professional only) 107 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 . Event summary for the acc...

  • Page 108

    108 chapter 6: components dictionary events inherited from the uicomponent class the following table lists the events the accordion class inherits from the uicomponent class. Accordion.Change availability flash player 6 (6.0 79.0). Edition flash mx professional 2004. Usage listenerobject = new objec...

  • Page 109

    Accordion component (flash professional only) 109 example in the following example, a handler called myaccordionlistener is defined and passed to the myaccordion.Addeventlistener() method as the second parameter. The event object is captured by the change handler in the eventobject parameter. When t...

  • Page 110

    110 chapter 6: components dictionary example the following code creates an instance of the paymentform movie clip symbol named payment as the last child of myaccordion : var child = myaccordion.Createchild("paymentform", "payment", {label: "payment", icon: "payicon"}); child.Cardtype.Text = "visa"; ...

  • Page 111

    Accordion component (flash professional only) 111 description method; creates a child for the accordion. The newly created child is added to the end of the list of children owned by the accordion. Use this method to place views inside the accordion. The created child is an instance of the class or m...

  • Page 112

    112 chapter 6: components dictionary returns nothing. Description method (inherited from view); destroys one of the accordion’s children. The child to be destroyed is specified by its index, which is passed to the method in the index parameter. Calling this method destroys the corresponding header a...

  • Page 113

    Accordion component (flash professional only) 113 accordion.Numchildren availability flash player 6 (6.0 79.0). Edition flash mx professional 2004. Usage myaccordion.Numchildren description property (inherited from view); indicates the number of children (of type uiobject) in an accordion instance. ...

  • Page 114

    114 chapter 6: components dictionary the default value is myaccordion.Getchildat(0) if the accordion has children. If the accordion doesn’t have children, the default value is undefined . Example the following example retrieves the label of the selected child view: var selectedlabel = myaccordion.Se...

  • Page 115: Chapter 6

    Alert component (flash professional only) 115 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 whos...

  • Page 116

    116 chapter 6: components dictionary 3. In the actions panel, enter the following code on frame 1 of the timeline to define an event handler for the click event: import mx.Controls.Alert; myclickhandler = function (evt){ if (evt.Detail == alert.Ok){ trace("start stock app"); // startstockapplication...

  • Page 117

    Alert component (flash professional only) 117 the alert component includes three different categories of text. Setting the text properties for the alert component itself provides default values for all three categories, as shown here: import mx.Controls.Alert; _global.Styles.Alert.Setstyle("color", ...

  • Page 118

    118 chapter 6: components dictionary the following example demonstrates how to set the title of an alert component to be italicized: import mx.Controls.Alert; import mx.Styles.Cssstyledeclaration; var titlestyles = new cssstyledeclaration(); titlestyles.Setstyle("fontweight", "bold"); titlestyles.Se...

  • Page 119

    Alert component (flash professional only) 119 4. If the advanced view is not displayed, click the advanced button. 5. Select export for actionscript. 6. The identifier will be automatically filled out with titlebackground . 7. Set the as 2.0 class to mx.Skins.Skinelement . Skinelement is a simple cl...

  • Page 120

    120 chapter 6: components dictionary to understand more about the alert class, see “window component” on page 878 and “popupmanager class” on page 601 . Method summary for the alert class the following table lists the method of the alert class. Methods inherited from the uiobject class the following...

  • Page 121

    Alert component (flash professional only) 121 property summary for the alert class the following table lists properties of the alert class. Properties inherited from the uiobject class the following table lists the properties the alert class inherits from the uiobject class. When calling these prope...

  • Page 122

    122 chapter 6: components dictionary properties inherited from the uicomponent class the following table lists the properties the alert class inherits from the uicomponent class. When calling these properties from the alert object, use the form alert.Propertyname . Properties inherited from the wind...

  • Page 123

    Alert component (flash professional only) 123 events inherited from the uicomponent class the following table lists the events the alert class inherits from the uicomponent class. When calling these events from the alert object, use the form alert.Eventname . Events inherited from the window class t...

  • Page 124

    124 chapter 6: components dictionary alert.Buttonwidth availability flash player 6 (6.0 79.0). Edition flash mx professional 2004. Usage alert.Buttonwidth description property (class); a class (static) property that changes the width of the buttons. The default value is 100. See also alert.Buttonhei...

  • Page 125

    Alert component (flash professional only) 125 alert.Cancellabel availability flash player 6 (6.0 79.0). Edition flash mx professional 2004. Usage alert.Cancellabel description property (class); a class (static) property that indicates the label text on the cancel button. Example the following exampl...

  • Page 126

    126 chapter 6: components dictionary example in the following example, a handler called myclickhandler is defined and passed to the alert.Show() method as the fifth parameter. The event object is captured by myclickhandler in the evt parameter. The detail property of the event object is then used in...

  • Page 127

    Alert component (flash professional only) 127 alert.Nolabel availability flash player 6 (6.0 79.0). Edition flash mx professional 2004. Usage alert.Nolabel description property (class); a class (static) property that indicates the label text on the no button. Example the following example sets the n...

  • Page 128

    128 chapter 6: components dictionary 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’...

  • Page 129

    Alert component (flash professional only) 129 clickhandler a handler for the click events broadcast when the buttons are clicked. In addition to the standard click event object properties, there is an additional detail property, which contains the flag value of the button that was clicked ( alert.Ok...

  • Page 130

    130 chapter 6: components dictionary alert.Yes availability flash player 6 (6.0 79.0). Edition flash mx professional 2004. Usage alert.Yes description property (constant); a property with the constant hexadecimal value 0x1. This property can be used for the flags or defaultbutton parameter of the al...

  • Page 131: Chapter 6

    Button component 131 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 ag...

  • Page 132

    132 chapter 6: components dictionary button parameters you can set the following authoring parameters for each button component instance in the property inspector or in the component inspector: label sets the value of the text on the button; the default value is button. Icon adds a custom icon to th...

  • Page 133

    Button component 133 customizing the button component you can transform a button component horizontally and vertically while authoring and at runtime. While authoring, select the component on the stage and use the free transform tool or any of the modify > transform commands. At runtime, use the set...

  • Page 134

    134 chapter 6: components dictionary using skins with the button component the button component includes 32 different skins that can be customized to correspond to the border and icon in 16 different states. To skin the button component while authoring, create new movie clip symbols with the desired...

  • Page 135

    Button component 135 if a button is enabled, it displays its over state when the pointer moves over it. The button receives input focus and displays its down state when it’s pressed. The button returns to its over state when the mouse is released. If the pointer moves off the button while the mouse ...

  • Page 136

    136 chapter 6: components dictionary the default value for all skin properties ending in “skin” is buttonskin , and the default for all “icon” properties is undefined . The properties with the “skin” suffix provide a background and border, whereas those with the “icon” suffix provide a small icon. I...

  • Page 137

    Button component 137 to create an actionscript customized button skin: 1. Create a new actionscript class file. For this example, name the file redgreenblueskin.As. 2. Copy the following actionscript to the file: import mx.Skins.Rectborder; import mx.Core.Ext.Uiobjectextensions; class redgreenbluesk...

  • Page 138

    138 chapter 6: components dictionary this class creates a square box based on the border style: a blue box for the false up, rollover, and disabled states; a green box for the normal pressed state; and a red box for the expanded child. It draws a hairline border in the normal case and a thick border...

  • Page 139

    Button component 139 12. Repeat steps 2-11 and create green and blue skins, named accordingly. 13. Click the back button to return to the main timeline. 14. Drag a button component to the stage. 15. Set the toggled property value to true to see all three skins. 16. Copy the following actionscript co...

  • Page 140

    140 chapter 6: components dictionary method summary for the button class there are no methods exclusive to the button class. Methods inherited from the uiobject class the following table lists the methods the button class inherits from the uiobject class. When calling these methods from the button o...

  • Page 141

    Button component 141 properties inherited from the simplebutton class the following table lists the properties the button class inherits from the simplebutton class. When accessing these properties, use the form buttoninstance.Propertyname . Properties inherited from the uiobject class the following...

  • Page 142

    142 chapter 6: components dictionary properties inherited from the uicomponent class the following table lists the properties the button class inherits from the uicomponent class. When accessing these properties from the button object, use the form buttoninstance.Propertyname . Event summary for the...

  • Page 143

    Button component 143 button.Icon availability flash player 6 (6.0 79.0). Edition flash mx 2004. Usage buttoninstance.Icon description property; a string that specifies the linkage identifier of a symbol in the library to be used as an icon for a button instance. The icon can be a movie clip symbol o...

  • Page 144

    144 chapter 6: components dictionary description property; specifies the text label for a button instance. By default, the label appears centered on the button. Calling this method overrides the label authoring parameter specified in the property inspector or the component inspector. The default val...

  • Page 145: Chapter 6

    Cellrenderer api 145 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, suc...

  • Page 146

    146 chapter 6: components dictionary because of this scrolling behavior, you cannot expect a cell to be used for only one value. Recycling of rows means that the cell renderer must know how to completely reset its state when it is set to a new value. For example, if your cell renderer creates an ico...

  • Page 147

    Cellrenderer api 147 simple cell renderer example this section presents an example of a cell renderer that displays multiple lines of text in a cell. A cell renderer class must implement the following methods: • cellrenderer.Getpreferredheight() • cellrenderer.Getpreferredwidth() this method is nece...

  • Page 148

    148 chapter 6: components dictionary var c = multilinelabel = createlabel("multilinelabel", 10); // links the style of the label to the // style of the grid c.Stylename = listowner; c.Selectable = false; c.Tabenabled = false; c.Background = false; c.Border = false; c.Multiline = true; c.Wordwrap = t...

  • Page 149

    Cellrenderer api 149 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. Properties provided by the cellrenderer api the list, datagrid, tree...

  • Page 150

    150 chapter 6: components dictionary this method is provided by the list class; you do not have to implement it. Declare it in your cell renderer class as follows, and use it in the functions in your cell renderer: var getcellindex:function; example this example edits a datagrid component’s data pro...

  • Page 151

    Cellrenderer api 151 usage componentinstance.Getpreferredheight() parameters none. Returns the correct height for the cell. Description method; returns the preferred height of a cell. This is especially important for getting the right height of text within the cell. If you set this value higher than...

  • Page 152

    152 chapter 6: components dictionary returns a value (of type number) that indicates the correct width of the cell. Description method; the preferred width of a cell. If you specify a width greater than that of the component, the cell may be cut off. You need to implement this method only for the me...

  • Page 153

    Cellrenderer api 153 cellrenderer.Owner availability flash player 6 (6.0 79.0). Edition flash mx 2004. Usage componentinstance.Owner description property; a reference to the row that contains the cell. This method is provided by the list class; you do not have to implement it. Declare it in your cel...

  • Page 154

    154 chapter 6: components dictionary example this example sizes an image in the cell to fit within the bounds specified by the list: function setsize(w:number, h:number):void { image._width = w-2; image._height = h-2; image._x = image._y = 1; } this example is in a cell renderer class that extends u...

  • Page 155

    Cellrenderer api 155 description method; takes the values given and creates a representation of them in the cell. This resolves any difference between what was displayed in the cell and what needs to be displayed in the cell for the new item. (remember that any cell could display many values during ...

  • Page 156

    156 chapter 6: components dictionary if (mycheck.Enabled!=itm.Enabled){ mycheck.Enabled = itm.Enabled; } } if you want to enable the check box on the second row, you communicate through the data provider. Any change to the data provider (when made through a dataprovider method such as dataprovider.E...

  • Page 157: Chapter 6

    Checkbox component 157 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 applic...

  • Page 158

    158 chapter 6: components dictionary checkbox parameters you can set the following authoring parameters for each checkbox component instance in the property inspector or in the component inspector: label sets the value of the text on the check box; the default value is defaultvalue . Selected sets t...

  • Page 159

    Checkbox component 159 customizing the checkbox component you can transform a checkbox component horizontally and vertically while authoring and at runtime. While authoring, select the component on the stage and use the free transform tool or any of the modify > transform commands. At runtime, use t...

  • Page 160

    160 chapter 6: components dictionary 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. The checkbox component skins are located in the flash u...

  • Page 161

    Checkbox component 161 3. In the theme’s library panel, expand the flash ui components 2/themes/mmdefault folder and drag the checkbox assets folder to the library for your document. 4. Expand the checkbox assets/states folder in the library of your document. 5. Open the symbols you want to customiz...

  • Page 162

    162 chapter 6: components dictionary 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 . Methods inherited from the uicompo...

  • Page 163

    Checkbox component 163 properties inherited from the uiobject class the following table lists the properties the checkbox class inherits from the uiobject class. When accessing these properties from the checkbox object, use the form checkboxinstance.Propertyname . Properties inherited from the uicom...

  • Page 164

    164 chapter 6: components dictionary properties inherited from the simplebutton class the following table lists the properties the checkbox class inherits from the simplebutton class. When accessing these properties from the checkbox object, use the form checkboxinstance.Propertyname . Properties in...

  • Page 165

    Checkbox component 165 events inherited from the uicomponent class the following table lists the events the checkbox class inherits from the uicomponent class. Events inherited from the simplebutton class the following table lists the event the checkbox class inherits from the simplebutton class. Ch...

  • Page 166

    166 chapter 6: components dictionary the first usage example uses an on() handler and must be attached directly to a checkbox instance. The keyword this , used inside an on() handler attached to a component, refers to the component instance. For example, the following code, attached to the check box...

  • Page 167

    Checkbox component 167 checkbox.Label availability flash player 6 (6.0 79.0). Edition flash mx 2004. Usage checkboxinstance.Label description property; indicates the text label for the check box. By default, the label appears to the right of the check box. Setting this property overrides the label p...

  • Page 168

    168 chapter 6: components dictionary • "left" the check box is pinned to the upper right corner of the bounding area. The label is set to the left of the check box. • "bottom" the label is set below the check box. The check box and label are centered horizontally and vertically. • "top" the label is...

  • Page 169: Chapter 6

    Collection interface (flash professional only) 169 collection interface (flash professional only) actionscript class name mx.Utils.Collection the collection class is distributed in the common classes library as a compiled clip symbol. To access this class, select window > other panels > common libra...

  • Page 170

    170 chapter 6: components dictionary parameters item the object to be added to the collection. If item is null , it is not added to the collection. Returns a boolean value of true if the collection was changed as a result of the operation. Description method; adds a new item to the end of the collec...

  • Page 171

    Collection interface (flash professional only) 171 example the following example calls contains() : var mycoll:mx.Utils.Collection; mycoll = _parent.Thisshelf.Mycompactdiscs; var itr:mx.Utils.Iterator = mycoll.Getiterator(); while (itr.Hasnext()) { var cd:compactdisc = compactdisc(itr.Next()); var t...

  • Page 172

    172 chapter 6: components dictionary collection.Getitemat() availability flash player 7. Edition flash mx professional 2004. Usage collection.Getitemat(index) parameters index a number that indicates the location of item within the collection. This is a zero-based index, so 0 retrieves the first ite...

  • Page 173

    Collection interface (flash professional only) 173 description method; returns an iterator over the elements in the collection. There are no guarantees concerning the order in which the elements are returned (unless this collection is an instance of a class that provides a guarantee). Example the fo...

  • Page 174

    174 chapter 6: components dictionary collection.Isempty() availability flash player 7. Edition flash mx professional 2004. Usage collection.Isempty() returns a boolean value of true if the collection is empty. Description method; indicates whether the collection is empty. Example the following examp...

  • Page 175

    Collection interface (flash professional only) 175 description method; removes the specified item from the collection. Because collection.Removeitem() dynamically reduces the size of the collection, do not call this method while looping through an iterator. Example the following example calls remove...

  • Page 176: Chapter 6

    176 chapter 6: components dictionary combobox component a combo box allows a user to make a single selection from a drop-down list. A combo box can be static or editable. An editable combo box allows a user to enter text directly into a text field at the top of the list, as well as selecting an item...

  • Page 177

    Combobox component 177 when the drop-down list of a combo box has focus, alphanumeric keystrokes move the selection up and down the drop-down list to the next item with the same first character. You can also use the following keys to control a drop-down list: note: the page size used by the page up ...

  • Page 178

    178 chapter 6: components dictionary using the combobox component you can use a combobox component in any form or application that requires a single choice from a list. For example, you could provide a drop-down list of states in a customer address form. You can use an editable combo box for more co...

  • Page 179

    Combobox component 179 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 mor...

  • Page 180

    180 chapter 6: components dictionary the following example demonstrates how to use list styles to control the behavior of the drop- down portion of a combobox component. // combobox is an instance of the combobox component on stage combobox.Setstyle("alternatingrowcolors", [0xffffff, 0xbfbfbf]); bor...

  • Page 181

    Combobox component 181 using skins with the combobox component the combobox component uses symbols in the library to represent the button states and has skin variables for the down arrow. These skins are located in the flash ui components 2/ themes/mmdefault/combobox assets/states folder of the halo...

  • Page 182

    182 chapter 6: components dictionary combobox class inheritance movieclip > uiobject class > uicomponent class > combobase > combobox actionscript class name mx.Controls.Combobox the combobox component combines three separate subcomponents: button, textinput, and list. Most of the methods, propertie...

  • Page 183

    Combobox component 183 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 . Methods inherited from the uicomponent class the...

  • Page 184

    184 chapter 6: components dictionary property summary for the combobox class the following table lists properties of the combobox class. Properties inherited from the uiobject class the following table lists the properties the combobox class inherits from the uiobject class. When accessing these pro...

  • Page 185

    Combobox component 185 properties inherited from the uicomponent class the following table lists the properties the combobox class inherits from the uicomponent class. When accessing these properties from the combobox object, use the form comboboxinstance.Propertyname . Event summary for the combobo...

  • Page 186

    186 chapter 6: components dictionary events inherited from the uicomponent class the following table lists the events the combobox class inherits from the uicomponent class. Combobox.Additem() availability flash player 6 (6.0 79.0). Edition flash mx 2004. Usage comboboxinstance.Additem(label[, data]...

  • Page 187

    Combobox component 187 combobox.Additemat() availability flash player 6 (6.0 79.0). Edition flash mx 2004. Usage comboboxinstance.Additemat(index, label[, data]) comboboxinstance.Additemat(index, {label:label[, data:data]}) comboboxinstance.Additemat(index, obj); parameters index a number 0 or great...

  • Page 188

    188 chapter 6: components dictionary usage 2: listenerobject = new object(); listenerobject.Change = function(eventobject){ // your code here } comboboxinstance.Addeventlistener("change", listenerobject) description event; broadcast to all registered listeners when the combobox.Selectedindex or comb...

  • Page 189

    Combobox component 189 combobox.Close() availability flash player 6 (6.0 79.0). Edition flash mx 2004. Usage mycombobox.Close() parameters none. Returns nothing. Description method; closes the drop-down list. Example the following example closes the drop-down list of the mybox combo box: mybox.Close...

  • Page 190

    190 chapter 6: components dictionary description event; broadcast to all registered listeners when the drop-down list of the combo box is fully retracted. The first usage example uses an on() handler and must be attached directly to a combobox instance. The keyword this , used in an on() handler att...

  • Page 191

    Combobox component 191 description property; the data model for items viewed in a list. The value of this property can be an array or any object that implements the dataprovider api. The default value is [] . The list component and the combobox component share the dataprovider property, and changes ...

  • Page 192

    192 chapter 6: components dictionary description property (read-only); returns a reference to the list contained by the combo box. The list subcomponent isn’t instantiated in the combo box until it needs to be displayed. However, when you access the dropdown property, the list is created. See also c...

  • Page 193

    Combobox component 193 making a combo box editable clears the combo box text field. It also sets the selected index (and item) to undefined . To make a combo box editable and still retain the selected item, use the following code: var ix = mycombobox.Selectedindex; mycombobox.Editable = true; // cle...

  • Page 194

    194 chapter 6: components dictionary the second usage example uses a dispatcher/listener event model. A component instance ( comboboxinstance ) dispatches an event (in this case, enter ) and the event is handled by a function, also called a handler, on a listener object ( listenerobject ) that you c...

  • Page 195

    Combobox component 195 example the following code displays the item at index position 4: trace(mybox.Getitemat(4).Label); combobox.Itemrollout availability flash player 6 (6.0 79.0). Edition flash mx 2004. Usage usage 1: on(itemrollout){ // your code here } usage 2: listenerobject = new object(); li...

  • Page 196

    196 chapter 6: components dictionary the second usage example uses a dispatcher/listener event model. A component instance ( comboboxinstance ) dispatches an event (in this case, itemrollout ) and the event is handled by a function, also called a handler, on a listener object ( listenerobject ) that...

  • Page 197

    Combobox component 197 description event; broadcast to all registered listeners when the mouse pointer rolls over drop-down list items. This is a list event that is broadcast from a combo box. For more information, see list.Itemrollover . The first usage example uses an on() handler and must be atta...

  • Page 198

    198 chapter 6: components dictionary description property; the name of the field in dataprovider array objects to use as the label field. This is a property of the list component that is available from a combobox component instance. For more information, see list.Labelfield . The default value is un...

  • Page 199

    Combobox component 199 see also list.Labelfield combobox.Length availability flash player 6 (6.0 79.0). Edition flash mx 2004. Usage mycombobox.Length description property (read-only); the length of the drop-down list. This is a property of the list component that is available from a combobox instan...

  • Page 200

    200 chapter 6: components dictionary see also combobox.Close() combobox.Open availability flash player 6 (6.0 79.0). Edition flash mx 2004. Usage usage 1: on(open){ // your code here } usage 2: listenerobject = new object(); listenerobject.Open = function(eventobject){ // your code here } comboboxin...

  • Page 201

    Combobox component 201 example the following example sends a message to the output panel: function open(evt) { trace("the combo box has opened with text " + evt.Target.Text); } mybox.Addeventlistener("open", this); see also combobox.Close , eventdispatcher.Addeventlistener() combobox.Removeall() ava...

  • Page 202

    202 chapter 6: components dictionary usage listinstance.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 i...

  • Page 203

    Combobox component 203 description method; replaces the content of the item at the specified index. This is a method of the list component that is available from the combobox component. Example the following example changes the third index position: mycombo.Replaceitemat(3, "new label"); see also co...

  • Page 204

    204 chapter 6: components dictionary however, since this expression is surrounded by double quotation marks, the value 0-9-^\ is sent to the restrict interpreter, and the restrict interpreter doesn’t understand this value. Because you must enter this expression within double quotation marks, you mus...

  • Page 205

    Combobox component 205 example the following example specifies that the combo box should have 20 or fewer rows visible: mycombobox.Rowcount = 20; combobox.Scroll availability flash player 6 (6.0 79.0). Edition flash mx 2004. Usage usage 1: on(scroll){ // your code here } usage 2: listenerobject = ne...

  • Page 206

    206 chapter 6: components dictionary the second usage example uses a dispatcher/listener event model. A component instance ( comboboxinstance ) dispatches an event (in this case, scroll ) and the event is handled by a function, also called a handler, on a listener object ( listenerobject ) that you ...

  • Page 207

    Combobox component 207 see also combobox.Selecteditem combobox.Selecteditem availability flash player 6 (6.0 79.0). Edition flash mx 2004. Usage mycombobox.Selecteditem description property; the value of the selected item in the drop-down list. If the combo box is editable, selecteditem returns unde...

  • Page 208

    208 chapter 6: components dictionary parameters comparefunc a reference to a function that compares two items to determine their sort order. For details, see array.Sort() in flash actionscript language reference. This parameter is optional. Optionsflag lets you perform multiple sorts of different ty...

  • Page 209

    Combobox component 209 mycombobox.Sortitems(uppercasefunc, array.Descending); // the resulting sort order of mycombobox will be: // venus // planet // mercury // earth combobox.Sortitemsby() availability flash player 7. Edition flash mx professional 2004. Usage mycombobox.Sortitemsby(fieldname, orde...

  • Page 210

    210 chapter 6: components dictionary returns nothing. Description method; sorts the items in the combo box alphabetically or numerically, in the specified order, using the specified field name. If the fieldname items are a combination of text strings and integers, the integer items are listed first....

  • Page 211

    Combobox component 211 usage mycombobox.Text description property; the text of the text box. You can get and set this value for editable combo boxes. For static combo boxes, the value is read-only. Example the following example sets the current text value of an editable combo box: mycombobox.Text = ...

  • Page 212

    212 chapter 6: components dictionary description property (read-only); if the combo box is editable, value returns the value of the text box. If the combo box is static, value returns the value of the drop-down list. The value of the drop-down list is the data field, or, if the data field doesn’t ex...

  • Page 213: Chapter 6

    Data binding classes (flash professional only) 213 data binding classes (flash professional only) the data binding classes provide the runtime functionality for the data binding feature in flash mx professional 2004. You can visually create and configure data bindings in the flash authoring environm...

  • Page 214

    214 chapter 6: components dictionary binding class (flash professional only) actionscript class name mx.Data.Binding.Binding the binding class defines an association between two endpoints, a source and a destination. It listens for changes to the source endpoint and copies the changed data to the de...

  • Page 215

    Data binding classes (flash professional only) 215 destination the destination endpoint of the binding. This parameter is nominally of type mx.Data.Binding.Endpoint , but can be any actionscript object that has the required endpoint fields. Format an optional object that contains formatting informat...

  • Page 216

    216 chapter 6: components dictionary src.Component = src_txt; src.Property = "text"; src.Event = "focusout"; var dest= new endpoint(); dest.Component = text_dest; dest.Property = "text"; new binding(src, dest, {cls: mx.Data.Formatters.Custom, settings: {classname: "com.Mycompany.Specialformatter"}})...

  • Page 217

    Data binding classes (flash professional only) 217 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 t...

  • Page 218

    218 chapter 6: components dictionary if (rawvalue == numarray[i]) { returnvalue = strarray[i]; break; } } return returnvalue; } // convert a formatted value, return a raw value function unformat(formattedvalue) { var returnvalue; var strarray = new array('one', 'two', 'three'); var numarray = new ar...

  • Page 219

    Data binding classes (flash professional only) 219 method summary for the customformatter class the following table lists the methods of the customformatter class. Customformatter.Format() availability flash player 6 (6.0 79.0). Edition flash mx professional 2004. Usage this method is called automat...

  • Page 220

    220 chapter 6: components dictionary returns an unformatted value. Description method; converts from a string, or other data type, to the raw data type. This transformation should be the exact inverse transformation of customformatter.Format() . This method is not implemented by default. You must de...

  • Page 221

    Data binding classes (flash professional only) 221 method summary for the customvalidator class the following table lists the methods of the customvalidator class. Customvalidator.Validate() availability flash player 6 (6.0 79.0). Edition flash mx professional 2004. Usage this method is called autom...

  • Page 222

    222 chapter 6: components dictionary to create and use a custom validator class: 1. In flash mx professional 2004, create a new actionscript (as) file. 2. Add the following code to the as file: class oddnumbersonly extends mx.Data.Binding.Customvalidator { public function validate(value) { // make s...

  • Page 223

    Data binding classes (flash professional only) 223 18. Open the timeline and select the first frame on layer 1. 19. Open the actions panel. 20. Add the following code to the actions panel: function dataisinvalid(evt) { if (evt.Property == "text") { status.Text = evt.Messages; } } function dataisvali...

  • Page 224

    224 chapter 6: components dictionary each message you pass to validationerror() is available in the messages property of the event object that was passed to the invalid event handler. Example see the example section for customvalidator.Validate() . Endpoint class (flash professional only) actionscri...

  • Page 225

    Data binding classes (flash professional only) 225 property summary for the endpoint class the following table lists the properties of the endpoint class. Constructor for the endpoint class availability flash player 6 (6.0 79.0). Edition flash mx professional 2004. Usage new endpoint() returns nothi...

  • Page 226

    226 chapter 6: components dictionary usage endpointobj.Component description property; a reference to a component instance. Example this example assigns an instance of the list component ( listbox1 ) as the component parameter of an endpoint object. Var sourceendpoint = new mx.Data.Binding.Endpoint(...

  • Page 227

    Data binding classes (flash professional only) 227 description property; specifies the name of an event, or an array of event names, generated by the component when data assigned to the bound property changes. When the event occurs, the binding executes. The specified event only applies to component...

  • Page 228

    228 chapter 6: components dictionary if you specify an object as the location, the object must specify two properties: path and indices . The path property is an array of strings, as discussed above, except that one or more of the specified strings may be the special token "[n]" . For each occurrenc...

  • Page 229

    Data binding classes (flash professional only) 229 description property; specifies a property name of the component instance specified by endpoint.Component that contains the bindable data. Note: endpoint.Component and endpoint.Property must combine to form a valid actionscript object/ property comb...

  • Page 230

    230 chapter 6: components dictionary componentmixins.Getfield() availability flash player 6 (6.0 79.0). Edition flash mx professional 2004. Usage componentinstance.Getfield(propertyname, [location]) parameters propertyname a string that contains the name of a property of the specified component. Loc...

  • Page 231

    Data binding classes (flash professional only) 231 componentmixins.Initcomponent() availability flash player 6 (6.0 79.0). Edition flash mx professional 2004. Usage mx.Data.Binding.Componentmixins.Initcomponent(componentinstance) parameters componentinstance a reference to a component instance. Retu...

  • Page 232

    232 chapter 6: components dictionary example the following example executes all the bindings for which the dataset component instance named user_data is the source endpoint object: user_data.Refreshdestinations(); componentmixins.Refreshfromsources() availability flash player 6 (6.0 79.0). Edition f...

  • Page 233

    Data binding classes (flash professional only) 233 returns an array, or null . Description method; determines if the data in propertyname is valid based on the property’s schema settings. The property’s schema settings are those specified on the schema tab in the component inspector panel. The metho...

  • Page 234

    234 chapter 6: components dictionary 7. Add the following code to the actions panel: // add componentmixin methods to textinput component. // note that this step is only necessary if the component // isn’t already involved in a data binding, // either as the source or destination. Mx.Data.Binding.Co...

  • Page 235

    Data binding classes (flash professional only) 235 you can also use the methods of the datatype class to get or set fields in various data types. The datatype class automatically converts the raw data to the requested type, if possible. For example, in the code example above, the data that’s retriev...

  • Page 236

    236 chapter 6: components dictionary datatype.Encoder availability flash player 6 (6.0 79.0). Edition flash mx professional 2004. Usage datatypeobject.Encoder description property; provides a reference to the encoder object associated with this field, if one exists. You can use this property to acce...

  • Page 237

    Data binding classes (flash professional only) 237 for more information about the formatters provided with flash mx professional 2004, see “schema formatters” in using flash. Example this example assumes that the field being accessed is using the number formatter (mx.Data.Formatters.Numberformatter)...

  • Page 238

    238 chapter 6: components dictionary 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: dataty...

  • Page 239

    Data binding classes (flash professional only) 239 parameters none. Returns a number. Description method; fetches the current value of the field and converts it to number form, if necessary. Example in this example, a field named propname that belongs to a component named mycomponent is retrieved as...

  • Page 240

    240 chapter 6: components dictionary datatype.Gettypedvalue() availability flash player 6 (6.0 79.0). Edition flash mx professional 2004. Usage datatypeobject.Gettypedvalue(requestedtype) parameters requestedtype a string containing the name of a data type, or null . Returns a typedvalue object (see...

  • Page 241

    Data binding classes (flash professional only) 241 datatype.Setanytypedvalue() availability flash player 6 (6.0 79.0). Edition flash mx professional 2004. Usage datatypeobject.Setanytypedvalue(newtypedvalue) parameters newtypedvalue a typedvalue object value to set in the field. For more information...

  • Page 242

    242 chapter 6: components dictionary datatype.Setasboolean() availability flash player 6 (6.0 79.0). Edition flash mx professional 2004. Usage datatypeobject.Setasboolean(newbooleanvalue) parameters newbooleanvalue a boolean value. Returns nothing. Description method; sets the field to the new value...

  • Page 243

    Data binding classes (flash professional only) 243 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). Edit...

  • Page 244

    244 chapter 6: components dictionary for more information about typedvalue objects, see “typedvalue class (flash professional only)” on page 244 . Returns an array of strings describing any errors that occurred while attempting to set the new value. Errors can occur under any of the following condit...

  • Page 245

    Data binding classes (flash professional only) 245 property summary for the typedvalue class the following table lists the properties of the typedvalue class. Constructor for the typedvalue class availability flash player 6 (6.0 79.0). Usage new mx.Data.Binding.Typedvalue(value, typename, [type]) pa...

  • Page 246

    246 chapter 6: components dictionary 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...

  • Page 247: Chapter 6

    Datagrid component (flash professional only) 247 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 coldfusio...

  • Page 248

    248 chapter 6: components dictionary 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 t...

  • Page 249

    Datagrid component (flash professional only) 249 • lists perform worse as a function of their visible rows. Although lists can display 5000 records, they can’t render 5000 records at once. The more visible rows (specified by the rowcount property) you have on the stage, the more work the list must t...

  • Page 250

    250 chapter 6: components dictionary the view consists of three main parts: • row this is a view object responsible for rendering the items of the grid by laying out cells. Each row is laid out horizontally below the previous one. • column columns are fields that are displayed in the grid; the field...

  • Page 251

    Datagrid component (flash professional only) 251 creating an application with the datagrid component to create an application with the datagrid component, you must first determine where your data is coming from. The data for a grid can come from a recordset that is fed from a database query in macro...

  • Page 252

    252 chapter 6: components dictionary using styles with the datagrid component you can set style properties to change the appearance of a datagrid component. The datagrid component inherits styles from the list component. (see “using styles with the list component” on page 453 .) the datagrid compone...

  • Page 253

    Datagrid component (flash professional only) 253 setting styles for an individual column color and text styles can be set for the grid as a whole or for a column. You can use the following syntax to set a style for a particular column: grid.Getcolumnat(3).Setstyle("backgroundcolor", 0xff00aa); setti...

  • Page 254

    254 chapter 6: components dictionary target.Setstyle(style, source.Getstyle(style)); } for more information about class-level styles, see “setting styles for a component class” on page 71 . Using skins with the datagrid component the skins that the datagrid component uses to represent its visual sta...

  • Page 255

    Datagrid component (flash professional only) 255 methods inherited from the uiobject class the following table lists the methods the datagrid class inherits from the uiobject class. When calling these methods, use the form datagridinstance.Methodname . Methods inherited from the uicomponent class th...

  • Page 256

    256 chapter 6: components dictionary property summary for the datagrid class the following table lists the properties of the datagrid class. Properties inherited from the uiobject class the following table lists the properties the datagrid class inherits from the uiobject class. When accessing these...

  • Page 257

    Datagrid component (flash professional only) 257 properties inherited from the uicomponent class the following table lists the properties the datagrid class inherits from the uicomponent class. When accessing these properties from the datagrid object, use the form datagridinstance.Propertyname . Pro...

  • Page 258

    258 chapter 6: components dictionary event summary for the datagrid class the following table lists the events of the datagrid class. Events inherited from the uiobject class the following table lists the events the datagrid class inherits from the uiobject class. List.Maxhposition the number of pix...

  • Page 259

    Datagrid component (flash professional only) 259 events inherited from the uicomponent class the following table lists the events the datagrid class inherits from the uicomponent class. Events inherited from the list class the following table lists the events the datagrid class inherits from the lis...

  • Page 260

    260 chapter 6: components dictionary returns a reference to the datagridcolumn object that was added. Description method; adds a new column to the end of the data grid. For more information, see “datagridcolumn class (flash professional only)” on page 278 . Example the following code adds a new data...

  • Page 261

    Datagrid component (flash professional only) 261 datagrid.Additem() availability flash player 6 (6.0 79.0). Edition flash mx professional 2004. Usage mydatagrid.Additem(item) parameters item an instance of an object to be added to the grid. Returns a reference to the instance that was added. Descrip...

  • Page 262

    262 chapter 6: components dictionary example the following example inserts an object instance to the grid at index position 4: var anobject= {name:"jim!!", age:30}; mygrid.Additemat(4, anobject); datagrid.Celledit availability flash player 6 (6.0 79.0). Edition flash mx professional 2004. Usage list...

  • Page 263

    Datagrid component (flash professional only) 263 var cell = "(" + event.Columnindex + ", " + event.Itemindex + ")"; trace("the value of the cell at " + cell + " has changed"); } mydatagrid.Addeventlistener("celledit", mydatagridlistener); note: the grid must be editable for the above code to work. D...

  • Page 264

    264 chapter 6: components dictionary trace("the cell at " + cell + " has gained focus"); }; grid.Addeventlistener("cellfocusin", mylistener); note: the grid must be editable for the above code to work. Datagrid.Cellfocusout availability flash player 6 (6.0 79.0). Edition flash mx professional 2004. ...

  • Page 265

    Datagrid component (flash professional only) 265 trace("the cell at " + cell + " has lost focus"); }; grid.Addeventlistener("cellfocusout", mylistener); note: the grid must be editable for the above code to work. Datagrid.Cellpress availability flash player 6 (6.0 79.0). Edition flash mx professiona...

  • Page 266

    266 chapter 6: components dictionary trace("the cell at " + cell + " has been clicked"); }; grid.Addeventlistener("cellpress", mylistener); datagrid.Change availability flash player 6 (6.0 79.0). Edition flash mx professional 2004. Usage listenerobject = new object(); listenerobject.Change = functio...

  • Page 267

    Datagrid component (flash professional only) 267 datagrid.Columncount availability flash player 6 (6.0 79.0). Edition flash mx professional 2004. Usage mydatagrid.Columncount description property (read-only); the number of columns displayed. Example the following example gets the number of displayed...

  • Page 268

    268 chapter 6: components dictionary usage listenerobject = new object(); listenerobject.Columnstretch = function(eventobject){ // insert your code here } mydatagridinstance.Addeventlistener("columnstretch", listenerobject) description event; broadcast to all registered listeners when a user resizes...

  • Page 269

    Datagrid component (flash professional only) 269 the data grid adds methods to the prototype of the array class so that each array object conforms to the dataprovider api (see dataprovider.As in the classes/mx/controls/listclasses folder). Any array that is in the same frame or screen as a data grid...

  • Page 270

    270 chapter 6: components dictionary caution: the datagrid is not editable or sortable if it is bound directly to a webserviceconnector component or an xmlconnector component. You must bind the datagrid component to the dataset component and bind the dataset component to the webserviceconnector comp...

  • Page 271

    Datagrid component (flash professional only) 271 datagrid.Focusedcell availability flash player 6 (6.0 79.0). Edition flash mx professional 2004. Usage mydatagrid.Focusedcell description property; in editable mode only, an object instance that defines the cell that has focus. The object must have th...

  • Page 272

    272 chapter 6: components dictionary 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....

  • Page 273

    Datagrid component (flash professional only) 273 usage listenerobject = new object(); listenerobject.Headerrelease = function(eventobject){ // insert your code here } mydatagridinstance.Addeventlistener("headerrelease", listenerobject) description event; broadcast to all registered listeners when a ...

  • Page 274

    274 chapter 6: components dictionary description property; specifies whether the data grid has a horizontal scroll bar. This property can have the value "on" , "off" , or "auto" . The default value is "off" . If hscrollpolicy is set to "off" , columns scale proportionally to accommodate the finite w...

  • Page 275

    Datagrid component (flash professional only) 275 usage mydatagrid.Removecolumnat(index) parameters index the index of the column to remove. Returns a reference to the datagridcolumn object that was removed. Description method; removes the datagridcolumn object at the specified index. Example the fol...

  • Page 276

    276 chapter 6: components dictionary datagrid.Resizablecolumns availability flash player 6 (6.0 79.0). Edition flash mx professional 2004. Usage mydatagrid.Resizablecolumns description property; a boolean value that determines whether the columns of the grid can be stretched by the user ( true ) or ...

  • Page 277

    Datagrid component (flash professional only) 277 usage mydatagrid.Showheaders description property; a boolean value that indicates whether the data grid displays the column headers ( true ) or not ( false ). Column headers are shaded to differentiate them from the other rows in a grid. Users can cli...

  • Page 278

    278 chapter 6: components dictionary 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 res...

  • Page 279

    Datagrid component (flash professional only) 279 • datagrid.Columnnames takes in the field names of the desired item fields and generates datagridcolumn objects, in order, for each field listed. This approach lets you select and order columns quickly with a minimal amount of configuration. This appr...

  • Page 280

    280 chapter 6: components dictionary 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 datag...

  • Page 281

    Datagrid component (flash professional only) 281 description property (read-only); the name of the field associated with this column. The default value is the name called in the datagridcolumn constructor. Example the following example assigns the column name of the column at the third index positio...

  • Page 282

    282 chapter 6: components dictionary 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...

  • Page 283

    Datagrid component (flash professional only) 283 usage mydatagrid.Getcolumnat(index).Labelfunction description property; specifies a function to determine which field (or field combination) of each item to display. This function receives one parameter, item , which is the item being rendered, and mu...

  • Page 284

    284 chapter 6: components dictionary description property; a boolean value that indicates whether a column can be sorted by a user ( true ) or not ( false ). The datagrid.Sortablecolumns property must be set to true for this property to take effect. The default value is true . Caution: the datagrid ...

  • Page 285

    Datagrid component (flash professional only) 285 datagridcolumn.Width availability flash player 6 (6.0 79.0). Edition flash mx professional 2004. Usage mydatagrid.Getcolumnat(index).Width description property; a number that indicates the width of the column, in pixels. The default value is 50. Examp...

  • Page 286: Chapter 6

    286 chapter 6: components dictionary dataholder component (flash professional only) the dataholder component is a repository for data and a means of generating events when that data has changed. Its main purpose is to hold data and act as a connector between other components that use data binding. I...

  • Page 287

    Dataholder component (flash professional only) 287 note: the dataholder component is not meant to implement the same control over your data as the dataset component. It does not manage or track data, nor does it have the ability to update data. It is a repository for holding data and generating even...

  • Page 288

    288 chapter 6: components dictionary dataholder class inheritance movieclip > dataholder actionscript class name mx.Data.Components.Dataholder the dataholder component is a repository for data and a means of generating events when that data has changed. Its main purpose is to hold data and act as a ...

  • Page 289

    Dataholder component (flash professional only) 289 // drag two button components onto the stage (adddate_btn and dumpdataholder_btn), a textinput (mydate_txt) and a dataholder (mydataholder). Add the following actionscript to frame 1: var dhlistener:object = {}; dhlistener.Click = function() { trace...

  • Page 290: Chapter 6

    290 chapter 6: components dictionary dataprovider api actionscript class name mx.Controls.Listclasses.Dataprovider the dataprovider api is a set of methods and properties that a data source needs so that a list- based class can communicate with it. Arrays, recordsets, and data sets implement this ap...

  • Page 291

    Dataprovider api 291 property summary for the dataprovider api the following table lists the properties of the dataprovider api. Event summary for the dataprovider api the following table lists the events of the dataprovider api. Dataprovider.Additem() availability flash player 6 (6.0 79.0). Edition...

  • Page 292

    292 chapter 6: components dictionary dataprovider.Additemat() availability flash player 6 (6.0 79.0). Edition flash mx professional 2004. Usage mydp.Additemat(index, item) parameters index a number greater than or equal to 0. This number indicates the position at which to insert the item; it is the ...

  • Page 293

    Dataprovider api 293 returns nothing. Description method; changes one field of the data provider. This method triggers the modelchanged event with the event name updatefield . Example the following code modifies the label field of the third item: mydp.Editfield(2, "label", "mynewdata"); dataprovider...

  • Page 294

    294 chapter 6: components dictionary usage mydp.Getitemat(index) parameters index a number greater than or equal to 0 and less than dataprovider.Length . This number is the index of the item to retrieve. Returns a reference to the retrieved item; undefined if the index is out of range. Description m...

  • Page 295

    Dataprovider api 295 dataprovider.Length availability flash player 6 (6.0 79.0). Edition flash mx professional 2004. Usage mydp.Length description property (read-only); the number of items in the data provider. Example this example sends the number of items in the myarray data provider to the output...

  • Page 296

    296 chapter 6: components dictionary ■ removeitems a series of items has been deleted. ■ updateitems a series of items needs refreshing. ■ sort the data has been sorted. ■ updatefield a field in an item must be changed and needs refreshing. ■ updatecolumn an entire field’s definition in the data pro...

  • Page 297

    Dataprovider api 297 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...

  • Page 298

    298 chapter 6: components dictionary parameters index a number greater than or equal to 0. This number is the index of the item to change. Item an object that is the new item. Returns nothing. Description method; replaces the content of the item at the specified index. This method triggers the model...

  • Page 299

    Dataprovider api 299 • array.Returnindexedarray , which returns an integer index array that is the result of the sort. For example, the following array would return the second line of code and the array would remain unchanged: ["a", "d", "c", "b"] [0, 3, 2, 1] you can combine these options into one ...

  • Page 300

    300 chapter 6: components dictionary the following are possible values for optionsflag : • array.Descending —sorts highest to lowest. • array.Caseinsensitive —sorts case-insensitively. • array.Numeric —sorts numerically if the two elements being compared are numbers. If they aren’t numbers, use a st...

  • Page 301: Chapter 6

    Dataset component (flash professional only) 301 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 me...

  • Page 302

    302 chapter 6: components dictionary logchanges is a boolean value that defaults to true . If this parameter is set to true , the data set logs all changes made to its data and any method calls made on the associated transfer objects. Readonly is a boolean value that defaults to false . If this para...

  • Page 303

    Dataset component (flash professional only) 303 to create an application using the dataset component: 1. In flash mx professional 2004, select file > new. In the type column, select flash document and click ok. 2. Open the components panel if it’s not already open. 3. Drag a dataset component from t...

  • Page 304

    304 chapter 6: components dictionary 17. Double-click the bound to field in the component inspector to open the bound to dialog box. 18. In the component path field, select “dataset ” from the component path column, and then select “selectedindex : number” from the schema location column. 19. Enter ...

  • Page 305

    Dataset component (flash professional only) 305 dataset.Disableevents() stops sending dataset events to listeners. Dataset.Enableevents() resumes sending dataset events to listeners. Dataset.Find() locates an item in the current view of the collection. Dataset.Findfirst() locates the first occurrenc...

  • Page 306

    306 chapter 6: components dictionary property summary for the dataset class the following table lists the properties of the dataset class. Event summary for the dataset class the following table lists the events of the dataset class. Property description dataset.Currentitem returns the current item ...

  • Page 307

    Dataset component (flash professional only) 307 dataset.Additem availability flash player 7. Edition flash mx professional 2004. Usage on(additem) { // insert your code here } listenerobject = new object(); listenerobject.Additem = function (eventobj) { // insert your code here } dataset.Addeventlis...

  • Page 308

    308 chapter 6: components dictionary dataset.Additem() availability flash player 7. Edition flash mx professional 2004. Usage dataset.Additem([obj]) parameters obj an object to add to this collection. This parameter is optional. Returns a boolean value: true if the item was added to the collection, ...

  • Page 309

    Dataset component (flash professional only) 309 parameters index a number greater than or equal to 0. This number indicates the position at which to insert the item; it is the index of the new item. Item an object containing the data for the item. Returns a boolean value indicating whether the item ...

  • Page 310

    310 chapter 6: components dictionary a dataseterror exception is thrown when datasetiterator.Unique is specified as a sort option and the data being sorted is not unique, when the specified sort name has already been added, or when a property specified in the fieldlist array does not exist in this d...

  • Page 311

    Dataset component (flash professional only) 311 example in this example, a form named contactform (not shown) is made visible once the items in the data set contact_ds have been assigned. Contact_ds.Addeventlistener("afterloaded", loadlistener); loadlistener = new object(); loadlistener.Afterloaded ...

  • Page 312

    312 chapter 6: components dictionary dataset.Calcfields availability flash player 7. Edition flash mx professional 2004. Usage on(calcfields) { // insert your code here } listenerobject = new object(); listenerobject.Calcfields = function (eventobj) { // insert your code here } dataset.Addeventliste...

  • Page 313

    Dataset component (flash professional only) 313 description method; returns true if the collection, or any item in the collection, has changes pending that have not yet been sent in a delta packet; otherwise, returns false . Example the following code enables a save changes button (not shown) if the...

  • Page 314

    314 chapter 6: components dictionary dataset.Createitem() availability flash player 7. Edition flash mx professional 2004. Usage dataset.Createitem([itemdata]) parameters itemdata data associated with the item. This parameter is optional. Returns the newly constructed item. Description method; creat...

  • Page 315

    Dataset component (flash professional only) 315 usage dataset.Currentitem description property (read-only); returns the current item in the dataset collection, or null if the collection is empty or if the current iterator’s view of the collection is empty. This property provides direct access to the...

  • Page 316

    316 chapter 6: components dictionary 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...

  • Page 317

    Dataset component (flash professional only) 317 dataset.Disableevents() availability flash player 7. Edition flash mx professional 2004. Usage dataset.Disableevents() returns nothing. Description method; disables events for the dataset object. While events are disabled, no user interface controls (s...

  • Page 318

    318 chapter 6: components dictionary usage dataset.Enableevents() returns nothing. Description method; reenables events for the dataset objects after events have been disabled by a call to dataset.Disableevents() . To reenable events for the dataset object, the enableevents() method must be called a...

  • Page 319

    Dataset component (flash professional only) 319 example in the following example, filtering is enabled on the dataset object named employee_ds . Suppose that each record in the dataset collection contains a field named emptype . The following filter function returns true if the emptype field in the ...

  • Page 320

    320 chapter 6: components dictionary return(item.Emptype != "management"); } see also dataset.Filtered dataset.Find() availability flash player 7. Edition flash mx professional 2004. Usage dataset.Find(searchvalues) parameters searchvalues an array that contains one or more field values to be found ...

  • Page 321

    Dataset component (flash professional only) 321 // note that the order of the search fields matches those // specified in addsort(). If(studentdata.Find(["bobby", 105])) { studentid = studentdata.Getitemid(); } // now use locatebyid() to position the current iterator // on the item in the collection...

  • Page 322

    322 chapter 6: components dictionary example this example searches for the first item in the current collection whose name and age fields contain "bobby" and "13" . If found, dataset.Getitemid() is used to get the unique identifier for the item in the collection, and dataset.Locatebyid() is used to ...

  • Page 323

    Dataset component (flash professional only) 323 conversion of the data specified is based on the underlying field’s type. For example, if the search value specified is ["05-02-02"] , the underlying date field is used to convert the value with the date’s setasstring() method. If the value specified i...

  • Page 324

    324 chapter 6: components dictionary example the following code positions the data set inventorydata at the first item in its collection, and then displays the value of the price property contained by that item using the dataset.Currentitem property. Inventorydata.First(); trace("the price of the fi...

  • Page 325

    Dataset component (flash professional only) 325 edition flash mx professional 2004. Usage dataset.Getiterator() returns a valuelistiterator object. Description method; returns a new iterator for this collection; this iterator is a clone of the current iterator in use, including its current position ...

  • Page 326

    326 chapter 6: components dictionary edition flash mx professional 2004. Usage dataset.Hasnext() returns a boolean value. Description method; returns false if the current iterator is at the end of its view of the collection; otherwise, returns true . Example this example iterates over all of the ite...

  • Page 327

    Dataset component (flash professional only) 327 mydataset.Last(); while(mydataset.Hasprevious()) { var price = mydataset.Currentitem.Price; price = price * 0.5; // everything's 50% off! Mydataset.Currentitem.Price = price; mydataset.Previous(); } see also dataset.Currentitem , dataset.Skip() , datas...

  • Page 328

    328 chapter 6: components dictionary dataset.Isempty() availability flash player 7. Edition flash mx professional 2004. Usage dataset.Isempty() returns a boolean value. Description method; returns true if the specified dataset object doesn’t contain any items (that is, if dataset.Length == 0). Examp...

  • Page 329

    Dataset component (flash professional only) 329 dataset.Itemclassname availability flash player 7. Edition flash mx professional 2004. Usage dataset.Itemclassname description property; a string indicating the name of the class that should be created when items are added to the collection. The class ...

  • Page 330

    330 chapter 6: components dictionary 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: target the dataset object that generated the event. Type the string "iteratorscrolle...

  • Page 331

    Dataset component (flash professional only) 331 see also dataset.First() dataset.Length availability flash player 7. Edition flash mx professional 2004. Usage dataset.Length description property (read-only); specifies the number of items in the current view of the collection. The viewable number of ...

  • Page 332

    332 chapter 6: components dictionary returns nothing. Description method; loads all of the relevant data needed to restore this dataset collection from a shared object. To save a dataset collection to a shared object, use dataset.Savetosharedobj() . The dataset.Loadfromsharedobject() method overwrit...

  • Page 333

    Dataset component (flash professional only) 333 example this example uses dataset.Find() to search for an item in the current collection whose name and id fields contain the values "bobby" and 105, respectively. If found, dataset.Getitemid() is used to get the unique identifier for that item, and da...

  • Page 334

    334 chapter 6: components dictionary dataset.Modelchanged availability flash player 7. Edition flash mx professional 2004. Description on(modelchanged) { // insert your code here } listenerobject = new object(); listenerobject.Modelchanged = function (eventobj) { // insert your code here } dataset.A...

  • Page 335

    Dataset component (flash professional only) 335 example in this example, a delete item button is disabled if the items have been removed from the collection and the target dataset object has no more items. On(modelchanged) { delete_btn.Enabled = ((eventobj.Eventname == "removeitems") && (eventobj.Ta...

  • Page 336

    336 chapter 6: components dictionary employee.Name = "newguy"; // property data happens to be xml employee.Zip = employee.Getpropertydata().Firstchild.Childnodes[1].Attributes.Zip; } employees_ds.Addeventlistener("newitem", newitemevent); dataset.Next() availability flash player 7. Edition flash mx ...

  • Page 337

    Dataset component (flash professional only) 337 returns nothing. Description method; makes the previous item in the current view of the collection the current item. Which items are in the current view depends on any current filter and range settings. This example loops over all the items in the curr...

  • Page 338

    338 chapter 6: components dictionary usage dataset.Readonly description property; a boolean value that specifies whether this collection can be modified ( false ) or is read-only ( true ). Setting this property to true prevents updates to the collection. The default value is false . You can also set...

  • Page 339

    Dataset component (flash professional only) 339 dataset.Removeitem availability flash player 7. Edition flash mx professional 2004. Usage on(removeitem) { // insert your code here } listenerobject = new object(); listenerobject.Removeitem = function (eventobj) { // insert your code here } dataset.Ad...

  • Page 340

    340 chapter 6: components dictionary dataset.Removeitem() availability flash player 7. Edition flash mx professional 2004. Usage dataset.Removeitem([item]) parameters item the item to be removed. This parameter is optional. Returns a boolean value. Returns true if the item was successfully removed; ...

  • Page 341

    Dataset component (flash professional only) 341 returns a boolean value indicating whether the item was removed. Description method; removes the item at the specified index. The indices after the removed index collapse by one. This method triggers the modelchanged event with the event name removeite...

  • Page 342

    342 chapter 6: components dictionary } mydataset.Removerange(); mydataset.Removesort("name_id"); see also dataset.Applyupdates() , dataset.Hasnext() , dataset.Next() , dataset.Removesort() , dataset.Setrange() dataset.Removesort() availability flash player 7. Edition flash mx professional 2004. Usag...

  • Page 343

    Dataset component (flash professional only) 343 dataset.Resolvedelta availability flash player 7. Edition flash mx professional 2004. Usage on(resolvedelta) { // insert your code here } listenerobject = new object(); listenerobject.Resolvedelta = function (eventobj) { // insert your code here } data...

  • Page 344

    344 chapter 6: components dictionary for (var i = 0; i cl = data[i].Getchangelist(); for (var j = 0; j di = cl[j]; msg = di.Getmessage(); if (msg.Length>0) { trace("the following problem occurred '"+msg+"' while performing a '"+ops[di.Kind]+"' modification on/with '"+di.Name+"' current server value ...

  • Page 345

    Dataset component (flash professional only) 345 example this example calls savetosharedobj() in a try..Catch block and displays an error if there is a problem saving the data to the shared object. Try { mydataset.Savetosharedobj("webapp/customerinfo"); } catch(e:dataseterror) { trace("unable to crea...

  • Page 346

    346 chapter 6: components dictionary example the following example sets the schema of the data set mydataset to a new xml object containing appropriately formatted xml: mydataset.Schema = new xml(" ..Etc.. Properties>"); dataset.Selectedindex availability flash player 7. Edition flash mx professiona...

  • Page 347

    Dataset component (flash professional only) 347 description method; assigns the specified iterator to this dataset object and makes it the current iterator. The specified iterator must come from a previous call to dataset.Getiterator() on the dataset object to which it is being assigned; otherwise; ...

  • Page 348

    348 chapter 6: components dictionary see also dataset.Applyupdates() , dataset.Hasnext() , dataset.Next() , dataset.Removerange() , dataset.Removesort() dataset.Skip() availability flash player 7. Edition flash mx professional 2004. Usage dataset.Skip(offset) parameters offset an integer specifying ...

  • Page 349

    Dataset component (flash professional only) 349 parameters sortname a string that contains the name of the sort to use. Order an integer value that indicates the sort order for the sort; the value must be datasetiterator.Ascending or datasetiterator.Descending. Returns nothing. Description method; s...

  • Page 350: Chapter 6

    350 chapter 6: components dictionary datechooser component (flash professional only) the datechooser component is a calendar that allows users to select a date. It has buttons that allow users to scroll through months and click a date to select it. You can set parameters that indicate the month and ...

  • Page 351

    Datechooser component (flash professional only) 351 to create an application with the datechooser component: 1. Double-click the datechooser component in the components panel to add it to the stage. 2. In the property inspector, enter the instance name flightcalendar. 3. In the actions panel, enter ...

  • Page 352

    352 chapter 6: components dictionary the datechooser component uses four categories of text to display the month name, the days of the week, today’s date, and regular dates. The text style properties set on the datechooser component itself control the regular date text and provide defaults for the o...

  • Page 353

    Datechooser component (flash professional only) 353 the following example demonstrates how to set the month name and days of the week to a deep red color. _global.Styles.Headerdatetext.Setstyle("color", 0x660000); _global.Styles.Weekdaystyle.Setstyle("color", 0x660000); using skins with the datechoo...

  • Page 354

    354 chapter 6: components dictionary 6. Customize the symbol as desired. For example, change the tint of the arrow to red. 7. Repeat steps 5-6 for all symbols you want to customize. For example, change the tint of the forward arrow down symbol to match the back arrow. 8. Click the back button to ret...

  • Page 355

    Datechooser component (flash professional only) 355 methods inherited from the uiobject class the following table lists the methods the datechooser class inherits from the uiobject class. When calling these methods from the datechooser object, use the form datechooserinstance.Methodname . Methods in...

  • Page 356

    356 chapter 6: components dictionary properties inherited from the uiobject class the following table lists the properties the datechooser class inherits from the uiobject class. When accessing these properties from the datechooser object, use the form datechooserinstance.Propertyname . Properties i...

  • Page 357

    Datechooser component (flash professional only) 357 event summary for the datechooser class the following table lists the events that are exclusive to the datechooser class. Events inherited from the uiobject class the following table lists the events the datechooser class inherits from the uiobject...

  • Page 358

    358 chapter 6: components dictionary usage 2: listenerobject = new object(); listenerobject.Change = function(eventobject){ ... } chooserinstance.Addeventlistener("change", listenerobject) description event; broadcast to all registered listeners when a date is selected. The first usage example uses ...

  • Page 359

    Datechooser component (flash professional only) 359 datechooser.Daynames availability flash player 6 (6.0 79.0). Edition flash mx professional 2004. Usage mydc.Daynames description property; an array containing the names of the days of the week. Sunday is the first day (at index position 0) and the ...

  • Page 360

    360 chapter 6: components dictionary datechooser.Disabledranges availability flash player 6 (6.0 79.0). Edition flash mx professional 2004. Usage mydc.Disabledranges description property; disables a single day or a range of days. This property is an array of objects. Each object in the array must be...

  • Page 361

    Datechooser component (flash professional only) 361 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 di...

  • Page 362

    362 chapter 6: components dictionary description property; a number indicating which day of the week (0-6, 0 being the first element of the daynames array) is displayed in the first column of the datechooser component. Changing this property changes the order of the day columns but has no effect on ...

  • Page 363

    Datechooser component (flash professional only) 363 ... } usage 2: listenerobject = new object(); listenerobject.Scroll = function(eventobject){ ... } mydc.Addeventlistener("scroll", listenerobject) description event; broadcast to all registered listeners when a month button is clicked. The first us...

  • Page 364

    364 chapter 6: components dictionary } mydc.Addeventlistener("scroll", form); datechooser.Selectablerange availability flash player 6 (6.0 79.0). Edition flash mx professional 2004. Usage mydc.Selectablerange description property; sets a single selectable date or a range of selectable dates. The use...

  • Page 365

    Datechooser component (flash professional only) 365 datechooser.Selecteddate availability flash player 6 (6.0 79.0). Edition flash mx professional 2004. Usage mydc.Selecteddate description property; a date object that indicates the selected date if that value falls within the value of the selectable...

  • Page 366: Chapter 6

    Datefield component (flash professional only) 367 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 ...

  • Page 367

    368 chapter 6: components dictionary creating an application with the datefield component the following procedure explains how to add a datefield component to an application while authoring. In this example, the datefield component allows a user to pick a date for an airline reservation system. All ...

  • Page 368

    Datefield component (flash professional only) 369 the datefield component supports the following styles: style theme description themecolor halo the glow color for the rollover and selected dates. Possible values are "halogreen" , "haloblue" , and "haloorange" . The default value is "halogreen" back...

  • Page 369

    370 chapter 6: components dictionary the datefield component uses four categories of text to display the month name, the days of the week, today’s date, and regular dates. The text style properties set on the datefield component itself control the regular date text and the text displayed in the coll...

  • Page 370

    Datefield component (flash professional only) 371 5. Ensure that the datefieldassets symbol is selected for export in first frame. 6. Expand the datefield assets/states folder in the library of your document. 7. Open the symbols you want to customize for editing. For example, open the openiconup sym...

  • Page 371

    372 chapter 6: components dictionary 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 . Methods inherited from the uico...

  • Page 372

    Datefield component (flash professional only) 373 properties inherited from the uiobject class the following table lists the properties the datefield class inherits from the uiobject class. When accessing these properties from the datefield object, use the form datefieldinstance.Propertyname . Datef...

  • Page 373

    374 chapter 6: components dictionary properties inherited from the uicomponent class the following table lists the properties the datefield class inherits from the uicomponent class. When accessing these properties from the datefield object, use the form datefieldinstance.Propertyname . Event summar...

  • Page 374

    Datefield component (flash professional only) 375 datefield.Change availability flash player 6 (6.0 79.0). Edition flash mx professional 2004. Usage usage 1: on(change){ ... } usage 2: listenerobject = new object(); listenerobject.Change = function(eventobject){ ... } mydf.Addeventlistener("change",...

  • Page 375

    376 chapter 6: components dictionary example this example, written on a frame of the timeline, sends a message to the output panel when a date field called mydf is changed. The first line of code creates a listener object called form . The second line defines a function for the change event on the l...

  • Page 376

    Datefield component (flash professional only) 377 usage usage 1: on(close){ ... } usage 2: listenerobject = new object(); listenerobject.Close = function(eventobject){ ... } mydf.Addeventlistener("close", listenerobject) description event; broadcast to all registered listeners when the datechooser s...

  • Page 377

    378 chapter 6: components dictionary form.Close = function(eventobj){ trace("pulldown closed" + eventobj.Target.Selecteddate); } mydf.Addeventlistener("close", form); datefield.Dateformatter availability flash player 6 (6.0 79.0). Edition flash mx professional 2004. Usage mydf.Dateformatter descript...

  • Page 378

    Datefield component (flash professional only) 379 datefield.Disableddays availability flash player 6 (6.0 79.0). Edition flash mx professional 2004. Usage mydf.Disableddays description property; an array indicating the disabled days of the week. All the dates in a month that fall on the specified da...

  • Page 379

    380 chapter 6: components dictionary example the following example defines an array with rangestart and rangeend date objects that disable the dates between may 7 and june 7: mydf.Disabledranges = [ {rangestart: new date(2003, 4, 7), rangeend: new date(2003, 5, 7)}]; the following example disables a...

  • Page 380

    Datefield component (flash professional only) 381 usage mydf.Displayedyear description property; a number indicating which year is displayed. The default value is the current year. Example the following example sets the displayed year to 2010: mydf.Displayedyear = 2010; see also datefield.Displayedm...

  • Page 381

    382 chapter 6: components dictionary description property; an array of strings indicating the month names at the top of the datefield component. The default value is ["january", "february", "march", "april", "may", "june", "july", "august", "september", "october", "november", "december"] . Example t...

  • Page 382

    Datefield component (flash professional only) 383 ... } usage 2: listenerobject = new object(); listenerobject.Open = function(eventobject){ ... } mydf.Addeventlistener("open", listenerobject) description event; broadcast to all registered listeners when a datechooser subcomponent opens after a user...

  • Page 383

    384 chapter 6: components dictionary } mydf.Addeventlistener("open", form); datefield.Pulldown availability flash player 6 (6.0 79.0). Edition flash mx professional 2004. Usage mydf.Pulldown description property (read-only); a reference to the datechooser component contained by the datefield compone...

  • Page 384

    Datefield component (flash professional only) 385 description event; broadcast to all registered listeners when a month button is clicked. The first usage example uses an on() handler and must be attached directly to a datefield instance. The keyword this , used inside an on() handler attached to a ...

  • Page 385

    386 chapter 6: components dictionary datefield.Selectablerange availability flash player 6 (6.0 79.0). Edition flash mx professional 2004. Usage mydf.Selectablerange description property; sets a single selectable date or a range of selectable dates. The value of this property is an object that consi...

  • Page 386

    Datefield component (flash professional only) 387 datefield.Selecteddate availability flash player 6 (6.0 79.0). Edition flash mx professional 2004. Usage mydf.Selecteddate description property; a date object that indicates the selected date if that value falls within the value of the selectablerang...

  • Page 387: Chapter 6

    388 chapter 6: components dictionary delegate class inheritance object > delegate actionscript class name mx.Utils.Delegate the delegate class lets you run a function in a specific scope. This class is provided so that you can dispatch the same event to two different functions (see “delegating event...

  • Page 388

    Delegate class 389 see also eventdispatcher.Addeventlistener().

  • Page 389: Chapter 6

    390 chapter 6: components dictionary delta interface (flash professional only) actionscript interface name mx.Data.Components.Datasetclasses.Delta the delta interface provides access to the transfer object, collection, and transfer object-level changes. With this interface you can access the new and...

  • Page 390

    Delta interface (flash professional only) 391 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("id1...

  • Page 391

    392 chapter 6: components dictionary } //... Delta.Getdeltapacket() availability flash player 7. Edition flash mx professional 2004. Usage delta.Getdeltapacket() parameters none. Returns the delta packet that contains this delta. Description method; returns the delta packet that contains this delta....

  • Page 392

    Delta interface (flash professional only) 393 description method; returns a unique identifier for this item within the deltapacket collection. Use this id in the source component for the delta packet to receive updates and make changes to items that the delta packet was generated from. For example, ...

  • Page 393

    394 chapter 6: components dictionary if (deltaobj.Getoperation() != deltapacketconsts.Added) { oldvalue = (chgitem != null ? (chgitem.Oldvalue != null ? Encodefieldvalue(field.Name, chgitem.Oldvalue) : __nullvalue) : encodefieldvalue(field.Name, deltaobj.Getsource()[field.Name])); newvalue = (chgite...

  • Page 394

    Delta interface (flash professional only) 395 delta.Getoperation() availability flash player 7. Edition flash mx professional 2004. Usage delta.Getoperation() parameters none. Returns a number; returns the operation that was performed on the item within the original collection. Description method; r...

  • Page 395

    396 chapter 6: components dictionary parameters none. Returns the transfer object on which the changes were performed. Description method; returns the transfer object on which the changes were performed. Example the following example calls the getsource() method: while(dpcursor.Hasnext()) { dpdelta ...

  • Page 396: Chapter 6

    Deltaitem class (flash professional only) 397 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 di...

  • Page 397

    398 chapter 6: components dictionary usage deltaitem.Arglist description property (read-only); an array of values passed to the change method. This property applies only if the change’s kind is deltaitem.Method . Deltaitem.Curvalue availability flash player 7. Edition flash mx professional 2004. Usa...

  • Page 398

    Deltaitem class (flash professional only) 399 usage deltaitem.Kind description property; a number that indicates the type of change. Use the following constants to evaluate this property: • deltaitem.Property the change was made to a property on the transfer object. • deltaitem.Method the change was...

  • Page 399

    400 chapter 6: components dictionary 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.Propert...

  • Page 400: Chapter 6

    Deltapacket interface (flash professional only) 401 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 manageme...

  • Page 401

    402 chapter 6: components dictionary usage deltapacket.Getconfiginfo(info) parameters info object; contains information specific to the implementation. Returns an object that contains information required for the specific deltapacket implementation. Description method; returns configuration informat...

  • Page 402

    Deltapacket interface (flash professional only) 403 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 del...

  • Page 403

    404 chapter 6: components dictionary deltapacket.Gettimestamp() availability flash player 7. Edition flash mx professional 2004. Usage deltapacket.Gettimestamp() parameters none. Returns a date object containing the date and time at which the delta packet was created. Description method; returns the...

  • Page 404

    Deltapacket interface (flash professional only) 405 description method; returns the transaction id for the delta packet. This unique identifier is used to group a send/receive transaction for a delta packet. The data set uses this to determine if the delta packet is part of the same transaction it o...

  • Page 405: Chapter 6

    406 chapter 6: components dictionary depthmanager class actionscript class name mx.Managers.Depthmanager the depthmanager class allows you manage the relative depth assignments of any component or movie clip, including _root . It also lets you manage reserved depths in a special highest-depth clip o...

  • Page 406

    Depthmanager class 407 property summary for the depthmanager class the following table lists the properties of the depthmanager class. Depthmanager.Createchildatdepth() availability flash player 6 (6.0 79.0). Edition flash mx 2004. Usage movieclipinstance.Createchildatdepth(linkagename, depthflag[, ...

  • Page 407

    408 chapter 6: components dictionary example the following example creates a minutehand instance of the minutesymbol movie clip and places it in front of the clock: import mx.Managers.Depthmanager; minutehand = clock.Createchildatdepth("minutesymbol", depthmanager.Ktop); depthmanager.Createclasschil...

  • Page 408

    Depthmanager class 409 depthmanager.Createclassobjectatdepth() availability flash player 6 (6.0 79.0). Edition flash mx 2004. Usage depthmanager.Createclassobjectatdepth(classname, depthspace[, initobj]) parameters classname a class name. This parameter is of type function. Depthspace one of the fol...

  • Page 409

    410 chapter 6: components dictionary depthspace one of the following values: depthmanager.Kcursor , depthmanager.Ktooltip . All depth flags are static properties of the depthmanger class. You must either reference the depthmanager package (for example, mx.Managers.Depthmanager.Kcursor ), or use the ...

  • Page 410

    Depthmanager class 411 description property (static); a property with the constant value 101. This property is passed as a parameter in calls to depthmanager.Createclassobjectatdepth() and depthmanager.Createobjectatdepth() to request placement at cursor depth. Depthmanager.Knotopmost availability f...

  • Page 411

    412 chapter 6: components dictionary description property (static); a property with the constant value 201. This property is passed as a parameter in calls to depthmanager.Createclasschildatdepth() and depthmanager.Createchildatdepth() to request placement on top of other content but below depthmana...

  • Page 412

    Depthmanager class 413 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 me...

  • Page 413

    414 chapter 6: components dictionary example the following example sets the depth of the mc1 instance to a depth of 10: mc1.Setdepthto(10); for more information about depth and stacking order, see “determining the next highest available depth” in using actionscript in flash..

  • Page 414: Chapter 6

    Eventdispatcher class 415 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 c...

  • Page 415

    416 chapter 6: components dictionary method summary for the eventdispatcher class the following table lists the methods of the eventdispatcher class. Eventdispatcher.Addeventlistener() availability flash player 6 (6.0 79.0). Edition flash mx 2004 and flash mx professional 2004. Usage componentinstan...

  • Page 416

    Eventdispatcher class 417 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...

  • Page 417

    418 chapter 6: components dictionary parameters eventobject a reference to an event object. The event object must have a type property that is a string indicating the name of the event. Generally, the event object also has a target property that is the name of the instance broadcasting the event. Yo...

  • Page 418: Chapter 6

    Focusmanager class 419 focusmanager class you can use the focus manager to specify the order in which components receive focus when a user presses the tab key to navigate in an application. You can also use the focus manager to set a button in your document that receives keyboard input when a user p...

  • Page 419

    420 chapter 6: components dictionary to create a button that receives focus when a user presses enter (windows) or return (macintosh), set the focusmanager.Defaultpushbutton property to the instance name of the desired button, as shown here: focusmanager.Defaultpushbutton = okbutton; note: the focus...

  • Page 420

    Focusmanager class 421 if a flash application is playing in a web browser, the application doesn’t have focus until a user clicks somewhere in the application. Also, once a user clicks in the flash application, pressing tab can cause focus to jump outside the flash application. To keep tabbing limit...

  • Page 421

    422 chapter 6: components dictionary tip: in a class file that inherits from uicomponent, it is not good practice to refer to _root.Focusmanager . Every uicomponent instance inherits a getfocusmanager() method, which returns a reference to the focusmanager instance responsible for controlling that c...

  • Page 422

    Focusmanager class 423 property summary for the focusmanager class the following table lists the properties of the focusmanager class. Properties inherited from the uiobject class the following table lists the properties the focusmanager class inherits from the uiobject class. Property description f...

  • Page 423

    424 chapter 6: components dictionary properties inherited from the uicomponent class the following table lists the properties the focusmanager class inherits from the uicomponent class. Event summary for the focusmanager class there are no events exclusive to the focusmanager class. Events inherited...

  • Page 424

    Focusmanager class 425 usage focusmanager.Defaultpushbutton description property; specifies the default push button for an application. When the user presses enter (windows) or return (macintosh), the listeners of the default push button receive a click event. The default value is undefined and the ...

  • Page 425

    426 chapter 6: components dictionary example the following code disables default push button handling: focusmanager.Defaultpushbuttonenabled = false; focusmanager.Enabled availability flash player 6 (6.0 79.0). Edition flash mx 2004. Usage focusmanager.Enabled description property; a boolean value t...

  • Page 426

    Focusmanager class 427 example the following code sets the focus to myokbutton if the object that currently has focus is myinputtext : if (focusmanager.Getfocus() == myinputtext) { focusmanager.Setfocus(myokbutton); } see also focusmanager.Setfocus() focusmanager.Nexttabindex availability flash play...

  • Page 427

    428 chapter 6: components dictionary 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 us...

  • Page 428

    Focusmanager class 429 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 specif...

  • Page 429: Chapter 6

    430 chapter 6: components dictionary form class (flash professional only) the form class provides the runtime behavior of forms you create in the screen outline pane in flash mx professional 2004. For an overview of working with screens, see chapter 12, “working with screens (flash professional only...

  • Page 430

    Form class (flash professional only) 431 form parameters you can set the following authoring parameters for each form instance in the property inspector or in the component inspector: autoload indicates whether the content specified by the contentpath parameter should load automatically ( true ), or...

  • Page 431

    432 chapter 6: components dictionary methods inherited from the uicomponent class the following table lists the methods the form class inherits from the uicomponent class. When calling these methods from the form object, use the syntax forminstance.Methodname . Methods inherited from the loader clas...

  • Page 432

    Form class (flash professional only) 433 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 . Properties inherited from t...

  • Page 433

    434 chapter 6: components dictionary 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 . Properties inherited from the scree...

  • Page 434

    Form class (flash professional only) 435 events inherited from the uiobject class the following table lists the events the form class inherits from the uiobject class. Events inherited from the uicomponent class the following table lists the events the form class inherits from the uicomponent class....

  • Page 435

    436 chapter 6: components dictionary form.Currentfocusedform availability flash player 6 (6.0 79.0). Edition flash mx professional 2004. Usage mx.Screens.Form.Currentfocusedform description property (read-only); returns the form object that contains the global current focus. The actual focus may be ...

  • Page 436

    Form class (flash professional only) 437 returns a form object. Description method; returns the child form of myform whose index is childindex . Example the following example displays in the output panel the names of all the child form objects belonging to the root form object named application . Fo...

  • Page 437

    438 chapter 6: components dictionary form.Numchildforms availability flash player 6 (6.0 79.0). Edition flash mx professional 2004. Usage myform.Numchildforms description property (read-only); the number of child forms contained by myform that are derived directly from the class mx.Screens.Form. Thi...

  • Page 438

    Form class (flash professional only) 439 example if (myform.Parentisform) { trace("i have "+myform._parent.Numchildscreens+" sibling screens"); } else { trace("i am the root form and have no siblings"); } form.Parentform availability flash player 6 (6.0 79.0). Edition flash mx professional 2004. Usa...

  • Page 439

    440 chapter 6: components dictionary example in the following example, a reference to the root form of myform is placed in a variable named root . If the value assigned to root refers to myform , then myform is at the top of its form tree. Var root:mx.Screens.Form = myform.Rootform; if(rootform == m...

  • Page 440: Chapter 6

    Iterator interface (flash professional only) 441 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...

  • Page 441

    442 chapter 6: components dictionary iterator.Next() availability flash player 7. Edition flash mx professional 2004. Usage iterator.Next() returns an object that is the next item in the iterator. Description method; returns an instance of the next item in the iterator. You must cast this instance t...

  • Page 442: Chapter 6

    Label component 443 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 ...

  • Page 443

    444 chapter 6: components dictionary note: the label component’s autosize property is different from the built-in actionscript textfield object’s autosize property. You can write actionscript to set additional options for label instances using its methods, properties, and events. For more informatio...

  • Page 444

    Label component 445 using skins with the label component the label component does not have any visual elements to skin. 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 ...

  • Page 445

    446 chapter 6: components dictionary property summary for the label class the following table lists properties of the label class. Properties inherited from the uiobject class the following table lists the properties the label class inherits from the uiobject class. When accessing these properties, ...

  • Page 446

    Label component 447 event summary for the label class there are no events exclusive to the label class. Events inherited from the uiobject class the following table lists the events the label class inherits from the uiobject class. Label.Autosize availability flash player 6 (6.0 79.0). Edition flash...

  • Page 447

    448 chapter 6: components dictionary • center the bottom side of the label resizes to fit the text. The horizontal center of the label stays anchored at its original horizontal center position. • right the left and bottom sides of the label resize to fit the text. The top and right sides don’t resiz...

  • Page 448

    Label component 449 description property; the text of a label. The default value is "label" . Example the following code sets the text property of the label instance labelcontrol and sends the value to the output panel: labelcontrol.Text = "the royal nonesuch"; trace(labelcontrol.Text);.

  • Page 449: Chapter 6

    450 chapter 6: components dictionary list component the list component is a scrollable single- or multiple-selection list box. A list can also display graphics, including other components. You add the items displayed in the list by using the values dialog box that appears when you click in the label...

  • Page 450

    List component 451 using the list component you can set up a list so that users can make either single or multiple selections. For example, a user visiting an e-commerce website needs to select which item to buy. There are 30 items, and the user scrolls through a list and selects one by clicking it....

  • Page 451

    452 chapter 6: components dictionary • lists aren’t tables. For example, datagrid components, which extend the list class, are intended to provide an interface for many records. They’re not designed to display complete information; they’re designed to display enough information so that users can dri...

  • Page 452

    List component 453 4. Select frame 1 of the timeline and, in the actions panel, enter the following: mylist.Dataprovider = mydp; if you have defined a data provider named mydp , the list will fill with data. (for more information about data providers, see list.Dataprovider .) 5. Select control > tes...

  • Page 453

    454 chapter 6: components dictionary embedfonts both a boolean value that indicates whether the font specified in fontfamily is an embedded font. This style must be set to true if fontfamily refers to an embedded font. Otherwise, the embedded font will not be used. If this style is set to true and f...

  • Page 454

    List component 455 setting styles for all list components in a document the list class 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 ...

  • Page 455

    456 chapter 6: components dictionary target.Setstyle(style, source.Getstyle(style)); } to provide styles for the list component but not for components that extend list (datagrid and tree), you must provide class-level style declarations for these subclasses. Import mx.Styles.Cssstyledeclaration; if ...

  • Page 456

    List component 457 to add a list component to the tab order of an application, set its tabindex property (see uicomponent.Tabindex ). The list component uses the focus manager to override the default flash player focus rectangle and draw a custom focus rectangle with rounded corners. For more inform...

  • Page 457

    458 chapter 6: components dictionary methods inherited from the uicomponent class the following table lists the methods the list class inherits from the uicomponent class. When calling these methods, use the form listinstance.Methodname . Property summary for the list class the following table lists...

  • Page 458

    List component 459 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 . Properties inherited from the uicomponent class the following table list...

  • Page 459

    460 chapter 6: components dictionary event summary for the list class the following table lists events that of the list class. Events inherited from the uiobject class the following table lists the events the list class inherits from the uiobject class. Events inherited from the uicomponent class th...

  • Page 460

    List component 461 usage listinstance.Additem(label[, data]) listinstance.Additem(itemobject) parameters 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 ...

  • Page 461

    462 chapter 6: components dictionary data the data for the item. This parameter is optional and can be of any data type. Itemobject an item object that usually has label and data properties. Returns the index at which the item was added. Description method; adds a new item to the position specified ...

  • Page 462

    List component 463 list.Change availability flash player 6 (6.0 79.0). Edition flash mx 2004. Usage usage 1: on(change){ // your code here } usage 2: listenerobject = new object(); listenerobject.Change = function(eventobject){ // your code here } listinstance.Addeventlistener("change", listenerobje...

  • Page 463

    464 chapter 6: components dictionary example the following example sends the instance name of the component that generated the change event to the output panel: form.Change = function(eventobj){ trace("value changed to " + eventobj.Target.Value); } mylist.Addeventlistener("change", form); see also e...

  • Page 464

    List component 465 this example creates a data provider array and assigns it to the dataprovider property, as in the following: mydp = new array(); list.Dataprovider = mydp; for (var i=0; i // these changes to the data provider will be broadcast to the list mydp.Additem({label: accounts[i].Name, dat...

  • Page 465

    466 chapter 6: components dictionary description property; scrolls the list horizontally to the number of pixels specified. You can’t set hposition unless the value of hscrollpolicy is "on" and the list has a maxhposition that is greater than 0. Example the following example gets the horizontal scro...

  • Page 466

    List component 467 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 th...

  • Page 467

    468 chapter 6: components dictionary list.Itemrollout availability flash player 6 (6.0 79.0). Edition flash mx 2004. Usage usage 1: on(itemrollout){ // your code here } usage 2: listenerobject = new object(); listenerobject.Itemrollout = function(eventobject){ // your code here } listinstance.Addeve...

  • Page 468

    List component 469 example the following example sends a message to the output panel that indicates which item index number has been rolled over: form.Itemrollout = function (eventobj) { trace("item #" + eventobj.Index + " has been rolled out."); } mylist.Addeventlistener("itemrollout", form); see a...

  • Page 469

    470 chapter 6: components dictionary the second usage example uses a dispatcher/listener event model. A component instance ( listinstance ) dispatches an event (in this case, itemrollover ) and the event is handled by a function, also called a handler, on a listener object ( listenerobject ) that yo...

  • Page 470

    List component 471 list.Labelfunction availability flash player 6 (6.0 79.0). Edition flash mx 2004. Usage listinstance.Labelfunction description property; specifies a function that determines which field (or field combination) of each item to display. This function receives one parameter, item , wh...

  • Page 471

    472 chapter 6: components dictionary list.Maxhposition availability flash player 6 (6.0 79.0). Edition flash mx 2004. Usage listinstance.Maxhposition description property; specifies the number of pixels the list can scroll when list.Hscrollpolicy is set to "on" . The list doesn’t precisely measure t...

  • Page 472

    List component 473 list.Removeall() availability flash player 6 (6.0 79.0). Edition flash mx 2004. Usage listinstance.Removeall() parameters none. Returns nothing. Description method; removes all items in the list. Calling this method modifies the data provider of the list component. If the data pro...

  • Page 473

    474 chapter 6: components dictionary calling this method modifies the data provider of the list component. If the data provider is shared with other components, those components will update as well. Example the following code removes the item at index position 3: mylist.Removeitemat(3); list.Replace...

  • Page 474

    List component 475 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...

  • Page 475

    476 chapter 6: components dictionary description property; the height, in pixels, of every row in the list. The font settings do not make the rows grow to fit, so setting the rowheight property is the best way to make sure items are fully displayed. The default value is 20. Example the following exa...

  • Page 476

    List component 477 the second usage example uses a dispatcher/listener event model. A component instance ( listinstance ) dispatches an event (in this case, scroll ) and the event is handled by a function, also called a handler, on a listener object ( listenerobject ) that you create. You define a m...

  • Page 477

    478 chapter 6: components dictionary description property; the selected index of a single-selection list. The value is undefined if nothing is selected; the value is equal to the last item selected if there are multiple selections. If you assign a value to selectedindex , any current selection is cl...

  • Page 478

    List component 479 list.Selecteditem availability flash player 6 (6.0 79.0). Edition flash mx 2004. Usage listinstance.Selecteditem description property (read-only); an item object in a single-selection list. (in a multiple-selection list with multiple items selected, selecteditem returns the item t...

  • Page 479

    480 chapter 6: components dictionary list.Setpropertiesat() availability flash player 6 (6.0 79.0). Edition flash mx 2004. Usage listinstance.Setpropertiesat(index, styleobj) parameters index a number greater than 0 or less than list.Length indicating the index of the item to change. Styleobj an obj...

  • Page 480

    List component 481 description method; sorts the items in the list by using the function specified in the comparefunc parameter. Example the following example sorts the items according to uppercase labels. Note that the a and b parameters that are passed to the function are items that have label and...

  • Page 481

    482 chapter 6: components dictionary • array.Returnindexedarray , which returns an integer index array that is the result of the sort. For example, the following array would return the second line of code and the array would remain unchanged: ["a", "d", "c", "b"] [0, 3, 2, 1] you can combine these o...

  • Page 482

    List component 483 example the following example sets the position of the list to the first index item: mylist.Vposition = 0; list.Vscrollpolicy availability flash player 6 (6.0 79.0). Edition flash mx 2004. Usage listinstance.Vscrollpolicy description property; a string that determines whether the ...

  • Page 483: Chapter 6

    484 chapter 6: components dictionary loader component the loader component is a container that can display a swf or jpeg file. You can scale the contents of the loader or resize the loader itself to accommodate the size of the contents. By default, the contents are scaled to fit the loader. You can ...

  • Page 484

    Loader component 485 contentpath an absolute or relative url indicating the file to load into the loader. A relative path must be relative to the swf file loading the content. The url must be in the same subdomain as the url where the flash content currently resides. For use in flash player or in te...

  • Page 485

    486 chapter 6: components dictionary using skins with the loader component the loader component uses an instance of rectborder for its border (see “rectborder class” on page 647 ). Loader class inheritance movieclip > uiobject class > uicomponent class > view > loader actionscript class name mx.Cont...

  • Page 486

    Loader component 487 methods inherited from the uicomponent class the following table lists the methods the loader class inherits from the uicomponent class. When calling these methods from the loader object, use the form loaderinstance.Methodname . Property summary for the loader class the followin...

  • Page 487

    488 chapter 6: components dictionary properties inherited from the uicomponent class the following table lists the properties the loader class inherits from the uicomponent class. When accessing these properties from the loader object, use the form loaderinstance.Propertyname . Event summary for the...

  • Page 488

    Loader component 489 events inherited from the uicomponent class the following table lists the events the loader class inherits from the uicomponent class. Loader.Autoload availability flash player 6 (6.0 79.0). Edition flash mx 2004. Usage loaderinstance.Autoload description property; a boolean val...

  • Page 489

    490 chapter 6: components dictionary description property (read-only); the number of bytes of content that have been loaded. The default value is 0 until content begins loading. Example the following code creates a progress bar and a loader component. It then creates a listener object with a progres...

  • Page 490

    Loader component 491 // eventobj.Target is the component that generated the progress event, // that is, the loader pbar.Setprogress(loader.Bytesloaded, loader.Bytestotal); // show progress } loader.Addeventlistener("progress", loadlistener); loader.Content = "logo.Swf"; see also loader.Bytesloaded l...

  • Page 491

    492 chapter 6: components dictionary the second usage example uses a dispatcher/listener event model. A component instance ( loaderinstance ) dispatches an event (in this case, complete ) and the event is handled by a function, also called a handler, on a listener object ( listenerobject ) that you ...

  • Page 492

    Loader component 493 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...

  • Page 493

    494 chapter 6: components dictionary example the following code creates a loader instance and sets the autoload property to false so that the loader must wait for a call to load() to begin loading content. Next, the contentpath property is set, which indicates where to load content from. Then other ...

  • Page 494

    Loader component 495 loader.Progress availability flash player 6 (6.0 79.0). Edition flash mx 2004. Usage usage 1: on(progress){ ... } usage 2: listenerobject = new object(); listenerobject.Progress = function(eventobject){ ... } loaderinstance.Addeventlistener("progress", listenerobject) descriptio...

  • Page 495

    496 chapter 6: components dictionary example the following code creates a loader instance and then creates a listener object with an event handler for the progress event that sends a message to the output panel telling what percent of the content has loaded: createclassobject(mx.Controls.Loader, "lo...

  • Page 496: Chapter 6

    Media components (flash professional only) 497 media components (flash professional only) the streaming media components make it easy to incorporate streaming media into flash presentations. These components let you present your media in a variety of ways. You can use the following three media compo...

  • Page 497

    498 chapter 6: components dictionary understanding media components (flash professional only) this section provides an overview of how the media components work. Most of the properties listed in this section can be set with the component inspector. (see “using the component inspector with media comp...

  • Page 498

    Media components (flash professional only) 499 • cue point objects, along with their name, time, and player properties (see media.Addcuepoint() and media.Cuepoints ). The name of the cue point is arbitrary; use a name that will have meaning when using listener and trace events. A cue point broadcast...

  • Page 499

    500 chapter 6: components dictionary for flv files, when media.Autosize is set to true , the media is displayed at its preferred size, regardless of the size of the component. This means that if the size of the mediadisplay instance size is different from the size of the media, the media will either...

  • Page 500

    Media components (flash professional only) 501 you can associate the mediadisplay and mediacontroller components with each other by using the media.Associatedisplay() and media.Associatecontroller() methods. These methods allow the mediacontroller instance to update its controls based on events broa...

  • Page 501

    502 chapter 6: components dictionary 7. Set the desired options for the automatically play, use preferred media size, and respect aspect ratio check boxes. 8. Set the control placement to the desired side of the mediaplayback component. 9. Add a cue point toward the end of the media; this cue point ...

  • Page 502

    Media components (flash professional only) 503 using the mediadisplay and mediacontroller components if you want a lot of control over the look and feel of your media display, you may want to use the mediadisplay and mediacontroller components together. The following example creates a flash applicat...

  • Page 503

    504 chapter 6: components dictionary 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 com...

  • Page 504

    Media components (flash professional only) 505 to control a media component with a behavior, you use the behaviors panel to apply the behavior to a given media component instance. You specify the event that will trigger the behavior (such as reaching a specified cue point), select a target object (t...

  • Page 505

    506 chapter 6: components dictionary to use a labeled frame cuepoint navigation behavior: 1. Place a mediadisplay or mediaplayback component instance on the stage. 2. Select the desired frame that you want the media to navigate to and, using the property inspector, enter the frame name mylabeledfram...

  • Page 506

    Media components (flash professional only) 507 mediadisplay parameters mediacontroller parameters name type default value description automatically play ( media.Autoplay ) boolean selected determines if the media plays as soon as it has loaded. Use preferred media size ( media.Autosize ) boolean sel...

  • Page 507

    508 chapter 6: components dictionary mediaplayback parameters horizontal ( media.Horizontal ) boolean true determines whether the controller portion of the instance is vertically or horizontally oriented. A true value indicates that the component will have a horizontal orientation. Enabled boolean t...

  • Page 508

    Media components (flash professional only) 509 creating applications with media components (flash professional only) creating flash content by using media components is quite simple and often requires only a few steps. This example shows how to create an application to play a small, publicly availab...

  • Page 509

    510 chapter 6: components dictionary media class (flash professional only) inheritance movieclip > uiobject class > uicomponent class > media actionscript class names mx.Controls.Mediacontroller, mx.Controls.Mediadisplay, mx.Controls.Mediaplayback each component class has a version property, which i...

  • Page 510

    Media components (flash professional only) 511 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, ...

  • Page 511

    512 chapter 6: components dictionary event summary for the media class the following table lists events of the media class. Media.Activeplaycontrol applies to mediacontroller availability flash player 7. Edition flash mx professional 2004. Usage mymedia.Activeplaycontrol media.Preferredwidth mediadi...

  • Page 512

    Media components (flash professional only) 513 description property; a string value that specifies the state the mediacontroller component should be in when it is loaded at runtime. A value of "play" indicates a play state; a value of "pause" indicates a paused state. Set this property and the autop...

  • Page 513

    514 chapter 6: components dictionary description method; adds a cue point object to a mediaplayback or mediadisplay instance. When the playhead time equals a cue point time, a cuepoint event is broadcast. Example the following code adds a cue point called homerun to mymedia when the playhead time eq...

  • Page 514

    Media components (flash professional only) 515 edition flash mx professional 2004. Usage mymedia.Associatecontroller(instancename) parameters instancename a string that specifies the instance name of the mediacontroller component to associate. Returns nothing. Description method; associates a mediad...

  • Page 515

    516 chapter 6: components dictionary 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 f...

  • Page 516

    Media components (flash professional only) 517 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...

  • Page 517

    518 chapter 6: components dictionary media.Backgroundstyle applies to mediacontroller availability flash player 7. Edition flash mx professional 2004. Usage mymedia.Backgroundstyle description property; a boolean value that indicates which background is drawn for the mediacontroller instance. A valu...

  • Page 518

    Media components (flash professional only) 519 // perform some function until playback ready for (playbackload somefunction(); } media.Bytestotal applies to mediadisplay, mediaplayback availability flash player 7. Edition flash mx professional 2004. Usage mymedia.Bytestotal description read-only pro...

  • Page 519

    520 chapter 6: components dictionary when the event is triggered, it automatically passes an event object ( eventobject ) to the handler. Each event object has properties that contain information about the event. You can use these properties to write code that handles the event. The media.Change eve...

  • Page 520

    Media components (flash professional only) 521 example the following example opens a pop-up window when the user clicks play: var mymedialistener = new object() mymedialistener.Click = function(){ popupmanager.Createpopup(_root, mx.Containers.Window, false, {contentpath: moviesale}); } mymedia.Addev...

  • Page 521

    522 chapter 6: components dictionary media.Contentpath applies to mediadisplay, mediaplayback availability flash player 7. Edition flash mx professional 2004. Usage mymedia.Contentpath description property; a string that holds the relative path and filename of the media to be streamed and/or played....

  • Page 522

    Media components (flash professional only) 523 the possible values for this property are as follows: • "on" specifies that the controls are always expanded. • "off" specifies that the controls are always collapsed. • "auto" (the default) specifies that the control remains in the collapsed state unti...

  • Page 523

    524 chapter 6: components dictionary edition flash mx professional 2004. Usage listenerobject = new object(); listenerobject.Cuepoint = function(eventobject){ // insert your code here } mymedia.Addeventlistener("cuepoint", listenerobject) description event; notification that the playhead has reached...

  • Page 524

    Media components (flash professional only) 525 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 ...

  • Page 525

    526 chapter 6: components dictionary media.Displaynormal() applies to mediaplayback availability flash player 7. Edition flash mx professional 2004. Usage mymedia.Displaynormal() parameters none. Returns nothing. Description method; sets the mediaplayback instance back to its normal size after a med...

  • Page 526

    Media components (flash professional only) 527 returns a cue point object. Description method; returns a cue point object based on its cue point name. Example the following code retrieves a cue point named mycuepointname . Mymedia.Removecuepoint(mymedia.Getcuepoint("mycuepointname")); see also media...

  • Page 527

    528 chapter 6: components dictionary edition flash mx professional 2004. Usage mymedia.Mediatype description property; indicates the type of media (flv or mp3) to be played. The default value is "flv" . See “importing macromedia flash video (flv) files” in using flash. Example the following example ...

  • Page 528

    Media components (flash professional only) 529 media.Play() applies to mediadisplay, mediaplayback availability flash player 7. Edition flash mx professional 2004. Usage mymedia.Play(startingpoint) parameters startingpoint a non-negative integer that indicates the starting point (in seconds) at whic...

  • Page 529

    530 chapter 6: components dictionary } mymedia.Addeventlistener("playheadchange", listenerobject) description event; broadcast by the mediacontroller or mediaplayback component when the user moves the playback slider or clicks the go to beginning or go to end button. The media.Playheadchange event o...

  • Page 530

    Media components (flash professional only) 531 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...

  • Page 531

    532 chapter 6: components dictionary example the following example sizes a mediaplayback instance according to the media it is playing and accounts for the pixel margin needed for the component instance: if(myplayback.Contentpath = !Undefined){ var mediaheight = myplayback.Preferredheight; var media...

  • Page 532

    Media components (flash professional only) 533 description event; is generated continuously until media has completely downloaded. The media.Progress event object has the following properties: target a reference to the mediadisplay or mediaplayback instance. Type the string "progress" . Example the ...

  • Page 533

    534 chapter 6: components dictionary returns nothing. Description method; deletes all cue point objects associated with a component instance. Example the following code deletes all cue point objects: mymedia.Removeallcuepoints(); see also media.Addcuepoint() , media.Cuepoints , media.Removecuepoint(...

  • Page 534

    Media components (flash professional only) 535 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. ...

  • Page 535

    536 chapter 6: components dictionary edition flash mx professional 2004. Usage mymedia.Stop() parameters none. Returns nothing. Description method; stops the playhead and moves it to position 0, which is the beginning of the media. Example the following code stops the playhead and moves it to positi...

  • Page 536

    Media components (flash professional only) 537 media.Volume applies to mediadisplay, mediaplayback availability flash player 7. Edition flash mx professional 2004. Usage mymedia.Volume description property; stores an integer that indicates the volume setting, which can range from 0 to 100. The defau...

  • Page 537

    538 chapter 6: components dictionary description event; broadcast when the volume value is adjusted by the user. The media.Volume event object has the following properties: detail an integer between 0 and 100 that represents the volume level. Type the string "volume" . Example the following example ...

  • Page 538: Chapter 6

    538 chapter 6: components dictionary menu component (flash professional only) the menu component lets a user select an item from a pop-up menu, much like the file or edit menu of most software applications. A menu component usually opens in an application when a user rolls over or clicks a button-li...

  • Page 539

    Menu component (flash professional only) 539 radio the item’s selected attribute is set to true , and the previously selected item’s selected attribute in the radio group is set to false . The selection property of the corresponding radio group object is set to refer to the selected menu item. Undef...

  • Page 540

    540 chapter 6: components dictionary 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...

  • Page 541

    Menu component (flash professional only) 541 about menu item xml attributes the attributes of a menu item xml element determine what is displayed, how the menu item behaves, and how it is exposed to actionscript. The following table describes the attributes of an xml menu item: about menu item types...

  • Page 542

    542 chapter 6: components dictionary normal menu items the normal item menu item doesn’t have a type attribute, which means that the type attribute defaults to normal . Normal items can be command activators or submenu activators, depending on whether they have nested subitems. Separator menu items ...

  • Page 543

    Menu component (flash professional only) 543 radio button menu items menu items whose type attribute is set to radio can be grouped together so that only one of the items can be selected at a time. You create a radio group by giving the menu items the same value for their groupname attribute, as in ...

  • Page 544

    544 chapter 6: components dictionary 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 ...

  • Page 545

    Menu component (flash professional only) 545 creating an application with the menu component (flash professional only) in the following example, a developer is building an application and uses the menu component to expose some of the commands that users can issue, such as open, close, and save. To c...

  • Page 546

    546 chapter 6: components dictionary to use xml data from a server to create and populate a menu: 1. Select file > new and create a flash document. 2. Drag the menu component from the components panel to the stage and delete it. This adds the menu component to the library without adding it to the ap...

  • Page 547

    Menu component (flash professional only) 547 to use the menudataprovider class to create and populate a menu: 1. Select file > new and create a flash document. 2. Drag the menu component from the components panel to the stage and delete it. This adds the menu component to the library without adding ...

  • Page 548

    548 chapter 6: components dictionary using styles with the menu component you can call the setstyle() method to change the style of the menu, its items, and its submenus.The menu component supports the following styles: style theme description themecolor halo the base color scheme of a component. Po...

  • Page 549

    Menu component (flash professional only) 549 textdecoration both the text decoration: either "none" or "underline" . The default value is "none" . Textindent both a number indicating the text indent. The default value is 0. Defaulticon both the name of the default icon to display on each row. The de...

  • Page 550

    550 chapter 6: components dictionary setting styles for all menu components in a document the menu class inherits from the scrollselectlist class. The default class-level style properties are defined on the scrollselectlist class, which is shared by all list-based components. You can set new default...

  • Page 551

    Menu component (flash professional only) 551 5. Open the symbols you want to customize for editing. For example, open the menucheckenabled symbol. 6. Customize the symbol as desired. For example, change the image to be an x instead of a check mark. 7. Repeat steps 6-7 for all symbols you want to cus...

  • Page 552

    552 chapter 6: components dictionary methods inherited from the uiobject class the following table lists the methods the menu class inherits from the uiobject class. When calling these methods from the menu object, use the form menuinstance.Methodname . Methods inherited from the uicomponent class t...

  • Page 553

    Menu component (flash professional only) 553 property summary for the menu class the following table lists the property of the menu class. Properties inherited from the uiobject class the following table lists the properties the menu class inherits from the uiobject class. When accessing these prope...

  • Page 554

    554 chapter 6: components dictionary event summary for the menu class the following table lists events of the menu class. Events inherited from the uiobject class the following table lists the events the menu class inherits from the uiobject class. Events inherited from the uicomponent class the fol...

  • Page 555

    Menu component (flash professional only) 555 usage usage 1: mymenu.Addmenuitem(initobject) usage 2: mymenu.Addmenuitem(childmenuitem) parameters initobject an object containing properties that initialize a menu item’s attributes. See “about menu item xml attributes” on page 541 . Childmenuitem an xm...

  • Page 556

    556 chapter 6: components dictionary parameters index an integer indicating the index position (among the child nodes) at which the item is added. Initobject an object containing properties that initialize a menu item’s attributes. See “about menu item xml attributes” on page 541 . Childmenuitem an ...

  • Page 557

    Menu component (flash professional only) 557 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.Cha...

  • Page 558

    558 chapter 6: components dictionary description method (static); instantiates a menu instance, and optionally attaches it to the specified parent, with the specified menudataprovider as the data source for the menu items. If the parent parameter is omitted or null, the menu is attached to the _root...

  • Page 559

    Menu component (flash professional only) 559 description property; the data source for items in a menu component. Menu.Dataprovider is an xml node object. Setting this property replaces the existing data source of the menu. The default value is undefined . Note: all xml or xmlnode instances are auto...

  • Page 560

    560 chapter 6: components dictionary menu.Hide() availability flash player 6 (6.0 79.0). Edition flash mx professional 2004. Usage mymenu.Hide() parameters none. Returns nothing. Description method; closes a menu. Example the following example retracts an extended menu: mymenu.Hide(); see also menu....

  • Page 561

    Menu component (flash professional only) 561 example the following example adds a menu item to a parent item and then gets the item’s index within its parent: var myitem = mymenu.Addmenuitem({label:"that item"}); var myindex = mymenu.Indexof(myitem); menu.Menuhide availability flash player 6 (6.0 79...

  • Page 562

    562 chapter 6: components dictionary } mymenu.Addeventlistener("menuhide", form); see also menu.Menushow menu.Menushow availability flash player 6 (6.0 79.0). Edition flash mx professional 2004. Usage listenerobject = new object(); listenerobject.Menushow = function(eventobject){ // insert your code...

  • Page 563

    Menu component (flash professional only) 563 } mymenu.Addeventlistener("menushow", form); see also menu.Menuhide menu.Removeall() availability flash player 6 (6.0 79.0). Edition flash mx professional 2004. Usage mymenu.Removeall() parameters none. Returns nothing. Description method; removes all ite...

  • Page 564

    564 chapter 6: components dictionary example the following example removes the menu item referenced by the variable theitem : theitem.Removemenuitem(); menu.Removemenuitemat() availability flash player 6 (6.0 79.0). Edition flash mx professional 2004. Usage mymenu.Removemenuitemat(index) parameters ...

  • Page 565

    Menu component (flash professional only) 565 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...

  • Page 566

    566 chapter 6: components dictionary 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 ev...

  • Page 567

    Menu component (flash professional only) 567 see also menu.Setmenuitemselected() menu.Setmenuitemselected() availability flash player 6 (6.0 79.0). Edition flash mx professional 2004. Usage mymenu.Setmenuitemselected(item, select) parameters item an xml node. The target menu item’s node in the data ...

  • Page 568

    568 chapter 6: components dictionary 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 loc...

  • Page 569

    Menu component (flash professional only) 569 method summary for the menudataprovider class the following table lists the methods of the menudataprovider class. Menudataprovider.Addmenuitem() availability flash player 6 (6.0 79.0). Edition flash mx professional 2004. Usage usage 1: mymenudataprovider...

  • Page 570

    570 chapter 6: components dictionary example the following example adds a new node to a specified node in the menu: var item0 = mymenudp.Getmenuitemat(0); item0.Addmenuitem("inbox", { label:"item 1", icon:"radioitemicon", type:"radio", selected:false, enabled:true, instancename:"radioitem1", groupna...

  • Page 571

    Menu component (flash professional only) 571 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 specifie...

  • Page 572

    572 chapter 6: components dictionary description method; returns the index of the specified menu item in this parent menu item. Any node or menu item in a menudataprovider instance can call the methods of the menudataprovider class. Example the following example adds a menu item to a parent item and...

  • Page 573

    Menu component (flash professional only) 573 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...

  • Page 574: Chapter 6

    574 chapter 6: components dictionary menubar component (flash professional only) the menubar component lets you create a horizontal menu bar with pop-up menus and commands, just like the menu bars that contain file and edit menus in common software applications. The menubar component complements the...

  • Page 575

    Menubar component (flash professional only) 575 using the menubar component (flash professional only) you can use the menubar component to add a set of menus (for example, file, edit, special, window) to the top edge of an application. Menubar parameters you can set the following authoring parameter...

  • Page 576

    576 chapter 6: components dictionary this code creates a listener object, listen , that uses the event object, evt , to catch menu item selections. Note: you must call the addeventlistener() method to register the listener with the menu instance, not with the menu bar instance. 7. Select control > t...

  • Page 577

    Menubar component (flash professional only) 577 using skins with the menubar component the menubar component uses three skins to represent its background, uses a movie clip symbol for highlighting individual items, and contains a menu component as the pop-up which itself is skinnable. The menubar sk...

  • Page 578

    578 chapter 6: components dictionary menubar class (flash professional only) inheritance movieclip > uiobject class > uicomponent class > menubar actionscript class name mx.Controls.Menubar the methods and properties of the menubar class let you create a horizontal menu bar with pop- up menus and co...

  • Page 579

    Menubar component (flash professional only) 579 methods inherited from the uicomponent class the following table lists the methods the menubar class inherits from the uicomponent class. When calling these methods from the menubar object, use the form menubar.Methodname . Property summary for the men...

  • Page 580

    580 chapter 6: components dictionary 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 . Event summary for the menuba...

  • Page 581

    Menubar component (flash professional only) 581 events inherited from the uicomponent class the following table lists the events the menubar class inherits from the uicomponent class. When calling these events from the menubar object, use the form menubar.Eventname . Menubar.Addmenu() availability f...

  • Page 582

    582 chapter 6: components dictionary mymenu = mymenubar.Addmenu("file"); mymenu.Addmenuitem({label:"new", instancename:"newinstance"}); mymenu.Addmenuitem({label:"open", instancename:"openinstance"}) usage 2: the following example adds a font menu with the menu items bold and italic that are defined...

  • Page 583

    Menubar component (flash professional only) 583 usage 2: the following example adds an edit menu with the menu items undo, redo, cut, and copy, which are defined in the menudataprovider instance mymenudp : var mymenudp = new xml(); mymenudp.Addmenuitem({label:"undo", instancename:"undoinst"}); mymen...

  • Page 584

    584 chapter 6: components dictionary menubar.Getmenuat() availability flash player 6 (6.0 79.0). Edition flash mx professional 2004. Usage mymenubar.Getmenuat(index) parameters index an integer indicating the position of the menu. Returns a reference to the menu at the specified index. This value is...

  • Page 585

    Menubar component (flash professional only) 585 description method; returns a boolean value that indicates whether this menu can be chosen ( true ) or not ( false ). Example the following example calls the method on the menu in the first position of mymenubar : mymenubar.Getmenuenabledat(0); menubar...

  • Page 586

    586 chapter 6: components dictionary example the following example of a label function builds and returns a custom label from the node attributes: mymenubar.Labelfunction = function(node){ var a = node.Attributes; return "the price for " + a.Name + " is " + a.Price; }; menubar.Removemenuat() availab...

  • Page 587

    Menubar component (flash professional only) 587 boolean a boolean value indicating whether the menu item at the specified index is enabled ( true ) or not ( false ). Returns nothing. Description method; enables the menu at the specified index. If there is no menu at that index, calling this method h...

  • Page 588: Chapter 6

    588 chapter 6: components dictionary numericstepper component the numericstepper component allows a user to step through an ordered set of numbers. The component consists of a number in a text box displayed beside small up and down arrow buttons. When a user presses the buttons, the number is raised...

  • Page 589

    Numericstepper component 589 numericstepper parameters you can set the following authoring parameters for each numericstepper instance in the property inspector or in the component inspector: value sets the value displayed in the text area of the stepper. The default value is 0. Minimum sets the min...

  • Page 590

    590 chapter 6: components dictionary customizing the numericstepper component you can transform a numericstepper component horizontally and vertically while authoring and at runtime. While authoring, select the component on the stage and use the free transform tool or any of the modify > transform c...

  • Page 591

    Numericstepper component 591 using skins with the numericstepper component the numericstepper component uses skins to represent its up and down button states. To skin the numericstepper component while authoring, modify skin symbols in the flash ui components 2/themes/mmdefault/stepper assets/states...

  • Page 592

    592 chapter 6: components dictionary 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...

  • Page 593

    Numericstepper component 593 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.C...

  • Page 594

    594 chapter 6: components dictionary property summary for the numericstepper class the following table lists properties of the numericstepper class. Properties inherited from the uiobject class the following table lists the properties the numericstepper class inherits from the uiobject class. When c...

  • Page 595

    Numericstepper component 595 properties inherited from the uicomponent class the following table lists the properties the numericstepper class inherits from the uicomponent class. When calling these properties from the numericstepper object, use the form numericstepper.Propertyname . Event summary f...

  • Page 596

    596 chapter 6: components dictionary numericstepper.Change availability flash player 6 (6.0 79.0). Edition flash mx 2004. Usage usage 1: on(click){ ... } usage 2: listenerobject = new object(); listenerobject.Change = function(eventobject){ ... } stepperinstance.Addeventlistener("change", listenerob...

  • Page 597

    Numericstepper component 597 example this example, written on a frame of the timeline, sends a message to the output panel when a stepper called mynumericstepper is changed. The first line of code creates a listener object called form . The second line defines a function for the change event on the ...

  • Page 598

    598 chapter 6: components dictionary usage stepperinstance.Minimum description property; the minimum range value of the stepper. This property can contain a number of up to three decimal places. The default value is 0. Example the following example sets the minimum value of the stepper range to 100:...

  • Page 599

    Numericstepper component 599 usage stepperinstance.Previousvalue description property (read-only); the previous sequential value. This property can contain a number of up to three decimal places. Example the following example sets the stepsize property to 1 and the starting value to 4, which would m...

  • Page 600

    600 chapter 6: components dictionary usage stepperinstance.Value description property; the current value displayed in the text area of the stepper. The value is not assigned if it does not correspond to the stepper’s range and step increment as defined in the stepsize property. This property can con...

  • Page 601: Chapter 6

    Popupmanager class 601 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 c...

  • Page 602

    602 chapter 6: components dictionary example the following code creates a modal window when the button is clicked: lo = new object(); lo.Click = function(){ mx.Managers.Popupmanager.Createpopup(_root, mx.Containers.Window, true); } button.Addeventlistener("click", lo); popupmanager.Deletepopup() ava...

  • Page 603: Chapter 6

    Progressbar component 603 progressbar component the progressbar component displays the progress of loading content. The loading process can be determinate or indeterminate. A determinate progress bar is a linear representation of a task’s progress over time and is used when the amount of content to ...

  • Page 604

    604 chapter 6: components dictionary labelplacement indicates the position of the label in relation to the progress bar. This parameter can be one of the following values: top , bottom , left , right , center . The default value is bottom . Conversion is a number by which to divide the %1 and %2 val...

  • Page 605

    Progressbar component 605 to create an application with the progressbar component in polled mode: 1. Drag a progressbar component from the components panel to the stage. 2. In the property inspector, do the following: ■ enter the instance name pbar. ■ select polled for the mode parameter. ■ enter lo...

  • Page 606

    606 chapter 6: components dictionary a progressbar component supports the following styles: 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 author...

  • Page 607

    Progressbar component 607 a progressbar component supports the following skin properties: to create movie clip symbols for progressbar 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 co...

  • Page 608

    608 chapter 6: components dictionary 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: tr...

  • Page 609

    Progressbar component 609 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 . Progressbar.Indeterminate indicat...

  • Page 610

    610 chapter 6: components dictionary event summary for the progressbar class the following table lists events of the progressbar class. 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...

  • Page 611

    Progressbar component 611 event object in addition to the standard event object properties, there are two additional properties defined for the progressbar.Complete event: current (the loaded value equals total), and total (the total value ). Description event; broadcast to all registered listeners ...

  • Page 612

    612 chapter 6: components dictionary progressbar.Conversion availability flash player 6 (6.0 79.0). Edition flash mx 2004. Usage pbarinstance.Conversion description property; a number that sets a conversion value for the incoming values. It divides the current and total values, floors them, and disp...

  • Page 613

    Progressbar component 613 usage pbarinstance.Indeterminate description property; a boolean value that indicates whether the progress bar has a striped fill and a loading source of unknown size ( true ), or a solid fill and a loading source of a known size ( false ). For example, you might use this p...

  • Page 614

    614 chapter 6: components dictionary description property; text that indicates the loading progress. This property is a string in the format "%1 out of %2 loaded (%3%%)" . In this string, %1 is a placeholder for the current bytes loaded, %2 is a placeholder for the total bytes loaded, and %3 is a pl...

  • Page 615

    Progressbar component 615 usage pbarinstance.Maximum description property; the largest value for the progress bar when the progressbar.Mode property is set to "manual" . Example the following code sets the maximum property to the total frames of a flash application that’s loading: pbar.Maximum = _to...

  • Page 616

    616 chapter 6: components dictionary description property; the mode in which the progress bar loads content. This value can be "event" , "polled" , or "manual" . Event mode and polled mode are the most common modes. In event mode, the source property specifies loading content that emits progress and...

  • Page 617

    Progressbar component 617 description property (read-only); tells what percentage of the content has been loaded. This value is floored. (the floor is the closest integer value that is less than or equal to the specified value. For example, the number 7.8 becomes 7.) the following formula is used to...

  • Page 618

    618 chapter 6: components dictionary the second usage example uses a dispatcher/listener event model. A component instance ( pbarinstance ) dispatches an event (in this case, progress ) and the event is handled by a function, also called a handler, on a listener object ( listenerobject ) that you cr...

  • Page 619

    Progressbar component 619 returns a number indicating the amount of progress that has been made. Description method; sets the state of the progress bar to reflect the amount of progress made when the progressbar.Mode property is set to "manual" . You can call this method to make the bar reflect the ...

  • Page 620

    620 chapter 6: components dictionary progressbar.Value availability flash player 6 (6.0 79.0). Edition flash mx 2004. Usage pbarinstance.Value description property (read-only); indicates the amount of progress that has been made. This property is a number between the value of progressbar.Minimum and...

  • Page 621: Chapter 6

    Radiobutton component 621 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...

  • Page 622

    622 chapter 6: components dictionary radiobutton parameters you can set the following authoring parameters for each radiobutton component instance in the property inspector or in the component inspector: label sets the value of the text on the button; the default value is radio button . Data is the ...

  • Page 623

    Radiobutton component 623 customizing the radiobutton component you can transform a radiobutton component horizontally and vertically while authoring and at runtime. While authoring, select the component on the stage and use the free transform tool or any of the modify > transform commands. At runti...

  • Page 624

    624 chapter 6: components dictionary using skins with the radiobutton component you can skin the radiobutton component while authoring by modifying the component’s symbols in the library. The skins for the radiobutton component are located in the following folder in the library of halotheme.Fla or s...

  • Page 625

    Radiobutton component 625 to create movie clip symbols for radiobutton skins: 1. Create a new fla file. 2. Select file > import > open external library, and select the halotheme.Fla file. This file is located in the application-level configuration folder. For the exact location on your operating sys...

  • Page 626

    626 chapter 6: components dictionary note: the code trace(myradiobuttoninstance.Version); returns undefined . Method summary for the radiobutton class there are no methods exclusive to the radiobutton class. Methods inherited from the uiobject class the following table lists the methods the radiobut...

  • Page 627

    Radiobutton component 627 properties inherited from the uiobject class the following table lists the properties the radiobutton class inherits from the uiobject class. When accessing these properties from the radiobutton object, use the form radiobuttoninstance.Propertyname . Radiobutton.Label the t...

  • Page 628

    628 chapter 6: components dictionary 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 . Proper...

  • Page 629

    Radiobutton component 629 events inherited from the uiobject class the following table lists the events the radiobutton class inherits from the uiobject class. Events inherited from the uicomponent class the following table lists the events the radiobutton class inherits from the uicomponent class. ...

  • Page 630

    630 chapter 6: components dictionary usage 2: listenerobject = new object(); listenerobject.Click = function(eventobject){ ... } radiobuttongroup.Addeventlistener("click", listenerobject) description event; broadcast to all registered listeners when the mouse is clicked (pressed and released) over t...

  • Page 631

    Radiobutton component 631 } radiogroup.Addeventlistener("click", form); the following code also sends a message to the output panel when radiobuttoninstance is clicked. The on() handler must be attached directly to radiobuttoninstance . On(click){ trace("radio button component was clicked"); } radio...

  • Page 632

    632 chapter 6: components dictionary example the following example sets the group name of a radio button instance to colorchoice and then changes the group name to sizechoice . To test this example, place a radio button on the stage, name the instance name myradiobutton , and enter the following cod...

  • Page 633

    Radiobutton component 633 the following are the four possible values: • "right" the radio button is pinned to the upper left corner of the bounding area. The label is placed to the right of the radio button. • "left" the radio button is pinned to the upper right corner of the bounding area. The labe...

  • Page 634

    634 chapter 6: components dictionary usage radiobuttongroup.Selecteddata description property; selects the radio button with the specified data value and deselects the previously selected radio button. If the data property is not specified for a selected instance, the label value of the selected ins...

  • Page 635: Chapter 6

    Radiobuttongroup component 635 radiobuttongroup component for information about the radiobuttongroup class, see radiobutton component . Chapter 6 components dictionary.

  • Page 636: Chapter 6

    636 chapter 6: components dictionary rdbmsresolver component (flash professional only) resolver components are used with the dataset component (part of the data management functionality in the flash data architecture) to save changes to an external data source. Resolvers include both the rdbmsresolv...

  • Page 637

    Rdbmsresolver component (flash professional only) 637 • 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 ...

  • Page 638

    638 chapter 6: components dictionary 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 rdb...

  • Page 639

    Rdbmsresolver component (flash professional only) 639 property summary for the rdbmsresolver component the following table lists properties of the rdbmsresolver class. Event summary for the rdbmsresolver component the following table lists the events of the rdbmsresolver class. Rdbmsresolver.Addfiel...

  • Page 640

    640 chapter 6: components dictionary parameters fieldname string; provides the name of the field that this information object describes. Ownername 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 t...

  • Page 641

    Rdbmsresolver component (flash professional only) 641 returns nothing. Description property; a property of type deltapacket . It receives a delta packet to be translated into an update packet, and outputs a delta packet from any server results placed in the updateresults property. This event handler...

  • Page 642

    642 chapter 6: components dictionary messages in the updateresults property are treated as errors. This means that a delta with messages is added to the delta packet again so it can be re-sent the next time the delta packet is sent to the server. You must write code to handle deltas that have messag...

  • Page 643

    Rdbmsresolver component (flash professional only) 643 rdbmsresolver.Reconcileresults availability flash player 7. Edition flash mx professional 2004. Usage resolvedata.Reconcileresults(eventobject) parameters eventobject resolver event object; describes the event object used to compare two update pa...

  • Page 644

    644 chapter 6: components dictionary edition this method is not currently available; for more information, see flash mx 2004 release notes. Usage resolvedata.Reconcileupdates(eventobject) parameters eventobject resolver event object; describes the customizations to the xml packet before the update i...

  • Page 645

    Rdbmsresolver component (flash professional only) 645 usage resolvedata.Tablename description property; a string that represents the table name in the xml for the database table to be updated. This property also determines which fields to send in the update packet. To make this determination, the rd...

  • Page 646

    646 chapter 6: components dictionary rdbmsresolver.Updatepacket availability flash player 7. Edition flash mx professional 2004. Usage resolvedata.Updatepacket description property; property of type xml, containing an xml packet used to bind to a connector property that transmits the translated upda...

  • Page 647: Chapter 6

    Rectborder class 647 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 ...

  • Page 648

    648 chapter 6: components dictionary creating a custom rectborder implementation the rectborder class is used as a border skin in most version 2 components. The default implementations in both the halo and sample themes use actionscript to draw the border. A custom implementation must use actionscri...

  • Page 649

    Rectborder class 649 // all of these borders have the same size edges, one pixel var offset:number = 1; function init(void):void { super.Init(); } function drawborder(void):void { // the graphics are on the symbol's timeline, // so all you need to do here is size the border _width = __width; _height...

  • Page 650

    650 chapter 6: components dictionary 14. Ensure that the graphics are flush against the upper left corner with x and y coordinates set to (0,0). Your custom drawborder implementation will set the width and height according to the component requirements. 15. Click back to return to the main timeline....

  • Page 651: Chapter 6

    Screen class (flash professional only) 651 screen class (flash professional only) the screen class is the base class for screens you create in the screen outline pane in flash mx professional 2004. Screens are high-level containers for creating applications and presentations. For an overview of work...

  • Page 652

    652 chapter 6: components dictionary for example, suppose you have a slide presentation in which three people are each contributing a single section. You could ask each presenter to create a separate slide presentation (swf file). You would then create a “master slide presentation” that contains thr...

  • Page 653

    Screen class (flash professional only) 653 referencing loaded screens with actionscript the loader class creates an internal movie clip named contentnode into which it loads the swf or jpeg file specified by the contentpath property. This movie clip, in effect, adds an extra screen node between the ...

  • Page 654

    654 chapter 6: components dictionary the methods, properties, and events of the screen class allow you to create and manipulate screens at runtime. Method summary for the screen class the following table lists the method of the screen class. Methods inherited from the uiobject class the following ta...

  • Page 655

    Screen class (flash professional only) 655 methods inherited from the loader class the following table lists the method the screen class inherits from the loader class. When calling this method from the screen object, use the form screeninstance.Methodname . Property summary for the screen class the...

  • Page 656

    656 chapter 6: components dictionary properties inherited from the uicomponent class the following table lists the properties the screen class inherits from the uicomponent class. When accessing these properties from the screen object, use the form screeninstance.Propertyname . Properties inherited ...

  • Page 657

    Screen class (flash professional only) 657 event summary for the screen class the following table lists events of the screen class. Events inherited from the uiobject class the following table lists the events the screen class inherits from the uiobject class. Events inherited from the uicomponent c...

  • Page 658

    658 chapter 6: components dictionary events inherited from the loader class the following table lists the events the screen class inherits from the loader class. Screen.Alltransitionsindone availability flash player 6 (6.0 79.0). Edition flash mx professional 2004. Usage on(alltransitionsindone) { /...

  • Page 659

    Screen class (flash professional only) 659 screen.Alltransitionsoutdone availability flash player 6 (6.0 79.0). Edition flash mx professional 2004. Usage on(alltransitionsoutdone) { // your code here } listenerobject = new object(); listenerobject.Alltransitionsoutdone = function(eventobject){ // in...

  • Page 660

    660 chapter 6: components dictionary screen2 subscreen1_2 if myuibutton has focus, the leafmost screen containing the focus is subscreen1_1 , which is what currentfocusedscreen would return. In this case, presentation , screen1 , and subscreen1_1 all contain the focus but the one that is “closest” (...

  • Page 661

    Screen class (flash professional only) 661 screen.Indexinparent availability flash player 6 (6.0 79.0). Edition flash mx professional 2004. Usage myscreen.Indexinparent description property (read-only); contains the zero-based index of myscreen in its parent’s list of child screens. Example the foll...

  • Page 662

    662 chapter 6: components dictionary example the following code displays the name of the screen that captured the mouse event in the output panel. On(mousedown) { trace("mouse down event on: " + eventobj.Target._name); } screen.Mousedownsomewhere availability flash player 6 (6.0 79.0). Edition flash...

  • Page 663

    Screen class (flash professional only) 663 description event; broadcast when the mouse moves while over the screen. This event is sent only when the mouse is over the bounding box of this screen. When the event is triggered, it automatically passes an event object ( eventobj ) to the handler. Each e...

  • Page 664

    664 chapter 6: components dictionary // your code here } listenerobject = new object(); listenerobject.Mouseover = function(eventobject){ // insert your code here } screenobj.Addeventlistener("mouseover", listenerobject) description event; broadcast when the mouse moves from outside the screen’s bou...

  • Page 665

    Screen class (flash professional only) 665 screen.Mouseupsomewhere availability flash player 6 (6.0 79.0). Edition flash mx professional 2004. Usage on(mouseupsomewhere) { // your code here } listenerobject = new object(); listenerobject.Mouseupsomewhere = function(eventobject){ // insert your code ...

  • Page 666

    666 chapter 6: components dictionary see also screen.Getchildscreen() screen.Parentisscreen availability flash player 6 (6.0 79.0). Edition flash mx professional 2004. Usage myscreen.Parentisscreen description property (read-only): returns a boolean value indicating whether the specified screen’s pa...

  • Page 667

    Screen class (flash professional only) 667 example the following example displays the name of the screen that contains the screen myscreen . Var myparent:mx.Screens.Screen = myscreen.Rootscreen; screen.Rootscreen availability flash player 6 (6.0 79.0). Edition flash mx professional 2004. Usage myscr...

  • Page 668: Chapter 6

    668 chapter 6: components dictionary scrollpane component the scrollpane component displays movie clips, jpeg files, and swf files in a scrollable area. By using a scroll pane, you can limit the amount of screen area occupied by these media types. The scroll pane can display content that is loaded f...

  • Page 669

    Scrollpane component 669 contentpath indicates the content to load into the scroll pane. This value can be a relative path to a local swf or jpeg file, or a relative or absolute path to a file on the internet. It can also be the linkage identifier of a movie clip symbol in the library that is set to...

  • Page 670

    670 chapter 6: components dictionary the first block of code is a scroll event handler on the myscrollpane instance that displays the value of the vposition property in a textfield instance called txtposition . The second block of code creates an event handler for the complete event that sends a mes...

  • Page 671

    Scrollpane component 671 using skins with the scrollpane component the scrollpane component uses an instance of rectborder for its border and scroll bars for scroll assets. For more information about skinning these visual elements, see “rectborder class” on page 647 and “using skins with the uiscrol...

  • Page 672

    672 chapter 6: components dictionary 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 . Methods inherited from the u...

  • Page 673

    Scrollpane component 673 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 . Scrollpane.Hposition the ho...

  • Page 674

    674 chapter 6: components dictionary properties inherited from the uicomponent class the following table lists the properties the scrollpane class inherits from the uicomponent class. When accessing these properties from the scrollpane object, use the form scrollpaneinstance.Propertyname . Event sum...

  • Page 675

    Scrollpane component 675 scrollpane.Complete availability flash player 6 (6.0 79.0). Edition flash mx 2004. Usage usage 1: on(complete){ ... } usage 2: listenerobject = new object(); listenerobject.Complete = function(eventobject){ ... } scrollpaneinstance.Addeventlistener("complete", listenerobject...

  • Page 676

    676 chapter 6: components dictionary example the following example creates a listener object with a complete event handler for the scrollpane instance: form.Complete = function(eventobj){ // insert code to handle the event } scrollpane.Addeventlistener("complete",form); scrollpane.Content availabili...

  • Page 677

    Scrollpane component 677 if you load content using a relative url, the loaded content must be relative to the location of the swf file that contains the scroll pane. For example, an application using a scrollpane component that resides in the directory /scrollpane/nav/example.Swf could load contents...

  • Page 678

    678 chapter 6: components dictionary loadlistener.Progress = function(eventobj){ // eventobj.Target is the component that generated the change event var bytesloaded = scrollpane.Getbytesloaded(); var bytestotal = scrollpane.Getbytestotal(); var percentcomplete = math.Floor(bytesloaded/bytestotal); i...

  • Page 679

    Scrollpane component 679 usage scrollpaneinstance.Hlinescrollsize description property; the number of pixels to move the content when an arrow in the horizontal scroll bar is clicked. The default value is 5. Example this example increases the horizontal scroll unit to 10: scrollpane.Hlinescrollsize ...

  • Page 680

    680 chapter 6: components dictionary example this example positions the scroll bar at pixel 20: scrollpane.Hposition = 20; scrollpane.Hscrollpolicy availability flash player 6 (6.0 79.0). Edition flash mx 2004. Usage scrollpaneinstance.Hscrollpolicy description property; determines whether the horiz...

  • Page 681

    Scrollpane component 681 description event; broadcast to all registered listeners while content is loading. The progress event is not always broadcast; the complete event may be broadcast without any progress events being dispatched. This can happen especially if the loaded content is a local file. ...

  • Page 682

    682 chapter 6: components dictionary 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...

  • Page 683

    Scrollpane component 683 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 ...

  • Page 684

    684 chapter 6: components dictionary scrollpane.Scrolldrag availability flash player 6 (6.0 79.0). Edition flash mx 2004. Usage scrollpaneinstance.Scrolldrag description property; a boolean value that indicates whether scrolling occurs ( true ) or not ( false ) when a user drags within the scroll pa...

  • Page 685

    Scrollpane component 685 usage scrollpaneinstance.Vpagescrollsize description property; the number of pixels to move the content in the display area when the user clicks the track in a vertical scroll bar. The default value is 20. Example this code causes the content in the display area to move 30 p...

  • Page 686: Chapter 6

    686 chapter 6: components dictionary simplebutton class inheritance movieclip > uiobject class > uicomponent class > simplebutton actionscript class name mx.Controls.Simplebutton the properties of the simplebutton class let you control the following at runtime: • whether a button has the emphasized ...

  • Page 687

    Simplebutton class 687 property summary for the simplebutton class the following table lists properties of the simplebutton class. Properties inherited from the uiobject class the following table lists the properties the simplebutton class inherits from the uiobject class. When accessing these prope...

  • Page 688

    688 chapter 6: components dictionary properties inherited from the uicomponent class the following table lists the properties the simplebutton class inherits from the uicomponent class. When accessing these properties from the simplebutton object, use the form buttoninstance.Propertyname . Event sum...

  • Page 689

    Simplebutton class 689 simplebutton.Click availability flash player 6 (6.0 79.0). Edition flash mx 2004. Usage usage 1: on(click){ ... } usage 2: listenerobject = new object(); listenerobject.Click = function(eventobject){ ... } buttoninstance.Addeventlistener("click", listenerobject) description ev...

  • Page 690

    690 chapter 6: components dictionary the second usage example uses a dispatcher/listener event model. A component instance ( buttoninstance ) dispatches an event (in this case, click ) and the event is handled by a function, also called a handler, on a listener object ( listenerobject ) that you cre...

  • Page 691

    Simplebutton class 691 description property; indicates whether the button is in an emphasized state ( true ) or not ( false ). The emphasized state is equivalent to the appearance of a default push button. In general, use the focusmanager.Defaultpushbutton property instead of setting the emphasized ...

  • Page 692

    692 chapter 6: components dictionary usage buttoninstance.Selected description property; a boolean value that indicates whether the button is selected ( true ) or not ( false ). The default value is false . Simplebutton.Toggle availability flash player 6 (6.0 79.0). Edition flash mx 2004. Usage butt...

  • Page 693: Chapter 6

    Slide class (flash professional only) 693 slide class (flash professional only) the slide class corresponds to a node in a hierarchical slide presentation. In flash mx professional 2004, you can create slide presentations using the screen outline pane. For an overview of working with screens, see ch...

  • Page 694

    694 chapter 6: components dictionary you can also use the built-in behaviors that are available in the behaviors panel to control slide presentations. For more information, see “adding controls to screens using behaviors (flash professional only)” in using flash. Slide parameters you can set the fol...

  • Page 695

    Slide class (flash professional only) 695 6. Select the presentation slide and open the components panel. 7. Drag a button component from the components panel to the bottom of the stage. 8. In the property inspector, type next slide for the button component’s label property. 9. In the actions panel,...

  • Page 696

    696 chapter 6: components dictionary methods inherited from the uicomponent class the following table lists the methods the slide class inherits from the uicomponent class. When calling these methods from the slide object, use the form slideinstance.Methodname . Methods inherited from the loader cla...

  • Page 697

    Slide class (flash professional only) 697 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 . Slide.Currentslide read-o...

  • Page 698

    698 chapter 6: components dictionary properties inherited from the uicomponent class the following table lists the properties the slide class inherits from the uicomponent class. When accessing these properties from the slide object, use the form slideinstance.Propertyname . Properties inherited fro...

  • Page 699

    Slide class (flash professional only) 699 properties inherited from the screen class the following table lists the properties the slide class inherits from the screen class. When accessing these properties from the slide object, use the form slideinstance.Propertyname . Event summary for the slide c...

  • Page 700

    700 chapter 6: components dictionary events inherited from the uicomponent class the following table lists the events the slide class inherits from the uicomponent class. Events inherited from the loader class the following table lists the events the slide class inherits from the loader class. Event...

  • Page 701

    Slide class (flash professional only) 701 slide.Autokeynav availability flash player 6 (6.0 79.0). Edition flash mx professional 2004. Usage myslide.Autokeynav description property; determines whether the slide uses default keyboard handling to navigate to the next/ previous slide when myslide has f...

  • Page 702

    702 chapter 6: components dictionary description property (read-only); returns the immediate child of myslide that contains the currently active slide; returns null if no child slide contained by myslide has the current focus. Example consider the following screen outline: presentation slide_1 bulle...

  • Page 703

    Slide class (flash professional only) 703 slide.Currentslide availability flash player 6 (6.0 79.0). Edition flash mx professional 2004. Usage myslide.Currentslide description property (read-only); returns the currently active slide. This is always a “leaf ” slide—that is, a slide that contains no c...

  • Page 704

    704 chapter 6: components dictionary • shiftkey a boolean value indicating if the shift key is currently being pressed ( true ) or not ( false ). • ctrlkey a boolean value indicating if the control key is currently being pressed ( true ) or not ( false ). Returns nothing. Description callback handle...

  • Page 705

    Slide class (flash professional only) 705 description property (read-only); returns the first child slide of myslide that has no child slides. Example in the hierarchy of slides shown below, the following statements are both true: presentation.Intro.Firstslide == intro_bullet_1_1; presentation.Intro...

  • Page 706

    706 chapter 6: components dictionary 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 var childslide = _root.Presentation.Getchildslide(s...

  • Page 707

    Slide class (flash professional only) 707 this method call would navigate to the slide named intro_bullet_2_1 : presentation.Intro.Intro_bullet_2.Gotofirstslide(); see also slide.Firstslide , slide.Revealchild slide.Gotolastslide() availability flash player 6 (6.0 79.0). Edition flash mx professiona...

  • Page 708

    708 chapter 6: components dictionary example in the slide hierarchy illustrated below, the following method calls would navigate to the slide named intro_bullet_1_2 : presentation.Intro.Gotolastslide(); presentation.Intro.Intro_bullet_1.Gotolastslide(); these method calls would navigate to the slide...

  • Page 709

    Slide class (flash professional only) 709 description method; navigates to the next slide in the slide presentation. As control passes from one slide to the next, the outgoing slide is hidden and the incoming slide is revealed. If the outgoing and incoming slides are in different slide subtrees, the...

  • Page 710

    710 chapter 6: components dictionary also, still assuming that the current slide is intro_bullet_1_1 , calling results.Gotonextslide() would have no effect, because results does not contain the current slide (that is, results.Currentslide is null ). See also slide.Currentslide , slide.Gotoprevioussl...

  • Page 711

    Slide class (flash professional only) 711 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...

  • Page 712

    712 chapter 6: components dictionary 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 succ...

  • Page 713

    Slide class (flash professional only) 713 on(click) { _parent.Gotoslide(_parent.Currentslide.Nextslide); } this is equivalent to the following code, which uses the slide.Gotonextslide() method: on(click) { _parent.Currentslide.Gotonextslide(); } see also slide.Currentslide , slide.Gotonextslide() sl...

  • Page 714

    714 chapter 6: components dictionary slide.Indexinparentslide availability flash player 6 (6.0 79.0). Edition flash mx professional 2004. Usage myslide.Indexinparent description property (read-only); returns the zero-based index of myslide in its parent’s list of child slides. Example the following ...

  • Page 715

    Slide class (flash professional only) 715 intro_bullet_1.Lastslide._name == intro_bullet_1_2; results.Lastslide._name = results_bullet_1; slide.Nextslide availability flash player 6 (6.0 79.0). Edition flash mx professional 2004. Usage myslide.Nextslide description property (read-only); returns the ...

  • Page 716

    716 chapter 6: components dictionary nextbutton.Label = "end of this slide presentation."; } see also slide.Gotonextslide() , slide.Previousslide slide.Numchildslides availability flash player 6 (6.0 79.0). Edition flash mx professional 2004. Usage myslide.Numchildslides description property (read-o...

  • Page 717

    Slide class (flash professional only) 717 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 propert...

  • Page 718

    718 chapter 6: components dictionary if myslide is the root slide in a presentation, this property returns false , because the presentation slide’s parent is the main timeline (_level0), not a slide. This property also returns false if a form is the parent of myslide . Example the following code det...

  • Page 719

    Slide class (flash professional only) 719 description property (read-only); returns the slide you would reach if you called myslide.Gotopreviousslide() , but does not actually navigate to that slide. For example, you can use this property to display the name of the previous slide in a presentation a...

  • Page 720

    720 chapter 6: components dictionary 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 . Exam...

  • Page 721: Chapter 6

    Stylemanager class 721 stylemanager class actionscript class name mx.Styles.Stylemanager the stylemanager class keeps track of known inheriting styles and colors. You only need to use this class if you are creating components and want to add a new inheriting style or color. To determine which styles...

  • Page 722

    722 chapter 6: components dictionary stylemanager.Registercolorstyle() availability flash player 6 (6.0 79.0). Edition flash mx 2004. Usage stylemanager.Registercolorstyle(colorstyle) parameters colorstyle a string indicating the name of the color (for example, "highlightcolor" , "shadowcolor" , "di...

  • Page 723

    Stylemanager class 723 when a style’s value is not inherited, you can set its style only on an instance, not on a custom or global style sheet. A style that doesn’t inherit its value is set on the class style sheet, and therefore, setting it on a custom or global style sheet does not work. Example t...

  • Page 724: Chapter 6

    724 chapter 6: components dictionary systemmanager class actionscript class name mx.Managers.Systemmanager the systemmanager class works automatically with the focusmanager class to handle which top- level window is activated in an application that contains version 2 components. It also provides a s...

  • Page 725: Chapter 6

    Textarea component 725 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...

  • Page 726

    726 chapter 6: components dictionary editable indicates whether the textarea component is editable ( true ) or not ( false ). The default value is true . Wordwrap indicates whether the text wraps ( true ) or not ( false ). The default value is true . You can write actionscript to control these and a...

  • Page 727

    Textarea component 727 using styles with the textarea component the textarea component supports one set of component styles for all text in the field. However, you can also display html that is compatible with flash player html rendering. To display html text, set textarea.Html to true . The textare...

  • Page 728

    728 chapter 6: components dictionary the textarea and textinput components use exactly the same styles and are often used in the same manner. Thus, by default they share the same class-level style declaration. For example, the following code sets a style on the textinput declaration, but it affects ...

  • Page 729

    Textarea component 729 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.Control...

  • Page 730

    730 chapter 6: components dictionary property summary for the textarea class the following table lists properties of the textarea class. Properties inherited from the uiobject class the following table lists the properties the textarea class inherits from the uiobject class. When accessing these pro...

  • Page 731

    Textarea component 731 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 . Event summary for the textare...

  • Page 732

    732 chapter 6: components dictionary events inherited from the uicomponent class the following table lists the events the textarea class inherits from the uicomponent class. Textarea.Change availability flash player 6 (6.0 79.0). Edition flash mx 2004. Usage usage 1: on(change){ ... } usage 2: liste...

  • Page 733

    Textarea component 733 the second usage example uses a dispatcher/listener event model. A component instance ( textareainstance ) dispatches an event (in this case, change ) and the event is handled by a function, also called a handler, on a listener object ( listenerobject ) that you create. You de...

  • Page 734

    734 chapter 6: components dictionary description property; a boolean value that indicates whether the component is editable ( true ) or not ( false ). The default value is true . Textarea.Hposition availability flash player 6 (6.0 79.0). Edition flash mx 2004. Usage textareainstance.Hposition descri...

  • Page 735

    Textarea component 735 textarea.Html availability flash player 6 (6.0 79.0). Edition flash mx 2004. Usage textareainstance.Html description property; a boolean value that indicates whether the text field is formatted with html ( true ) or not ( false ). If the html property is true , the text field ...

  • Page 736

    736 chapter 6: components dictionary textarea.Maxchars availability flash player 6 (6.0 79.0). Edition flash mx 2004. Usage textareainstance.Maxchars description property; the maximum number of characters that the text field can contain. A script may insert more text than the maxchars property allow...

  • Page 737

    Textarea component 737 textarea.Maxvposition availability flash player 6 (6.0 79.0). Edition flash mx 2004. Usage textareainstance.Maxvposition description property (read-only); indicates the maximum value of textarea.Vposition . The default value is 0. Example the following code causes the text to ...

  • Page 738

    738 chapter 6: components dictionary textarea.Restrict availability flash player 6 (6.0 79.0). Edition flash mx 2004. Usage textareainstance.Restrict description property; indicates the set of characters that users can enter in the text field. The default value is undefined . If this property is nul...

  • Page 739

    Textarea component 739 the style sheet associated with a textarea component may be changed at any time. If the style sheet in use is changed, the textarea component is redrawn with the new style sheet. The style sheet may be set to null or undefined to remove the style sheet. If the style sheet in u...

  • Page 740

    740 chapter 6: components dictionary usage textareainstance.Text description property; the text contents of a textarea component. The default value is "" (an empty string). Example the following code places a string in the mytextarea instance, and then traces that string to the output panel: mytexta...

  • Page 741

    Textarea component 741 example the following code turns vertical scroll bars off all the time: text.Vscrollpolicy = "off"; textarea.Wordwrap availability flash player 6 (6.0 79.0). Edition flash mx 2004. Usage textareainstance.Wordwrap description property; a boolean value that indicates whether the...

  • Page 742: Chapter 6

    742 chapter 6: components dictionary textinput component the textinput component is a single-line text component that is a wrapper for the native actionscript textfield object. You can use styles to customize the textinput component; when an instance is disabled, its contents appear in a color repre...

  • Page 743

    Textinput component 743 you can write actionscript to control these and additional options for the textinput component using its properties, methods, and events. For more information, see “textinput class” on page 745 . Creating an application with the textinput component the following procedure exp...

  • Page 744

    744 chapter 6: components dictionary using styles with the textinput component the textinput component has its backgroundcolor and borderstyle style properties defined on a class style declaration. Class styles override global styles; therefore, if you want to set the backgroundcolor and borderstyle...

  • Page 745

    Textinput component 745 the textarea and textinput components both use the same styles and are often used in the same manner. Thus, by default they share the same class-level style declaration. For example, the following code sets a style on the textarea declaration but it affects both textarea and ...

  • Page 746

    746 chapter 6: components dictionary 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...

  • Page 747

    Textinput component 747 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 . Textinput.Length the number of ...

  • Page 748

    748 chapter 6: components dictionary properties inherited from the uicomponent class the following table lists the properties the textinput class inherits from the uicomponent class. When accessing these properties from the textinput object, use the form textinputinstance.Propertyname . Event summar...

  • Page 749

    Textinput component 749 textinput.Change availability flash player 6 (6.0 79.0). Edition flash mx 2004. Usage usage 1: on(change){ ... } usage 2: listenerobject = new object(); listenerobject.Change = function(eventobject){ ... } textinputinstance.Addeventlistener("change", listenerobject) descripti...

  • Page 750

    750 chapter 6: components dictionary example this example sets a flag in the application that indicates if contents in the textinput field have changed: form.Change = function(eventobj){ // note: eventobj.Target refers to the component that generated the change // event, i.E., the textinput componen...

  • Page 751

    Textinput component 751 } textinputinstance.Addeventlistener("enter", listenerobject) description event; notifies listeners that the enter key has been pressed. The first usage example uses an on() handler and must be attached directly to a textinput instance. The keyword this , used inside an on() ...

  • Page 752

    752 chapter 6: components dictionary usage textinputinstance.Hposition description property; defines the horizontal position of the text in the field. The default value is 0. Example the following code displays the leftmost character in the field: mytextinput.Hposition = 0; textinput.Length availabi...

  • Page 753

    Textinput component 753 example the following example limits the number of characters a user can enter to 255: mytextinput.Maxchars = 255; textinput.Maxhposition availability flash player 6 (6.0 79.0). Edition flash mx 2004. Usage textinputinstance.Maxhposition description property (read-only); indi...

  • Page 754

    754 chapter 6: components dictionary 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 ...

  • Page 755

    Textinput component 755 the restrict property restricts only user interaction; a script may put any text into the text field. This property does not synchronize with the embed font outlines check boxes in the property inspector. Example in the following example, the first line of code limits the tex...

  • Page 756: Chapter 6

    756 chapter 6: components dictionary transferobject interface actionscript class name mx.Data.To.Transferobject the transferobject interface defines a set of methods that items managed by the dataset component must implement. The dataset.Itemclassname property specifies the name of the transfer obje...

  • Page 757

    Transferobject interface 757 example the following function returns a copy of this transfer object with all of the properties set to the same values as the original: class itemclass implements mx.Data.To.Transferobject { function clone():object { var copy:itemclass = new itemclass(); for (var p in t...

  • Page 758

    758 chapter 6: components dictionary 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...

  • Page 759: Chapter 6

    Tree component (flash professional only) 759 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 re...

  • Page 760

    760 chapter 6: components dictionary the tree component comprises two sets of apis: the tree class and the treedataprovider interface. The tree class contains the visual configuration methods and properties. The treedataprovider interface lets you construct xml and add it to multiple tree instances....

  • Page 761

    Tree component (flash professional only) 761 when a tree displays a node, it uses the label attribute of the node by default as the text label. If any other attributes exist, they become additional properties of the node’s attributes within the tree. The actual root node is interpreted as the tree c...

  • Page 762

    762 chapter 6: components dictionary you cannot enter data parameters in the property inspector or in the component inspector for the tree component as you can with other components. For more information, see “using the tree component (flash professional only)” on page 759 and “creating an applicati...

  • Page 763

    Tree component (flash professional only) 763 var node = menutree.Selecteditem; // if this is a branch, expand/collapse it if (menutree.Getisbranch(node)) { menutree.Setisopen(node, !Menutree.Getisopen(node), true); } // if this is a hyperlink, jump to it var url = node.Attributes.Url; if (url) { get...

  • Page 764

    764 chapter 6: components dictionary }; mytree.Addeventlistener("change", treelistener); this code creates an xml object called mytreedp and calls the xml.Load() method to load an xml data source. The code then defines an onload event handler that sets the dataprovider property of the mytree instanc...

  • Page 765

    Tree component (flash professional only) 765 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...

  • Page 766

    766 chapter 6: components dictionary 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...

  • Page 767

    Tree component (flash professional only) 767 border styles both the tree component uses a rectborder instance as its border and responds to the styles defined on that class. See “rectborder class” on page 647 . The default border style is "inset" . Color both the text color. Disabledcolor both the c...

  • Page 768

    768 chapter 6: components dictionary folderopenicon both the icon displayed for an open folder node in a tree component if no node-specific icon is set. The default value is "treefolderopen" , which is a yellow open file folder image. Indentation both the number of pixels to indent each row of a tre...

  • Page 769

    Tree component (flash professional only) 769 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 ...

  • Page 770

    770 chapter 6: components dictionary tree class (flash professional only) inheritance movieclip > uiobject class > uicomponent class > view > scrollview > scrollselectlist > list component > tree actionscript class name mx.Controls.Tree the methods, properties, and events of the tree class allow you...

  • Page 771

    Tree component (flash professional only) 771 methods inherited from the uicomponent class the following table lists the methods the tree class inherits from the uicomponent class. When calling these methods from the tree object, use the form treeinstance.Methodname . Methods inherited from the list ...

  • Page 772

    772 chapter 6: components dictionary property summary for the tree class the following table lists properties of the tree class. Properties inherited from the uiobject class the following table lists the properties the tree class inherits from the uiobject class. When accessing these properties from...

  • Page 773

    Tree component (flash professional only) 773 properties inherited from the list class the following table lists the properties the tree class inherits from the list class. When accessing these properties from the tree object, use the form treeinstance.Propertyname . Event summary for the tree class ...

  • Page 774

    774 chapter 6: components dictionary events inherited from the uiobject class the following table lists the events the tree class inherits from the uiobject class. Events inherited from the uicomponent class the following table lists the events the tree class inherits from the uicomponent class. Eve...

  • Page 775

    Tree component (flash professional only) 775 usage usage 1: mytree.Addtreenode(label [, data]) usage 2: mytree.Addtreenode(child) parameters label a string that displays the node, or an object with a label field (or whatever label field name is specified by the labelfield property). Data an object o...

  • Page 776

    776 chapter 6: components dictionary parameters index the zero-based index position (among the child nodes) at which the node should be added. Label a string that displays the node. Data an object of any type that is associated with the node. This parameter is optional. Child any xmlnode object. Ret...

  • Page 777

    Tree component (flash professional only) 777 example the following example imports an xml file and assigns it to the mytree instance of the tree component: mytreedp = new xml(); mytreedp.Ignorewhite = true; mytreedp.Load("http://myserver.Mydomain.Com/source.Xml"); mytreedp.Onload = function(){ mytre...

  • Page 778

    778 chapter 6: components dictionary parameters node an xmlnode object. Returns the index of the specified node, or undefined if the node is not currently displayed. Description method; returns the display index of the node specified in the node parameter. The display index indicates the item’s posi...

  • Page 779

    Tree component (flash professional only) 779 tree.Getisopen() availability flash player 6 (6.0 79.0). Edition flash mx professional 2004. Usage mytree.Getisopen(node) parameters node an xmlnode object. Returns a boolean value that indicates whether the tree is open ( true ) or closed ( false ). Desc...

  • Page 780

    780 chapter 6: components dictionary the display index is an array of items that can be viewed in the tree window. For example, any children of a closed node are not in the display index. The display index starts with 0 and proceeds through the visible items regardless of parent. In other words, the...

  • Page 781

    Tree component (flash professional only) 781 } mytreeinstance.Addeventlistener("nodeclose", listenerobject) description event; broadcast to all registered listeners when the nodes of a tree component are closed by a user. Version 2 components use a dispatcher/listener event model. The tree component...

  • Page 782

    782 chapter 6: components dictionary version 2 components use a dispatcher/listener event model. The tree component dispatches a nodeopen event when a node is clicked open by a user; the event is handled by a function, also called a handler, that is attached to a listener object ( listenerobject ) t...

  • Page 783

    Tree component (flash professional only) 783 tree.Removeall() availability flash player 6 (6.0 79.0). Edition flash mx professional 2004. Usage mytree.Removeall() parameters none. Returns nothing. Description method; removes all nodes and refreshes the tree. Example the following code empties mytree...

  • Page 784

    784 chapter 6: components dictionary example the following code removes the fourth child of the root of the tree mytree : mytree.Removetreenodeat(3); tree.Selectednode availability flash player 6 (6.0 79.0). Edition flash mx professional 2004. Usage mytree.Selectednode description property; specifie...

  • Page 785

    Tree component (flash professional only) 785 tree.Seticon() availability flash player 6 (6.0 79.0). Edition flash mx professional 2004. Usage mytree.Seticon(node, linkid [, linkid2]) parameters node an xml node. Linkid the linkage identifier of a symbol to be used as an icon beside the node. This pa...

  • Page 786

    786 chapter 6: components dictionary returns nothing. Description method; specifies whether the node has a folder icon and expander arrow and either has children or can have children. A node is automatically set as a branch when it has children; you only need to call setisbranch() when you want to c...

  • Page 787: Chapter 6

    Treedataprovider interface (flash professional only) 787 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 fil...

  • Page 788

    788 chapter 6: components dictionary treedataprovider.Addtreenode() availability flash player 6 (6.0 79.0). Edition flash mx professional 2004. Usage usage 1: somenode.Addtreenode(label, data) usage 2: somenode.Addtreenode(child) parameters label a string that displays the node. Data an object of an...

  • Page 789

    Treedataprovider interface (flash professional only) 789 treedataprovider.Addtreenodeat() availability flash player 6 (6.0 79.0). Edition flash mx professional 2004. Usage usage 1: somenode.Addtreenodeat(index, label, data) usage 2: somenode.Addtreenodeat(index, child) parameters index an integer th...

  • Page 790

    790 chapter 6: components dictionary treedataprovider.Attributes.Data availability flash player 6 (6.0 79.0). Edition flash mx professional 2004. Usage somenode.Attributes.Data description property; specifies the data to associate with the node. This adds the value as an attribute in the xmlnode obj...

  • Page 791

    Treedataprovider interface (flash professional only) 791 treedataprovider.Gettreenodeat() availability flash player 6 (6.0 79.0). Edition flash mx professional 2004. Usage somenode.Gettreenodeat(index) parameters index an integer representing the position of the child node in the current node. Retur...

  • Page 792

    792 chapter 6: components dictionary example the following code removes a node: mytreedp.Firstchild.Removetreenode(); treedataprovider.Removetreenodeat() availability flash player 6 (6.0 79.0). Edition flash mx professional 2004. Usage somenode.Removetreenodeat(index) parameters index an integer ind...

  • Page 793: Chapter 6

    Uicomponent class 793 uicomponent class the uicomponent class does not represent a visual component; it contains methods, properties, and events that allow macromedia components to share some common behavior. All version 2 components extend uicomponent. The uicomponent class lets you do the followin...

  • Page 794

    794 chapter 6: components dictionary property summary for the uicomponent class the following table lists properties of the uicomponent class. Properties inherited from the uiobject class the following table lists the properties the uicomponent class inherits from the uiobject class. When accessing ...

  • Page 795

    Uicomponent class 795 event summary for the uicomponent class the following table lists events of the uicomponent class. 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...

  • Page 796

    796 chapter 6: components dictionary example the following example sets the enabled property of a checkbox component to false : checkboxinstance.Enabled = false; uicomponent.Focusin availability flash player 6 (6.0 79.0). Edition flash mx 2004. Usage usage 1: on(focusin){ ... } usage 2: listenerobje...

  • Page 797

    Uicomponent class 797 example the following code disables a button component, btn , while a user types in the textinput component, txt , and enables the button when the user click on it: var txt:mx.Controls.Textinput; var btn:mx.Controls.Button; var txtlistener:object = new object(); txtlistener.Foc...

  • Page 798

    798 chapter 6: components dictionary the second usage example uses a dispatcher/listener event model. A component instance ( componentinstance ) dispatches an event (in this case, focusout ) and the event is handled by a function, also called a handler, on a listener object ( listenerobject ) that y...

  • Page 799

    Uicomponent class 799 returns a reference to the object that currently has focus. Description method; returns a reference to the object that has keyboard focus. Example the following code returns a reference to the object that has focus and assigns it to the tmp variable: var tmp = checkbox.Getfocus...

  • Page 800

    800 chapter 6: components dictionary example the following code makes an icon blink when a key is pressed: formlistener.Handleevent = function(eventobj) { form.Icon.Visible = !Form.Icon.Visible; } form.Addeventlistener("keydown", formlistener); uicomponent.Keyup availability flash player 6 (6.0 79.0...

  • Page 801

    Uicomponent class 801 { form.Icon.Visible = !Form.Icon.Visible; } form.Addeventlistener("keyup", formlistener); uicomponent.Setfocus() availability flash player 6 (6.0 79.0). Edition flash mx 2004. Usage componentinstance.Setfocus(); parameters none. Returns nothing. Description method; sets the foc...

  • Page 802: Chapter 6

    802 chapter 6: components dictionary uieventdispatcher class actionscript class name mx.Events.Uieventdispatcher inheritance eventdispatcher class > uieventdispatcher the uieventdispatcher class is mixed in to the uicomponent class and allows components to emit certain events. If you want an object ...

  • Page 803

    Uieventdispatcher class 803 uieventdispatcher.Keydown availability flash player 6 (6.0 79.0). Edition flash mx professional 2004. Usage listenerobject = new object(); listenerobject.Keydown = function(eventobject){ // insert your code here } componentinstance.Addeventlistener("keydown", listenerobje...

  • Page 804

    804 chapter 6: components dictionary uieventdispatcher.Load availability flash player 6 (6.0 79.0). Edition flash mx professional 2004. Usage listenerobject = new object(); listenerobject.Load = function(eventobject){ // insert your code here } componentinstance.Addeventlistener("load", listenerobje...

  • Page 805

    Uieventdispatcher class 805 uieventdispatcher.Mouseout availability flash player 6 (6.0 79.0). Edition flash mx professional 2004. Usage listenerobject = new object(); listenerobject.Mouseout = function(eventobject){ // insert your code here } componentinstance.Addeventlistener("mouseout", listenero...

  • Page 806

    806 chapter 6: components dictionary 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", lis...

  • Page 807

    Uieventdispatcher class 807 uieventdispatcher.Unload availability flash player 6 (6.0 79.0). Edition flash mx professional 2004. Usage listenerobject = new object(); listenerobject.Unload = function(eventobject){ // insert your code here } componentinstance.Addeventlistener("unload", listenerobject)...

  • Page 808: Chapter 6

    808 chapter 6: components dictionary uiobject class inheritance movieclip > uiobject actionscript class name mx.Core.Uiobject uiobject is the base class for all version 2 components; it is not a visual component. The uiobject class wraps the actionscript movieclip object and contains functions and p...

  • Page 809

    Uiobject class 809 property summary for the uiobject class the following table lists properties of the uiobject class. Event summary for the uiobject class the following table lists events of the uiobject class. Uiobject.Setskin() sets a skin in the object. Uiobject.Setstyle() sets the style propert...

  • Page 810

    810 chapter 6: components dictionary 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...

  • Page 811

    Uiobject class 811 example the following code imports the assets of the button component and then makes a subobject of the button component. Import mx.Controls.Button; createclassobject(button,"button2",5,{label:"test button"}); the following example creates a checkbox object: import mx.Controls.Che...

  • Page 812

    812 chapter 6: components dictionary uiobject.Destroyobject() availability flash player 6 (6.0 79.0). Edition flash mx 2004. Usage componentinstance.Destroyobject(instancename) parameters instancename a string indicating the instance name of the object to be destroyed. Returns nothing. Description m...

  • Page 813

    Uiobject class 813 although properties that are set in a class or a frame script are available immediately, most properties assigned in the property inspector or component inspector are not set until the next frame within the component itself. Although any approach that delays access of the property...

  • Page 814

    814 chapter 6: components dictionary the second usage example uses a dispatcher/listener event model. A component instance ( componentinstance ) dispatches an event (in this case, draw ) and the event is handled by a function, also called a handler, on a listener object ( listenerobject ) that you c...

  • Page 815

    Uiobject class 815 example the following code sets the ib instance’s fontweight style property to bold if the cb instance’s fontweight style property is bold: if (cb.Getstyle("fontweight") == "bold") { ib.Setstyle("fontweight", "bold"); }; uiobject.Height availability flash player 6 (6.0 79.0). Edit...

  • Page 816

    816 chapter 6: components dictionary 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 f...

  • Page 817

    Uiobject class 817 uiobject.Left availability flash player 6 (6.0 79.0). Edition flash mx 2004. Usage componentinstance.Left description property (read-only); a number indicating the left edge of the object, in pixels, relative to its parent. To set this property, call uiobject.Move() . Uiobject.Loa...

  • Page 818

    818 chapter 6: components dictionary the second usage example uses a dispatcher/listener event model. A component instance ( componentinstance ) dispatches an event (in this case, load ) and the event is handled by a function, also called a handler, on a listener object ( listenerobject ) that you c...

  • Page 819

    Uiobject class 819 the second usage example uses a dispatcher/listener event model. A component instance ( componentinstance ) dispatches an event (in this case, move ) and the event is handled by a function, also called a handler, on a listener object ( listenerobject ) that you create. You define ...

  • Page 820

    820 chapter 6: components dictionary uiobject.Redraw() availability flash player 6 (6.0 79.0). Edition flash mx 2004. Usage componentinstance.Redraw(always) parameters always a boolean value. If true , the method draws the object, even if invalidate() wasn’t called. If false , the method draws the o...

  • Page 821

    Uiobject class 821 description event; notifies listeners that an object has been resized. The first usage example uses an on() handler and must be attached directly to a component instance. The second usage example uses a dispatcher/listener event model. A component instance ( componentinstance ) di...

  • Page 822

    822 chapter 6: components dictionary 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 200...

  • Page 823

    Uiobject class 823 example the following example makes the check box twice as wide and sets the tmp variable to the horizontal scale factor: checkbox.Scalex = 200; var tmp = checkbox.Scalex; uiobject.Scaley availability flash player 6 (6.0 79.0). Edition flash mx 2004. Usage componentinstance.Scaley...

  • Page 824

    824 chapter 6: components dictionary description method; resizes the object to the requested size. You should pass only integral values to uiobject.Setsize() , or the component may appear fuzzy. This method (like all methods and properties of uiobject) is available from any component instance. When ...

  • Page 825

    Uiobject class 825 var themeshape:string = "circle_skin" function shape(){ } function init(void):void{ super.Init(); } function createchildren():void{ setskin(1, themeshape); super.Createchildren(); } } uiobject.Setstyle() availability flash player 6 (6.0 79.0). Edition flash mx 2004. Usage componen...

  • Page 826

    826 chapter 6: components dictionary 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()...

  • Page 827

    Uiobject class 827 the second usage example uses a dispatcher/listener event model. A component instance ( componentinstance ) dispatches an event (in this case, unload ) and the event is handled by a function, also called a handler, on a listener object ( listenerobject ) that you create. You defin...

  • Page 828

    828 chapter 6: components dictionary 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); uiobjec...

  • Page 829: Chapter 6

    Uiscrollbar component 829 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 button...

  • Page 830

    830 chapter 6: components dictionary 3. Verify that object snapping is turned on (view > snapping > snap to objects). 4. Drag a uiscrollbar instance from the components panel onto the text input field near the side you want to attach it to. The component must overlap with the text field when you rel...

  • Page 831

    Uiscrollbar component 831 note, however, that with the halo theme, the width of a vertically oriented scroll bar must be 16 pixels, and the height of a horizontally oriented scroll bar must also be 16 pixels. These dimensions are determined strictly by the current theme used with the scroll bar. Onl...

  • Page 832

    832 chapter 6: components dictionary 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. Th...

  • Page 833

    Uiscrollbar component 833 uiscrollbar class inheritance movieclip > uiobject class > uicomponent class > scrollbar > uiscrollbar actionscript class name mx.Controls.Uiscrollbar the properties of the uiscrollbar class let you adjust the scroll position and the amount of scrolling that occurs when the...

  • Page 834

    834 chapter 6: components dictionary 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 . Property summary fo...

  • Page 835

    Uiscrollbar component 835 properties inherited from the uicomponent class the following table lists the properties the uiscrollbar class inherits from the uicomponent class. When accessing these properties from the uiscrollbar object, use the form uiscrollbarinstance.Propertyname . Event summary for...

  • Page 836

    836 chapter 6: components dictionary events inherited from the uicomponent class the following table lists the events the uiscrollbar class inherits from the uicomponent class. Uiscrollbar.Horizontal availability flash player 6 (6.0 79.0). Edition flash mx 2004. Usage scrollbarinstance.Horizontal de...

  • Page 837

    Uiscrollbar component 837 description property; gets or sets the number of lines or pixels scrolled when the user clicks the arrow buttons of the uiscrollbar component. If the scroll bar is oriented vertically, the value is a number of lines. If the scroll bar is oriented horizontally, the value is ...

  • Page 838

    838 chapter 6: components dictionary usage usage 1: on(scroll){ ... } usage 2: listenerobject = new object(); listenerobject.Scroll = function(eventobject){ ... } uiscrollbarinstance.Addeventlistener("scroll", listenerobject) description event; broadcast to all registered listeners when the mouse is...

  • Page 839

    Uiscrollbar component 839 example the following code implements usage 1. The code is attached to the uiscrollbar component instance and sends a message to the output panel when the user clicks the scroll bar. The on() handler must be attached directly to the uiscrollbar instance. On(scroll){ trace("...

  • Page 840

    840 chapter 6: components dictionary example the following example scrolls the text field to the beginning of the text it contains: myscrollbar.Scrollposition = 0; the following example scrolls the text field to the end of the text it contains: myscrollbar.Scrollposition = mytextfield.Maxscroll - 1;...

  • Page 841

    Uiscrollbar component 841 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 te...

  • Page 842: Chapter 6

    842 chapter 6: components dictionary web service classes (flash professional only) the web service classes, which are found in the mx.Services package, let you access web services that use simple object access protocol (soap). This api is not the same as the webserviceconnector component api. The we...

  • Page 843

    Web service classes (flash professional only) 843 callback summary for the log object the following table lists the callback of the log object. Constructor for the log class availability flash player 6 (6.0 79.0). Edition flash mx professional 2004. Usage mywebsrvclog = new log([loglevel] [, logname...

  • Page 844

    844 chapter 6: components dictionary 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. The following are examples of log...

  • Page 845

    Web service classes (flash professional only) 845 mytrace("log event:\r mywebsrvclog.Message="+message+); } pendingcall class (flash professional only) actionscript class name mx.Services.Pendingcall the pendingcall class is part of the mx.Services package and is used with the webservice class. For ...

  • Page 846

    846 chapter 6: components dictionary property summary for the pendingcall object the following table lists properties of the pendingcall class. Callback summary for the pendingcall object the following table lists the callbacks of the pendingcall class. Pendingcall.Getoutputparameter() availability ...

  • Page 847

    Web service classes (flash professional only) 847 description function; gets an additional output parameter of the soapparameter object, which contains the value and the xml element. Soap rpc calls may return multiple output parameters. The first (or only) return value is always delivered in the res...

  • Page 848

    848 chapter 6: components dictionary 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 onre...

  • Page 849

    Web service classes (flash professional only) 849 description function; gets additional output parameters of the soapparameter object, which contains the values and the xml elements. Soap rpc calls may return multiple output parameters. The first (or only) return value is always delivered in the res...

  • Page 850

    850 chapter 6: components dictionary see also pendingcall.Getoutputparameterbyname() , pendingcall.Getoutputparameter() , pendingcall.Getoutputparameters() , pendingcall.Getoutputvalues() pendingcall.Getoutputvalues() availability flash player 6 (6.0 79.0). Edition flash mx professional 2004. Usage ...

  • Page 851

    Web service classes (flash professional only) 851 example the following onresult callback traces the name of the soapcall operation. Callback.Onresult = function(result) { // check my operation name trace("my operation name is " + this.Mycall.Name); } pendingcall.Onfault availability flash player 6 ...

  • Page 852

    852 chapter 6: components dictionary this is a good place to put code that handles any faults, for example, by telling the user that the server isn’t available or to contact technical support, if appropriate. Example the following example handles errors returned from the web service method. // handl...

  • Page 853

    Web service classes (flash professional only) 853 example the following example handles results returned from the web service method. // handles results returned from the use of a web service method mypendingcallobj = mywebservice.Methodname(params) mypendingcallobj.Onresult = function(result) { // ...

  • Page 854

    854 chapter 6: components dictionary soapcall class (flash professional only) actionscript class name mx.Services.Soapcall the soapcall class is part of the mx.Services package and is an advanced class to be used with the webservice class (see “webservice class (flash professional only)” on page 856...

  • Page 855

    Web service classes (flash professional only) 855 description property; the number of concurrent requests. Possible values are listed in the table below: soapcall.Dodecoding availability flash player 6 (6.0 79.0). Edition flash mx professional 2004. Usage soapcall.Dodecoding description property; tu...

  • Page 856

    856 chapter 6: components dictionary 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 packag...

  • Page 857

    Web service classes (flash professional only) 857 method summary for the webservice object the following table lists methods of the webservice object. Callback summary for the webservice object the following table lists the callbacks of the webservice object. Supported types (flash professional only...

  • Page 858

    858 chapter 6: components dictionary date and time simple types name and string simple types boolean type byte number unsignedlong number unsignedshort number unsignedint number unsignedbyte number float number double number xml schema type actionscript binding date date object datetime date object ...

  • Page 860

    860 chapter 6: components dictionary usage mywebserviceobject = new webservice(wsdluri [, logobject]); parameters wsdluri the uri of the web service wsdl file. Logobject an optional parameter specifying the name of the log object for this web service. If this parameter is used, the log object must b...

  • Page 861

    Web service classes (flash professional only) 861 { outputfield.Text = result } mypendingcallobject.Onfault = function(fault) { debugfield.Text = fault.Faultcode + "," + fault.Faultstring; // add code to handle any faults, for example, by telling the // user that the server isn’t available or to con...

  • Page 862

    862 chapter 6: components dictionary usage callbackobj = mywebserviceobject.Mymethodname(param1, ... Paramn); parameters param1, ... Paramn various parameters, depending on the web service method that is called. Returns a pendingcall object to which you can attach a function for handling results and...

  • Page 863

    Web service classes (flash professional only) 863 parameters fault decoded actionscript object version of the error with properties. If the error information came from a server in the form of xml, then the soapfault object will be the decoded actionscript version of that xml. The type of error objec...

  • Page 864

    864 chapter 6: components dictionary 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...

  • Page 865: Chapter 6

    Webserviceconnector component (flash professional only) 865 webserviceconnector component (flash professional only) the webserviceconnector component lets you access remote methods exposed by a server using the industry-standard simple object access protocol (soap). A web service method may accept p...

  • Page 866

    866 chapter 6: components dictionary wsdlurl (string type) is the url of the wsdl file that defines the web service operation. When you set this url during authoring, the wsdl file is immediately fetched and parsed. The resulting parameters and results information can be seen in the schema tab of th...

  • Page 867

    Webserviceconnector component (flash professional only) 867 method summary for the webserviceconnector class the following table lists the method of the webserviceconnector class. Property summary for the webserviceconnector class the following table lists properties of the webserviceconnector class...

  • Page 868

    868 chapter 6: components dictionary webserviceconnector.Multiplesimultaneousallowed availability flash player 6 (6.0 79.0). Edition flash mx professional 2004. Usage componentinstance.Multiplesimultaneousallowed description property; indicates whether multiple calls can ( true ) or cannot ( false )...

  • Page 869

    Webserviceconnector component (flash professional only) 869 example this example returns data from a remote web service and traces a tip and how long the service takes to return the data to the swf file. Drag a webserviceconnector component into your library, and enter the following code on frame 1 ...

  • Page 870

    870 chapter 6: components dictionary example the following example sets the params property for a web service component named wsc : wsc.Params = [param_txt.Text]; webserviceconnector.Result availability flash player 6 (6.0 79.0). Edition flash mx professional 2004. Usage componentinstance.Addeventli...

  • Page 871

    Webserviceconnector component (flash professional only) 871 webserviceconnector.Results availability flash player 6 (6.0 79.0). Edition flash mx professional 2004. Usage componentinstance.Results description property; identifies data that was received from the server as a result of a trigger() opera...

  • Page 872

    872 chapter 6: components dictionary example the following example defines a function sendfunction for the send event and assigns the function to the addeventlistener event handler: var sendfunction = function (sendenv) { sendenv.Target.Params = [newparam_txt.Text]; }; wsc.Addeventlistener("send", s...

  • Page 873

    Webserviceconnector component (flash professional only) 873 here are the possible web service faults: faultcode faultstring detail timeout timeout while calling method xxx mustunderstand no callback for header xxx server.Connection unable to connect to endpoint: xxx versionmismatch request implement...

  • Page 874

    874 chapter 6: components dictionary example the following example defines a function statusfunction for the status event and assigns the function to the addeventlistener event handler: var statusfunction = function (stat) { trace(stat.Code); trace(stat.Data.Faultcode); trace(stat.Data.Faultstring);...

  • Page 875

    Webserviceconnector component (flash professional only) 875 case 'statuschange' : break; default : trace("error: "+error.Code); break; } }; var wsconn:webserviceconnector = new webserviceconnector(); wsconn.Addeventlistener("result", res); wsconn.Addeventlistener("status", stat); wsconn.Wsdlurl = "h...

  • Page 876

    876 chapter 6: components dictionary the trigger() method performs the following steps: 1. If any data is bound to the params property, the method executes all the bindings to ensure that up-to-date data is available. This also causes data validation to occur. 2. If the data is not valid and suppres...

  • Page 877

    Webserviceconnector component (flash professional only) 877 var res:function = function (evt:object) { trace(evt.Target.Results); }; var wsconn:webserviceconnector = new webserviceconnector(); wsconn.Addeventlistener("result", res); wsconn.Wsdlurl = "http://www.Flash-mx.Com/mm/tips/tips.Cfc?Wsdl"; w...

  • Page 878: Chapter 6

    878 chapter 6: components dictionary window component a window component displays the contents of a movie clip inside a window with a title bar, a border, and an optional close button. A window component can be modal or nonmodal. A modal window prevents mouse and keyboard input from going to other c...

  • Page 879

    Window component 879 title indicates the title of the window. Closebutton indicates whether a close button is displayed ( true ) or not ( false ). Clicking the close button broadcasts a click event, but doesn’t close the window. You must write a handler that calls window.Deletepopup() to explicitly ...

  • Page 880

    880 chapter 6: components dictionary this handler calls popupmanager.Createpopup() to instantiate a window component with the title bar “change password”; the window displays the contents of the passwordform movie clip when the button is clicked. To close the window when the ok or cancel button is c...

  • Page 881

    Window component 881 text styles can be set on the window component itself, or they can be set on the _global.Styles.Windowstyles class style declaration. This has the advantage of not causing style settings to propagate to child components through style inheritance. The following example demonstrat...

  • Page 882

    882 chapter 6: components dictionary the following example demonstrates how to create a new movie clip symbol to use as the title background. To set the title of an window component to a custom movie clip symbol: 1. Create a new fla file. 2. Create a new symbol by selecting insert > new symbol. 3. S...

  • Page 883

    Window component 883 the best way to instantiate a window is to call popupmanager.Createpopup() . This method creates a window that can be modal (overlapping and disabling existing objects in an application) or nonmodal. For example, the following code creates a modal window instance (the last param...

  • Page 884

    884 chapter 6: components dictionary 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 . Property summary for the window cl...

  • Page 885

    Window component 885 properties inherited from the uiobject class the following table lists the properties the window class inherits from the uiobject class. When accessing these properties from the window object, use the form windowinstance.Propertyname . Properties inherited from the uicomponent c...

  • Page 886

    886 chapter 6: components dictionary events inherited from the uiobject class the following table lists the events the window class inherits from the uiobject class. Events inherited from the uicomponent class the following table lists the events the window class inherits from the uicomponent class....

  • Page 887

    Window component 887 usage 2: listenerobject = new object(); listenerobject.Click = function(eventobject){ ... } windowinstance.Addeventlistener("click", listenerobject) description event; broadcast to all registered listeners when the mouse is clicked (released) over the close button. The first usa...

  • Page 888

    888 chapter 6: components dictionary window.Closebutton availability flash player 6 (6.0 79.0). Edition flash mx 2004. Usage windowinstance.Closebutton description property; a boolean value that indicates whether the title bar should have a close button ( true ) or not ( false ). This property must ...

  • Page 889

    Window component 889 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 objec...

  • Page 890

    890 chapter 6: components dictionary example the following code sets the value of the text property within the content inside the window component: myloginwindow.Content.Password.Text = "secret"; window.Contentpath availability flash player 6 (6.0 79.0). Edition flash mx 2004. Usage windowinstance.C...

  • Page 891

    Window component 891 example the following code creates a modal window, then creates a listener that deletes the window when the close button is clicked: import mx.Managers.Popupmanager; import mx.Containers.Window; var mytw:movieclip = popupmanager.Createpopup(_root, window, true, {closebutton:true...

  • Page 892

    892 chapter 6: components dictionary the second usage example uses a dispatcher/listener event model. A component instance ( windowinstance ) dispatches an event (in this case, mousedownoutside ) and the event is handled by a function, also called a handler, on a listener object ( listenerobject ) t...

  • Page 893

    Window component 893 window.Titlestyledeclaration availability flash player 6 (6.0 79.0). Edition flash mx 2004. Usage windowinstance.Titlestyledeclaration description property; a string indicating the style declaration that formats the title bar of a window. The default value is undefined , which i...

  • Page 894: Chapter 6

    894 chapter 6: components dictionary xmlconnector component (flash professional only) the xmlconnector component lets you read or write xml documents using http get or post operations. It acts as a connector between other components and external xml data sources. The xmlconnector component communica...

  • Page 895

    Xmlconnector component (flash professional only) 895 common workflow for the xmlconnector component the following procedure outlines the typical workflow for the xmlconnector component. To use an xmlconnector component: 1. Add an instance of the xmlconnector component to your application and give it...

  • Page 896

    896 chapter 6: components dictionary property summary for the xmlconnector class the following table lists properties of the xmlconnector class. Event summary for the xmlconnector class the following table lists events of the xmlconnector class. Xmlconnector.Direction availability flash player 6 (6....

  • Page 897

    Xmlconnector component (flash professional only) 897 description property; indicates whether data is being sent, received, or both. The values are the following: • send xml data for the params property is sent by http post method to the url for the xml document. Any data that is returned is ignored....

  • Page 898

    898 chapter 6: components dictionary usage componentinstance.Multiplesimultaneousallowed description property; indicates whether multiple calls can take place at the same time. If this property is false , the xmlconnector.Trigger() method performs a call if another call is already in progress. A sta...

  • Page 899

    Xmlconnector component (flash professional only) 899 xmlconnector.Params availability flash player 6 (6.0 79.0). Edition flash mx professional 2004. Usage componentinstance.Params description property; specifies data that will be sent to the server when the next trigger() operation is executed. Each...

  • Page 900

    900 chapter 6: components dictionary 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 defin...

  • Page 901

    Xmlconnector component (flash professional only) 901 you can retrieve or modify the actual parameter values by using the params property. Example the following example defines a function sendfunction for the send event and assigns the function to the addeventlistener event handler: var sendfunction ...

  • Page 902

    902 chapter 6: components dictionary the following are the faults that can occur with the status event: example the following example defines a function statusfunction for the status event and assigns the function to the addeventlistener event handler: var statusfunction = function (stat) { trace(st...

  • Page 903

    Xmlconnector component (flash professional only) 903 xmlconnector.Suppressinvalidcalls availability flash player 6 (6.0 79.0). Edition flash mx professional 2004. Usage componentinstance.Suppressinvalidcalls description property; indicates whether to suppress a call if parameters are invalid. If thi...

  • Page 904

    904 chapter 6: components dictionary xmlconnector.Trigger() availability flash player 6 (6.0 79.0). Edition flash mx professional 2004. Usage componentinstance.Trigger() description method; initiates a remote procedure call. Each rpc component defines exactly what this involves. If the operation is ...

  • Page 905

    Xmlconnector component (flash professional only) 905 this code specifies the url of the xml file and sets multiplesimultaneousallowed to false . It triggers the xmlconnector instance three times, which causes the event listener's status method to display the error code callalreadyinprogress two time...

  • Page 906

    906 chapter 6: components dictionary this code specifies the url of the xml file and sets multiplesimultaneousallowed to false . It triggers the xmlconnector instance three times, which causes the event listener’s status() method to display the error code callalreadyinprogress two times in the outpu...

  • Page 907: Chapter 6

    Xupdateresolver component (flash professional only) 907 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 ...

  • Page 908

    908 chapter 6: components dictionary xupdateresolver component parameter the xupdateresolver component has one authoring parameter, the boolean includedeltapacketinfo parameter. When this parameter is set to true , the update packet includes additional information that can be used by an external dat...

  • Page 909

    Xupdateresolver component (flash professional only) 909 6. Use the bindings tab of the component inspector to bind data elements (dataset fields) to the visual components in your application. 7. Select the schema tab of the xupdateresolver component. With the deltapacket component property selected,...

  • Page 910

    910 chapter 6: components dictionary property summary for the xupdateresolver class the following table lists properties of the xupdateresolver class. Event summary for the xupdateresolver class the following table lists events of the xupdateresolver class. Xupdateresolver.Beforeapplyupdates availab...

  • Page 911

    Xupdateresolver component (flash professional only) 911 parameters eventobject resolver event object; describes the customizations to the xml packet before the update is sent through the connector to the database. This event object should contain the following properties: returns none. Description e...

  • Page 912

    912 chapter 6: components dictionary messages in the updateresults property are treated as errors. This means that a delta with messages is added to the delta packet again so it can be re-sent the next time the delta packet is sent to the server. You must write code that handles deltas that have mes...

  • Page 913

    Xupdateresolver component (flash professional only) 913 returns none. Description event; called by the resolver component to compare two packets. Use this callback to insert any code after the results have been received from the server and immediately before the transmission, through data binding, o...

  • Page 914

    914 chapter 6: components dictionary 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 prop...

  • Page 915: Chapter 7

    915 chapter 7 creating components this chapter describes how to create your own component and package it for deployment. The version 2 architecture has simplified the component development process in several ways. For more information, see “what’s new in version 2 components” on page 916 . This chap...

  • Page 916

    916 chapter 7: creating components what’s new in version 2 components the current version (version 2) of the macromedia component architecture is very different from the macromedia flash mx version (version 1). The following list provides an overview of some of the changes that affect component deve...

  • Page 917

    Overview of component structure 917 overview of component structure a component is comprised of a flash (fla) file and an actionscript (as) file. There are other files (for example, an icon and a .Swd debugging file) that you can optionally create and package with your component, but all components ...

  • Page 918

    918 chapter 7: creating components building your first component in this section, you will build a dial component. The completed component files, dial.Fla, dial.As, dial.Swf, and dialassets.Fla are located in the examples folder on your hard disk: • macromedia/flash mx 2004/samples/helpexamples/dial...

  • Page 919

    Building your first component 919 11. Choose file > import > open external library and choose the standardcomponents.Fla file from the firstrun/componentfla folder. Dial extends the uicomponent base class; therefore, you must drag an instance of the uicomponent class into the dial document. Note: fo...

  • Page 920

    920 chapter 7: creating components creating the dial class file the following is the actionscript class for the dial component. Please read the comments in the code for a description of each section. To create this file, you can create a new actionscript file in the flash ide, or use any other text ...

  • Page 921

    Building your first component 921 size(); } // the draw method is invoked after the component has // been invalidated, by someone calling invalidate(). // this is better than redrawing from within the set function // for value, because if there are other properties, it's // better to batch up the ch...

  • Page 922

    922 chapter 7: creating components } // when the dial is pressed, the dragging flag is set. // the mouse events are assigned callback functions. Function begindrag() { dragging = true; onmousemove = mousemovehandler; onmouseup = mouseuphandler; } // remove the mouse events when the drag is complete,...

  • Page 923

    Building your first component 923 to test the dial component: 1. In the dial.Fla file, choose the dial component in the library and choose convert to compiled clip from the library options menu. A compiled clip is added to the library with the name dial swf. Note: if you’ve already created a compile...

  • Page 924

    924 chapter 7: creating components to export the dial component: 1. In the dial.Fla file, choose the dial component in the library and select export to swc from the library options menu. 2. Choose a location to save the swc file. If you save it to the components folder in the user-level configuratio...

  • Page 925

    Selecting a parent class 925 the following table briefly describes the version 2 base classes: understanding the uiobject class components based on version 2 of the macromedia component architecture descend from the uiobject class, which is a subclass of the movieclip class. The movieclip class is t...

  • Page 926

    926 chapter 7: creating components extending other version 2 classes to make component construction easier, you can extend any class; you are not required to extend the uiobject or uicomponent class directly. If you extend any other version 2 component’s class (except the media components), you exte...

  • Page 927

    Creating a component movie clip 927 creating a component movie clip to create a component, you must create a movie clip symbol and link it to the component’s class file. The movie clip has two frames and two layers. The first layer is an actions layer and has a stop() action on frame 1. The second l...

  • Page 928

    928 chapter 7: creating components editing the movie clip after you create the new symbol and define the linkages for it, you can define the component’s assets in the symbol’s timeline. A component’s symbol should have two layers. This section describes what layers to insert and what to add to those...

  • Page 929

    Creating a component movie clip 929 6. If you are extending an existing component, place an instance of that component and any other base classes in frame 2 of the assets layer. To do this, select the symbol from the components panel and drag it onto the stage. If you are extending a base class, ope...

  • Page 930

    930 chapter 7: creating components 3. Use other options in the component definition dialog box, if desired: ■ click the plus (+) button to define parameters. This is optional. The best practice is to use the metadata inspectable tag in the component’s class file to specify parameters. When an action...

  • Page 931

    Creating the actionscript class file 931 this example contains a minimal set of imports, methods, and declarations for a component, mycomponent, that inherits from the uicomponent class. The mycomponents.As file is saved in the mypackage folder. [event("eventname")] // import packages. Import mx.Cor...

  • Page 932

    932 chapter 7: creating components overview of a component class file the following procedure is an overview of the creation of an actionscript file for a component. Some steps may be optional, depending on the type of component you create. To write a component class file: 1. (optional) import class...

  • Page 933

    Creating the actionscript class file 933 importing classes you can import class files so that you don’t have to write fully qualified class names throughout your code. This can make code more concise and easier to read. To import a class, use the import statement at the top of the class file, as in ...

  • Page 934

    934 chapter 7: creating components the following table describes these variables: the following example adds the symbolname , symbolowner , and classname variables to the mybutton class: class mybutton extends mx.Controls.Button { static var symbolname:string = "mybutton"; static var symbolowner = m...

  • Page 935

    Creating the actionscript class file 935 using getter/setter methods to define parameters the simplest way to define a component parameter is to add a public member variable that is inspectable: [inspectable(defaultvalue="strawberry")] public var flavorstr:string; however, if code that employs a com...

  • Page 936

    936 chapter 7: creating components metadata is associated with a class declaration or an individual data field. If the value of an attribute is of type string, you must enclose that attribute in quotation marks. Metadata statements are bound to the next line of the actionscript file. When defining a...

  • Page 937

    Creating the actionscript class file 937 about the inspectable tag you use the inspectable tag to specify the user-editable (inspectable) parameters that appear in the component inspector and property inspector. This lets you maintain the inspectable properties and the underlying actionscript code i...

  • Page 938

    938 chapter 7: creating components the following table describes the attributes of the inspectable tag: none of these attributes are required. You can simply have inspectable as the metadata tag. All properties of the superclass that are marked inspectable are automatically inspectable in the curren...

  • Page 939

    Creating the actionscript class file 939 the inspectablelist tag must immediately precede the class definition because it applies to the entire class. The following example allows the flavorstr and colorstr properties to be displayed in the property inspector, but excludes other inspectable properti...

  • Page 940

    940 chapter 7: creating components use the bindable tag before a property in an actionscript class to make the property appear in the bindings tab in the component inspector. You can declare a property by using var or getter/ setter methods. If a property has both a getter and a setter method, you o...

  • Page 941

    Creating the actionscript class file 941 about the changeevent tag the changeevent tag tells data binding that the component will generate an event any time the value of a specific property changes. In response to the event, data binding executes any binding that has that property as a source. The c...

  • Page 942

    942 chapter 7: creating components about the collection tag use the collection tag to describe an array of objects that can be modified as a collection of items in the values dialog box while authoring. The type of the objects is identified by the collectionitem attribute. A collection property cont...

  • Page 943

    Creating the actionscript class file 943 for more information, see “collection properties” on page 959 . About the iconfile tag you can add an icon that represents your component in the components panel of the flash authoring environment. For more information, see “adding an icon” on page 956 . Defi...

  • Page 944

    944 chapter 7: creating components [inspectable(defaultvalue="default text")] function set text(t:string) } you can use any of the following types for parameters: • array • object • list • string • number • boolean • font name • color note: the jellybean class is a theoretical example. To see an act...

  • Page 945

    Creating the actionscript class file 945 if your component extends uicomponent or uiobject, flash automatically calls init() , createchildren() , and size() methods and you can leave your constructor function empty, as shown here: class mycomponent extends uicomponent{ ... // this is the constructor...

  • Page 946

    946 chapter 7: creating components the init() method is called from uiobject’s constructor, so the flow of control climbs up the chain of constructors until it reaches uiobject. Uiobject’s constructor calls the init() method that is defined on lowest subclass. Each implementation of init() should ca...

  • Page 947

    Creating the actionscript class file 947 if (mode_mc == undefined) createclassobject(simplebutton, "mode_mc", 1, { falseupskin: modeupskinname, falseoverskin: modeoverskinname, falsedownskin: modedownskinname }); mode_mc.Addeventlistener("click", this); size() invalidate() } defining the draw() meth...

  • Page 948

    948 chapter 7: creating components about invalidation macromedia recommends that a component not update itself immediately in most cases, but that it instead should save a copy of the new property value, set a flag indicating what is changed, and call the invalidate() method. (this method indicates ...

  • Page 949

    Creating the actionscript class file 949 the description of each event in the flash mx 2004 documentation lists the event properties that are optional and required. For example, the scrollbar.Scroll event takes a detail property in addition to the type and target properties. For more information, se...

  • Page 950

    950 chapter 7: creating components about assigning skins a user interface (ui) component is composed entirely of attached movie clips. This means that all assets for a ui component can be external to the ui component movie clip, so they can be used by other components. For example, if your component...

  • Page 951

    Creating the actionscript class file 951 registering skins to styles the following example creates a component called shape. This component displays a shape that is one of two skins: a circle or a square. The skins are registered to the themecolor style. To register a skin to a style: 1. Create a ne...

  • Page 952

    952 chapter 7: creating components 10. Select the shape movie clip in the library, select component definition from the library options menu, and enter the as 2.0 class shape. 11. Test the movie clip with the shape component on the stage. To change the theme color, set the style on the instance. The...

  • Page 953

    Exporting and distributing a component 953 symboldisabledcolor: true, themecolor:true, todayindicatorcolor: true, shadowcapcolor:true, bordercapcolor:true, focuscolor:true, shapecolor:true }; register the new style name to the circle and square skins on frame 1 of each skin movie clip, as follows: m...

  • Page 954

    954 chapter 7: creating components the following table describes the contents of a swc file: you can optionally include other files in the swc file, after you generate it from the flash environment. For example, you might want to include a read me file, or the fla file if you want users to have acce...

  • Page 955

    Adding the finishing touches 955 exporting a swc for a completed component you can export components as swc files that contain all the actionscript, swf files, and other optional files needed to use the component. To export a swc file for a completed component: 1. Select the component movie clip in ...

  • Page 956

    956 chapter 7: creating components adding an icon you can add an icon that represents your component in the components panel of the flash authoring environment. To add an icon for your component: 1. Create a new image. The image must measure 18 pixels square, and you must save it in png format. It m...

  • Page 957

    Adding the finishing touches 957 • when defining the symbol, do not select the export in first frame option unless absolutely necessary. Flash loads the component just before it is used in your flash application, so if you select this option, flash preloads the component in the first frame of its pa...

  • Page 958

    958 chapter 7: creating components.

  • Page 959: Appendix

    959 appendix collection properties this appendix explains how to create a collection property in a component. The collection class is a helper class used to manage a group of zero or more related objects, called collection items. If you define a property of your component as a collection and make it...

  • Page 960

    960 appendix: collection properties this appendix contains the following sections: defining a collection property . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 960 simple collection example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ...

  • Page 961

    Simple collection example 961 class myshelf extends mx.Core.Uiobject { // required variables for all classes static var symbolname:string = "myshelf"; static var symbolowner:object = object(myshelf); var classname:string = "myshelf"; // the collection metadata tag and attributes [collection(variable...

  • Page 962

    962 appendix: collection properties 5. Choose window > other panels > common libraries > classes, and drag utilclasses to the library of myshelf.Fla. 6. In the myshelf symbol’s timeline, name one layer assets. Create another layer and name it actions. 7. Place a stop() function on frame 1 of the act...

  • Page 963

    Accessing collection information programmatically 963 accessing collection information programmatically flash provides programmatic access to collection data through the collection and iterator interfaces. The collection interface lets you add, modify, and remove items in a collection. The iterator ...

  • Page 964

    964 appendix: collection properties accessing collection items at runtime in a flash application if a flash application uses a component that has a collection property, you can access the collection property at runtime. This example adds several items to a collection property using the values dialog...

  • Page 965

    Using a component that has a collection property 965 of these files, your code typically uses the collection and iterator interfaces, which marks them as dependent classes. Flash automatically includes dependent files in the swc file and output swf file. However, the collection implementation class ...

  • Page 966

    966 appendix: collection properties.

  • Page 967: Index

    967 index a accessibility 18 accordion component creating an application with 97 customizing 99 events 107 inheritance 105 methods 105 package 105 parameters 97 properties 106 using skins with 101 using styles with 100 using with movie clips (tutorial) 27 actionscript class files activators 574 aler...

  • Page 968

    968 index class style sheets 67 classes accordion 105 alert 119 and component inheritance 16 binding 214 button 139 checkbox 161 combobox 182 componentmixins 229 creating references to (tutorial) 33 creating. See creating components customformatter 217 customvalidator 220 data binding 213 datagrid 2...

  • Page 969

    Index 969 compiled clips about 17 in library panel 47 component categories data 92 managers 93 media 93 other 94 screens 94 ui components 91 component class file. See class file component definition 929 component inspector binding tab 32 media components and 503 setting parameters 47 component param...

  • Page 970

    970 index typedvalue class 244 using at runtime 213 data binding, with xml file (tutorial) 31 data components 92 data grids. See datagrid component data integration with components (tutorial) 22 data models datagrid component 249 menu component 540 data sets. See dataset component data types setting...

  • Page 971

    Index 971 dispatcher 56 dispatching events 948 documentation guide to terminology 9 overview 8 draw() method, defining 947 e element (pendingcall.Onfault) 851 element (webservice.Onfault) 863 endpoint class about 224 methods 225 event listeners. See listeners event metadata tag 939 event object 66, ...

  • Page 972

    972 index parameters 443 properties 446 tutorial 28 using styles 444 library adding instances to 23 compiled clips in 47 library panel 47 standardcomponents 928 linkage identifiers for skins 81 list component 450 creating an application 452 customizing 453 design 145 events 460 inheritance 456 metho...

  • Page 973

    Index 973 parameters 575 properties 579 using skins 577 using styles 576 menudataprovider class 568 events 569 methods 569 metadata 935 collection tag 942 event tag 939 inspectable tag 937 tags, list of 936 movie clips, component instances in (tutorial) 25 movieclip class, extending 926 multiplesimu...

  • Page 974

    974 index separator 542 simplebutton class 686 events 688 methods 686 properties 687 size() method, defining 947 skin properties changing in the prototype 89 setting 81 skinning 80 skins applying 85 applying to subcomponents 86 creating components 950 editing 83 linkage identifiers 81 see also indiv...

  • Page 975

    Index 975 themes 77 applying 79 creating 77 tip text, adding 956 transferobject interface about 756 methods 756 tree component 759 creating an application 762 customizing 766 events 773 inheritance 770 methods 771 package 770 parameters 761 properties 772 using skins 769 using styles 766 xml formatt...

  • Page 976

    976 index window component 878 creating an application 879 customizing 880 events 885 inheritance 882 methods 883 package 882 parameters 878 properties 884 using skins 881 using styles 880 wsdlurl parameter 866 x xml attributes of menu item 541 formatting for the tree component 760 schema types 857 ...