flex中UIComponent代码研究解析

今天看了下UIComponent.as觉得不错.把我看的稍微做个总结(部分):

1./**

* Dispatched when the component is added to a container as a content child

* by using the <code>addChild()</code> or <code>addChildAt()</code> method.

* If the component is added to the container as a noncontent child by

* using the <code>rawChildren.addChild()</code> or

* <code>rawChildren.addChildAt()</code> method, the event is not dispatched.

*

* @eventType mx.events.FlexEvent.ADD

*/

[Event(name="add", type="mx.events.FlexEvent")]

当一个组件被做为一个内容孩子通过使用addChild或addChildAt方法加到一个容器时,发送事件(名为:add).

如果一个非内容孩子组件通过使用rawChildren.addChild()方法加到一个容器里.add事件是不会被发送的.

2./**

* Dispatched when the component has finished its construction,

* property processing, measuring, layout, and drawing.

*

* <p>At this point, depending on its <code>visible</code> property,

* the component may not be visible even though it has been drawn.</p>

*

* @eventType mx.events.FlexEvent.CREATION_COMPLETE

*/

[Event(name="creationComplete", type="mx.events.FlexEvent")]

当一个组件完成了它的构造,属性的处理,测量,布局以及绘画时,这个名为creationComplete事件被发送.

按这点来说.它取决于它的可见属性,这个组件有可能是不可见的甚至它已经被画好了.

3./**

* Dispatched when an object has had its <code>commitProperties()</code>,

* <code>measure()</code>, and

* <code>updateDisplayList()</code> methods called (if needed).

*

* <p>This is the last opportunity to alter the component before it is

* displayed. All properties have been committed and the component has

* been measured and layed out.</p>

*

* @eventType mx.events.FlexEvent.UPDATE_COMPLETE

*/

[Event(name="updateComplete", type="flash.events.Event")]

当一个对象已经调用了它的commitProperties(),measure(),updateDisplayList()方法时,它将发 送名为updateComplete这个事件,它将这个是最后的机会去改变组件在它被显示之前.所有的属性都已经被提交并且该组件也已经被测量和布局了.

4./**

* Dispatched when an object’s state changes from visible to invisible.

*

* @eventType mx.events.FlexEvent.HIDE

*/

[Event(name="hide", type="mx.events.FlexEvent")]

当一个对象的状态改变从可视到不可视时,发送一个名为hide的事件

5./**

* Dispatched when the component has finished its construction

* and has all initialization properties set.

*

* <p>After the initialization phase, properties are processed, the component

* is measured, laid out, and drawn, after which the

* <code>creationComplete</code> event is dispatched.</p>

*

* @eventType mx.events.FlexEvent.INITIALIZE

*/

[Event(name="initialize", type="mx.events.FlexEvent")]

当一个组件已经被构造了,并且设置了所有初始化属性时.发送名为initialize事件.在初始化阶段后,属性被处理,组件被测量,布局,被画,在这些后,名为creationComplete的事件被发送.

6.**

* Dispatched when the object has moved.

*

* <p>You can move the component by setting the <code>x</code>

* or <code>y</code> properties, by calling the <code>move()</code>

* method, by setting one

* of the following properties either on the component or on other

* components such that the LayoutManager needs to change the

* <code>x</code> or <code>y</code> properties of the component:</p>

*

* <ul>

*    <li><code>minWidth</code></li>

*    <li><code>minHeight</code></li>

*    <li><code>maxWidth</code></li>

*    <li><code>maxHeight</code></li>

*    <li><code>explicitWidth</code></li>

*    <li><code>explicitHeight</code></li>

* </ul>

*

* <p>When you call the <code>move()</code> method, the <code>move</code>

* event is dispatched before the method returns.

* In all other situations, the <code>move</code> event is not dispatched

* until after the property changes.</p>

*

* @eventType mx.events.MoveEvent.MOVE

*/

[Event(name="move", type="mx.events.MoveEvent")]

发送名为move的事件,当对象被移动时.你可以移动组件通过设置属性X或Y,通过调用move()方法,通过在组件或其他组件上设置以下属性就像布局管理器需要改变组件的X或Y属性.

当你调用move()方法时,在这个方法返回前move事件会被调用.在其他所有的形式里,move事件不会被发送直到属性改变了.

1./**

* Dispatched at the beginning of the component initialization sequence.

* The component is in a very raw state when this event is dispatched.

* Many components, such as the Button control, create internal child

* components to implement functionality; for example, the Button control

* creates an internal UITextField component to represent its label text.

* When Flex dispatches the <code>preinitialize</code> event,

* the children, including the internal children, of a component

* have not yet been created.

*

* @eventType mx.events.FlexEvent.PREINITIALIZE

*/

[Event(name="preinitialize", type="mx.events.FlexEvent")]

在组件的初始化序列开始时发送一个名为preinitialize事件.当事件发送时,组件处于一个未加工的状态.

很多组件,像按钮控件,创建内部的孩子组件去实现功能;举个例子,按钮控件创建了一个内部的UITextField

组件来呈现它的标签内容.当Flex发送preinitialize事件时.组件的孩子,包括内部的孩子都还没有创建呢.

2./**

* Dispatched when the component is removed from a container as a content child

* by using the <code>removeChild()</code> or <code>removeChildAt()</code> method.

* If the component is removed from the container as a noncontent child by

* using the <code>rawChildren.removeChild()</code> or

* <code>rawChildren.removeChildAt()</code> method, the event is not dispatched.

*

* @eventType mx.events.FlexEvent.REMOVE

*/

[Event(name="remove", type="mx.events.FlexEvent")]

当组件做为一个内容孩子从一个容器里被移走时,发送一个名为remove的事件.如果一个组件做为一个非内容孩子从一个容器里通过 rawChildren.removeChild()或rawChildren.removeChildAt()被移走时,这个事件是不会被发送的.

3./**

* Dispatched when the component is resized.

*

* <p>You can resize the component by setting the <code>width</code> or

* <code>height</code> property, by calling the <code>setActualSize()</code>

* method, or by setting one of

* the following properties either on the component or on other components

* such that the LayoutManager needs to change the <code>width</code> or

* <code>height</code> properties of the component:</p>

*

* <ul>

*    <li><code>minWidth</code></li>

*    <li><code>minHeight</code></li>

*    <li><code>maxWidth</code></li>

*    <li><code>maxHeight</code></li>

*    <li><code>explicitWidth</code></li>

*    <li><code>explicitHeight</code></li>

* </ul>

*

* <p>The <code>resize</code> event is not

* dispatched until after the property changes.</p>

*

* @eventType mx.events.ResizeEvent.RESIZE

*/

[Event(name="resize", type="mx.events.ResizeEvent")]

当组件调整大小时发送一个名为resize的事件

你可以调整组件的大小通过设置属性width或height,通过调用setActualSize()方法或通过在任一组件上设置以下属性之一来设置.以上的,LayoutManager需要改变组件的width 或height属性.

resize事件直到这些属性改变后才会被发送.

4./**

* Dispatched when an object’s state changes from invisible to visible.

*

* @eventType mx.events.FlexEvent.SHOW

*/

[Event(name="show", type="mx.events.FlexEvent")]

当一个对象的状态改变,从不可见到可见时,一个名为show的事件被发送了.

5./**

* Dispatched from a component opened using the PopUpManager

* when the user clicks outside it.

*

* @eventType mx.events.FlexMouseEvent.MOUSE_DOWN_OUTSIDE

*/

[Event(name="mouseDownOutside", type="mx.events.FlexMouseEvent")]

当用户点击了一个用PopUpManager弹出的组件的外面时,发送一个名为mouseDownOutside的事件

6./**

* Dispatched from a component opened using the PopUpManager

* when the user scrolls the mouse wheel outside it.

*

* @eventType mx.events.FlexMouseEvent.MOUSE_WHEEL_OUTSIDE

*/

[Event(name="mouseWheelOutside", type="mx.events.FlexMouseEvent")]

当用户滚动鼠标的轮子在用PopUpManager打开的组件时发送一个名为mouseWheelOutside的事件

7./**

* Dispatched when values are changed programmatically

* or by user interaction.

*

* <p>Because a programmatic change triggers this event, make sure

* that any <code>valueCommit</code> event handler does not change

* a value that causes another <code>valueCommit</code> event.

* For example, do not change a control’s <code>dataProvider</code>

* property in a <code>valueCommit</code> event handler. </p>

*

* @eventType mx.events.FlexEvent.VALUE_COMMIT

*/

[Event(name="valueCommit", type="mx.events.FlexEvent")]

当值被程序化的或通过和用户交互来改变时发送一个名为valueCommit的事件.

8./**

* Dispatched when a component is monitored by a Validator

* and the validation failed.

*

* @eventType mx.events.FlexEvent.INVALID

*/

[Event(name="invalid", type="mx.events.FlexEvent")]

当一个组件被一个验证器监视并验证失败时,发送一个名为invalid的事件.

9.

/**

* Dispatched when a component is monitored by a Validator

* and the validation succeeded.

*

* @eventType mx.events.FlexEvent.VALID

*/

[Event(name="valid", type="mx.events.FlexEvent")]

当一个组件被一个验证器监视并验证成功时,发送一个名为valid的事件.

10./**

* Dispatched by a component when the user moves the mouse over the component

* during a drag operation.

*

* <p>In order to be a valid drop target, you must define a handler

* for this event.

* In the handler, you can change the appearance of the drop target

* to provide visual feedback to the user that the component can accept

* the drag.

* For example, you could draw a border around the drop target,

* or give focus to the drop target.</p>

*

* <p>If you want to accept the drag, you must call the

* <code>DragManager.acceptDragDrop()</code> method. If you don’t

* call <code>acceptDragDrop()</code>, you will not get any of the

* other drag events.</p>

*

* <p>The value of the <code>action</code> property is always

* <code>DragManager.MOVE</code>, even if you are doing a copy.

* This is because the <code>dragEnter</code> event occurs before

* the control recognizes that the Control key is pressed to signal a copy.

* The <code>action</code> property of the event object for the

* <code>dragOver</code> event does contain a value that signifies the type of

* drag operation.</p>

*

* <p>You may change the type of drag action by calling the

* <code>DragManager.showFeedback()</code> method.</p>

*

* @see mx.managers.DragManager

*

* @eventType mx.events.DragEvent.DRAG_ENTER

*/

[Event(name="dragEnter", type="mx.events.DragEvent")]

当用户在一个拖拉操作其间移动鼠标越过一个组件上时发送一个名为dragEnter的事件.

为了成为一个合法的拖拉目标,你必须为这个事件定义一个处理者.

在这个处理者里,你可以改变这个拖拉目标的外观来提供一个可视化的反馈给读者来表明这个组件已经接受拖拉.

举个例子,你可以在拖拉目标的周围画一个边框,并给其设置焦点.

如果你想接受拖拉,你必须调用DragManager.acceptDragDrop()方法.如果你调用acceptDragDrop()方法,你将不能再接受任何其他拖拉的事件.

这个ACTION属性的值经常是DragManager.MOVE,即使你做了一个copy.这是因为dragEnter事件是在控制器承认ctrl被按下,并发信号通知COPY前发生的.

DragOver事件的属性ACTION不包含一个能表示拖拉操作类型的值.

你可以通过调用DragManager.showFeedback()这个方法来改变拖拉动作的类型.

11./**

* Dispatched by a component when the user moves the mouse while over the component

* during a drag operation.

*

* <p>In the handler, you can change the appearance of the drop target

* to provide visual feedback to the user that the component can accept

* the drag.

* For example, you could draw a border around the drop target,

* or give focus to the drop target.</p>

*

* <p>You should handle this event to perform additional logic

* before allowing the drop, such as dropping data to various locations

* in the drop target, reading keyboard input to determine if the

* drag-and-drop action is a move or copy of the drag data, or providing

* different types of visual feedback based on the type of drag-and-drop

* action.</p>

*

* <p>You may also change the type of drag action by changing the

* <code>DragManager.showFeedback()</code> method.

* The default value of the <code>action</code> property is

* <code>DragManager.MOVE</code>.</p>

*

* @see mx.managers.DragManager

*

* @eventType mx.events.DragEvent.DRAG_OVER

*/

[Event(name="dragOver", type="mx.events.DragEvent")]

组件发送一个名为dragOver的事件在一个拖拉操作其间当用户移动鼠标正在越过组件时.

在这个处理者里,你可以改变这个拖拉目标的外观来提供一个可视化的反馈给读者来表明这个组件已经接受拖拉.

你应该处理这个事件来执行额外的逻辑在运行拖拉前,就像拖拉数据到拖拉目标的各种不同的位置里,阅读键盘的输入来决定拖拉的动作是要移动还是复制拖拉数据或在拖拉动作类型的基础上提供各种不同的可视化反馈.

你可以通过改变DragManager.showFeedbakc()方法来改变拖拉动作的类型.属性ACTION的默认值是DragManager.MOVE;

12./**

* Dispatched by the component when the user drags outside the component,

* but does not drop the data onto the target.

*

* <p>You use this event to restore the drop target to its normal appearance

* if you modified its appearance as part of handling the

* <code>dragEnter</code> or <code>dragOver</code> event.</p>

*

* @eventType mx.events.DragEvent.DRAG_EXIT

*/

[Event(name="dragExit", type="mx.events.DragEvent")]

当用户拖拉组件到外部但没有拖放数据到目标时,会发送一个时间叫dragExit.

你可以用这个事件去恢复这个拖拉目标到它的普通表现形式,如果你修改了它的外观在处理事件dragEvent和dragOver时,

13./**

* Dispatched by the drop target when the user releases the mouse over it.

*

* <p>You use this event handler to add the drag data to the drop target.</p>

*

* @eventType mx.events.DragEvent.DRAG_DROP

*/

[Event(name="dragDrop", type="mx.events.DragEvent")]

当用户释放在鼠标在经过他时,由拖放的目标来发送一个名为dragDrop的事件

你用这个事件来处理增加拖拉数据到拖放目标上.

14./**

* Dispatched by the drag initiator (the component that is the source

* of the data being dragged) when the drag operation completes,

* either when you drop the dragged data onto a drop target or when you end

* the drag-and-drop operation without performing a drop.

*

* <p>You can use this event to perform any final cleanup

* of the drag-and-drop operation.

* For example, if you drag a List control item from one list to another,

* you can delete the List control item from the source if you no longer

* need it.</p>

*

* @eventType mx.events.DragEvent.DRAG_COMPLETE

*/

[Event(name="dragComplete", type="mx.events.DragEvent")]

要么是当你把拖拉数据拖放到目标上,要么当你结束一个拖拉放的操作在没执行一个拖放时拖拉的操作完成,由拖拉的发起人发送一个名为dragComplete的事件(这个发起人就是被拖拉的数据的源)

你可以用这个事件来执行任何最终的拖拉放的清空操作.

举个例子,如果你拖拉一个List控件中的一项到另一个控件,你可以删除ITEM项从源List控件那里如果你不再需要它的话.

15./**

* Dispatched just before an effect starts.

*

* <p>The effect does not start changing any visuals

* until after this event is fired.</p>

*

* @eventType mx.events.EffectEvent.EFFECT_START

*/

[Event(name="effectStart", type="mx.events.EffectEvent")]

就在效果开始前发送一个名为effectStart的事件.

这个事件不会改变任何可视直到事件被燃起

16./**

* Dispatched after an effect ends.

*

* <p>The effect will have made the last set of visual changes

* before this event is fired, but those changes will not have

* been rendered on the screen.

* Thus, you might have to use the <code>callLater()</code> method

* to delay any other changes that you want to make until after the

* changes have been rendered onscreen.</p>

*

* @eventType mx.events.EffectEvent.EFFECT_END

*/

[Event(name="effectEnd", type="mx.events.EffectEvent")]

当一个效果结束时发送一个名为effectEnd的事件

在这个事件被燃起前,这个效果会执行最后一套的可视化改变,但这些改变还没有呈现到屏幕上.

因此,你也许不得不使用callLater()方法去延迟那些你想要的改变直到这些改变已经呈现在屏幕上.

17./**

* Dispatched after the <code>currentState</code> property changes,

* but before the view state changes.

*

* @eventType mx.events.StateChangeEvent.CURRENT_STATE_CHANGING

*/

[Event(name="currentStateChanging", type="mx.events.StateChangeEvent")]

在属性currentState改变后,但在界面状态改变前发送一个名为currentStateChanging的事件.

18./**

* Dispatched after the view state has changed.

*

* @eventType mx.events.StateChangeEvent.CURRENT_STATE_CHANGE

*/

[Event(name="currentStateChange", type="mx.events.StateChangeEvent")]

在界面状态发生改变后发送一个名为currentStateChange的事件

19./**

* Dispatched after the component has returned to the root view state.

*

* @eventType mx.events.FlexEvent.ENTER_STATE

*/

[Event(name="enterState", type="mx.events.FlexEvent")]

在组件回到了根界面状态后发送一个名为enterState的事件

20./**

* Dispatched before the component exits from the root view state.

*

* @eventType mx.events.FlexEvent.EXIT_STATE

*/

[Event(name="exitState", type="mx.events.FlexEvent")]

组件离开根界面状态前发送一个名为exitState的事件

1./**

* Dispatched by the component when it is time to create a ToolTip.

*

* <p>If you create your own IToolTip object and place a reference

* to it in the <code>toolTip</code> property of the event object

* that is passed to your <code>toolTipCreate</code> handler,

* the ToolTipManager displays your custom ToolTip.

* Otherwise, the ToolTipManager creates an instance of

* <code>ToolTipManager.toolTipClass</code> to display.</p>

*

* <p>The sequence of ToolTip events is <code>toolTipStart</code>,

* <code>toolTipCreate</code>, <code>toolTipShow</code>,

* <code>toolTipShown</code>, <code>toolTipHide</code>,

* and <code>toolTipEnd</code>.</p>

*

* @eventType mx.events.ToolTipEvent.TOOL_TIP_CREATE

*/

[Event(name="toolTipCreate", type="mx.events.ToolTipEvent")]

当要创建一个工具提示时,组件会发送一个名为toolTipCreate的事件

如果你创建了你自己的工具提示对象,放一个引用到经过toolTipCreate传来的事件的属性toolTip里去处理,

ToolTipManager显示你的自定义工具提示.否则的话,ToolTipManager创建一个ToolTipManager.toolTipClass的实例来显示.

ToolTip事件的顺序是toolTipStart,toolTipCreate,toolTipShow,toolTipShown,toolTipHide,

和toolTipEnd

2./**

* Dispatched by the component when its ToolTip has been hidden

* and will be discarded soon.

*

* <p>If you specify an effect using the

* <code>ToolTipManager.hideEffect</code> property,

* this event is dispatched after the effect stops playing.</p>

*

* <p>The sequence of ToolTip events is <code>toolTipStart</code>,

* <code>toolTipCreate</code>, <code>toolTipShow</code>,

* <code>toolTipShown</code>, <code>toolTipHide</code>,

* and <code>toolTipEnd</code>.</p>

*

* @eventType mx.events.ToolTipEvent.TOOL_TIP_END

*/

[Event(name="toolTipEnd", type="mx.events.ToolTipEvent")]

当组件的ToolTip已经隐藏并且不久将被丢弃时,组件将发送一个名为toolTipEnd的事件.

如果你指定了一个使用ToolTipManager.hideEffect的效果,当这个效果停止播放后,这个事件就会被发送

ToolTip事件的顺序是toolTipStart,toolTipCreate,toolTipShow,toolTipShown,toolTipHide,

和toolTipEnd

3.**

* Dispatched by the component when its ToolTip is about to be hidden.

*

* <p>If you specify an effect using the

* <code>ToolTipManager.hideEffect</code> property,

* this event is dispatched before the effect starts playing.</p>

*

* <p>The sequence of ToolTip events is <code>toolTipStart</code>,

* <code>toolTipCreate</code>, <code>toolTipShow</code>,

* <code>toolTipShown</code>, <code>toolTipHide</code>,

* and <code>toolTipEnd</code>.</p>

*

* @eventType mx.events.ToolTipEvent.TOOL_TIP_HIDE

*/

[Event(name="toolTipHide", type="mx.events.ToolTipEvent")]

当一个工具提示快要隐藏时,由组件发送一个名为toolTipHide的事件

如果你指定了一个使用ToolTipManager.hideEffect的效果,这个事件会被发送在效果开始播放前

ToolTip事件的顺序是toolTipStart,toolTipCreate,toolTipShow,toolTipShown,toolTipHide,

和toolTipEnd

4./**

* Dispatched by the component when its ToolTip is about to be shown.

*

* <p>If you specify an effect using the

* <code>ToolTipManager.showEffect</code> property,

* this event is dispatched before the effect starts playing.

* You can use this event to modify the ToolTip before it appears.</p>

*

* <p>The sequence of ToolTip events is <code>toolTipStart</code>,

* <code>toolTipCreate</code>, <code>toolTipShow</code>,

* <code>toolTipShown</code>, <code>toolTipHide</code>,

* and <code>toolTipEnd</code>.</p>

*

* @eventType mx.events.ToolTipEvent.TOOL_TIP_SHOW

*/

[Event(name="toolTipShow", type="mx.events.ToolTipEvent")]

当一个组件的工具提示将要显示时,组件会发送一个名为toolTipShow的事件

如果你指定了一个使用ToolTipManager.showEffect的效果,这个事件会在效果开始播放前发送

你可以使用这个事件来修改ToolTip在它出现前

ToolTip事件的顺序是toolTipStart,toolTipCreate,toolTipShow,toolTipShown,toolTipHide,

和toolTipEnd

5./**

* Dispatched by the component when its ToolTip has been shown.

*

* <p>If you specify an effect using the

* <code>ToolTipManager.showEffect</code> property,

* this event is dispatched after the effect stops playing.</p>

*

* <p>The sequence of ToolTip events is <code>toolTipStart</code>,

* <code>toolTipCreate</code>, <code>toolTipShow</code>,

* <code>toolTipShown</code>, <code>toolTipHide</code>,

* and <code>toolTipEnd</code>.</p>

*

* @eventType mx.events.ToolTipEvent.TOOL_TIP_SHOWN

*/

[Event(name="toolTipShown", type="mx.events.ToolTipEvent")]

当组件的工具提示已经显示时,组件将发送一个名为toolTipShown的事件

如果你指定了一个使用ToolTipManager.showEffect的效果,这个事件会在效果停止播放后发送.

ToolTip事件的顺序是toolTipStart,toolTipCreate,toolTipShow,toolTipShown,toolTipHide,

和toolTipEnd

6./**

* Dispatched by a component whose <code>toolTip</code> property is set,

* as soon as the user moves the mouse over it.

*

* <p>The sequence of ToolTip events is <code>toolTipStart</code>,

* <code>toolTipCreate</code>, <code>toolTipShow</code>,

* <code>toolTipShown</code>, <code>toolTipHide</code>,

* and <code>toolTipEnd</code>.</p>

*

* @eventType mx.events.ToolTipEvent.TOOL_TIP_START

*/

[Event(name="toolTipStart", type="mx.events.ToolTipEvent")]

当组件的toolTip属性已经被设置,一旦用户移动鼠标到组件上时,组件发送一个名为toolTipStart的事件

ToolTip事件的顺序是toolTipStart,toolTipCreate,toolTipShow,toolTipShown,toolTipHide,

和toolTipEnd

posted on 2011-03-17 20:53  Java码界探秘  阅读(154)  评论(0编辑  收藏  举报

导航