2009/10/23 Nirav V. Patel <[email protected]>:
> I was hoping someone could help me find an elegant solution for
> importing variables to the outputted swfmill SWF.
>
> [ ... ]
>
> I'm having swfmill generate a textfield on the stage (the text is
> '336699').  Then I'm using actionscript within an imported SWF
> (swfmill.swf) to extract the string of the swfmill textfield object to
> get the variable.  It's a few steps to go through, but I was wondering
> if there was something available within swfmill to import a variable
> directly without having to go through that process.

I suppose the cleanest way would be to set a property somewhere that
can be retrieved from the embedded movie. You can do that by mixing
the full SWF dialect with the simple dialect. The following example
sets _global.colorValue = 0x336699, which can then be read back from
the code in the FLA.

<?xml version="1.0" encoding="iso-8859-1" ?>
<movie version="8" width="600" height="400" framerate="12">
  <background color="#000000"/>
  <library>
    <clip id="mainBanner" import="swfmill.swf"/>
    <clip id="ImportedImage1" import="xml/assets/image1.jpg"/>
  </library>
  <frame>
    <DoAction>
      <actions>
        <PushData>
          <items>
            <StackString value="_global"/>
          </items>
        </PushData>
        <GetVariable/>
        <PushData>
          <items>
            <StackString value="squareColor"/>
            <StackInteger value="3368601"/>
          </items>
        </PushData>
        <SetMember/>
        <EndAction/>
      </actions>
    </DoAction>
    <font id="georgia" import="fonts/Georgia"
glyphs="QAZXSWEDCVFRTGBNHYUJMKIOLPzaqqwsxcderfvbgtyhnmjuiklop.0123456789/"/>
    <place id="mainBanner" x="0" y="0" depth="1" />
    <place id="squarecolor" name="squarecolorxml" x="10" y="10" depth="2"/>
  </frame>
</movie>


and change the code in the FLA to:
init1();
function init1()
{
        var sqrcolor=new Color ("square");
        sqrcolor.setRGB(_global.squareColor);
}


I tried the above and it worked for me.


The easiest way to find out the appropriate XML to set the variables
you want is to build a simple SWF with code like this on the first
frame:

_global.a = 1;
_global.b = 2;
// and so on

Then run swfmill swf2xml on the resulting SWF and look for the DoAction tag.

Hope this helps,
Dan.

_______________________________________________
swfmill mailing list
[email protected]
http://osflash.org/mailman/listinfo/swfmill_osflash.org

Reply via email to