开发者

Failing to import a class in ActionScript

开发者 https://www.devze.com 2022-12-20 11:25 出处:网络
Here is the erro开发者_如何学Cr I get: 1046: Type was not found or was not a compile-time constant: fbAPI.

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

精彩评论

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