2 Replies Latest reply on Oct 22, 2009 8:32 AM by msakrejda

    flex/facebook API question

    mjpsammon

      i'm using the actionscript API for facebook to build an application.

      in the API there's a class called FacebookUser().  i'd like to add

      fields to this class by extending it.

       

      here's my AS file that extends it:

      package objects
      {
              import com.facebook.data.users.FacebookUser;

              public class MyFacebookUser extends FacebookUser
              {

                      public var phone_number:String;
                      public var registered:Boolean;

                      public function MyFacebookUser():void
                      {
                              super();
                              phone_number = "";
                              registered = false;
                      }

              }

       

      }

       

      here's where i cast the returned data using MyFacebookUser():

       

      import objects.MyFacebookUser;

      private function handleGetFriendsInfoResponse(e:FacebookEvent):void {
              var freindsInfoResponseData:GetInfoData = GetInfoData(e.data);
              if (!freindsInfoResponseData || e.error){ // an error occurred
                      status.text = "Get Friends Info Error";
                      return;
              }

              facebookFriendsInfoArr = new ArrayCollection();
              var len:uint = freindsInfoResponseData.userCollection.length;
              for(var i:uint = 0; i < len; i++) {
                      var userFriend:MyFacebookUser = MyFacebookUser (freindsInfoResponseData.userCollection.getItemAt(i));
                      userFriend.phone_number = "908-555-1212";
                      facebookFriendsInfoArr.addItem(userFriend);
              }

       

      }

       

      when i execute the code i get the following error:

      TypeError: Error #1034: Type Coercion failed: cannot convert
      com.facebook.data.users::FacebookUser@f7e2a01 to
      objects.MyFacebookUser.
              at AvayaFBConf/handleGetFriendsInfoResponse()[C:\Documents and Settings\mjps\My Documents\Flex Builder 3\AvayaFBConf\src \AvayaFBConf.mxml:103]
              at flash.events::EventDispatcher/dispatchEventFunction()
              at flash.events::EventDispatcher/dispatchEvent()
              at com.facebook.net::FacebookCall/http://api.facebook.com/ 1.0/::handleResult()[/Users/wgorgichuk/Documents/Projects/ Facebook_API_Google_svn/trunk/source/actionscript/com/facebook/net/
      FacebookCall.as:83]
              at com.facebook.delegates::WebDelegate/handleResult()[/Users/wgorgichuk/Documents/Projects/F acebook_API_Google_svn/trunk/source/
      actionscript/com/facebook/delegates/WebDelegate.as:181]
              at com.facebook.delegates::WebDelegate/onDataComplete()[/Users/wgorgichuk/Documents/Projects /Facebook_API_Google_svn/trunk/source/
      actionscript/com/facebook/delegates/WebDelegate.as:160]
              at flash.events::EventDispatcher/dispatchEventFunction()
              at flash.events::EventDispatcher/dispatchEvent()
              at flash.net::URLLoader/onComplete()

       

      this seems to be a type conversion error.
      what am i doing wrong?

      TIA