[swfmill] Loading assets from runtime-loaded SWFs generated by swfmill (+followup for Jonas)

armencho at gmail.com armencho at gmail.com
Fri Nov 6 07:26:33 PST 2009


Actually I took a nap on the sofa, and it struck me that in fact the
kind of assembly we are talking about is ideally a domain for a more
complex "compiler" tool. swfmill is more of an "assembler", i.e. it
trans-codes a human readable file (xml) into a compact machine
readable file, without involving much "thinking logic". This is why
and how the xml format so closely resembles the swf, and is in fact
designed to do so. In that sense, swfmill is a "transcoder", rather
than a development tool like a compiler is. Building the kind of
functionality that allows class setup to be generated when importing
assets, would in my opinion shift and extend swfmills domain towards
the area of compilers and other kind of smart translators. This will
imply a more abstract and high-level language for input stream, and
swfmill will become a true smart translator itself. The question is,
should it become one, or should it be forked or possible
runtime-linked against (it becoming a library) to support a tool that
will do all the advanced stuff?

The following is a snippet of code one is required to have swfmill
process in order to have a font class stub, for example when trying to
write font asset SWFs:

      <DoABCDefine flags="1" name="">
        <actions>
          <Action3 minorVersion="16" majorVersion="46">
            <constants>
              <Constants>
                <!-- ints/>
                <uints/>
                <doubles/ -->
                <strings>
                  <String2 value=""/>
                  <String2 value="MyFont"/>
                  <String2 value="flash.text"/>
                  <String2 value="Font"/>
                  <String2 value="Object"/>
                </strings>
                <namespaces>
                  <PackageNamespace index="1"/>
                  <PackageNamespace index="3"/>
                  <ProtectedNamespace index="2"/>
                </namespaces>
                <namespaceSets/>
                <multinames>
                  <QName namespaceIndex="1" nameIndex="2"/><!-- MyFont -->
                  <QName namespaceIndex="2" nameIndex="4"/><!--
flash.text.Font -->
                  <QName namespaceIndex="1" nameIndex="5"/><!-- Object -->
                </multinames>
              </Constants>
            </constants>
            <methods>
              <MethodInfo retType="0" nameIndex="0" hasParamNames="0"
setSDXNs="0" isExplicit="0" ignoreRest="0" hasOptional="0"
needRest="0" needActivation="0" needArguments="0">
                <paramTypes/>
              </MethodInfo>
              <MethodInfo retType="0" nameIndex="0" hasParamNames="0"
setSDXNs="0" isExplicit="0" ignoreRest="0" hasOptional="0"
needRest="0" needActivation="0" needArguments="0">
                <paramTypes/>
              </MethodInfo>
              <MethodInfo retType="0" nameIndex="0" hasParamNames="0"
setSDXNs="0" isExplicit="0" ignoreRest="0" hasOptional="0"
needRest="0" needActivation="0" needArguments="0">
                <paramTypes/>
              </MethodInfo>
            </methods>
            <metadata/>
            <instances>
              <InstanceInfo nameIndex="1" superIndex="2"
hasProtectedNS="1" interface="0" final="0" sealed="0" protectedNS="3"
iInitIndex="1">
                <interfaces/>
                <traits/>
              </InstanceInfo>
            </instances>
            <classes>
              <ClassInfo cInitIndex="0">
                <traits/>
              </ClassInfo>
            </classes>
            <scripts>
              <ScriptInfo initIndex="2">
                <traits>
                  <TraitInfo nameIndex="1" override="0" final="0">
                    <trait>
                      <Class slotID="1" classInfo="0"/>
                    </trait>
                  </TraitInfo>
                </traits>
              </ScriptInfo>
            </scripts>
            <methodBodies>
              <MethodBody methodInfo="0" maxStack="1" maxRegs="1"
scopeDepth="4" maxScope="5" exceptionCount="0">
                <code>
                  <OpGetLocal0/>
                  <OpPushScope/>
                  <OpReturnVoid/>
                </code>
                <exceptions/>
                <traits/>
              </MethodBody>
              <MethodBody methodInfo="1" maxStack="1" maxRegs="1"
scopeDepth="5" maxScope="6" exceptionCount="0">
                <code>
                  <OpGetLocal0/>
                  <OpPushScope/>
                  <OpGetLocal0/>
                  <OpConstructSuper argc="0"/>
                  <OpReturnVoid/>
                </code>
                <exceptions/>
                <traits/>
              </MethodBody>
              <MethodBody methodInfo="2" maxStack="2" maxRegs="1"
scopeDepth="1" maxScope="4" exceptionCount="0">
                <code>
                  <OpGetLocal0/>
                  <OpPushScope/>
                  <OpGetScopeObject scopeIndex="0"/>
                  <OpGetLex name="3"/>
                  <OpPushScope/>
                  <OpGetLex name="2"/>
                  <OpPushScope/>
                  <OpGetLex name="2"/>
                  <OpNewClass classIndex="0"/>
                  <OpPopScope/>
                  <OpPopScope/>
                  <OpInitProperty name="1"/>
                  <OpReturnVoid/>
                </code>
                <exceptions/>
                <traits/>
              </MethodBody>
            </methodBodies>
          </Action3>
        </actions>
      </DoABCDefine>

Also another snippet right beside there somewhere:

<SymbolClass>
        <symbols>
          <Symbol objectID="1" name="MyFont"/>
        </symbols>
      </SymbolClass>

As you can see, it is not just a flag being set, the AVM is very
involved here, which sets up the entire class declaration and
definition and links it against the asset (usually just beside in the
same file, in a 'DefineFont3' tag, and also beside the 'SymbolClass'
tag).

If swfmill would automatically include the above snippets or similiar
for other kind of assets, we could safely say it is no longer just an
assembler, it would approach the intended domains of SamHaxe or a
generic SWF compiler.

But maybe it should do so?

I wish I had more time on my hands off commercial projects, I could
start patching it... :(

2009/11/6 Jonas Nyström <jonasnys at gmail.com>:
> Hi!
>
> Just want to underline what Armencho says here. Ideally, Swfmill should be
> THE tool for this kind asset compilation. It would be great if this case was
> solved.
>
> _______________________________________________
> swfmill mailing list
> swfmill at osflash.org
> http://osflash.org/mailman/listinfo/swfmill_osflash.org
>
>



More information about the swfmill mailing list