If you want to do it purely in MXML, I would just use a [Bindable] variable.
So you can do this:
<mx:Image id="myImage" source="{myvar}"/>
Then you can change the variable "myvar" to store any image you like and it
will automatically update the mxml.
So to add what Alex wrote you could do this:
<local:myContainerComponent id=”containerComponent”>
<local:imageVar>
<mx:Image source=”{myvar}” />
</local:imageVar>
</local:myContainerComponent>
Amanda
On Wed, Apr 14, 2010 at 3: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.
>
>
>
>
>
>
>
>
>
>
>
--
´¨) __o
.·´ .·´¨) ¸.·´¨) _'\< .
(¸.·´ (¸.·´ (¸.·´¨¨ Amanda ¨¨¨¨¨¨( * ) ( )