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

Migrating applications to flex 2
Table of Contents

Advertisement

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. You can use
the methods on the
For example, you can no longer use the following line:
myList.getItemAt(index).
Instead, use the following line:
myList.dataProvider.getItemAt(index)
In this case, the dataProvider property must specify a collection object that represents the
data.
Do not use raw Arrays or Objects in your dataProvider property if the data provider's
values change. The control that displays the data will not get updated when the
underlying data changes. Instead, convert your provider to an ArrayCollection class, as in
the following example:
<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" >
<mx:Script>
import mx.collections.*;
public var myArray:Array = ["MA", "ME", "MI", "MN","MO", "MS",
"MT"];
public var myICV:ICollectionView = new ArrayCollection(myArray);
</mx:Script>
<mx:ComboBox id="myCB0" dataProvider="{myICV}" />
</mx:Application>
If you use the DataProvider class directly in an existing application, replace it with the
ArrayCollection or XMLListCollection class. These classes are not one-for-one equivalents
to the old DataProvider class. They do not include the editField, getEditingData,
getItemID, replaceItemAt, sortItems and sortItemsBy methods. If you use any of these
methods, you must different techniques. For sorting, use the Sort class and the sort
property of the ICollectionView interface.
The Flex 1.5 Array class implemented the DataProvider interface methods, such as
replaceItemAt() and sortItems(). In Flex 2, there is no separate Flex Array class, only the
Flash Array class, which does not implement such methods. If you used the Array class
and its DataProvider methods, convert the Array to an ArrayCollection and use IList and
ICollectionView interface methods.
102
Data Providers
property or on the collection object directly.
dataProvider

Advertisement

Table of Contents
loading

This manual is also suitable for:

Flex 2

Table of Contents