0 Replies Latest reply on Sep 21, 2010 6:31 AM by stickamw

    2nd Cry for help!  How to access a function in a parent that is also a child?

    stickamw

      Hi guys,

       

           So I have a fun one today...

       

           In Flex 4, the folks at Adobe change the Application.application to FlexGlobals.topLevelApplication.  I get this, to a point, but it now presents a problem for me.

       

           I have a SWF (loginSWF) that loads an application (dashSWF) which loads numerous swf's (widgetSWF).  The problem I'm encoutering is that each widgetSWF needs to execute a function in the dashSWF so that manager in the dashSWF knows the widgets have been opened.

       

           Originally, I had the dashSWF as the main app that was loaded intially with the widgets being the 2nd level of app loads and the following methods worked fine:

       

           Flex3 =>  application.registerSWF(this);

           Flex4 =>  FlexGlobals.topLevelApplication.registerSWF(this);

       

           However, I had to add a login function to the mix. This loginSWF prompts the user for their credentials and once validated with the DB, the loginSWF loads the dashSWF via a SWFLoader() and passes the userID and userEmail as parameters.  I kept the loginSWF separate from the dashSWF mainly because it was simpler to code and more modular. But I still need these parameters passed. Now I looked at flashvars for this but given that the values are dynamic, I wasn't sure I could use them for this.  Additionally, I didn't want the values visible in a URL so I didn't simply redirect to the url for the dashSWF. In the end, the only way that looked viable was to load my dashSWF using a SWFLoader(0 within the loginSWF and pass the vars directly in from there. If anyone has a better way, I'm all ears.

       

           Now, the problem that I have is that I can't find a way, in the current setup, to access my registerSWF() function because the topLevelApplication is now dashSWF.  I've tried giving the SWFLoader() object an id to try to reference the dashSWF that way but it's not working.

       

           Anyone have ANY ideas on how I can do this?

       

      Thanks,

      Adrian