我怎麼能讀取的StageWebView中的Flex 4.6頁面的源代碼?如何從StageWebView中讀取頁面的源代碼中的Flex 4.6
我無法使用HttpRequest來讀取源代碼,因爲我的網址鏈接到另一個唯一的URL(對於每個人)包含會話和需要登錄,所以我想我有一種方法來使用StageWebView獲取頁面源,但我找不到任何方法或StageWebView類中的變量。
import mx.events.FlexEvent;
import mx.rpc.events.FaultEvent;
import mx.rpc.events.ResultEvent;
import mx.rpc.http.HTTPService;
private var webView:StageWebView;
private var httpReq:HTTPService;
private var urlVar:URLVariables;
private var session:String;
protected function creationCompleteHandler(event:FlexEvent):void
{
httpReq = new HTTPService();
httpReq.addEventListener(ResultEvent.RESULT, httpResult);
httpReq.addEventListener(FaultEvent.FAULT, httpFault);
httpReq.method = "POST";
httpReq.resultFormat = "text";
urlVar = new URLVariables();
urlVar.UserName = "test";
urlVar.Password = "test";
}
protected function httpResult(e:ResultEvent):void
{
trace(e.result);
trace("Done!");
}
protected function httpFault(e:FaultEvent):void
{
trace("Error!");
}
protected function addedToStageHandler(event:Event):void
{
webView = new StageWebView();
webView.stage = this.stage;
webView.viewPort = new Rectangle(0,0,stage.stageWidth,stage.stageHeight/2);
webView.loadURL("{URL}");
}
謝謝。