
174 Migration Patterns
Instantiating Flex controls
In Flex 1.x, you created a Flex control in ActionScript by first including a reference to that
control, and then using the
createEmptyObject(), createChild(), createChildren(),
createChildAtDepth(), or createClassChildAtDepth() method.
These methods were removed. In Flex 2, you use the
new operator to create child controls and
attach the control to a container with the
addChild() or addChildAt() method. For
example:
Flex 1.x:
var b:Button;
b = Button(createChild(Button, undefined, { label: "OK" }));
Flex 2:
var b:Button = new Button();
b.label = "OK";
addChild(b);
Similarly, in Flex 2 you would destroy the object with the destroyObject(),
destroyChild(), destroyChildAt(), or destroyAllChildren() method. These methods
are also deprecated. Instead, you use the
removeChild() or removeChildAt() method.
The
createComponent() method now takes only a descriptor as its first argument, rather
than either a descriptor or a descriptor index. If you know the index, use
childDescriptors[i] to get the descriptor itself.
For more information on creating and destroying Flex controls in ActionScript, see the Flex 2
Developer’s Guide.
Flex 1.x Flex 2
createComponent() method
createComponentFromDescriptor()
createComponents()
method
createComponentsFromDescriptors()
Commenti su questo manuale