ActionScript 2.0 Components Language Reference |
|
|
|
| DataProvider API > DataProvider.modelChanged | |||
Flash Player 6 (6.0.79.0).
Flash MX Professional 2004.
listenerObject= new Object();listenerObject.modelChanged = function(eventObject){ //Insert your code here. } myMenu.addEventListener("modelChanged",listenerObject)
Event; broadcast to all of its view listeners whenever the data provider is modified. You typically add a listener to a model by assigning its dataProvider property.
Components use a dispatcher/listener event model. When a data provider changes in some way, it broadcasts a modelChanged event, and data-aware components catch it to update their displays to reflect the changes in data.
The Menu.modelChanged event's event object has five additional properties:
eventName The eventName property is used to subcategorize modelChanged events. Data-aware components use this information to avoid completely refreshing the component instance (view) that is using the data provider. The eventName property supports the following values:
updateAll The entire view needs refreshing, excluding scroll position.addItems A series of items has been added.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 provider needs refreshing.filterModel The model has been filtered, and the view needs refreshing (reset the scroll position).schemaLoaded The field's definition of the data provider has been declared.firstItem The index of the first affected item.lastItem The index of the last affected item. The value equals firstItem if only one item is affected.removedIDs An array of the item identifiers that were removed.fieldName A string indicating the name of the field that is affected.For more information, see EventDispatcher class.
In the following example, a handler called listener is defined and passed to addEventListener() as the second parameter. The event object is captured by the modelChanged handler in the evt parameter. When the modelChanged event is broadcast, a trace statement is sent to the Output panel.
listener = new Object();
listener.modelChanged = function(evt){
trace(evt.eventName);
}
myList.addEventListener("modelChanged", listener);
|
|
|
|