actionscript-3puremvc

Pass proxy to loaded module in a PureMVC MultiCore app?


I'm creating a flash campaign which will be loaded into a client's framework, which I have no control over. The framework will already have loaded a few things such as locale, fonts and copy, and will pass these things to my swf upon initialization.

Since the size of my swf (let's call it the shell) is restricted it will in turn display a campaign-specific preloader and then load another swf (let's call this the campaign) with the rest of the site.

The shell and the campaign will both be PureMVC modules. The shell will create a few proxies and populate these with data passed from the framework (locale constants, fonts etc), before loading in the campaign.

When the campaign is loaded it too will need locale and fonts etc. so my question is, what is the best way to pass this data along to the campaign module from the shell module?


Solution

  • The solution I usually use is to create an interface:

    interface Campaign {
        function set campaignDetails(value:CampaignDetails):void;
    
        //...
    }
    

    The campaign-module should implement this interface - in the implementation I recommend you to use a different proxy in the module, so that you would avoid having duplicated notifications and references.

    When the shell is ready with the loading of the module it just has to:

    if (module is Campaign)
    {
        (module as Campaign).campaignDetails = ...;
    }
    

    I'm sure I'm telling you nothing new. You just need to make sure to keep the acquaintance between the shell and the module only on an interface level. Then you just pass the data and leave the module MVC core to deal with it independently from the shell.