【AS3】ベーシック認証

AS3のベーシック認証

var url:String = "URL";

var urlReq:URLRequest = new URLRequest(url); var base64Encoder:Base64Encoder = new Base64Encoder; base64Encoder.encodeUTFBytes("ID" + ":" + "パスワード"); var base64strings:String = base64Encoder.toString(); urlReq.requestHeaders = [new URLRequestHeader("Authorization", "Basic " + base64strings)];

var urlLoader:URLLoader = new URLLoader; urlLoader.addEventListener(Event.COMPLETE,onCompete); urlLoader.load(urlReq);

function onCompete(e:Event):void { var str:String = urlLoader.data as String; trace(str); }