2011-05-31 61 views
0

我正在嘗試創建新的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); 
     } 
    } 
} 

我檢查了所有論壇,我沒有得到任何解決方案來糾正這些錯誤。請提前引導我。

回答

1
  1. 僅限Flash Player 8支持的ActionScript 2
  2. 您的文檔設置爲ActionScript中2

PS該類看起來很熟悉,P

+0

謝謝馬蒂·華萊士,我得到的只能從壓縮文件中獲得。是它的工作正常,但如果我在另一個文檔中使用相同的類,我得到以下錯誤。 Flash Player 8不支持2.0意味着什麼是解決這個錯誤的方法。 – Kannan 2011-05-31 06:05:59

+0

所有你需要做的是去**文件 - >發佈設置**。從這裏指定要使用Flash Player 9或更高版本,然後在旁邊的下拉列表中選擇ActionScript 3。 – Marty 2011-05-31 06:21:39