Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/479.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/silverlight/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
将变量数据从动作脚本3发送到JavaScript_Javascript_Actionscript 3 - Fatal编程技术网

将变量数据从动作脚本3发送到JavaScript

将变量数据从动作脚本3发送到JavaScript,javascript,actionscript-3,Javascript,Actionscript 3,由于我的AS3和Php/Java知识不太好,我在这个问题上陷入了困境 我有一个AS3函数,它将位图数据发送到PHP文件以保存一些图像,在这个函数中,我还添加了一些其他参数,新参数应该给我一个我需要的字符串值 private function saveImageForFacebook(evt:MouseEvent) // Sends the Bitmap data to php { var bitmapData:BitmapData=new BitmapData(

由于我的AS3和Php/Java知识不太好,我在这个问题上陷入了困境

我有一个AS3函数,它将位图数据发送到PHP文件以保存一些图像,在这个函数中,我还添加了一些其他参数,新参数应该给我一个我需要的字符串值

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文件中跟踪SUFFEXURL值,但我不知道如何跟踪

这就是我的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函数中看到SUFFEXURL。这就是我试图处理该值的地方。

假设您的php文件是嵌入Flash的文件,您可以使用ExternalInterface从Flash调用重定向函数

闪光:

ExternalInterface.call("redirect", suffixUrl);
注意:需要导入flash.external.ExternalInterface

JavaScript:

function redirect (suffixUrl) {
     window.location.href = "http://www.facebook.com/sharer.php?u=http://www.someurl/flash-test/Main3D.html?" + suffixUrl;
}

您不想向Javascript发送变量;您希望向PHP发送一个变量

将后缀生成代码块移到位图发送部分上方,然后更改此行

var jpgURLRequest:URLRequest = new URLRequest ("http://www.someurl.com/flash-test/saveimg.php?suffixUrl=" + suffixUrl);
然后,在PHP中


这会起作用,但为了安全起见,您还必须对输入进行清理。

问题是,我正在尝试将该值传递给saveimg.php,我已经在使用它将图像保存在与函数相同的位置。
window.location.href = "http://www.facebook.com/sharer.php?u=http://www.someurl/flash-test/Main3D.html?" + <?php echo $_GET['suffixUrl'] ?>, '_self';