簡體   English   中英

導航開始后Flash NavigationToURL是否掛起?

[英]Flash navigateToURL hangs after navigation starts?

我在網頁中有一個Flash程序,試圖將圖片發布到網頁上。 當用戶單擊一個按鈕時,Web瀏覽器開始導航到新頁面,然后似乎掛起(我可以通過讀取Firefox狀態欄中的消息中的傳輸數據來看到它開始進入該頁面)

這似乎也可以在調試版本中工作,但不能在導出版本中工作。

Flash代碼:

var header:URLRequestHeader = new URLRequestHeader("Content-type", "application/octet-stream");
var jpgURLRequest:URLRequest = new URLRequest("http://myurl.com/webcam_upload.php");

jpgURLRequest.requestHeaders.push(header);
jpgURLRequest.method = URLRequestMethod.POST;
jpgURLRequest.data = encodedData;

try
{
    navigateToURL(jpgURLRequest, "_Self");
}
catch(e:Error)
{
    trace("error occured");
}

網頁:

<object width='534' height='450' type='application/x-shockwave-flash' data='flash/photobooth.swf'>
<param name='allowNetworking' value='all'>
<param name='allowScriptAccess' value='always'>
<param name='movie' value='flash/photobooth.swf'>       
<p>My stuff.</p>
</object>

您不想“導航到url”,因此NavigatorToURL不是您想要的。 您要做的是使用URLLoader以及標題和編碼的圖像來調用url。

// First create your URL variables — your encodedData
var variables:URLVariables = new URLVariables();
variables.image = encodedData;

// Secondly you need to create a URLRequest, passing the URLVariables and any header you want
var request:URLRequest = new URLRequest ("http://myurl.com/webcam_upload.php");
request.method = URLRequestMethod.POST;
request.data = variables;

// Finally you want to create the URLLoader, calling the URLRequest and listening to any listeners you want, ie COMPLETE...
var loader:URLLoader = new URLLoader();
loader.addEventListener (Event.COMPLETE, _onPostReturn, false, 0, true);
loader.load (request);

private function _onPostReturn(evt:Event):void {

       // This will trace the response upon completion.
       trace ( evt.target.data );

}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM