As JP said, make sure your UIComponent reserves some space by setting
width/height on it.

  <mx:UIComponent id="uic" width="200" height="200"/>

With more work you could make UIComponent look at its child sprites and
report measurements and then it will size to fit.  But for now, just make
some space.


Then your code will just pass in uic:

        e = new AddSprites(uic);

And AddSprites would call addChild on that thing.


On 7/17/13 9:57 AM, "Dennis Raddle" <[email protected]> wrote:

>Okay I'm trying to figure out how to write code that would let me add
>Sprite-based objects to a Flex framework. Looking at the bigger picture, I
>don't know if this is right way to go. My larger goal is to mix buttons
>and
>layouts and things that Flex provides, with animation of graphics. But
>anyway, here is my first attempt to code something. I'm stuck in the
>function addStuff(). Let's say that I create a class called AddSprites
>that
>does the work of adding Sprites and animating them. I'm going to need to
>pass the UIComponent into its constructor. How do I do that?
>
><?xml version="1.0" encoding="utf-8"?>
><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 {
>        .... ???? problem is next line ...
>        e = new AddSprites(..UIComponent?..);
>      }
>    ]]>
>
>  </fx:Script>
>
>  <s:layout>
>    <s:VerticalLayout/>
>  </s:layout>
>
>  <s:Button click="addStuff()" />
>
>  <mx:UIComponent id="uic"/>
></s:Application>
>
>
>
>On Wed, Jul 17, 2013 at 9:22 AM, Alex Harui <[email protected]> wrote:
>
>> Well, SkinnableComponent will probably require a Skin.  It is possible
>>to
>> use subclasses of UIComponent or SpriteVisualElement to do low-level
>>Flash
>> stuff.
>>
>> It is also possible to create a single UIComponent that will reserve a
>> bunch of screen space for you to add any combination of Sprites and
>>Shapes
>> that don't subclass Flex stuff.
>>
>>

Reply via email to