var s:UIComponent=new UIComponent();
s.graphics.beginFill(0x0000ff, 100);
s.graphics.drawCircle(100,100,40);
s.graphics.endFill();
this.addChild(s);
在类里边写时
框架:
package myComponents
{
public class MyComponent extends UIComponent
{
....
}
}
详细内容
// Declare two variables for the component children.
private var text_mc:TextArea;
private var mode_mc:Button;
override protected function createChildren():void {
// Call the createChildren() method of the superclass.
super.createChildren();
// Test for the existence of the children before creating them.
// This is optional, but do this so a subclass can create a different
// child.
if (!text_mc) {
text_mc = new TextArea();
text_mc.explicitWidth = 80;
text_mc.editable = false;
text_mc.addEventListener("change", handleChangeEvent);
// Add the child component to the custom component.
addChild(text_mc);
}
// Test for the existence of the children before creating them.
if (!mode_mc) {
mode_mc = new Button();
mode_mc.label = "Toggle Editing";
mode_mc.addEventListener("click", handleClickEvent);
// Add the child component to the custom component.
addChild(mode_mc);
}
}
理解加粗部分的重要性。