由於我的AS3和PHP/Java的知識不是很好,我就死在了這個問題。從動作腳本3發送可變數據給JavaScript
我有位圖數據發送到PHP文件來保存一些圖像的AS3功能,在這個功能我還添加了一些其他的參數和新的說法應該給我,我需要一個字符串值。
private function saveImageForFacebook(evt:MouseEvent)
// Sends the Bitmap data to php
{
var bitmapData:BitmapData=new BitmapData(wheelCanvas.width, wheelCanvas.height);
bitmapData.draw(wheelCanvas);
var jpgEncoder:JPGEncoder = new JPGEncoder(80);
var byteArray:ByteArray = jpgEncoder.encode(bitmapData);
var header:URLRequestHeader = new URLRequestHeader ("Content-type", "application/octet-stream");
var jpgURLRequest:URLRequest = new URLRequest ("http://www.someurl.com/flash-test/saveimg.php");
jpgURLRequest.requestHeaders.push(header);
jpgURLRequest.method = URLRequestMethod.POST;
jpgURLRequest.data = byteArray;
navigateToURL(jpgURLRequest, "_blank");
// Creates the string value that I need to use in saveimg.php
var suffixUrl:String = "";
for(var i:int=0; i < customizedColorArr.length; i++)
{
if(customizedColorArr[i] != "")
{
suffixUrl += "&" + customizedPartValueArr[i] + "=" + customizedColorArr[i];
}
}
suffixUrl = wheelName + "&variant_name=" + variantName + suffixUrl;
trace(suffixUrl);
}
不知怎的,我需要跟蹤我的saveimg.php文件中的「suffixUrl」值,但我不知道如何。
這是我的PHP文件的外觀和地方suffixUrl需要去。
<?php
if (isset ($GLOBALS["HTTP_RAW_POST_DATA"])) {
$uniqueStamp = date(U);
//$filename = "temp_image.jpg";
$filename = $uniqueStamp . ".jpg";
$fp = fopen($filename,"wb");
$result = fwrite($fp, $GLOBALS[ 'HTTP_RAW_POST_DATA' ]);
fclose($fp);
}
?>
<meta property="og:image" content="http://www.someurl.com/flash-test/src_server/<?php echo $filename ; ?>" />
<SCRIPT LANGUAGE="JavaScript">
function redirect() {
window.location.href = "http://www.facebook.com/sharer.php?u=http://www.someurl/flash-test/Main3D.html?"+suffixUrl, '_self';
}
</SCRIPT>
<BODY onload="redirect()">
你會在我的javascript函數中看到「suffixUrl」。那就是我試圖去探索這個價值的地方。
的問題是,我試圖傳遞的價值saveimg.php這我已經用它來保存在相同的圖片,功能。 –
http://www.someurl.com/flash-test/saveimg.php –