很笨很惱人又不值一提的問題: Packages cannot be nested. (更新)

Flash AS3初體驗: 一開始就遇到 “1037:Packages cannot be nested.” 在網路上找半天都沒有明確的答案。其實答案很簡單。package{public class test {}} 一定要存在external .as (比如說 123.as)然後再導入。接著在Flash CS3 property 裡的Document class 欄位填入該 class檔名test(如果在同一個檔案夾,這樣就可以,如果不同,以 “.”銜接相關路徑。如果Package 不是unnamed, 則是packageName. calssName)即可。因為很笨很惱人又不值一提,只好在我這個門外漢這裡提出。(注意大小寫)

1037:Packages cannot be nested- To solve this problem: all packages have to be saved as an external .as file (eg: 123.as), and you can simply associate your fla to this .as file by putting the class name (eg: ClassName, or packageName.yourClassName) in the “Document Class” field on property panel.

** packages the directory paths to your external .as files; if your .as and .fla are in same directory leave it as it is; if not, just write relative the path with dots;

注意: Every AS3 script starts with the word package. 這是和As2最大的不同。

Comments

comments

2 thoughts on “很笨很惱人又不值一提的問題: Packages cannot be nested. (更新)”

  1. 剛剛看了一下討論區,有人這麼回答 (大家愈改愈像 Java 了):

    You don’t need the first script tag, the reference to the class file will be worked out from the names. I think when you import the script you are already in a default package, so when it sees the package declaration in the source file it throws the nesting error.

    I think you also need to import multiupload.*; as you need to import the actual classes not the package itself (similar to Java). Alternatively you could replace * with the specific class name (e.g. “import multiupload.MultiUpload;”).

    http://www.adobe.com/cfusion/webforums/forum/messageview.cfm?forumid=60&catid=585&threadid=1286925&enterthread=y

  2. Fish, 我去看了你提供的連結,看起來是比較針對Flash cs3 vs. Flex2. 我把第二個package sample先移除了,因為,不懂得人會越看越不懂低。待我更了解後再來補充好了。

Leave a Reply

Your email address will not be published.

*