0

I want to build a flex library project directly through the mxmlc compiler. My library has one .as file and it is under a package call com.test

package com.test { public class Main {  public function Main(){...

I run the following command on the cmd

D:\4.11.0\bin\mxmlc D:\TestLibrary\src\com\test\Main.as

But it gives me the following error

Error: A file found in a source-path must have the same package structure '', as the definition's package, 'com.test'

If I remove the package definition from the script as follows, it works.

package { public class Main { ...

My question is why this happen and how to fix it?

ANJ
  • 301
  • 1
  • 2
  • 14

2 Answers2

2

You need to additionally tell the compiler the root of your sources:

mxmlc D:\TestLibrary\src\com\test\Main.as -source-path D:\TestLibrary\src\

by providing the "source-path" property you are telling the compiler where the root is and releative from that it now should know that com.test.Main is the relative path to your class.

Christofer Dutz
  • 2,305
  • 1
  • 23
  • 34
  • Thanks, It works now. I want to build a swc of the library project, but this command makes a swf file. How can I make a swc file? – ANJ Sep 23 '14 at 07:47
  • Well mxmlc is for compiling swfs, if you want to compile a swc, use compc instead (http://help.adobe.com/en_US/flex/using/WS2db454920e96a9e51e63e3d11c0bf69084-7ad5.html) – Christofer Dutz Sep 23 '14 at 08:22
0

Thanks Charisofer, Finally I could build the library project and make the swc file. This is the command I used. Hope it will help for others.

D:\4.11.0\bin\compc -source-path D:\TestLibrary\src -include-sources D:\TestLibrary\src\com\test\Main.as -debug=false -output D:\Auto_Release\main.swc

To build swf, need to use mxmlc

To build swc need to use compc

ANJ
  • 301
  • 1
  • 2
  • 14