You can go as deep as you want.  What you are doing is declaring a component, 
then naming one of its properties, then declaring the value of the property to 
be another component.  Once you do that you can name one of that component’s 
properties and define its value to be another component, etc.

It is easier to see the pattern if all of your components start with uppercase 
letters and properties start with lower case.

<thirdParty:SomeContainer>
    <thirdParty:somePropertyInSomeContainer>
        <local:MyContainer>
            <local:somePropertyInMyContainer>
                <s:Group>
                    <s:layout>
                        <s:VerticalLayout />


On 4/15/10 3:03 PM, "Christopher McArthur" <[email protected]> wrote:






Thanks for the response Alex.

And this works great for my test example!

However, I am curious, is this as deep as you can go, one level? Or is it 
possible to nest it deeper?

Just trying to get an idea of whats allowed and how its actually working.

Nesting one level deeper, in a simple test application, I get the error :
"could not resolve <local:imageVar> to a component implementation".
so, for an example, if you had a ParentContainer, that had a variable named 
"childComponent", that has a variable named "imageVar".


<local:ParentContainter>
  <local:childComponent>
          <local:imageVar>
               <mx:Image source=”myTestImage.jpg” />
       </local:imageVar>
    </local: childComponent >
</local: ParentContainter >

This gives the "could not resolve <local:imageVar> to a component 
implementation". error.




From: [email protected] [mailto:[email protected]] On Behalf 
Of Alex Harui
Sent: Wednesday, April 14, 2010 10:06 PM
To: [email protected]
Subject: Re: [flexcoders] What is the MXML syntax for this?



Are you looking for:

<local:myContainerComponent id=”containerComponent”>
    <local:imageVar>
        <mx:Image source=”myTestImage.jpg” />
    </local:imageVar>
</local:myContainerComponent>


On 4/14/10 12:53 PM, "Christopher McArthur" <[email protected]> wrote:






I have a component, that has a property of type Image. I need to assign a new 
Image component to it. this is trivial to do in action script. But, how do I do 
it in MXML?

Example:
mxml:
<local:myContainerComponent id="containerComponent"/>

actionscript:
var myImage:Image = new Image("myTestImage.jpg");
containerComponent.imageVar = myImage;


Is there anyway to do that creation of the image, and assignment purely from 
MXML? The image cant be a child of anything else, so I cant just declare it 
randomly somewhere in the same container.


For context, im using the Flash Component Kit, and the myContainerComponent is 
a container exported from flash a "mx.flash.ContainerMovieClip". And it 
requires you to assign a component to its "content" property. Ideally, id like 
to create and assign this content component using mxml only.









--
Alex Harui
Flex SDK Team
Adobe System, Inc.
http://blogs.adobe.com/aharui

Reply via email to