There was an older syntax which was specific to the 'runtime' property, and
the new syntax
can check any compile-time constant property.

So you can actually say

<when property="runtime" value="swf9">

Which I think would be the best way

e.g.,

<switch>
  <when property="runtime" value="swf9">
    <text>runtime is swf9</text>
  </when>
  <when property="runtime" value="swf10">
    <text>runtime is swf10</text>
  </when>
  <otherwise>
    <text>some other  runtime</text>
  </otherwise>
</switch>

"as3" is more of a language selector than a specific runtime, just as "as2"
and "js1" would be.

The compiler sets these constants, which can be checked at compile time

  boolean setRuntime(String runtime) {
    if (! ("dhtml".equals(runtime) || "j2me".equals(runtime) ||
"svg".equals(runtime) ||
           "swf9".equals(runtime) || "swf10".equals(runtime) ||
           "swf7".equals(runtime) || "swf8".equals(runtime))) {
      usage("runtime must be one of swf7, swf8, swf9, swf10, dhtml, j2me,
svg");
      return false;
    }
    compileTimeConstants.put("$runtime", runtime);

    // Kludges until compile-time constants can be expressions
    compileTimeConstants.put("$swf7",
Boolean.valueOf("swf7".equals(runtime)));
    compileTimeConstants.put("$swf8",
Boolean.valueOf("swf8".equals(runtime)));
    compileTimeConstants.put(
      "$as2",
      Boolean.valueOf("swf7".equals(runtime) || "swf8".equals(runtime) ));
    compileTimeConstants.put("$swf9",
Boolean.valueOf("swf9".equals(runtime)));
    compileTimeConstants.put("$swf10",
Boolean.valueOf("swf10".equals(runtime)));
    compileTimeConstants.put("$as3", Boolean.valueOf("swf9".equals(runtime)
|| "swf10".equals(runtime)));
    compileTimeConstants.put("$dhtml",
Boolean.valueOf("dhtml".equals(runtime)));
    compileTimeConstants.put("$j2me",
Boolean.valueOf("j2me".equals(runtime)));
    compileTimeConstants.put("$svg",
Boolean.valueOf("svg".equals(runtime)));
    compileTimeConstants.put(
      "$js1",
      Boolean.valueOf("dhtml".equals(runtime) || "j2me".equals(runtime) ||
"svg".equals(runtime)));

    compilerOptions.put(Compiler.RUNTIME, runtime);
    return true;
  }


On Wed, Aug 19, 2009 at 4:57 PM, Raju Bitter <[email protected]> wrote:

> Henry,
>
> why is it that you can say:
>
> <switch>
>  <when runtime="dhtml">
>
> for testing for DHTML runtime, but for SWF9 you have to say
>
> <switch>
>  <when property="as3">
>
> Is there a good reason for not supporting:
>
> <when runtime="swf9">
>
> What if we have swf9 and swf10 specific code?
>
> - Raju
>



-- 
Henry Minsky
Software Architect
[email protected]

Reply via email to