My goal is to write educational software to run in Flash or AIR. (Probably mostly AIR on mobile devices.) I'm envisioning that the stage will have an area with controls like Flex provides, but another area with animations and graphics that would be done in pure ActionScript. I have been told that if I use Flex I will need to inherit UIComponent in any new components that I create, but I was also told alternatively I could put a big UIComponent on the screen and add Sprite-based objects to it. So I am trying to code the latter, and I'm stuck. I created an MXML file with a button and a UIComponent. Then I would like to write a class in a seperate .AS file that takes the UIComponent in its constructor and handles adding objects. I don't know how to reference the UIComponent in the script code in the MXML file. Here's what I have:
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx">
<fx:Script>
<![CDATA[
import exper AddSprites;
private var e:AddSprites;
public function addStuff():void {
???? next line is question ???
e = new AddSprites(..UIComponent?..);
}
]]>
</fx:Script>
<s:layout>
<s:VerticalLayout/>
</s:layout>
<s:Button click="addStuff()" />
<mx:UIComponent id="uic"/>
</s:Application>