And if loose coupling is not a key issue for you, you can simply access
public members in the loaded swf using the "content" property of
SWFLoader.  If you are loading appliations, use SWFLoader, not Image.

 

Access top level application members using Application.application.

 

You will need to listen for the complete event of the loader and the
APPLICATION_COMPLETE event of the loaded app before you can access
properties via the "content" property:

        <mx:SWFLoader id="ldMain" progress="showProgress(event)"
width="100%" height="100%" 

          complete="onCompleteAppLoader(event)"/>

 

  /** runs when SWFLoader content has all downloaded */

  private function onCompleteAppLoader(oEvent:Event):void

  {

    var smAppLoaded:SystemManager =
SystemManager(oEvent.target.content);

    smAppLoaded.addEventListener(FlexEvent.APPLICATION_COMPLETE,
onCurrentApplicationComplete)

    //vbMask.visible = false;

  }//onCompleteAppLoader

  

  /** runs when the app loaded in the SWFLoader has completed
initialization

  *   and is ready for any access (applicationComplete event)

  */

  private function onCurrentApplicationComplete(oEvent:Event):void

  {

    _appLoaded = Application(oEvent.target.application);

    _sAppLoadedUrl = _appLoaded.url

    var iPosLastPathDelimiter:int = _sAppLoadedUrl.lastIndexOf("\\");

    if (iPosLastPathDelimiter == -1)  {

      iPosLastPathDelimiter = _sAppLoadedUrl.lastIndexOf("/");

    }

    _sAppLoadedName =
_sAppLoadedUrl.substring(iPosLastPathDelimiter+1,_sAppLoadedUrl.lastInde
xOf("."));

  }//onCurrentApplicationComplete

  

  /**  */

  public function showProgress(oEvent:Event):void

  {

    var sBytesLoaded:String = oEvent.target.bytesLoaded;

    var sBytesTotal:String = oEvent.target.bytesTotal;

    _nLoadProgress = (sBytesLoaded/sBytesTotal) * 100;

    lbLoading.alpha = 1/_nLoadProgress * 10;

    if (_nLoadProgress == 100)  {

      lbLoading.visible = false;

      lbLoading.alpha = 1; 

    }

 

  } //showProgress

 

Tracy

________________________________

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of Bjorn Schultheiss
Sent: Wednesday, May 16, 2007 7:29 PM
To: [email protected]
Subject: Re: [flexcoders] Communication of data between parent and child
movie.

 

Using the inbuilt event dispatching system is your best bet.

That way you can have your parent(s) and child(s) loosely coupled.

 

There are particular design patterns that also deal with this issue.

Personally i like the combination of DataBinding,
ModelLocator(Singleton) and Commands, ala Cairngorm :)

 

 

Bjorn

 

 

On 17/05/2007, at 8:58 AM, ivansebastiansurya wrote:





Hi everyone,

Currently I have to write a Flex application that holds other swf 
application within it (I will have a skeleton swf movie with menu on 
the left hand side and when a menu item is clicked, the corresponding 
sub application is loaded on the right hand side, onto an Image 
control).

The problem is that how can we propagate information from the child 
movie to the parent movie and vice versa? Say the sub movie does the 
login procedure and return the authentication information, how can I 
pass this information to the parent movie so that it can be used to 
control the access given to this particular user?

 

Reply via email to