让我们使用this第一部分中的代码网站。我没有看到类声明,并且我的程序无法在 FlashDevelop 中构建。我收到以下错误消息:
Error: A file found in a source-path must have an externally visible definition. If a definition in the file is meant to be externally visible, please put the definition in a package.
Build halted with errors (fcsh).
我应该做什么才能构建和运行它?
最佳答案
如果您使用 Flash 开发和纯 AS3(无 Flex),那么所有内容都必须位于类和包中。
只需将该代码包装在自定义类中即可在 flashDevelop 中使用它。如果您在 flash 开发中创建一个新项目,大多数模板都会创建一个 Main.as 文件 - 这是项目加载时运行的根类,只需将代码转储到该 .AS 文件中定义的 Main 类中即可(除了导入,它们需要位于包和类声明之间)。
package {
//imports here
public class Main extends MovieClip {
//put any vars that aren't in functions here (eg. var mFileReference:FileReference)
public function Main():void {
//put anything not contained in a function here
}
//put the functions here
}
}
关于actionscript-3 - 没有类定义的Flash文件是如何编译的?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12060555/