Adobe FLEX 2-MIGRATING APPLICATIONS TO FLEX 2 Manual
Adobe FLEX 2-MIGRATING APPLICATIONS TO FLEX 2 Manual

Adobe FLEX 2-MIGRATING APPLICATIONS TO FLEX 2 Manual

Migrating applications to flex 2
Table of Contents

Advertisement

Quick Links

Advertisement

Table of Contents
loading

Summary of Contents for Adobe FLEX 2-MIGRATING APPLICATIONS TO FLEX 2

  • Page 2 © 2006 Adobe Systems Incorporated. All rights reserved. Migrating Applications to Flex™ 2 If this guide is distributed with software that includes an end-user agreement, this guide, as well as the software described in it, is furnished under license and may be used or copied only in accordance with the terms of such license. Except as permitted by any such license, no part of this guide may be reproduced, stored in a retrieval system, or transmitted, in any form or by any means, electronic, mechanical, recording, or otherwise, without the prior written permission of Adobe Systems Incorporated.
  • Page 3: Table Of Contents

    Contents About Flex Documentation ....... . . 7 Using this manual ..........7 Accessing the Flex documentation .
  • Page 4 Events ............84 Formatters.
  • Page 5 Chapter 9: Data Services....... . 135 About Data Services ......... .135 Migrating RemoteObject components .
  • Page 6 Contents...
  • Page 7: About Flex Documentation

    About Flex Documentation Migrating Applications to Flex 2 provides information on updating applications written for Flex 1.x to Flex 2. Contents Using this manual ............7 Accessing the Flex documentation .
  • Page 8 Documentation set The Flex documentation set includes the following titles: Book Description Flex 2 Developer’s Guide Describes how to develop your dynamic web applications. Getting Started with Flex 2 Contains an overview of Flex features and application development procedures. Creating and Extending Flex 2 Describes how to create and extend Flex Components components.
  • Page 9: Chapter 1: Getting Started

    CHAPTER 1 Getting Started This topic describes the first steps of migrating a Macromedia Flex 1.x application to Adobe Flex 2. This topic describes steps that are meant to be accomplished quickly and resolve most of the warnings and errors that you encounter. When you complete the steps in this topic, you should read other topics in this manual for more information about specific migration operations.
  • Page 10: Step 1: Find And Replace

    The basic steps are the following: “Step 1: Find and replace” on page 10 ■ “Step 2: Add access modifiers” on page 14 ■ “Step 3: Add types” on page 15 ■ “Step 4: Update events” on page 16 ■ “Step 6: Put all ActionScript components in packages”...
  • Page 11 Flex classes that have changed that are not mentioned here. For a complete list, see Chapter 3, “Flex Classes,” on page Application namespace Change the MXML namespace. Change the following: xmlns:mx="http://www.macromedia.com/2003/mxml" to this: xmlns:mx="http://www.adobe.com/2006/mxml" For example: <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">...
  • Page 12 Application and container initialization event is now dispatched later in the startup and component creation life initialize cycle. In particular, it is now dispatched after the object’s children have been created. If your event handler assumes that the object’s children have already been created, you can use the event.
  • Page 13 Replace _root Remove the use of “ ” from your application code if you used it to access the Application _root instance. In Flex 1.x, you could use to refer to the main application from anywhere in _root your application or one of the components. This was never a recommended practice, but was a convenient way to access the application root.
  • Page 14: Step 2: Add Access Modifiers

    Effects/behaviors For each effect, such as Fade, Sequence, and Parallel, change the property to . Also, name remove the tags; for example: <mx:Effect> <mx:Sequence id="myWipes"> <mx:WipeLeft/> <mx:WipeRight/> <mx:WipeUp/> <mx:WipeDown/> </mx:Sequence> For more information, see Chapter 8, “Behaviors,” on page 129. getURL() method Replace the method with the...
  • Page 15: Step 3: Add Types

    The default access modifier for methods, variables, and classes is . This means that internal all classes in the same package can access them, but classes outside of the package cannot. However, the Flex compiler issues a warning if you do not specify any access modifier. For more information about access modifiers, see “Access modifiers”...
  • Page 16: Step 4: Update Events

    Step 4: Update events The Event model changed in Flex 2. However, you can migrate most event handlers with minimal effort. This section describes the most popular changes that you must make to your event handling code. For more information about migrating events, see Chapter 6, “Events,”...
  • Page 17: Step 5: Import Classes For Package-Level Functions

    Step 5: Import classes for package-level functions When you use package-level functions, you must import the package. For example, in Flex 1.x you could call the method in the following way: show() mx.controls.Alert.show("This is an Alert!"); In Flex 2, you must import the package before calling the function, as the following example shows: import mx.controls.Alert;...
  • Page 18: Step 7: Update Data Services

    Step 7: Update data services The RemoteObject, HTTPService, and WebService MXML services are now known as RPC services. The RemoteObject tag is not functional unless you use Adobe Flex Data Services. You must replace use of this with another tag. You can still use the HTTPService and WebService tags, but you can only access resources on a server that is in the same domain as the Flex application or from a server that has a crossdomain.xml file installed on it.
  • Page 19: Step 10: Binding

    Step 10: Binding To make a user-defined variable bindable, you must now explicitly identify it by adding the metadata tag to the property; for example: [Bindable] [Bindable] public var catalog:Array; In addition, the tag must be moved to the top level. The following example <mx:Binding>...
  • Page 20 Expanded abbreviations. Abbreviations in property and method names have been ■ expanded where practical. For example, the property is now hPosition horizontalPosition Property names. Some properties have been renamed so that their function is more ■ evident. For example, the Boolean is now multipleSelection allowMultipleSelection...
  • Page 21: Chapter 2: Actionscript 2.0 To 3.0

    CHAPTER 2 ActionScript 2.0 to 3.0 The ActionScript language has undergone a complete redesign. It is now a more robust, type- safe, and usable language. This topic provides an overview of changes to the ActionScript language. For information about using ActionScript 3.0, see Programming ActionScript 3.0. For a complete reference on using ActionScript 3.0, see the ActionScript 3.0 Language Reference.
  • Page 22: Usability Improvements

    A subclass cant have a var with the same name as one visible from the superclass, and you ■ can’t override a var. You must declare a type for everything or you’ll get a compiler warning. ■ Accessing methods or properties of the target of an event object won't compile unless you ■...
  • Page 23 Capitalization of identifiers The ActionScript 3.0 naming conventions match the Flex application model and the ECMAScript standard. All identifiers are in “camel case.” This means that an identifier’s characters are in lowercase, except that the first letter of each word in the identifier is capitalized.
  • Page 24 ActionScript 2.0 had many instances where getter and setter methods existed rather than accessors. Now, ActionScript 3.0 uses accessors wherever possible. Unless a function has arguments, it was converted to an accessor. Methods that return a Boolean such as were converted to accessors, Socket.isConnected() but retained the “is”...
  • Page 25: Classes And Packages

    Abbreviations ActionScript 3.0 contains fewer abbreviations in method and property names. The names are as descriptive as possible. For example, the method is now mapPt() mapPoint() Some abbreviations are still used in ActionScript 3.0. For example, the method getBounds() was not changed to because it is shorter but just as descriptive.
  • Page 26 Using packages statement syntax has changed. In addition, you are now required to put custom package ActionScript components inside packages. If you do not put a class inside a package, then the class is only visible in the current script. For example: class Foo {} is a class that is not in any package, so it is only visible in the current script.
  • Page 27 Using classes This section describes changes to ActionScript classes. Access modifiers The new access modifier refers to a different namespace in each package definition, internal and is not defined outside of a package definition (that is, in global code). If a class in a package isn’t marked , then it defaults to .
  • Page 28: Using External Files

    Using external files This section describes changes to embedding, including, and importing external resources with ActionScript in your Flex applications. include In ActionScript 2.0, the keyword was preceded by an octothorp: . You now include #include use the keyword without the octothorp, and end the line with a semi-colon. For example: ActionScript 2.0: #include "../scripts/thescript.as"...
  • Page 29: Initializing Variables

    Doing the latter results in a “Type annotation is not a compile-time constant” error. Embed The Embed syntax in ActionScript is , and this metadata must be used over [Embed(params)] a variable. The variable should be of type Class; for example: [Embed(source="holdon.mp3")] var sndCls:Class;...
  • Page 30 Default values The following example shows the default values for variables of different types: var dog:int; // defaults to 0 var dog:uint; // defaults to 0 var dog:Boolean;// defaults to false var dog:Number; // defaults to NaN var dog:Object; // defaults to undefined var cat;...
  • Page 31 About undefined In general, ActionScript 2.0 allowed accessing undeclared variables whose value had not yet been set. By default, their value was . In ActionScript 3.0, accessing undeclared undefined variables results in a ReferenceError. You can use the method to check if a hasOwnProperty() variable has been declared: if (hasOwnProperty('b') == false)
  • Page 32: Typing

    If you previously checked against undefined for a Number, you use a similar syntax; for example: if (n == undefined) // ActionScript 2.0 if (isNaN(n)) // ActionScript 3.0 Typing ActionScript 3.0 is more strongly typed than previous versions of ActionScript. This section describes changes to the rules of typing.
  • Page 33 Type detection To perform type detection, you should use rather than . The typeof instanceof function examines types, whereas the function looks at the prototype chain. The instanceof function has been deprecated. instanceof For example: class B { public function B() {} class A extends B { public function A() { super();...
  • Page 34: Global Functions

    is the non-assignment expression. The variable (hintString ? String:Number) myVar dynamically typed to be String if , else its type will be Number. You can hintString true use a non-assignment expression anywhere that you would use a type-assignment expression. Global functions Most global functions have changed packages.
  • Page 35 Function changes Some global functions have been removed and replaced with new functions. The following table shows removed global functions and their ActionScript 3.0 equivalents: ActionScript 2.0 ActionScript 3.0 chr(num) String.fromCharCode(num) int(expr) Math.round(expr) length(expr) expr.length mbchr(num) String.fromCharCode(num) mblength(string) string.length mbord(char) String(char).charCodeAt(0) mbsubstring(string, index, count) string.substr(index,count)
  • Page 36: Miscellaneous

    Miscellaneous This section describes miscellaneous changes to the ActionScript language. MovieClip MovieClip has been replaced by Sprite as the parent class of the base object for Flex controls, UIComponent. The following table lists changes to methods of MovieClip: ActionScript 2.0 method ActionScript 3.0 equivalent method has been removed.
  • Page 37 Arrays Arrays no longer automatically update if you change the data. This means that you should no longer databind to an Array unless you manually call the each time an dispatchEvent() element in the Array changes. Otherwise, the control to which the data is bound will not reflect the changes.
  • Page 38 Constants You can use the keyword to define constants in ActionScript 3.0. First, you determine const which class and instance variables qualify as constants, and then declare them with const instead of ; for example: static const NONMODAL:Number = Alert.NONMODAL; const backgroundColorName:String = "buttonColor";...
  • Page 39 __proto__ ActionScript 3.0 does not support “hacking” the prototype chain. The use of is no __proto__ longer supported. For example: ActionScript 2.0: Class A {} var a: A = new A; trace(a.b) // Output: undefined a.__proto__.b = 10 // Ok trace(a.b) // Output: 10 class C {...
  • Page 40 newstring2.prop = 1; trace(newstring2.prop); // prints '1' ActionScript 3.0: newstring = new String("hello"); String.prototype.sayHi = function() { trace("hi!"); newstring.sayHi(); newstring2 = "hello"; newstring2.prop = 1; // Warning, String is sealed... String.prototype.prop = 1; trace(newstring2.prop); // Output: 1 Working with keys The Key class is now the Keyboard class.
  • Page 41: Chapter 3: Flex Classes

    CHAPTER 3 Flex Classes This topic describes API changes to the Flex class library in Adobe Flex 2 SDK, including class-level changes to containers, core classes, and UI components. Contents Core classes ............. 42 Containers .
  • Page 42: Core Classes

    Core classes The UIObject and UIComponent classes have been combined. As a result, references to the UIObject class should be replaced by UIComponent. Visual Flex controls are subclasses of the UIComponent class (formerly UIObject). In Flex 1.5, the UIComponent class was a descendent of the MovieClip class.
  • Page 43 Member Change description createLater addToCreationQueue property has been replaced by the direction direction layout property. fillAlphas/fillColors The application background gradient now uses the backgroundGradientAlphas backgroundGradientColors style properties for styling, instead of the fillAlphas style properties. If the fillColors property is undefined (which is backgroundGradientColors the default), the background colors are calculated based on the...
  • Page 44 The following table describes changes to the Container class: Member Change description allChildrenList rawChildren Deprecated. Use the style to set this value. backgroundAlpha background Deprecated. backgroundDisabledColor Deprecated. Use the style to set this value. backgroundSize background (formerly childAdd childAdded childCreated (formerly childRemove childRemoved...
  • Page 45 Member Change description hScroller horizontalScroller hScrollPolicy horizontalScrollPolicy marginBottom paddingBottom marginLeft paddingLeft marginRight paddingRight marginTop paddingTop maxHPosition maxHorizontalScrollPosition maxVPosition maxVerticalScrollPosition Removed. showInAutomationHierarchy viewMetricsAndMargins viewMetricsAndPadding vLineScrollSize verticalLineScrollSize vPageScrollSize verticalPageScrollSize vPosition verticalSrollPosition vScrollBarStyleName verticalScrollBarStyleName vScroller verticalScroller vScrollPolicy verticalScrollPolicy If you set the style, Flex ignores any value that is supplied for background backgroundAlpha , or...
  • Page 46 mx.core.MovieClipLoaderAsset The following table describes changes to the mx.core.MovieClipLoaderAsset class: Member Change description Removed. Use the event instead. addedHandler complete mx.core.MXMLUIObject The MXMLObject class is now the IMXMLObject class, to conform with the Flex 2 interface naming style. mx.core.Repeater The following table describes changes to the mx.core.Repeater class: Member Change description Removed.
  • Page 47 mx.core.Skin* The mx.core.Skin* classes have been renamed to use the term Asset in the class name. For example, the SkinSprite class is now named SpriteAsset, and the SkinMovieClip class is now named MovieClipAsset. These classes now implement the IFlexAsset interface. mx.core.UIComponent The UIComponent class has been combined with UIObject to form a single base class for visual Flex components.
  • Page 48 Member Change description Removed. Use the operator and the createEmptyObject() addChild() method or other methods to add new visual objects to the display list. createToolTip toolTipCreate currentStateChanged currentStateChange deleteStyle() clearStyle() Removed. Use the method or other destroyObject() removeChild() methods to remove a child from its parent. doLater() callLater() draw...
  • Page 49 Member Change description mouseOverEffect rollOverEffect mouseOutEffect rollOutEffect mouseWheelOutside This event is now of type instead of FlexMouseEvent MouseEvent notifyEffectEnding effectEnding notifyEffectPlaying effectPlaying popUp isPopUp This event is no longer dispatched by UIComponent. record regenerateProtoChain() regenerateStyleCache() Removed. scrollTrackColor This method is now private. setFocusLater() setSize() setActualSize()
  • Page 50 The alpha, scaleX, and scaleY properties This change formerly applied to the UIObject class, but because UIObject and UIComponent have been combined into a single base class, the change now applies to the UIComponent class. , and properties now range from 0 to 1 instead of from 0 to 100. alpha scaleX scaleY...
  • Page 51 getURL() method This change formerly applied to the UIObject class, but because UIObject and UIComponent have been combined into a single base class, the change now applies to the UIComponent class. In Flex 1.5, every UIObject inherited the method from the MovieClip class. This is getURL() no longer the case.
  • Page 52 Enumerated values are now constants In many cases, properties that took a predefined list of values (such as the Button control’s property taking , and ) now take class constants as labelPlacement right left bottom well. For example, the property can now take one of the following labelPlacement constants: ButtonLabelPlacement.RIGHT...
  • Page 53: Containers

    mx.core.UITextFormat The following table describes the changes to the UITextFormat class: Member Change description Moved to the SystemManager class. isFontFaceEmbedded mx.core.View The mx.core.View class has been removed and its functionality has been distributed between the SWFLoader (formerly Loader), ScrollControlBase (formerly ScrollView), and Container classes.
  • Page 54 mx.containers.Accordion The following table describes changes to the Accordion class: Member Change description Child indices The types have been changed from uint to int. Dispatched when a user clicked on an Accordion header or change when you programmatically set the value of the property to a new number.
  • Page 55 mx.containers.ApplicationControlBar The following table describes changes to the ApplicationControlBar class: Member Change description borderStyle Can no longer be set on ApplicationControlBar. fillAlphas The default value has changed to [0,0] Is now (with an s). The default value is fillColor fillColors [0xFFFFFF, 0xFFFFFF] mx.containers.Box The following table describes the changes to the Box class:...
  • Page 56 mx.containers.DividedBox The following table describes changes to the DividedBox class: Member Change description dividerDragged dividerDrag dividerPressed dividerPress dividerReleased dividerRelease getDividerCount numDividers horizontalCursor horizontalDividerCursor verticalCursor verticalDividerCursor mx.containers.dividedboxclasses.* The dividedboxclasses package is now named dividedBoxClasses. mx.containers.Form The following table describes changes to the Form class: Member Change description marginBottom...
  • Page 57 mx.containers.FormItem The following table describes changes to the FormItem class: Member Change description This property is now internal only. labelObject marginBottom paddingBottom marginRight paddingRight marginTop paddingTop mx.containers.gridclasses.* The gridclasses package is now named dataGridClasses. mx.containers.GridRow The GridRow class now subclasses HBox instead of Box. mx.containers.HBox The following table describes changes to the HBox class: Member...
  • Page 58 The following table describes changes to the LinkBar class: Member Change description click itemClick marginBottom paddingBottom marginTop paddingTop strokeColor separatorColor strokeWidth separatorWidth mx.containers.NavBar The mx.containers.NavBar class has been moved to mx.controls.NavBar. The following table describes changes to the NavBar class: Member Change description click...
  • Page 59 Member Change description The range for this property is now 0 to 1, instead of 0 to modalTransparency 100. panelAlpha borderAlpha panelBorderStyle roundBottomCorners Removed. Use the style. statusStyleDeclaration statusStyleName This property is now protected. statusTestField Removed. Use the style. titleStyleDeclaration titleStyleName This property is now protected.
  • Page 60 Member Change description Parameter renamed from getTabAt index tabSkin tabStyleName mx.containers.Tile The following table describes changes to the Tile class: Member Change description marginBottom paddingBottom marginTop paddingTop mx.containers.TitleWindow The following table describes changes to the TitleWindow class: Member Change description closeButton showCloseButton In Flex 1.x, clicking on the close button (and only the close button) generated a...
  • Page 61: Controls

    mx.containers.ViewStack The following table describes changes to the ViewStack class: Member Change description Child indices The type of the child indices in the ViewStack container has been changed from uint to int. cachePolicy The ViewStack container no longer overrides the property.
  • Page 62 Member Change description show() method now has the following signature: show() show(text:String, title:String=null, flags:uint=0x4, parent:Sprite=null, closeHandler:Function=null, iconClass:Class=null,defaultButtonFlag:uint=0x4):A lert Removed. Use the style. titleStyleDeclaration titleStyleName mx.controls.alertclasses.* The alertclasses package is now named alertClasses. mx.controls.Button The Button class no longer inherits from SimpleButton. The following table describes changes to the Button class: Member Change description...
  • Page 63 Member Change description trueUpSkin selectedUpSkin Removed. version mx.controls.ButtonBar The following table describes changes to the ButtonBar class: Member Change description click itemClick mx.controls.ButtonBarButton The ButtonBarButton class has been made internal only. mx.controls.CalendarLayout The following table describes changes to the CalendarLayout class: Member Change description background...
  • Page 64 Member Change description This property is now internal only. upYearButton This property is now internal only. upYearHit weekDayStyleDeclaration weekDayStyleName This property is now internal only. yearDisplay mx.controls.ColorPicker The following table describes changes to the ColorPicker class: Member Change description closeEasing closeEasingFunction marginBottom paddingBottom...
  • Page 65 mx.controls.ComboBox The following table describes changes to the ComboBox class: Member Change description alternatingRowColors alternatingItemColors cellRenderer itemRenderer dataChanged dataChange textDisabledColor disabledColor itemSkin itemRenderer openEasing openEasingFunction selectionEasing selectionEasingFunction mx.controls.DataGrid The DataGrid class now extends the new GridBase class, which extends the ListBase class. The following table describes changes to the DataGrid class: Member Change description...
  • Page 66 Member Change description headerColor headerColors headerStyle headerStyleName hGridLineColors horizontalGridLineColors hGridLines horizontalGridLines hPosition horizontalScrollPosition minColWidth minColumnWidth Removed. removeAllColumns() Removed. removeColumnAt() Removed. setColumnIndex vGridLineColors verticalGridLineColors vGridLines verticalGridLines In Flex 2, when a DataGrid control’s width is not wide enough to show all columns, only the first column gets smaller.
  • Page 67 mx.controls.dataGridClasses.DataGridListData The following table describes changes to the DataGridListData class: Member Change description columnName dataField mx.controls.DateChooser The following table describes changes to the DateChooser class: Member Change description This property is now internal only. background This property is now internal only. backMonthButton This property is now internal only.
  • Page 68 Member Change description weekDayStyleDeclaration weekDayStyleName This property is now internal only. yearDisplay mx.controls.DateField The following table describes changes to the DateField class: Member Change description dataChanged dataChange formattingFunction labelFunction headerStyleDeclaration headerStyleName Removed. Replaced with the headerColor dateChooserStyleName property. Deprecated. Replaced with the headerColors dateChooserStyleName property.
  • Page 69 mx.controls.HRule The following table describes changes to the HRule class: Member Change description color strokeColor mx.controls.HSlider The following table describes changes to the HSlider class: Member Change description Removed. Use the style instead. labelStyleDeclaration labelStyleName Removed. Instead of setting it to to turn off tick showTicks false...
  • Page 70 mx.controls.List The following table describes changes made to the List class: Member Change description cellBeginEdit itemEditBegin cellEditor itemEditorInstance cellEndEdit itemEditEnd cellFocusIn itemFocusIn cellFocusOut itemFocusOut cellRequestEdit itemEditBeginning editedCell editedItemRenderer focusedCell editedItemPosition DataProvider APIs are no longer on the list-based classes. getItemAt() Instead of myList.getItemAt(index), you use myList.dataProvider.getItemAt(index).
  • Page 71 mx.controls.listclasses.ListBase The following table describes changes to the ListBase class: Member Change description activeTabStyleDeclaration SelectedTabStyleName alternatingRowColors alternatingItemColors This property is now internal. cachedPaddingBottom This property is now internal. cachedPaddingTop This property is now internal. cachedVerticalAlign calculateHeight measureHeightOfItems calculateWidth measureWidthOfItems cellRenderer itemRenderer This method is now internal.
  • Page 72 mx.controls.listClasses.ListCellRenderer The ListCellRenderer class is now named ListItemRenderer. The following table describes changes to the ListItemRenderer class: Member Change description dataChanged dataChange mx.controls.listClasses.TileListItemRenderer The following table describes changes to the TileListItemRenderer class: Member Change description dataChanged dataChange mx.controls.Loader The mx.controls.Loader class name has changed to mx.controls.SWFLoader. The following table describes changes to the Loader class: Member Change description...
  • Page 73 mx.controls.Menu The following table describes changes to the Menu class: Member Change description alternatingRowColors alternatingItemColors cellRenderer listItemRenderer change itemClick Removed. defaultIcon Removed. getMenuItemAt() This property is now internal. menuData menuItemRollOut itemRollOut menuItemRollOver itemRollOver popupDuration openDuration setMenuItemSelected() This method has been made protected. rootVisible showRoot textDisabledColor...
  • Page 74 mx.controls.menuclasses.* The menuclasses package has been renamed menuClasses. mx.controls.menuclasses.IMenuDataDescriptor The following table describes changes to the IMenuDataDescriptor class: Member Change description isSelected() isToggled() setSelected() setToggled() mx.controls.menuclasses.MenuCellRenderer The MenuCellRenderer class is now named MenuItemRenderer. The following table describes changes to the MenuItemRenderer class: Member Change description dataChanged...
  • Page 75 Member Change description popUpObject popUp popUpOnMainButton openAlways mx.controls.PopUpMenuButton The following table describes changes to the PopUpMenuButton class: Member Change description change itemClick menuItemRollOut itemRollOut menuItemRollOver itemRollOver popUpObject popUp mx.controls.RadioButton The following table describes changes to the RadioButton class: Member Change description data value mx.controls.RadioButtonGroup...
  • Page 76 mx.controls.richtexteditorclasses.* The richtexteditorclasses package is now named richTextEditorClasses. mx.controls.scrollClasses.ScrollBar The following table describes changes to the ScrollBar class: Member Change description maxPos maxScrollPosition minPos minScrollPosition thumbDisabledSkin Removed. mx.controls.SimpleButton The SimpleButton class has been removed. mx.controls.Slider The thumb labels, which were known as ToolTips on the Slider, HSlider, and VSlider controls, are now known as data tips on those controls.
  • Page 77 Member Change description snapToTicks snapInterval thumbDragged thumbDrag thumbPressed thumbPress thumbReleased thumbRelease Removed. Use thumb skins to create custom thumbs. thumbWidth tickFrequency tickInterval tickHeight tickLength tickSpacing tickOffset toolTipFormatFunction dataTipFormatFunction toolTipOffset dataTipOffset toolTipPlacement dataTipPlacement toolTipPrecision dataTipPrecision toolTipStyleDeclaration Removed. Use the style. toolTipStyleName toolTipStyleName dataTipStyleName trackHighlight...
  • Page 78 Member Change description maxHPosition maxHorizontalScrollPosition password displayAsPassword Removed. underlineLink vPosition verticalSrollPosition vScrollPolicy verticalScrollPolicy mx.controls.textclasses.* The textclasses package has been renamed textClasses. mx.controls.TextInput The following table describes changes to the TextInput class: Member Change description dataChanged dataChange dropShadow dropShadowEnabled hPosition horizontalScrollPosition maxHPosition maxHorizontalScrollPosition password...
  • Page 79 Flex 1.x: <mx:TileList id="myTile" dataProvider="{dataObject}" cellRenderer="ProdtThumbnail" itemWidth="120" itemHeight="116"> Flex 2: <mx:TileList id="myTile" dataProvider="{dataObject}" listItemRenderer="ProdThumbnail" columnWidth="120" rowHeight="116"> mx.controls.ToolTip The following table describes changes to the ToolTip class: Member Change description dropShadow dropShadowEnabled mx.controls.Tree The following table describes changes to the Tree class: Member Change description This method is now internal.
  • Page 80 mx.controls.treeclasses.* The treeclasses package is now named treeClasses. mx.controls.treeclasses.DefaultDataDescriptor The following table describes changes to the DefaultDataDescriptor class: Member Change description Supports nodes in E4X XML, but not XMLNode objects or isBranch() data that is serialized into ActionScript objects. isSelected() isToggled() setSelected() setToggled()
  • Page 81: Effects

    Member Change description Removed. Instead of setting it to to turn off tick showTicks false marks, you set to 0; for example: tickInterval <mx:HSlider id="hs1" snapInterval="1" tickInterval="0"/> Removed. Use the style. toolTipStyleDeclaration toolTipStyleName Effects The “instance” classes (such as mx.effects.RotateInstance and mx.effects.ResizeInstance) have been moved to the mx.effects.effectClasses package.
  • Page 82 mx.effects.EffectInstance The following table describes changes to the EffectInstance class: Member Change description repeat repeatCount stopRepeat This property is now internal. mx.effects.MaskEffect The following table describes changes to the MaskEffect class: Member Change description moveEasing moveEasingFunction scaleEasing scaleEasingFunction These changes also apply to the MaskEffectInstance class. mx.effects.Resize The following table describes changes to the Resize class: Member...
  • Page 83 mx.effects.SoundEffect The following table describes changes to the SoundEffect class: Member Change description panEasing panEasingFunction soundHolder Renamed to the property. This property is now read- sound write. volumeEasing volumeEasingFunction These changes also apply to the SoundEffectInstance class. mx.effects.Tween The following table describes changes to the Tween class: Member Change description easing...
  • Page 84: Events

    Events All events in the mx.collections package were moved to the mx.events package. In addition to the changes listed here, the events architecture has changed. For more information, see Chapter 6, “Events,” on page 111. mx.events.ChildExistenceChangedEvent The following table describes changes to the ChildExistenceChangedEvent class: Member Change description CHILD_ADDED...
  • Page 85 mx.events.DataGridEvent The following table describes changes to the DataGridEvent class: Member Change description cell itemRenderer CELL_BEGIN_EDIT ITEM_EDIT_BEGIN CELL_END_EDIT ITEM_EDIT_END CELL_FOCUS_IN ITEM_FOCUS_IN CELL_FOCUS_OUT ITEM_FOCUS_OUT CELL_REQUEST_EDIT ITEM_EDIT_BEGINNING Removed. CELL_PRESS cellRenderer itemRenderer columnName dataField itemIndex rowIndex itemSkin itemRenderer view Removed. Use instead. target mx.events.DateChooserEvent The following table describes changes to the DateChooserEvent class: Member...
  • Page 86 mx.events.DropdownEvent The following table describes changes to the DropdownEvent class: Member Change description inputType triggerEvent mx.events.EventDispatcher This class has been moved to flash.events.EventDispatcher and is no longer used as a mixin. mx.events.FlexEvent The following table describes changes to the FlexEvent class: Member Change description DATA_CHANGED...
  • Page 87 mx.events.ListEvent The following table describes changes to the ListEvent class: Member Change description cell itemRenderer CELL_BEGIN_EDIT ITEM_EDIT_BEGIN CELL_END_EDIT ITEM_EDIT_END CELL_FOCUS_IN ITEM_FOCUS_IN CELL_FOCUS_OUT ITEM_FOCUS_OUT CELL_REQUEST_EDIT ITEM_EDIT_BEGINNING cellRenderer itemRenderer itemIndex rowIndex itemSkin itemRenderer mx.events.ListItemSelectEvent The following table describes changes to the ListItemSelectEvent class: Member Change description cellRenderer...
  • Page 88 Member Change description menuItemRollOut itemRollOut menuItemRollOver itemRollOver mx.events.MouseEvent The MouseEvent class is now called FlexMouseEvent. Do not confuse this with the flash.events.MouseEvent class, which still exists. The following table describes changes to the mx.events.MouseEvent class: Member Change description MOUSE_SCROLL_OUTSIDE MOUSE_WHEEL_OUTSIDE mx.utils.events.ObjectEvent The ObjectEvent class is now named and is moved to mx.events.PropertyChangeEvent.
  • Page 89: Formatters

    Member Change description SHOW_TOOL_TIP TOOL_TIP_SHOW SHOWN_TOOL_TIP TOOL_TIP_SHOWN START_TOOL_TIP TOOL_TIP_START mx.events.TreeEvent The following table describes changes to the TreeEvent class: Member Change description Removed. CELL_PRESS cellRenderer itemRenderer inputType triggerEvent itemSkin itemRenderer mx.events.UIEventDispatcher This class has been removed. Formatters This section describes changes to formatters. mx.formatters.DateFormater The DateFormatter pattern string can contain other text in addition to pattern letters.
  • Page 90: Interfaces

    The following table describes the changes to the NumberBase class: Member Change description dSymbolFrom decimalSeparatorFrom dSymbolTo decimalSymbolTo tSymbolFrom thousandsSeparatorFrom tSymbolTo thousandsSeparatorTo mx.formatters.SwitchSymbolFormatter The following table describes the changes to the SwitchSymbolFormatter class: Member Change description This is now private. isValid This is now private.
  • Page 91: Managers

    Old name New name IFocusManager Removed. Refer to mx.managers.FocusManager instead. IFocusManagerContainer mx.managers.IFocusManagerContainer IHistoryState mx.managers.IHistoryManagerClient IInteractionReplayer mx.automation.IAutomationReplayer ILayoutClient mx.managers.ILayoutManagerClient ILayoutManager mx.managers.LayoutManager IObjectChanged mx.core.IPropertyChangeNotifier IRecorder Removed. IRepeaterContainer Removed. Refer to mx.core.Container instead. IScrollBar Removed. Refer to mx.controls.ScrollBar instead. IStyleable mx.styles.ISimpleStyleClient IStyleClient mx.styles.IStyleClient ISystemManager The framework refers to mx.managers.SystemManager instead.
  • Page 92 mx.managers.DragManager Instead of setting event.handled inside the dragEnter event listener, you must call the method. DragManager.acceptDragDrop(event.target) You cannot set the property of the event object. Instead, you must call the action method. For example, change the following code: setFeedback() event.action=DragManager.Link; to the following: DragManager.showFeedback(DragManager.LINK);...
  • Page 93 mx.managers.PopUpManager The following table describes changes to the PopUpManager class: Member Change description The default value of the property is now closeButton closeButton false To enable a close button on your pop-ups, you must explicitly set the value of the property to closeButton true...
  • Page 94: Media Controls

    Media controls This section describes changes to media controls in Flex 2. mx.controls.MediaDisplay The MediaDisplay control has been replaced by the mx.controls.VideoDisplay control. The API is the same, but it does not support MP3 files. mx.controls.MediaController The MediaController control has been removed. Use the VideoDisplay control instead. mx.controls.MediaPlayback The MediaPlayback control has been removed.
  • Page 95: Resources

    mx.print.PrintJobType The following table describes the changes to the PrintJobType class: Member Change description HEIGHT MATCH_HEIGHT WIDTH MATCH_WIDTH Resources This section provides information about changes to classes in the mx.resources package. mx.resource.* The mx.resource package is now named mx.resources. Service tags This section describes changes to Flex classes in the mx.servicetags package.
  • Page 96 mx.servicetags.RemoteObject The RemoteObject class was moved to mx.rpc.remoting.RemoteObject. It now extends the mx.rpc.AbstractService class. The following table describes changes to the RemoteObject class: Member Change description Removed. encoding Was removed. Channels defined in the flex-services.xml endpoint file replace the need for this property. Has been added again to allow clients to use this tag without the configuration file at compile time.
  • Page 97: Skins

    Callback URLs Callback URLs are no longer necessary in Flex 2. Use messaging channels with endpoint mappings instead. Skins This section describes changes to Flex classes in the mx.skins package. For more information, “Using skinning” on page 124. mx.skins.halo.RectBorder This class is now named HaloBorder. mx.skins.halo.PopUpIcon The following table describes changes to the PopUpIcon class: Member...
  • Page 98: States

    States This section provides information about changes to classes in the mx.states package. mx.states.AddChild The following table describes changes to AddChild class: Member Change description This property is now internal. added This property is now internal. instanceCreated target relativeTo mx.states.SetEventHandler The following table describes changes to SetEventHandler class: Member Change description...
  • Page 99: Utilities

    Utilities This section provides information about changes to classes in the mx.utils package. mx.utils.XMLUtil The following table describes changes to XMLUtil class: Member Change description createXML() createXMLDocument() Validators This section provides information about changes to classes in the mx.validator package. mx.validator.Validator The following table describes the changes to the Validator class: Member...
  • Page 100 Flex Classes...
  • Page 101: Chapter 4: Data Providers

    CHAPTER 4 Data Providers This topic describes migrating data providers, including the property of Flex dataProvider controls and the ways you access and manipulate the data represented by the dataProvider property. For detailed information on using data providers in Flex 2, see Chapter 7, “Using Data Providers and Collections,”...
  • Page 102 The following information briefly describes major migration issues: Because the DataProvider interface has been replaced by methods of the collection classes, ■ controls that have dataProvider properties do not include any of the DataProvider interface methods, such as getItemAt(). Instead, you manipulate the control contents by manipulating the object, normally a collection, that acts as the data source.
  • Page 103 The Tree, Menu, MenuBar, and PopUpMenuButton controls, now use a data descriptor ■ class to access and manipulate control-specific information, such as menu item type, that is contained in the data provider. Tree controls require a class that implements the ITreeDataDescriptor interface, and menu-based controls require a class that implements IMenuDataDescriptor interface.
  • Page 104 Data Providers...
  • Page 105: About Binding

    CHAPTER 5 Binding This topic describes the steps required to convert properties in your applications to be usable as the source for a data binding expression in Adobe Flex. For more information binding, see Chapter 5, “Using Metadata Tags in Custom Components,”...
  • Page 106: Binding From A Property

    The <mx:Binding> tag must be a top-level In Flex 1.5, you could place the tag in a Flex container. In Flex 2.0, the <mx:Binding> tag must be a top-level tag in the MXML file. For example: <mx:Binding> Flex 1.x: <mx:HBox> <mx:Label id="myLabel"/>...
  • Page 107 The Flex compiler automatically generates an event named for all public propertyChange properties so the properties can be used as the source of a data binding expression. In this case, specifying the metadata tag with no event is the same as specifying the following: [Bindable] [Bindable(event="propertyChange")] Binding from a single property...
  • Page 108 The following is a Flex 2 example of a getter/setter pair that uses the metadata [Bindable] tag: // Define private variable. private var _maxFontSize:Number = 15; [Bindable(event="maxFontSizeChanged")] // Define public getter method. public function get maxFontSize():Number { return _maxFontSize; // Define public setter method. public function set maxFontSize(value:Number):void { if (value <= 30) { _maxFontSize = value;...
  • Page 109 Dispatching binding events from a custom component To dispatch an event to trigger data binding for a property, the property’s class must either extend EventDispatcher or implement the IEventDispatcher interface. Be sure to update the object that is passed to the method.
  • Page 110: Binding With Arrays

    Binding with Flex component properties You can no longer use all properties of Flex components as the source of a data binding expression without extending those controls. Properties of Flex components that can be used as the source of a data binding expression contain the following description in their entry in the ActionScript 3.0 Language Reference: This property can be used as the source for data binding.
  • Page 111 CHAPTER 6 Events This topic describes changes to the Adobe Flex 2 event model for developers who are migrating Flex applications. Contents About events .............112 Component startup life cycle .
  • Page 112: About Events

    About events The following list is a general overview of the changes to the Event model. Review all event handling in your Flex application by using these guidelines. All event objects are either of type Event or a subclass of Event. You should explicitly ■...
  • Page 113: Migrating The Event Object

    Migrating the Event object This section describes migration issues related to accessing the Event object. Using the Event object The Event object is no longer of type Object. It is now of type flash.events.Event. Specify a stricter type in functions, as follows: private function eventHandler(event:Object):Void { // Flex 1.5 private function eventHandler(event:Event):void { // Flex 2 You should also now cast the...
  • Page 114: Using Static Constants

    If you try to call another method on the target (for example, the method), Flex getStyle() returns an error. The method is a method of UIComponent, a subclass of getStyle() DisplayObject. Therefore, you must cast event.target to UIComponent before calling the method, as the following example shows: getStyle() function myEventListener(e:Event) {...
  • Page 115: Using Function Listeners

    Function, but is now of type Function. If you try to pass an object listener, Flex reports an error. For example, if you had the following: <?xml version="1.0"?> <mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml" creationComplete="createHandler()"> <mx:Script> import mx.core.Alert; function createHandler() { var myListener = new Object();...
  • Page 116: Using The Eventdispatcher Class

    You must also change your code if you created a custom event handler class and defined a method that listened for all events. Flex implicitly registered this method as a handleEvent() handler for all events. Functions named no longer catch all events by default handleEvent() as they did in Flex 1.x.
  • Page 117: Maintaining Scope

    Maintaining scope Previously, you used the mx.utils.Delegate class to provide access to the document scope within an event handler. You would pass the Delegate object into a call to the method so that the listener would execute in that scope. This is no addEventListener() longer necessary.
  • Page 118 Events...
  • Page 119: Using Styles

    CHAPTER 7 Styles and Skinning This topic describes styleable objects; new skinning workflow; and CSS rules. For information about changes to individual classes such as ProgrammaticSkin, see Chapter 3, “Flex Classes,” on page Contents Using styles ............. .119 Using skinning .
  • Page 120 Using the StyleManager When you use the StyleManager to apply styles to entire classes, you must now access the class with the method. For example: getStyleDeclaration() Flex 1.x: StyleManager.styles.Button.setStyle("color","red"); Flex 2: StyleManager.getStyleDeclaration("Button").setStyle("color","red"); You can no longer set or get styles as properties of a component or class. You now use .
  • Page 121 Changed style properties The following table shows changes to the CSS style property names: Flex 1.x Name Flex 2 Name drop-shadow drop-shadow-enabled margin-bottom padding-bottom margin-left padding-left margin-right padding-right margin-top padding-top tool-tip-offset data-tip-offset tool-tip-precision data-tip-precision tool-tip-placement data-tip-placement track-highlight show-track-highlight Missing style properties If you applied a style property to a component that did not support that style property, Flex would fail silently.
  • Page 122 The following are the valid color value formats in CSS: .b1 { color: red; } .b2 { color: #66CC66; } .b3 { color: rgb(22%,22%,77%); } .b4 { color: rgb(255,0,0); } .b5 { color: "0xFFFF00"; } The following are the invalid color value formats in CSS: .b6 { color: 0xFFFF00;...
  • Page 123 For example: <mx:Style> // The following class selector fails in Flex 2 if // there is no associated class: myClass { color: red; // The following class selector works fine in Flex 2: .myOtherClass { color: red; </mx:Style> You must include the period when you use the method.
  • Page 124: Using Skinning

    Using units Flex no longer supports using the plus (+) and minus (-) unit modifiers. Flex no longer supports the em and ex unit types. Using skinning Previously, you defined graphical skins as symbols in a FLA file, exported the FLA file as a SWC file from the Flash IDE, and added it to your Flex source path.
  • Page 125 Skinning assets The assets that Flex includes for you to use as a basis for reskinning components are changed. Flex 1.x included: Flex 2 includes: • Sample programmatic skins in the • HaloClassic skins for users who want the flex_install_dir/resources/themes/ original look and feel of Flex applications.
  • Page 126: Using Embedded Fonts

    <manager-class>flash.fonts.BatikFontManager</manager-class> </managers> </fonts> The class names of the font managers are changed from macromedia.* to flash.*. Syntactically, you must now specify the font face in the selector or you receive a warning similar to the following: “An embedded font was found for family 'myFont' but it did not have the requested plain font face.”...
  • Page 127: Themes

    In Flex 1.5, you could use the following syntax to embed a bold italic font face: @font-face { src: url("GOTHICBI.TTF"); font-style: italic; font-weight: bold; font-family: myFont; .myStyleBoldItalic { font-family: myFont; In Flex 2, you still use the rule to embed the font: @font-face @font-face { src:url("GOTHICBI.TTF");...
  • Page 128 Styles and Skinning...
  • Page 129 CHAPTER 8 Behaviors This topic describes the new architecture for behaviors in Macromedia Flex and syntax changes from Flex 1.5. For detailed information, see Chapter 17, “Using Behaviors,” in the Flex 2 Developer’s Guide and Chapter 15, “Creating Effects,” in Creating and Extending Flex Components.
  • Page 130 Overview Flex implements effects using an architecture in which each effect is represented by two classes: Creates an object of the instance class to perform the effect on the target. Factory class ■ You create instances of the factory class in your application, and configure it with the necessary properties to control the effect, such as the zoom size or effect duration.
  • Page 131: New Behaviors Syntax

    New Behaviors syntax This section describes the syntax changes to behaviors. The name property is now the id property You now use the property with effects, instead of the property: name Flex 1.5: <mx:Zoom name="small" duration="100"/> Flex 2: <mx:Zoom id="small" duration="100"/> The <mx:Effect>...
  • Page 132 Use binding in MXML to specify the effect In Flex 1.5, you assigned the effect to an effect trigger property with no data binding: <mx:Button id="myButton" creationCompleteEffect="myWL"/> <mx:Button id="myOtherButton" creationCompleteEffect="myWL"/> In Flex 2, you use data binding to assign an effect to a target: <mx:Button id="myButton"...
  • Page 133 Change to the range of several effect properties For the Zoom, Fade and Dissolve effects, the range of the alpha scaleX scaleY , and properties have zoomHeightFrom zoomWidthFrom zoomHeightTo zoomWidthTo changed. You used to set these values as percentages using integer values, where 0 corresponded to 0%, and 100 to 100%.
  • Page 134 New events for effect classes You can now associate event listeners with effects, rather than with effect targets. All effect classes now support the following event types: Dispatched when the effect starts playing. The property of the event effectStart type object for this event is set to EffectEvent.EFFECT_START Dispatched after the effect stops playing, either when the effect finishes playing...
  • Page 135: About Data Services

    CHAPTER 9 Data Services This topic describes how to migrate HTTPService, WebService, and RemoteObject components. Contents About Data Services ........... . . 135 Migrating HTTPService components .
  • Page 136 Flex 2 separates the definitions of services into a new file, services-config.xml. This file contains definitions of the services and security constraints that were previously in the flex- config.xml file. Optionally, it can include other configuration files by reference. The services- config.xml file is located in the flex_deploy_dir/flex/WEB-INF/flex directory of a web application in which you are using Flex Data Services.
  • Page 137 Channels are defined in the section of the services-config.xml file. There are several channels predefined channels that you can assign to your RPC service destinations. For more information about channels, see Chapter 43, “Configuring Data Services,” in the Flex 2 Developer’s Guide.
  • Page 138 The syntax for statefulness has changed. In Flex 1.5, you set the to either type stateless- . In Flex 2, you set the attribute to class stateful-class scope application session . The default was , and is now , which is equivalent to request stateless-class request...
  • Page 139 Named RemoteObject This section describes how to migrate your named RemoteObject tags from Flex 1.5 to Flex 2. Flex 1.5 syntax In Flex 1.5, you used the attribute to identify which named RemoteObject to use. named MXML tag: <mx:RemoteObject id="employeeRO" named="SalaryRO"> <mx:method name="getList"/>...
  • Page 140: Migrating Httpservice Components

    Migrating HTTPService components This section describes how to migrate your HTTPService from Flex 1.5 to Flex 2.0 syntax. For HTTPService tags, you specify the URL of the service in the property of the tag. The following examples shows and HTTPService tag that contacts a service directly: <mx:HTTPService id="yahoo_web_search"...
  • Page 141 Flex 1.5 syntax In Flex 1.5, you added a URL pattern to the whitelist that matched the of the HTTPService tag. MXML tag: <mx:HTTPService id="MyService" url="http://myServer.com/services/my.jsp"/> flex-config.xml file: <http-proxy> <whitelist> <unnamed> <url>http://myServer.com/services/*</url> </unnamed> </whitelist> </http-proxy> Flex 2 syntax In Flex 2, the MXML tag syntax is almost the same, but you must also set the value of the property to .
  • Page 142 Named HTTPService This section describes how to migrate named HTTPService tags from Flex 1.5 to Flex 2 syntax. Flex 1.5 syntax In Flex 1.5, a named HTTPService was defined as a named whitelist entry in the <http- section. You used the attribute of the HTTPService tag to service-proxy>...
  • Page 143: Migrating Webservice Components

    Migrating WebService components The default value of the property is . The WebService tags are now useProxy false configured in the section of the services-config.xml file or a file that it <proxy-service> includes by reference. They were previously described in the section <web-service-proxy>...
  • Page 144 MXML tag: <mx:WebService id="MyService" wsdl="http://myServer.com/services/my.wsdl" useProxy="true"/> services-config.xml file: <destination id="defaultHTTP"> <properties> <wsdl>{context.root}/services/ContactManagerWS?wsdl</wsdl> <soap>{context.root}/services/ContactManagerWS</soap> </properties> <adapter ref="soap-proxy"/> </destination> Named WebService This section describes how to migration your named WebService tags from Flex 1.5 to Flex 2. Flex 1.5 syntax In Flex 1.5, you referred to a named WebService with the attribute of the serviceName tag.
  • Page 145: Migrating Secure Data Services

    Flex 2 syntax In Flex 2, you refer to named WebServices with the attribute of the destination tag. In the configuration file, you define the location of the WSDL file <mx:WebService> and the endpoint as part of the service destination. MXML tag: <mx:WebService id="employeeWS"...
  • Page 146 Flex 1.5 syntax In Flex 1.5, you specified run-as credentials as attributes to pass through user password credentials to a service. flex-config.xml file: <web-service-proxy> <whitelist> <named> <service name="MyService"> <wsdl>http://somewhere.com/webservice.wsdl</wsdl> <endpoint>http://somewhere.com/myservice</endpoint> <run-as user="user1" password="opensaysme"/> </service> </named> </whitelist> </web-service-proxy> Flex 2 syntax In Flex 2, you set the and remote-password elements in the destination remote-username...
  • Page 147 Migrating services that use Basic authentication For Basic authentication, you must change the value of the security constraint’s url-pattern in the web.xml file. This section assumes that you have already migrated the service’s destination, as described in previous sections. Flex 1.5 syntax In Flex 1.5, for WebService and HTTPService, you specified the /flashproxy/service_name as , as the following example shows: url-pattern...
  • Page 148 Flex 2 syntax In Flex 2, you specify the URI of the channel endpoint for which you want to require authentication as the . You use the value of the channel definition’s endpoint url-pattern URI in the services-config.xml file. The boldface text in the following example shows a URI that requires authentication: <web-app>...
  • Page 149 Flex 1.5 syntax In Flex 1.5, you specified the type of authentication and the role in the named service definition in the flex-config.xml file: <named> <object name="myobj"> <use-custom-authentication>true</use-custom-authentication> <roles> <role>sampleusers</role> </roles> </object> </named> Flex 2 syntax In Flex 2, you define the security constraint in the services-config.xml file: <service-config>...
  • Page 150: Mapping Java Types For Remoteobject

    Login commands For custom authentication, Flex uses a custom login adapter, known as a login command, to check a principal’s credentials and let that principal log into the application server. A login command must implement the flex.messaging.security.LoginCommand API. Flex 1.5 and Flex 2 include default login command implementations for Adobe JRun, BEA WebLogic, IBM WebSphere, Apache Tomcat, and Oracle.
  • Page 151 is not available in Flex 2. ActionScript 3 provides the Object.registerClass() flash.net.registerClassAlias. To simplify using this class Flex 2, you can specify a remote class in the metadata tag above the class definition [RemoteClass(alias="remoteclassname")] in your ActionScript class. Flex 1.5 ActionScript class example: class com.Product { public var id:Number;...
  • Page 152: Accessing Request/Response Data With Remoteobject

    Accessing request/response data with RemoteObject A Java object that you call using the tag has access to request, response, <mx:RemoteObject> and servlet data. For Flex 1.5, from within a Java object, you can call the following methods: Method Description Returns the HttpServletRequest object for the flashgateway.Gateway.getHttpRequest() current request.
  • Page 153 CHAPTER 10 Configuration and Command Line Tools The flex-config.xml file has undergone significant changes for Adobe Flex 2. In addition, the mxmlc, compc, and fdb utilities are also changed. This topic describes these changes. Contents Configuration files............154 Security.
  • Page 154: Configuration Files

    Configuration files The Flex server relied on configuration files in the WEB-INF/flex directory. The following table describes changes to those configuration files: Configuration file Flex 1.5 Flex 2 flash-unicode- Lists convenient mappings of the No changes. table.xml Flash MX 2004 UnicodeTable.xml character ranges for use in the Flex configuration file.
  • Page 155: Security

    The following configuration files were renamed since Flex 2 Beta 2: Flex 1.x Name Flex 2 Name flex-enterprise-services.xml, became fds-config.xml services-config.xml flex-data-service.xml, became fds-data-management.xml, data-management-config.xm flex-message-service.xml, became fds-messaging.xml, messaging-config.xml flex-remoting-service.xml, became fds-remoting.xml, remoting-config.xml flex-proxy-service.xml, became fds-proxy.xml, proxy-config.xml Security This section describes changes to Flex security. Flex changes You do not define the security of web services and other data services in the flex-config.xml file.
  • Page 156: Command-Line Compilers

    Command-line compilers The mxmlc and compc compilers are changed for Flex 2. This section describes these changes. mxmlc The mxmlc utility compiles SWF files from your MXML and ActionScript files. The mxmlc options that are no longer available include the following: batch ■...
  • Page 157 Flex 1.x Name Flex 2 Name Comment option no longer 0 (optimize) optimize optimize suppresses method output. You trace() must manually remove the output. report link-report usenetwork use-network In addition, because the data services subsystem changed, mxmlc no longer takes the following options: gatewayurl ■...
  • Page 158: Fdb Debugger

    fdb debugger This section describes changes to the fdb debugger. For more information on using fds, see Chapter 12, “Using the Command-Line Debugger,” in Building and Deploying Flex 2 Applications. SWD files The fdb debugger no longer uses SWD files. Instead, Flex generates debuggable SWF files by using the option with the mxmlc and compc command line compilers.
  • Page 159 run command On Windows, you can enter either , in which case fdb launches Flash Player, or run foo.swf , in which case fdb displays the “Waiting for Player to connect” message; at that point, you must manually launch Flash Player. On the Macintosh, the command is no longer supported;...
  • Page 160 Configuration and Command Line Tools...
  • Page 161: Uiobject Class Removed

    CHAPTER 11 Customizing Components This topic describes modifications to the process of creating components in ActionScript in Adobe Flex. This topic only contains an overview of the major changes to the process from Flex 1.5 to Flex 2.0. For detailed information on creating custom components, see Creating and Extending Flex 2 Components.
  • Page 162: Specifying The Package

    Specifying the package Define your custom components within an ActionScript package. The package reflects the directory location of your component within the directory structure of your application. package myComponents // Class definition goes here. Defining the class The class definition must be prefixed by the keyword, as the following example shows: public // Class definition goes here.
  • Page 163: Overriding A Method

    Overriding a method If the method is overriding a method in a superclass, add the keyword as the first override attribute: override public function createChildren():void If the getter/setter is overriding a getter/setter in a superclass, add the keyword as override the first attribute: override public function get label():String override public function set label(value:String):void...
  • Page 164 Customizing Components...
  • Page 165: Historymanager

    CHAPTER 12 Additional Migration Issues This topic describes miscellaneous migration issues, including charting and Runtime Shared Libraries (RSLs). Contents HistoryManager ............165 Charting .
  • Page 166 Skins Skins are now called renderers. For example, the CandlestickSkin class is now CandlestickRenderer. Renderers Some functionality for the AxisRenderer was moved to other axis objects. property, which was a property of AxisRenderer, is now a property of the labelFunction axis type (such as CategoryAxis).
  • Page 167 In Flex 2, you set the value of the series’ property to a skin class that draws the itemRenderer ChartItem’s icon: <mx:PlotSeries itemRenderer="mx.charts.skins.halo.CrossSkin"/> In addition, you can no longer use the AssetRenderer to use graphics in your charts. Instead, you must use a class that implements the IDataObject interface. Binding In many cases, you declare a data provider object and bind the chart to that data provider.
  • Page 168 Legends You now enclose the data provider for Legend controls in curley braces; for example: Flex 1.x: <mx:LineChart id="linechart"> </mx:LineChart> <mx:Legend dataProvider="linechart"/> Flex 2: <mx:LineChart id="linechart"> </mx:LineChart> <mx:Legend dataProvider="{linechart}"/> Interfaces All chart interfaces now follow the I* naming scheme, as the following table shows: Flex 1.x Name Flex 2 Name BoxRenderer...
  • Page 169: Cell Renderers

    Cell renderers In Flex 1.5, a cell renderer had to implement the method to access the data setValue() passed to the cell renderer: <mx:VBox xmlns:mx="http://www.adobe.com/2003/mxml" width="198" backgroundAlpha="0"> <mx:Script> function setValue(str:String, item:Object) { // Set values of the cell renderer controls. </mx:Script>...
  • Page 170: Validators

    Validators In Flex 1.5, validators were usually triggered in response to an update of the destination of a data binding expression. You typically assigned the validator to the destination of a data binding expression, and triggered the validation when the destination of the data binding expression was updated, as the following example shows: <!-- Define a data model for storing the phone number.
  • Page 171 In ActionScript, you can use the following constants: ■ CreditCardValidatorCardType.AMERICAN_EXPRESS CreditCardValidatorCardType.DINERS_CLUB ■ ■ CreditCardValidatorCardType.DISCOVER ■ CreditCardValidatorCardType.MASTERCARD CreditCardValidatorCardType.VISA ■ Deprecated methods, properties, and events The following validator methods, properties, and events were deprecated: Deprecated item New item property Validator.enable() Validator.enabled methods Validator.disable() method Validator.isValid()
  • Page 172: Embedding Resources

    Embedding resources In Flex 1.5, embedded resources were bound to Strings that were used to reference the individual images by name. Although the preferred method of embedding resources in Flex 2 uses Class variables, you can still use String variables for some level of backward compatibility. However, the various objects and tags that use your embedded assets expect them to be tied to Class variables, so you need to use the method to cast your string...
  • Page 173 CHAPTER 13 Migration Patterns This topic describes some common patterns in migrating ActionScript in Adobe Flex applications. Contents Instantiating Flex controls..........174 Using mixins.
  • Page 174: Instantiating Flex Controls

    Instantiating Flex controls In Flex 1.x, you created a Flex control in ActionScript by first including a reference to that control, and then using the createEmptyObject() createChild() createChildren() , or method. createChildAtDepth() createClassChildAtDepth() These methods were removed. In Flex 2, you use the operator to create child controls and attach the control to a container with the method.
  • Page 175: Using Mixins

    Using mixins You can no longer attach a function to a class, unless that class has prior knowledge of that function. For example, you can no longer do this: UIComponent.prototype.doSomething = myFunction or this: dataGridInstance.doSomething = myFunction You can still declare a Function type property on an Object and then supply an implementation of that function later.
  • Page 176: Variable Enumeration And Object Introspection

    Variable enumeration and object introspection In Flex 1.x (ActionScript 2.0), using a loop on an object let you enumerate over all for-in properties on an object. In Flex 2 (which uses ActionScript 3.0), only dynamically added properties are enumerated by loops.
  • Page 177 // List accessors as properties: for each (var a:XML in classInfo..accessor) { ta1.text += "Property " + a.@name + "=" + button1[a.@name] + " (" + a.@type +")\n"; // List the object's methods: for each (var m:XML in classInfo..method) { ta1.text += "Method "...
  • Page 178: Using The Drag-And-Drop Feature

    Using the drag-and-drop feature When you convert drag-and-drop code, be aware of the following changes: method takes an additional required attribute, . This ■ doDrag() mouse_event attribute is the MouseEvent object that contains the mouse information for the start of the drag.
  • Page 179 Flex 2: <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"> <mx:Script><![CDATA[ import mx.managers.DragManager; // Import events package for MouseEvent: import mx.events.*; // Specify types for all arguments: function dragIt(event:MouseEvent, text:String, format:String) { var ds:mx.core.DragSource = new mx.core.DragSource(); ds.addData(text, format); // New doDrag signature: DragManager.doDrag(event.target, ds, event); function doDragEnter(event:DragEvent) { if (event.dragSource.hasFormat('color')) { /? For a drop target to accept an item for dropping, it calls the...
  • Page 180 Other issues In addition to the changes shown here, you might also encounter the issues described in this section when you convert drag-and-drop code. Accessing event targets Because a TextArea control uses a Flash TextField control, and mouse events are dispatched by Flash Player, not Flex, you must use the property instead of the currentTarget...
  • Page 181 Controlling the feedback indicator To control the feedback indicator that accompanies a drag proxy, you now use the new methods of the DragManager class. The indicator showFeedback() getFeedback() shows what happens if you try to drop the item; for example, a red circle with a white x represents an aborted drop, or a green circle with a white plus (+) indicates a valid drop.
  • Page 182: Using Timer

    Using Timer methods were deprecated in favor of the Timer setInterval() clearInterval() class. You can still use these methods; they are in the flash.util package. When you use Timers, keep the following in mind: When a Timer is first created with the new operator, it is stopped; you must use the ■...
  • Page 183: Using The Preloader

    Using the Preloader The Application container supports an application preloader that uses a download progress bar to show the download progress of an application SWF file. By default, the application preloader is enabled. The preloader keeps track of how many bytes are downloaded and continually updates the progress bar.
  • Page 184 In Flex 2, you must use the property to get the Application.application.parameters values of these variables. The property is an Object, which is a dynamic class that parameters you can use to store name and value pairs pass in as variables.

This manual is also suitable for:

Flex 2

Table of Contents