0
votes

I want to use SoundFacade class from Adobe. (Here, from github). I simple created an "ActionScript File" and paste all the code. But when I want to compile my app I got following error:

1037: Packages cannot be nested.

The only reason I can guess is that the package must somehow put into the project or something.

EDIT: Even when I just put a simple empty package I got the error:

package {

}

How to Reproduce the bug?

  • Create a new Flex Mobile Project.
  • Click New > ActionScript File
  • type package { }
  • include new package in one your views

code:

<fx:Script source="../SoundFacade.as" /> 

You will get the error

1
You likely have a syntax error in your package statement at the top of the class. The package statement probably appears twice. Show the package statement(s) at the top of your class, AND specify which directory (relative to your application's project) you've put the class on disk... Someone will then confirm what is wrong :) - Sunil D.
You can also try to check for { and } matching, I'm not sure, but I think I had similar error because of {}. - user1875642
There is no syntax error. Even when I just put an empty package I get the error. - bman
Pasted code from github, works perfectly fine. Clean you project, it always helps - randomUser56789
Clean did not help. Did you test this yourself out? I added how to reproduce the error. - bman

1 Answers

0
votes

I find the solution. I was actually unaware of the package naming rule. Here is the answer to this problem: http://forums.adobe.com/message/4299377

The tag will insert your SoundFacade.as file into the MXML file (similar to an include in C/C++). That will cause an invalid syntax.

Give your package a name (in this case it should be called SoundFacade because that is the name of the folder it is in) then use the import statement inside your script tag. Make sure you adhere to the recommended file, namespace, package and class naming structure. That's usually a reverse-DNS style: com.adobe.utils.bla.bla.bla.

If package name is blank and the source is in the default folder, you don't need to import it.