[ASC internals] How to define classes, properties and methods?

None of the standard classes are defined in ASC, thus, when compiling:

class A
{
}

The compiler fails saying the AS3::Object class (the “base” class) doesn’t exist.

But how to define it then, if there’s no way to define the Object class too? Have tried with a function definition too, but same:

function Object() {}

To compile with ASC you need the builtins definition
which you have by default when using MXMLC

the builtins are found in playerglobal.swc and airglobal.swc
but ASC is not able to compile against SWC libraries, you need to provide an ABC library

see flex-sdk/modules/asc/build/util/README.txt for example

also see Redtamarin - Compiling Programs wiki page

in the file flex-sdk/modules/asc/build/java/build.xml
you can see how the builtin.abc, playerglobal.abc etc. are built

for ex

    <target name="globalabc">
        <java classname="macromedia.asc.embedding.ScriptCompiler" fork="true" maxmemory="200M" dir="${avm.core}">
            <arg line="-builtin -out builtin builtin.as Math.as Error.as RegExp.as Date.as XML.as" />
            <jvmarg value="-ea" />
            <sysproperty key="AVMPLUS" value=""/>
            <sysproperty key="AS3" value=""/>
            <classpath>
                <pathelement location="${basedir}/../../lib/asc.jar"/>
            </classpath>
        </java>
        <copy file="${avm.core}/builtin.abc" tofile="${global.dest}" />
    </target>

Inside an AIR SDK you will find under the path frameworks/libs/air/
an airglobal.abc besides the airglobal.swc

in the project adobe/avmplus
you can find how the builtins are built and their sources

see

in short

  • to build the “builtins” with ASC, you use the param -builtin
  • you need to compile the builtins file in a specific order
    eg. builtin.as Math.as Error.as Date.as RegExp.as JSON.as XML.as ...
  • etc.

or you use an already built *.abc file

and then you use

$ java -jar asc.jar -AS3 -import builtin.abc helloworld.as
1 Like

Again after agains, thanks very much, Zwetan Kjukov. It’s interesting how AVMPlus supports some types above ActionScript 3.0, like float and float4.