如何Flash文件不类定义编译? [英] How are Flash files without class definitions compiled?

查看:111
本文介绍了如何Flash文件不类定义编译?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

让我们用code从<一个第一部分href="http://permadi.com/blog/2010/06/flash-as3-using-filereference-to-load-files-example-for-flash-cs4-and-above/"相对=nofollow>这个网站。我没有看到一个类的声明,我的程序不能建的FlashDevelop。我收到以下错误信息:

Let's use the code from the first section of this website. I don't see a class declaration, and my program cannot be built in FlashDevelop. I receive the following error message:

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).

我应该怎么做,以便能够建立和放大器;运行呢?

What should I do in order to be able to build & run it?

推荐答案

如果您使用的是Flash开发和纯AS3(没有弯曲),那么一切都必须在一个类和包。

If you're using flash develop and pure AS3 (no flex) then everything has to be in a class and package.

简单地用那只code在自定义类使用它的FlashDevelop。如果您在Flash中创建一个新的项目开发最模板创建一个Main.as文件 - 这是当你的项目负荷运行的根类,只是转储code在.AS文件中定义的主类中(除了进口,他们需要成为其间的包和类声明)。

Simply wrap that code in a custom class to use it in flashDevelop. If you create a new project in flash develop most templates create a Main.as file - which is the root class that runs when you're project loads, just dump the code inside the Main class defined in that .AS file (except for the imports, they'll need to be inbetween the package and class declarations).

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

    }

}

这篇关于如何Flash文件不类定义编译?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆