How are these things supposed to be used? I'm apparently missing the mark. I figured I could use them to display images & shapes in my application. But it doesn't look like I can add them in my MXML or Actionscript:
Code:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application
xmlns:mx="http://www.adobe.com/2006/mxml"
layout="absolute"
width="800"
height="600"
creationComplete="onLoad()"
>
<mx:Script>
<![CDATA[
private function onLoad():void
{
var square:Sprite = new Sprite();
square.graphics.beginFill(0xFF88CC);
square.graphics.drawRect(0, 0, 80, 80);
panel1.addChild(square);
}
]]>
</mx:Script>
<mx:Panel id="panel1"
x="0" y="1000"
width="50%"
height="80%"
title="panel1">
</mx:Panel>
<mx:Panel id="panel2"
x="400" y="1000"
width="50%"
height="80%"
title="panel2">
</mx:Panel>
</mx:Application>
Throws an error during runtime:
TypeError: Error #1034: Type Coercion failed: cannot convert flash.display::Sprite@4dee191 to mx.core.IUIComponent.
at mx.core::Container/http://www.adobe.com/2006/flex/mx/internal::addingChild()
at mx.core::Container/addChildAt()
at mx.core::Container/addChild()
at SpaceFlex/:

nLoad()
at SpaceFlex/___Application1_creationComplete()
at flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEventFunctio n()
at flash.events::EventDispatcher/dispatchEvent()
at mx.core::UIComponent/set initialized()
at mx.managers::LayoutManager/::doPhasedInstantiation()
at Function/http://adobe.com/AS3/2006/builtin::apply()
at mx.core::UIComponent/::callLaterDispatcher2()
at mx.core::UIComponent/::callLaterDispatcher()
So I can see that a Sprite isn't of IUIComponent -- so it won't let me add it directly to the panel or to the application. How am I supposed to use these things in my Flex application? I checked out the livedocs:
http://livedocs.macromedia.com/flex/...ay/Sprite.html and I don't see why their subclass of Sprite would work, while a regular plain-jane Sprite wouldn't. It doesn't look like they've made any conversion of the Sprite to a IUIComponent...
Pretty much all I'm after is trying to programatically draw a square (or whatever other shape my miniscule brain can conjure

) and display that to the screen.