不可见的 Flash:通过使用不可见的 Flash Player 增强 Web 应用程序
2010-07-09 00:00:00 来源:WEB开发网清单 5. 跨域工具 SWF
package{
import flash.display.Sprite;
import flash.events.Event;
import flash.external.ExternalInterface;
import flash.net.URLLoader;
import flash.net.URLRequest;
public class JsHelper extends Sprite{
private const SEND_REQUEST:String = "sendRequest";
public function JsHelper(){
ExternalInterface.addCallback(SEND_REQUEST, sendRequest);
}
public function sendRequest(url:String, handlerName:String,
method:String="GET", content:Object=null,
headers:Object=null):void{
var loader:URLLoader = new URLLoader();
var request:URLRequest = new URLRequest(url);
if (method){
request.method = method;
}
if (headers){
for each (var name:String in headers){
request.requestHeaders[name] = headers[name];
}
}
if (content){
request.data = content;
}
loader.addEventListener(Event.COMPLETE,
function(e:Event):void{
ExternalInterface.call(handlerName, loader.data);
});
loader.load(request);
}
}
}
更多精彩
赞助商链接