Skip to main content
Participant
June 7, 2013
Question

Can't use compiler constant to set source for embed tag in ASC2.0

Hi.

I'm poring an application to ASC2.0. The code I'm talking about is being compiled as a flash movie, but I'm sure it applies to AIR also.

So we have some code like this:

class Test

{

  [Embed(source=CONFIG::FILE,mimeType="application/octet-stream")]

  private var TextClass:Class;

  public function test():String

  {

    var ba:ByteArray = new TextClass();

    var str:String = ba.readUTFBytes(ba.length);

    return str;

  }

}

CONFIG::FILE is set as compiler options like this

    <define append="true">

      <name>CONFIG::FILE</name>

      <value>'../../../../TEXT.txt'</value>

    </define>

This code compiles, but at runtime, the TextClass is null. If I replace the embed line with this, it works.

[Embed(source="../../../../TEXT.txt",mimeType="application/octet-stream")]

If I change the source string location, compilation fails. If I change the content of the compile constant, it does not fail, regardless if it points to a correct location or not.

Seems like another ASC2.0 bug. I suggest to open a forum that deals with ASC2.0 specifically.

This topic is closed to new replies. Start a new post to keep the conversation going.