July 31st, 2007

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

Posted in Work . 用功, flash by pei 2,388 views

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最大的不同。

* * *
You can leave a comment, or trackback from your own site. RSS 2.0 del.icio.us this

RSS feed | Trackback URI

2 Comments »

Comment by fish
2007-07-31 21:06:31

剛剛看了一下討論區,有人這麼回答 (大家愈改愈像 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

 
Comment by pei
2007-08-01 09:29:40

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

 
Name
E-mail
URI
Your Comment (smaller size | larger size)
You may use <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> in your comment.
現在可以貼圖貼影片喔(flash, youtube只要直接把embed的code整個貼上即可)!Now you can comment with graphics, links and videos!

如沒有登入 請回答上面的加法
android bike blackberry book Curve 8300 design HTC movie museum music new year new york photo plugin podcast Read . 囫圇讀 show snowboard Taiwan wordpress 公告 台灣 工作 廢文 心得 感想 感言 懶人料理 找工作 料理 新年 日劇 滑雪 真人版 紐約 綠卡 美國工作 設計 讀書心得 賀年卡 近況 閱讀 電影 食譜 黑莓