Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

Embedded images causes compilation failure

Fx2Ant
2009-08-18
2013-04-29
  • Rob Brueckmann
    Rob Brueckmann
    2009-08-18

    I just downloaded and installed the Clear Toolkit.  The first thing I attempted was the Fx2Ant utility...it successfully generated my build files but when I attempt to build through the Eclipse interface by right-clicking the flex2ant-build.xml file and selecting Run As...Ant Build, it fires up and fails with a whole slew of errors related to images I have embedded in my application similar to the following:

    C:\bea103\user_projects\workspaces\merlinpb-upgrade\merlinpb - flex3\merlinpbWebApp\flex_src\com\merlinpb\view\tradeManagement\TradeEntry.mxml(837): Error: unable to resolve '../WebContent/images/calculator.png' for transcoding
         [java]                                 <mx:LinkButton toolTip="Fills" icon="@Embed('../WebContent/images/calculator.png')" tabEnabled="false"/>
         [java] C:\bea103\user_projects\workspaces\merlinpb-upgrade\merlinpb - flex3\merlinpbWebApp\flex_src\com\merlinpb\view\tradeManagement\TradeEntry.mxml(837): Error: Unable to transcode ../WebContent/images/calculator.png.
         [java]                                 <mx:LinkButton toolTip="Fills" icon="@Embed('../WebContent/images/calculator.png')" tabEnabled="false"/>

    The thing is, when I compile my application using just Eclipse, it works just fine and has been all along...am I doing something wrong?  Is there some configuration for FX2Ant that needs setting to properly resolve and transcode these image files?  The flex2ant-build.properties file all looks in order, so I'm not sure what's going on.  Any help is greatly appreciated.

    Thanks!
    Rob

     
    • Rob,

      WebContent is an output area. Please keep your images under flex_src/assets.

      Kind Regards,
      Victor

       
      • Rob Brueckmann
        Rob Brueckmann
        2009-08-20

        Victor -

        I moved all of my images I am using the 'Embed' descriptor for to an 'assets' folder within my flex_src directory, as per your suggestion, and tried Fx2Ant and it still wasn't working until I went through and changed every single Embed statement to point to the absolute directory location of the image files...originally they were all something like:

        icon="@Embed('assets/calculator.png')"

        but the compilation would not work until I changed it to something like:

        icon="@Embed('../../../../assets/calculator.png')"

        Why does the embedded FlexBuilder compiler know how to resolve the first one with the relative assets folder references, but the command-line mxmlc compiler used by the Fx2Ant build script need the absolute path to all the images...this is kind of annoying.  Is this a Fx2Ant thing or an mxmlc thing?

        Also - if I don't want to embed every single image - some of them I want to externally reference, in those situations, is it ok to leave those files in the images directory in my WebContent folder?  You said that's an output folder and made me think it's not ok to have anything in there...but I can't think of any other way to structure the app and the images still be available to the Flex app.

        Thanks for your help.

         
        • Rob,

          a) Obviously Fx2Ant is agnostic to paths.
          b) Having "assets" as the child of the src (or flex_src) should be totally sufficient as long as you leave "Copy non-embedded file to the output folder" FB Flex compiler check on

          Kind regards,
          Victor