2 Replies Latest reply on Nov 9, 2007 1:02 PM by aib42

    [Embed] search path

    aib42
      Hi, I have a few embedded assets:

      [Embed(source="button.png")] private var btnImg:Class;
      var b:Bitmap = new btnImg() as Bitmap;

      However, I can't seem to add something to the search path that the Embed tag uses to locate resources.

      There's the additional problem that my .as file is referenced from another file, e.g:

      project1\MyButton.as -- has the embed tag
      project2\client.as -- has a MyButton() control
      project2\skin\* -- is where Embed[] should look for assets, including those found in MyButton.as

      this is my command line:

      %SDKPATH%\bin\mxmlc.exe %SRCFILE% -compiler.source-path=%COMMON_CLASSES%

      Where SDKPATH is where the flex-2.0.1 SDK is, SRCFILE is the full path to 'client.as' and COMMON_CLASSES refers to the 'project1' directory. Ideally, I should be able to add another parameter:

      -compiler.embed-path=c:\project2\skin

      and have the MyButton inside client.as read its resources from there...
        • 1. Re: [Embed] search path
          ntsiii Level 3
          Remember that Embed is a compile-time only process. The assets have to be available , usually via relative path.
          [Embed(source="..\assets\button.png")] private var btnImg:Class;

          I do not recall whether the compiler uses the source-path to find assets. the docs should say.

          Tracy
          • 2. Re: [Embed] search path
            aib42 Level 1
            Yes, but the problem is that the relative path is relative to the source file...

            1) common_classes/CoolButton.as [uses img/cool1.png]
            2) project1/TwoButtons.as [uses img/background.png]

            When I try to compile TwoButtons, the compiler is looking for "common_classes/img/cool1.png" and "project1/img/background.png".

            However, I want the CoolButton class to be fully generic, and thus use skins from inside the project folder, i.e. "project1/img/cool1.png".

            There _has_ to be a way to change the embed search path. I don't want to maintain N different copies of my common classes just because they use N different embedded assets.