This is because Canvas, or more specific, Container tries to cast our newly
created Sprite to a UIComponent, which is an Object lower in the Flex
inheritance chain and casting to a more specific type is not allowed. You could
just add your Sprite to the rawChildren property of my container like this:
var sprite:Sprite = new Sprite();
You need to wrap your sprite in a UIComponent. Accessing rawChildren can be dangerous.
var mySprite:Sprite = new Sprite();
mySprite.graphics.drawCircle(30, 30, 30);
var uic:UIComponent = new UIComponent();
If this post answers your question or helps, please mark it as such.
Flex Development and Support Services