How best to accept variables from HTML code _OR_ a parent clip?

In days of old, I developed a library of AS2-based clips that could be loaded as either standalone SWFs or embedded into a larger SWF container. The clips received some data from outside themselves, using FlashVars when loaded into HTML or main timeline variables when loaded from the container.

e.g. when “test.swf” is loaded into an HTML page, it would have its var1 variable set to “banana” via the FlashVars parameter:

<param name="FlashVars" value="var1=banana">

BUT, when loaded into a knowledgeable parent container, the parent could then “inject” the necessary variables on init:


loaderListener.onLoadComplete = function (clip:MovieClip)    {
 clip.var1 = "banana";
}

Today, AS3 adds those FlashVars variables to the loaderInfo.parameters object, which is fine, but… loaderInfo.parameters is apparently read only! Has anyone come up with a good way to create/set variables in clips via either FlashVars OR a parent-child “push?”

I’m guessing I’d have to edit and republish the clips again, regardless, but I’m looking for a good substitute method.

For what it’s worth, here’s what I used to do in AS2 (from the parent Clip, to “inject” a FlashVars string into the child clip):


        var loaderListener = new Object ();
        loaderListener.flashVarsString = "var1=banana";
        loaderListener.onLoadComplete = function (clip:MovieClip)    {
  
            var pairs:Array = this.flashVarsString.split('&');
            for(var i in pairs)    {
                var piece = pairs*.split('=');
                //trace ("For " + pairs* + ", " + piece[0] + " should be set to " + piece[1]);
                clip[piece[0]] = piece[1];
            }
                            
        }



Any ideas?