JSON エンコードおよびデコード用に AS 3.0 コードを作成しましたが、AS 2.0 で作成された以下のコードが必要です。AS 3.0 は知っていますが、AS 2 は知りません。
コードは次のとおりです。
stop();
var getFBId:String = ExternalInterface.call("getFBIdFromJS");
var getFBName:String = ExternalInterface.call("getFBNameFromJS");
import com.adobe.serialization.json.JSON;
import flash.events.Event;
import flash.net.URLLoader;
import flash.net.URLRequest;
import flash.net.URLRequestMethod;
import flash.net.URLVariables;
import fl.transitions.*;
import fl.transitions.Tween;
import fl.transitions.easing.*;
import fl.transitions.TweenEvent;
import flash.display.MovieClip;
import flash.events.MouseEvent;
playerInformation.visible = true;
var loginObj:Object = new Object();
var fbId:String = new String();
var Id:String = new String();
var varUid:String = new String();
var ImageUrl:String = new String();
var CreditBalance:String = new String();
//var PointBalance:String = new String();
var CoinBalance:String = new String();
var IsDailyBonus:String = new String();
var DailyBonusAmount:int = new int();
var fbvarsLoader:URLLoader = new URLLoader();
var fbvarsReq:URLRequest = new URLRequest("fbvars.php");
var fbvarsVariables:URLVariables = new URLVariables();
fbvarsLoader.dataFormat = URLLoaderDataFormat.VARIABLES;
fbvarsReq.method = URLRequestMethod.POST;
fbvarsReq.data = fbvarsVariables;
fbvarsLoader.load(fbvarsReq);
fbvarsLoader.addEventListener(Event.COMPLETE, receiveLoad);
function receiveLoad(evt:Event):void
{
fbId = getFBId;
varUid = getFBName;
ImageUrl = "https://graph.facebook.com/" + getFBId + "/picture";
trace (getFBId);
trace (getFBName);
trace (ImageUrl);
loginObj.FacebookId = fbId;
loginObj.UserName = varUid;
loginObj.PlatformId = 1;
loginReq.data = JSON.encode(loginObj);
loginLoader.load(loginReq);
trace("login ENCODE: " + JSON.encode(loginObj));
FBlogindata.text = JSON.encode(loginObj);
}
//--------------- FB Vars (E)
var serverURL:String = "http://serverURL";
var playerPicLoader:Loader = new Loader();
//--------------------------------
var loginReq: URLRequest = new URLRequest();
loginReq.method = URLRequestMethod.POST;
loginReq.url =
"http://serverURL";
var loginLoader:URLLoader = new URLLoader();
loginLoader.addEventListener(Event.COMPLETE, onComplete_login);
function onComplete_login(e_login:Event)
{
var loginReturn:Object=JSON.decode(e_login.target.data,true);
trace("login DECODE: " + e_login.target.data);
logindata.text = e_login.target.data;
if (loginReturn.Player.Status == "Valid")
{
Id = String(loginReturn.Player.Id);
CreditBalance = String(loginReturn.Player.CreditBalance);
var playerPic:URLRequest = new URLRequest(ImageUrl);
playerPicLoader.load(playerPic);
playerInformation.mcPlayerThumbHolder.addChild(playerPicLoader);
playerInformation.txtPlayerName.text = varUid;
playerInformation.txtPlayerCredit.text = CreditBalance;
playerInformation.visible = true;
UIDShow.text = Id;
FBIDShow.text = fbId;
if (this.parent.parent != null){
trace (CreditBalance);
MovieClip(this.parent.parent).credit = CreditBalance;
}
}
}
上記のコードを AS 2.0 で記述できる人はいますか?