mxmlc embedding assets
Asked Answered
R

2

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?

Removal answered 8/6, 2011 at 12:0 Comment(0)
A
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.

Aphorism answered 20/6, 2012 at 16:51 Comment(0)
P
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?

Penitentiary answered 8/6, 2011 at 12:47 Comment(5)
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?"Removal
@Removal 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.Penitentiary
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.Removal
@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: <source-path path-element="${app.src.path}"/>. However in my case assets/foo is relative to Main.mxml.Aphorism
Oddly, though, if I change views/FooView.mxml to point to ../assets/foo.png instead of assets/foo.png, mxmlc will compile it.Aphorism

© 2022 - 2024 — McMap. All rights reserved.