MACROMEDIA FLEX 2-MIGRATING APPLICATIONS TO FLEX 2 Manual do Utilizador Página 102

  • Descarregar
  • Adicionar aos meus manuais
  • Imprimir
  • Página
    / 184
  • Índice
  • MARCADORES
  • Avaliado. / 5. Com base em avaliações de clientes
Vista de página 101
102 Data Providers
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
dataProvider property or on the collection object directly.
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.
Vista de página 101
1 2 ... 97 98 99 100 101 102 103 104 105 106 107 ... 183 184

Comentários a estes Manuais

Sem comentários