【问题标题】:Imported classes not loaded properly导入的类未正确加载
【发布时间】:2011-05-31 14:00:05
【问题描述】:

我正在尝试创建一个新的 Flash 电影。我正在使用 CS4 发布电影 -> flash 8 - AS-> 3.0 。我的问题是,如果我发布电影,我会收到以下编译器错误 - >

ActionScript 2.0 class scripts may only define class or interface constructs.
Attribute used outside class.
The class or interface 'flash.net.URLVariables' could not be loaded.
The class or interface 'flash.net.URLRequest' could not be loaded.
The class or interface 'flash.net.URLLoader' could not be loaded.
The class or interface 'flash.events.Event' could not be loaded.
The class or interface 'flash.net.URLVariables' could not be loaded.
ActionScript 2.0 class scripts may only define class or interface constructs.
The class or interface 'URLVariables' could not be loaded.

我正在使用此代码。

   package
{   

    import flash.net.URLRequest;
    import flash.net.URLLoader;
    import flash.net.URLVariables;
    import flash.net.URLRequestMethod;
    import flash.events.Event;


    public class PHPData extends Object
    {

        public function send(script:String, vars:URLVariables):void
        {
            var req:URLRequest = new URLRequest(script);

            req.data = vars;
            req.method = URLRequestMethod.POST;

            var loader:URLLoader = new URLLoader();
            loader.load(req);


            loader.addEventListener(Event.COMPLETE, _complete);
        }


        private function _complete(e:Event):void
        {
            var vars:URLVariables = new URLVariables(e.target.data);

            var i:String;
            for(i in vars)
            {
                trace(i + ": " + vars[i]);
            }

            e.target.removeEventListener(Event.COMPLETE, _complete);
        }
    }
}

我查看了所有论坛,但没有找到任何解决方案来纠正这些错误。请指导我提前谢谢。

【问题讨论】:

    标签: flash


    【解决方案1】:
    1. Flash Player 8 仅支持 ActionScript 2。
    2. 您的文档设置为 ActionScript 2。

    PS 这个类看起来很眼熟;P

    【讨论】:

    • 谢谢你,Marty Wallace,我只从你的压缩文件中得到了这门课。是的,它工作正常,但如果我在另一个文档中使用相同的类,我会收到以下错误。 Flash Player 8 不支持 2.0 意味着有什么办法可以解决这个错误。
    • 您只需转到文件 -> 发布设置。从这里指定您要使用 Flash Player 9 或更高版本,然后在旁边的下拉列表中选择 ActionScript 3。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-07-21
    • 2020-11-23
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多