6

I'm trying complie my project via mxmlc this way:

[prj_folder]\src>mxmlc mymxml.mxml -library-path+=../libs -sp+=..\assets

and i get such errors:

[prj_folder]\src\view\controls\controlname.mxml(7): Error: Problem finding external st
ylesheet: assets/cssname.css
        <fx:Style source="assets/cssname.css"/>

[prj_folder]\src\view\constants\Images.as(24): col: 3: Error: Unable to transcode assets/ icons/icon1.png.

how to include assets for the compiler?

2xMax
  • 1,639
  • 6
  • 21
  • 41

2 Answers2

6

Flash Builder preprocesses the files.

For a directory structure like this:

projectdir/src/Main.mxml
projectdir/src/views/SomeView.mxml
projectdir/src/assets/MyImage.png

And if SomeView.mxml references assets/MyImage.png, Flash Builder will allow this:

@Embed('assets/MyImage.png')

because it is preprocessed to /assets/MyImage.png by the IDE, but ant/maven + mxmlc won't do that.

@Embed('/assets/MyImage.png')

works for both Flash Builder and mxmlc.

If you are using a relative path like this:

@Embed('../assets/MyImage.png')

try changing it to this, odd as it may seem:

@Embed('/../assets/MyImage.png')

The leading / gets translated to "my src directory", and mxmlc does the remainder of the path calculation from there.

Hope this helps.

Scott A
  • 7,745
  • 3
  • 33
  • 46
0

This is a directory setup issue; not a compiler error. And you aren't actually embedding assets; just referencing them.

When using Flash Builder, the file "assets/cssname.css" should be relative to the main application file. I believe the same should occur if you're using the command line compiler.

Does your source directory have an assets subdirectory? Is the cssname.css file inside it?

JeffryHouser
  • 39,401
  • 4
  • 38
  • 59
  • assets directory is located outside of the source folder(.-src folder, ../assets, ../libs - folder outside the source package). I aloso tried to move the assets to src, but it produces the same error. About "This is a directory setup issue; not a compiler error.". What is "directory setup issue"? Is Flash Builder uses mxmlc? so, my question is "how to pass the arguments to mxmlc to compile swf?" – 2xMax Jun 08 '11 at 13:53
  • @2xMax I believe you have your directories in the wrong location. That is what I mean by "Directory setup issue." I don't think you can store the assets directory outside of the source folder. The assets you want to reference from your Flex code should be relative to the Main application file; not above it. It's like putting an image outside of the web root and asking why it won't load in the web page. – JeffryHouser Jun 08 '11 at 14:24
  • Flesh Builder complies my project. Hence, assets can be located outside the project. P.S. I also wrote "I aloso tried to move the assets to src" above. – 2xMax Jun 09 '11 at 21:41
  • @www.Flextras.com I have the same issue as 2xMax: Flash Builder compiles the project fine, but I'm trying to create a build.xml to automate things. mxmlc can't find the assets folder in src: . However in my case assets/foo is relative to Main.mxml. – Scott A Jun 20 '12 at 16:29
  • Oddly, though, if I change views/FooView.mxml to point to ../assets/foo.png instead of assets/foo.png, mxmlc will compile it. – Scott A Jun 20 '12 at 16:34