Bob,

 

The ViewStack component has a createChild method to dynamically add components into the view stack.  createChild(class,name,initprops).  You could create a new mx:Image.  You may have to create a container component with the mx:Image inside since containers can lay themselves out. 

 

the view stack may only allow containers as children.  You could create a container extending VBox with an image inside. Then you would add the child dynamically like:

 

function setLink(url) {

   myViewStack.createChild(MyLinkContainer, undefined, {source: url} );

}

 

MyLinkContainer.mxml:

<?xml version="1.0" ?>

<mx:VBox xmlns:mx="http://www.macromedia.com/2003/mxml" initialize="img.source=source;">

<mx:Script>

   // source contains the url to an mxml file load e.g. link0.mxml.swf

     var source;

  </mx:Script>

  <mx:Image id="img" width="500" height="400"/>

</mx:VBox>

 

Dan

 

-----Original Message-----
From: bobpardoe1959 [mailto:[EMAIL PROTECTED]
Sent:
Wednesday, April 28, 2004 9:26 AM
To: [email protected]
Subject: [flexcoders] runtime loading a mxml file into a viewstack

 

I have my menu on the left side of the screen and the 'working area'
on the right separated by a Divider.

In my menu (accordian) I have a number of Links. When the user
clicks on one I want to load a new 'form' (mxml file) as a child of
the Viewstack on the right side of the screen.

Please could anyone point me in the right direction. I have looked
at getURL and loadMovie, but canot see how to make the newly loaded
file a child of the view stack

Thanks in advance

BOb


Reply via email to