3 Replies Latest reply: Sep 19, 2012 12:57 PM by Peter Farland RSS

    Embed path lookup in actionscript projects

    dmccluer

      The paths inside [Embed] metadata tags seem to be handled differently depending on if it's a pure Actionscript project or a Flex project.

       

      In a Flex project, I can create a tag like this:

      [ Embed(source="myAsset.png") ]

      And the compiler will search for the file myAsset.png at the root of the project

       

      In an actionscript project however (AIR or SWF) I get the following compiler error:

      DescriptionResourcePathLocationType
      Could not find Embed source 'myAsset.png'. Searched '/Users/doug/Documents/Adobe Flash Builder 4.7/asWebTest4.7/src/myAsset.png', 'embeds/myAsset.png' in SWCs on the library pathMain.as/asWebTest4.7/srcline 8Flex Problem

       

      In order to get Flash Builder to find the file, I must either supply an absolute path, or a path relative to the file containing the [Embed] tag. 

       

      This disconnect between Flex projects and Actionscript projects is problematic from a user experience perspective, and likely to cause confusion.  Also, this causes projects built in previous versions of Flash Builder to no longer compile.  The actionscript compiler should interpret Embed paths as relative to the project folder, IMO.  

       

      As a side note, the phrase "in SWCs on the library path" in the compiler error is confusing in my opinion as it seems to imply that the compiler is searching filepaths inside of SWCs somehow.  Perhaps it should say, "Searched '/Users/doug/Documents/Adobe Flash Builder 4.7/asWebTest4.7/src/myAsset.png', 'embeds/myAsset.png', and in SWCs on the library path" ?

        • 1. Re: Embed path lookup in actionscript projects
          Radhakrishna Bhat Community Member

          Hi,

           

          There is a change in new compiler on how it resolves [Embed] metadata paths. (refer http://bugs.adobe.com/jira/browse/FBG-4671 )

           

          The reason this behavior is different from Flex projects is they still use legacy compiler.

          • 2. Re: Embed path lookup in actionscript projects
            dmccluer Community Member

            unfortunately I don't have the necessary permissions to view that jira ticket.

             

            The path resolution in the new compiler has some drawbacks.

             

            1. Having to add a bunch of "../../../" to the source path makes for less readable code.

            2. Under the new scheme, any time you move a file, and potentially when you rename a package, you must update all the [Embed] metadata contained within. 

            3. Legacy projects will break in the new compiler.  It will not be possible to work on the same project in both FB 4.6 and FB 4.7

             

            Im not sure exactly what's going on under the hood, but it would sure be nice if Flash Builder could feed the compiler the project root as one of the locations to try resolving the path.

             

            [Edit] Or, if we had the option in 4.7 to specify which AIR SDK we wanted to use on a per-project basis

            • 3. Re: Embed path lookup in actionscript projects
              Peter Farland Adobe Employee

              Hi,

               

              You can refer to embedded assets either relative to the embedding file (though this is less portable, as you note) or relative to a rooted location (Mac/Unix OS root, source root(s), library-path SWC roots) using a leading forward slash (this is similar to how paths are used in HTML to refer to items from the webroot):

               

              [Embed(source="/embeds/myAsset.png")]

               

              The forward slash approach should work in 4.6 and 4.7.

               

              The special "Eclipse path" resolution is no longer supported in sourc ecode embedded paths in 4.7 (since those are not portable to command-line or ant builds).