From last 2 days I was working on the flex drawing objects. I tried with following example from flex help.
import flash.display.*;
var circle:Shape = new Shape()
var xPos:Number = 100;
var yPos:Number = 100;
var radius:Number = 50;;, yPos, radius);

But there was a error pop up comes every-time –
“Type Coercion failed: cannot convert flash.display::Shape to mx.core.IUIComponent.”

Then I studied the sprite object, Sprite objects can act as display object containers and respond to mouse clicks. Then I tried flex help for sprite & I got this code –

var mySprite:Sprite = new Sprite();;, 30, 30);
var label:TextField = new TextField();
label.text = “hello”;
label.x = 20;
label.y = 20;

But it also gives meĀ  “Type Coercion failed: cannot convert flash.display::Sprite to mx.core.IUIComponent.” error.
Then I searched on google & I got this code. Works fine & I can draw any object at run-time.

var myUIComponent:UIComponent = new UIComponent();;, 30, 30);
var label:Label = new Label();
label.text = “hello”;
label.x = 20;
label.y = 20;

Here is the link for this page in google –

Thank you,