开发者

Failing to import a class in ActionScript

Here is the erro开发者_如何学Cr I get:

1046: Type was not found or was not a compile-time constant: fbAPI.

Here is my MXML:

<?xml version="1.0" encoding="utf-8"?>
  <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" 
          creationComplete="startGame();">

  <mx:Script>
    <![CDATA[
      import fbAPI;
      public function startGame():void {
        var fbAPI:fbAPI = new fbAPI();   // breaks on this line
        fbAPI.fbLogin();
      }           
    ]]>
  </mx:Script>
</mx:Application>

And here is my fbAPI.as stub that doesn't seem to get imported:

package {
  public class fbAPI {
    import mx.controls.Alert;
    public function fbLogin():void {
     Alert.show('test');
    }
  }
}


Try putting your import statements above your class and also just rename the instance name of the fbapi in your mxml real quick.


Edit: nevermind, I forgot in AS3 you don't need a constructor.

Make sure you put the fbAPI.as file in the same location as your mxml file.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜