// Copyright 2007. Adobe Systems Incorporated. All Rights Reserved. package fl.events { import flash.events.Event; /** * The DataChangeEvent class defines the event that is dispatched when the data * that is associated with a component changes. This event is used by the List, * DataGrid, TileList, and ComboBox components. * *

This class provides the following event:

* * * @includeExample examples/DataChangeEventExample.as * * @see DataChangeType * * @langversion 3.0 * @playerversion Flash 9.0.28.0 */ public class DataChangeEvent extends Event { /** * Defines the value of the type property of a dataChange * event object. * *

This event has the following properties:

* * * * * * * * * * *
PropertyValue
bubblesfalse
cancelablefalse; there is no default behavior to cancel.
changeTypeIdentifies the type of change that was made.
currentTargetThe object that is actively processing * the event object with an event listener.
endIndexIdentifies the index of the last changed item.
itemsAn array that lists the items that were changed.
startIndexIdentifies the index of the first changed item.
targetThe object that dispatched the event. The target is * not always the object listening for the event. Use the currentTarget * property to access the object that is listening for the event.
* * @eventType dataChange * * @see #PRE_DATA_CHANGE * * @langversion 3.0 * @playerversion Flash 9.0.28.0 */ public static const DATA_CHANGE:String = "dataChange"; /** * Defines the value of the type property of a preDataChange * event object. This event object is dispatched before a change is made to component data. * *

This event has the following properties:

* * * * * * * * * * *
PropertyValue
bubblesfalse
cancelablefalse; there is no default behavior to cancel.
changeTypeIdentifies the type of change to be made.
currentTargetThe object that is actively processing * the event object with an event listener.
endIndexIdentifies the index of the last item to be * changed.
itemsAn array that lists the items to be changed.
startIndexIdentifies the index of the first item to be * changed.
targetThe object that dispatched the event. The target is * not always the object listening for the event. Use the currentTarget * property to access the object that is listening for the event.
* * @eventType preDataChange * * @see #DATA_CHANGE * * @langversion 3.0 * @playerversion Flash 9.0.28.0 */ public static const PRE_DATA_CHANGE:String = "preDataChange"; /** * @private (protected) * * @langversion 3.0 * @playerversion Flash 9.0.28.0 */ protected var _startIndex:uint; /** * @private (protected) * * @langversion 3.0 * @playerversion Flash 9.0.28.0 */ protected var _endIndex:uint; /** * @private (protected) * * @langversion 3.0 * @playerversion Flash 9.0.28.0 */ protected var _changeType:String; /** * @private (protected) * * @langversion 3.0 * @playerversion Flash 9.0.28.0 */ protected var _items:Array; /** * Creates a new DataChangeEvent object with the specified parameters. * * @param eventType The type of change event. * * @param changeType The type of change that was made. The DataChangeType class defines the possible values for * this parameter. * * @param items A list of items that were changed. * * @param startIndex The index of the first item that was changed. * * @param endIndex The index of the last item that was changed. * * @langversion 3.0 * @playerversion Flash 9.0.28.0 */ public function DataChangeEvent(eventType:String, changeType:String, items:Array,startIndex:int=-1, endIndex:int=-1):void { super(eventType); _changeType = changeType; _startIndex = startIndex; _items = items; _endIndex = (endIndex == -1) ? _startIndex : endIndex; } /** * Gets the type of the change that triggered the event. The DataChangeType class * defines the possible values for this property. * * @see DataChangeType * * @langversion 3.0 * @playerversion Flash 9.0.28.0 */ public function get changeType():String { return _changeType; } /** * Gets an array that contains the changed items. * * @langversion 3.0 * @playerversion Flash 9.0.28.0 */ public function get items():Array { return _items; } /** * Gets the index of the first changed item in the array of items * that were changed. * * @see #endIndex * * @langversion 3.0 * @playerversion Flash 9.0.28.0 * */ public function get startIndex():uint { return _startIndex; } /** * Gets the index of the last changed item in the array of items * that were changed. * * @see #startIndex * * @langversion 3.0 * @playerversion Flash 9.0.28.0 */ public function get endIndex():uint { return _endIndex; } /** * Returns a string that contains all the properties of the DataChangeEvent object. The * string is in the following format: * *

[DataChangeEvent type=value changeType=value * startIndex=value endIndex=value * bubbles=value cancelable=value]

* * @return A string that contains all the properties of the DataChangeEvent object. * * @langversion 3.0 * @playerversion Flash 9.0.28.0 */ override public function toString():String { return formatToString("DataChangeEvent", "type", "changeType", "startIndex", "endIndex", "bubbles", "cancelable"); } /** * Creates a copy of the DataEvent object and sets the value of each parameter to match * that of the original. * * @return A new DataChangeEvent object with property values that match those of the * original. * * @langversion 3.0 * @playerversion Flash 9.0.28.0 */ override public function clone():Event { return new DataChangeEvent(type, _changeType, _items, _startIndex, _endIndex); } } }