適用於 Adobe® Flash® Platform 的 ActionScript® 3.0 參考
首頁  |  隱藏套件和類別清單 |  套件  |  類別  |  新增內容  |  索引  |  附錄  |  為什麼顯示英文?
篩選: 從伺服器擷取資料...
從伺服器擷取資料...
mx.states 

AddChild  - AS3 Flex

套件mx.states
類別public class AddChild
繼承AddChild Inheritance OverrideBase Inheritance OnDemandEventDispatcher Inheritance Object

語言版本: ActionScript 3.0
產品版本: Flex 3
執行階段版本: Flash Player 9, AIR 1.1

The AddChild class adds a child display object, such as a component, to a container as part of a view state. You use this class in the overrides property of the State class. Use the creationPolicy property to specify to create the child at application startup or when you change to a view state.

The child does not dispatch the creationComplete event until it is added to a container. For example, the following code adds a Button control as part of a view state change:

  <mx:AddChild relativeTo="{v1}">
      <mx:Button id="b0" label="New Button"/>
  </mx:AddChild> 

In the previous example, the Button control does not dispatch the creationComplete event until you change state and the Button control is added to a container. If the AddChild class defines both the Button and a container, such as a Canvas container, then the Button control dispatches the creationComplete event when it is created. For example, if the creationPolicy property is set to all, the Button control dispatches the event at application startup. If the creationPolicy property is set to auto, the Button control dispatches the event when you change to the view state.

MXML 語法expanded隱藏 MXML 語法

The <mx:AddChild> tag has the following attributes:

  <mx:AddChild
  Properties
  target="null"
  targetFactory="null"
  creationPolicy="auto"
  position="lastChild"
  relativeTo="parent of the State object"
  />
  

預設 MXML 屬性targetFactory

相關 API 元素



公用屬性
 屬性定義自
 Inheritedconstructor : Object
類別物件的參照或是特定物件實體的建構函數。
Object
  creationPolicy : String
The creation policy for this child.
AddChild
  position : String
The position of the child in the display list, relative to the object specified by the relativeTo property.
AddChild
  relativeTo : Object
The object relative to which the child is added.
AddChild
  target : DisplayObject
The child to be added.
AddChild
  targetFactory : IDeferredInstance
The factory that creates the child.
AddChild
公用方法
 方法定義自
  
AddChild(relativeTo:UIComponent = null, target:DisplayObject = null, position:String = "lastChild")
Constructor.
AddChild
 Inherited
addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void
Registers an event listener object with an EventDispatcher object so that the listener receives notification of an event.
OnDemandEventDispatcher
  
[覆寫] Applies the override.
AddChild
  
Creates the child instance from the factory.
AddChild
 Inherited
Dispatches an event into the event flow.
OnDemandEventDispatcher
 Inherited
Checks whether the EventDispatcher object has any listeners registered for a specific type of event.
OnDemandEventDispatcher
 Inherited
指出物件是否有已定義的指定屬性。
Object
  
[覆寫] IOverride interface method; this class implements it as an empty method.
AddChild
 Inherited
指出 Object 類別的實體是否位於指定為參數的物件原型鏈中。
Object
 Inherited
指出指定的屬性是否存在,以及是否可列舉。
Object
  
[覆寫] Removes the override.
AddChild
 Inherited
removeEventListener(type:String, listener:Function, useCapture:Boolean = false):void
Removes a listener from the EventDispatcher object.
OnDemandEventDispatcher
 Inherited
為迴圈作業設定動態屬性的可用性。
Object
 Inherited
傳回代表此物件的字串,根據地區特定慣例進行格式化。
Object
 Inherited
會傳回指定之物件的字串形式。
Object
 Inherited
會傳回指定之物件的基本值。
Object
 Inherited
Checks whether an event listener is registered with this EventDispatcher object or any of its ancestors for the specified event type.
OnDemandEventDispatcher
屬性詳細資訊

creationPolicy

屬性
creationPolicy:String

語言版本: ActionScript 3.0
產品版本: Flex 3
執行階段版本: Flash Player 9, AIR 1.1

The creation policy for this child. This property determines when the targetFactory will create the instance of the child. Flex uses this properthy only if you specify a targetFactory property. The following values are valid:

ValueMeaning
auto(default)Create the instance the first time it is needed.
allCreate the instance when the application started up.
noneDo not automatically create the instance. You must call the createInstance() method to create the instance.

預設值為 "auto"。



實作
    public function get creationPolicy():String
    public function set creationPolicy(value:String):void

position

屬性 
public var position:String

語言版本: ActionScript 3.0
產品版本: Flex 3
執行階段版本: Flash Player 9, AIR 1.1

The position of the child in the display list, relative to the object specified by the relativeTo property. Valid values are "before", "after", "firstChild", and "lastChild".

預設值為 "lastChild"。

relativeTo

屬性 
public var relativeTo:Object

語言版本: ActionScript 3.0
產品版本: Flex 3
執行階段版本: Flash Player 9, AIR 1.1

The object relative to which the child is added. This property is used in conjunction with the position property. This property is optional; if you omit it, Flex uses the immediate parent of the State object, that is, the component that has the states property, or <mx:states>tag that specifies the State object.

target

屬性 
target:DisplayObject

語言版本: ActionScript 3.0
產品版本: Flex 3
執行階段版本: Flash Player 9, AIR 1.1

The child to be added. If you set this property, the child instance is created at app startup. Setting this property is equivalent to setting a targetFactory property with a creationPolicy of "all".

Do not set this property if you set the targetFactory property.



實作
    public function get target():DisplayObject
    public function set target(value:DisplayObject):void

targetFactory

屬性 
targetFactory:IDeferredInstance

語言版本: ActionScript 3.0
產品版本: Flex 3
執行階段版本: Flash Player 9, AIR 1.1

The factory that creates the child. You can specify either of the following items:

  • A factory class that implements the IDeferredInstance interface and creates the child instance or instances.
  • A Flex component, (that is, any class that is a subclass of the UIComponent class), such as the Button contol. If you use a Flex component, the Flex compiler automatically wraps the component in a factory class.

If you set this property, the child is instantiated at the time determined by the creationPolicy property.

Do not set this property if you set the target property. This propety is the AddChild class default property. Setting this property with a creationPolicy of "all" is equivalent to setting a target property.



實作
    public function get targetFactory():IDeferredInstance
    public function set targetFactory(value:IDeferredInstance):void
建構函式詳細資料

AddChild

()建構函式
public function AddChild(relativeTo:UIComponent = null, target:DisplayObject = null, position:String = "lastChild")

語言版本: ActionScript 3.0
產品版本: Flex 3
執行階段版本: Flash Player 9, AIR 1.1

Constructor.

參數
relativeTo:UIComponent (default = null) — The component relative to which child is added.
 
target:DisplayObject (default = null) — The child object. All Flex components are subclasses of the DisplayObject class.
 
position:String (default = "lastChild") — the location in the display list of the target relative to the relativeTo component. Must be one of the following: "firstChild", "lastChild", "before" or "after".
方法詳細資訊

apply

()方法
override public function apply(parent:UIComponent):void

語言版本: ActionScript 3.0
產品版本: Flex 3
執行階段版本: Flash Player 9, AIR 1.1

Applies the override. Flex retains the original value, so that it can restore the value later in the remove() method.

This method is called automatically when the state is entered. It should not be called directly.

參數

parent:UIComponent — The parent of the state object containing this override. The override should use this as its target if an explicit target was not specified.

createInstance

()方法 
public function createInstance():void

語言版本: ActionScript 3.0
產品版本: Flex 3
執行階段版本: Flash Player 9, AIR 1.1

Creates the child instance from the factory. You must use this method only if you specify a targetFactory property and a creationPolicy value of "none". Flex automatically calls this method if the creationPolicy property value is "auto" or "all". If you call this method multiple times, the child instance is created only on the first call.

initialize

()方法 
override public function initialize():void

語言版本: ActionScript 3.0
產品版本: Flex 3
執行階段版本: Flash Player 9, AIR 1.1

IOverride interface method; this class implements it as an empty method.

remove

()方法 
override public function remove(parent:UIComponent):void

語言版本: ActionScript 3.0
產品版本: Flex 3
執行階段版本: Flash Player 9, AIR 1.1

Removes the override. The value remembered in the apply() method is restored.

This method is called automatically when the state is entered. It should not be called directly.

參數

parent:UIComponent — The parent of the state object containing this override. The override should use this as its target if an explicit target was not specified.





[ X ]為什麼顯示英文?
「ActionScript 3.0 參考」的內容是以英文顯示

並非所有「ActionScript 3.0 參考」的內容都翻譯為所有語言。當語言元素未翻譯時,就會以英文顯示。例如,ga.controls.HelpBox 類別並沒有翻譯為任何語言。因此在參考的繁體中文版本中,ga.controls.HelpBox 類別就會以英文顯示。