3 Replies Latest reply on Dec 12, 2009 6:24 PM by LocheNis

    CSS embed resource using relative path

    LocheNis

      I'm trying to migrate a Flex 3 app to Flex 4 right now, but I've run into a problem with relative paths in embed directives in CSS files. I have the directory structure set up like this:

       

      src

      .../assets

      ....../images

      .........../testimage.gif

      ....../styles

      .........../styles.css

      .../com

      ....../test

      ........../main.mxml

       

      In main.mxml, I have:

       

      <mx:Style source="../../assets/styles/styles.css"/>

       

      In styles.css:

       

       

      .testButton {

      skin: Embed(source="../images/testimage.gif");

      }

       

       

      I'm getting "Invalid Embed directive in stylesheet - can't resolve source 'Embed(source = '../images/testimage.gif')" in styles.css

       

      Does anyone know why I'm getting this error?

       

      Thanks

        • 1. Re: CSS embed resource using relative path
          injpix Level 3

          If testButton is a Spark Button, then that will not work.  The CSS skin property has been replaced by skinClass, which its value must extend UIComponent.

          1 person found this helpful
          • 2. Re: CSS embed resource using relative path
            Peter Farland Level 3

            I tried your scenario using the Flex 4 SDK (sync'ed from SVN trunk) command line compiler and it compiled fine. I ran it like so: "mxmlc.exe com/test/main.mxml" and it produced "com/test/main.swf" and the Button successfully had the image style asset applied.

             

            Pete

            1 person found this helpful
            • 3. Re: CSS embed resource using relative path
              LocheNis Level 1

              Sorry I hadn't gotten around to posting the solution to my problem. It turned out it was a "bug", if I can call it that, with Flash Builder. After migrating my code from Flex 3 to 4, there were some relative embed paths in some mxml files that were broken, and somehow Flash Builder misinterpreted those errors as being in the CSS file. The "Problems" view in FB had over 100 of those errors, and the real ones got truncated due to the limit per group. Once I increased the limit, I saw the other errors and fixed those first. The CSS resource errors disappeared after that. According to my coworker, he once ran into a similar problem with Flex Builder 3 as well. The error report can sometimes be very misleading...