WEB开发网      婵犵數濞€濞佳囧磹婵犳艾鐤炬い鎰堕檮閸嬬喐銇勯弽銊с€掗梻鍕閺岋箑螣娓氼垱笑闂佽姘﹂褔婀佸┑鐘诧工妤犲憡绂嶉崜褏纾奸弶鍫涘妼缁楁岸鏌熷畡鐗堝殗闁诡喒鏅犲畷褰掝敃閵堝棙顔忔繝鐢靛仦閸ㄥ爼骞愰幘顔肩;闁规崘绉ぐ鎺撳亹闁绘垶锕╁Λ鍕⒑閹肩偛濡奸悗娑掓櫇缁顓兼径妯绘櫇闂佹寧绻傞弻濠囨晝閸屾稓鍘甸柣搴㈢⊕閿氶柣蹇ョ稻缁绘繃绻濋崘銊т紝闂佽鍨伴崯鏉戠暦閻旂⒈鏁傞柛鈾€鏅欑槐妯衡攽閻愬樊鍤熷┑顔藉劤铻為柛鏇ㄥ墯閸欏繘鏌嶉崫鍕櫣缂佲偓婢跺绠鹃柟瀛樼箘閿涘秵顨ラ悙顏勭伈闁诡喖缍婂畷鎯邦槻婵℃彃顭烽弻娑㈠Ω閵夈儺鍔夌紓浣稿€哥粔褰掑极閹剧粯鏅搁柨鐕傛嫹 ---闂傚倷鐒︾€笛兠洪埡鍛闁跨噦鎷�
开发学院图形图像Flash Official Facebook Actionscript API released –... 阅读

Official Facebook Actionscript API released – AS3 version

 2009-10-27 00:00:00 来源:WEB开发网 闂傚倷绶氬ḿ褍螞閹绢喖绠柨鐕傛嫹闂傚倷绀侀幉锟犲垂閻㈠灚宕查柟鎵閸庡秵銇勯幒鎴濃偓鐢稿磻閹炬枼妲堟繛鍡楃С濞岊亞绱撻崒姘扁枌闁瑰嚖鎷�婵犵數濮幏鍐川椤撴繄鎹曢梻渚€娼уú銈吤洪妸鈺佺劦妞ゆ帊鑳堕埊鏇㈡煏閸モ晛浠х紒杈╁仱閺佹捇鏁撻敓锟�闂傚倷绶氬ḿ褍螞閹绢喖绠柨鐕傛嫹  闂傚倷鑳舵灙缂佺粯顨呴埢宥夊即閵忕姵鐎梺缁樺姈椤愮厧鈽夊Ο閿嬬€婚梺褰掑亰閸撴稑鈻斿鑸碘拺闁告稑饪村▓鏃€绻涚仦鍌氬闁崇粯鎹囬獮瀣攽閹邦剚顔傛俊鐐€栧濠氬储瑜忛幉鎾晸閿燂拷
核心提示:This post contains a script made combining Official Facebook Actionscript API released! with Understanding Flash button component.package{importflash.display.Sp

This post contains a script made combining Official Facebook Actionscript API released! with Understanding Flash button component.

package {
 import flash.display.Sprite;
 import fl.controls.Button;
 import flash.events.MouseEvent;
 import flash.text.TextField;
 import com.facebook.data.users.GetInfoData;
 import com.facebook.utils.FacebookSessionUtil;
 import com.facebook.data.users.FacebookUser;
 import com.facebook.data.users.GetInfoFieldValues;
 import com.facebook.commands.users.GetInfo;
 import com.facebook.net.FacebookCall;
 import com.facebook.events.FacebookEvent;
 import com.facebook.Facebook;
 public class as3facebook extends Sprite {
  var my_text:TextField = new TextField();
  var fbook:Facebook;
  var session:FacebookSessionUtil;
  var user:FacebookUser;
  public var button_labels:Array = ["Click here to login into Facebook","Click here once you logged in into Facebook"];
  var my_button:Button;
  public function as3facebook() {
   addChild(my_text);
   my_text.width=460;
   my_text.x=20;
   my_text.y=100;
   my_text.text = "Facebook API test";
   for (var i:int=0; i<2; i++) {
    my_button=new Button();
    addChild(my_button);
    my_button.label=button_labels[i];
    my_button.setSize(250,30);
    my_button.move(125, i*40+10);
    my_button.addEventListener(MouseEvent.CLICK, clickHandler);
   }
   session=new FacebookSessionUtil("83ccead57ece4086338470a75e13c5b1","1fff6abf608e90e70e1aad07798aa8e4",loaderInfo);
   session.addEventListener(FacebookEvent.CONNECT,onConnect);
   fbook=session.facebook;
  }
  function clickHandler(event:MouseEvent):void {
   switch (event.currentTarget.label) {
    case "Click here to login into Facebook" :
     onLogin();
     break;
    case "Click here once you logged in into Facebook" :
     onConfirmLogin();
     break;
   }
  }
  private function onLogin():void {
   session.login();
  }
  private function onConfirmLogin():void {
   session.validateLogin();
  }
  private function onConnect(e:FacebookEvent):void {
   var call:FacebookCall=fbook.post(new GetInfo([fbook.uid],[GetInfoFieldValues.ALL_VALUES]));
   call.addEventListener(FacebookEvent.COMPLETE,onGetInfo);
  }
  private function onGetInfo(e:FacebookEvent):void {
   user=(e.data as GetInfoData).userCollection.getItemAt(0) as FacebookUser;
   my_text.text="Hello "+user.first_name+" "+user.last_name+" born on "+user.birthday;
  }
 
 }
}

And this is the result:

As in the Flex example, you should click the 2nd button (the one saying “Click here once…”) only when you get “You may now close this window and return to the application.” message on your FB page.

I am really excited for this new API and I can’t wait to include it in a game.

本文示例源代码或素材下载

Tags:Official Facebook Actionscript

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接