My favorites | Sign in
Logo
                
Search
for
Updated Aug 29, 2009 by zwetan
ConditionalCompilation  
Conditional compilation options explained.

Introduction

Even if we try to make our AS3 code as portable as possible we have to deal with different little nuggets

Usage

All conditional compilation options deal mainly with hosts and API differences

DO NOT USE THEM for dynamic configuration, eg. it will not replace the namespaces standard, optimized and experimental.

from the doc

You can use inline constants in ActionScript.

Boolean values can be used to conditionalize top-level definitions of
functions, classes, and variables,
in much the same way you would use an #IFDEF preprocessor command in C or C++.

You cannot use constant Boolean values to conditionalize metadata or import statements. 

for Flex Builder

 1. Project properties
 2. ActionScript Compiler
 3. in Additional compiler arguments

 -define+=TAMARIN::exclude,true -define+=TAMARIN::alternate,false

for mxmlc, compc

        <compc
            output="foobar.swc"
            include-classes="foobar.as"
            target-player="9.0.45"
        >
            <define name="TAMARIN::exclude" value="true" />
            <define name="TAMARIN::alternate" value="false" />
            <strict>true</strict>
            <optimize>true</optimize>

for ASDoc

        <exec executable="${asdoc.exe}">
        	<arg line="-define+=TAMARIN::exclude,true" />
        	<arg line="-define+=TAMARIN::alternate,false" />

for ASC

        <exec executable="java">
            <arg line="-jar ${redshell.asc}" />
            <arg line="-AS3 -strict -md -optimize" />
        	<arg line="-config TAMARIN::exclude=false -config TAMARIN::alternate=true" />

Options

TAMARIN::exclude

Excludes block of code when compiling for Tamarin/redtamarin

some examples:

/* reason:
   no TextField support in Tamarin
*/
TAMARIN::exclude
{
    suite.addTestSuite( TextFieldTargetTest );
}

TAMARIN::alternate

Allows to provide an alternative for Tamarin/redtamarin only.

TAMARIN::alternate will be replaced by API::RT_0_2_5 etc.

API versioning

Based on API Versioning in AVM from the Tamarin project, we will use the same naming convention.

constant description
API::FP_9_0 Flash Player 9.0
API::FP_10_0 Flash Player 10.0
API::FP_10_1 Flash Player 10.1
API::AR_1_0 AIR 1.0
API::AR_1_5 AIR 1.5
API::AR_1_5_1 AIR 1.5.1
API::AR_2_0 AIR 2.0

Technically we will almost never use API::FP_9_0 as this our default minimum version of the API (unless we have to isolate some code for tamarin), but as we want also to support command-line AS3 (via redtamarin) we need specialized API for that

(as Tamarin itself does not support all the features in the FP_9_0 API).

constant description
API::RT_0_1 redtamarin 0.1
API::RT_0_2 redtamarin 0.2
API::RT_0_2_5 redtamarin 0.2.5

We will mainly support redtamarin API but not Tamarin itself.

Contrary to the FP and RT API where each version is a subset of itself and zero or more other versions, the RT API works differently and can be totally incompatible and for those cases we will uses TAMARIN::exclude.

Proposals

These conditionals are not used yet


Sign in to add a comment
Hosted by Google Code