Taking screenshot functionality in flex 3.5 was working but now it is not working

35 views Asked by At

Taking screenshot functionality was working in my application but now it is not working. The code I am using for taking screen shot in flex is as below:

I am using flex 3.5 SDK

private function captureScreenShot():void
{
    var jpgSource:BitmapData = new BitmapData (siteDisplayContainer.width, siteDisplayContainer.height); // siteDisplayContainer is the <mx:VBox> flex container 
    jpgSource.draw(siteDisplayContainer);

    var jpgEncoder:JPGEncoder = new JPGEncoder(85);
    var jpgStream:ByteArray = jpgEncoder.encode(jpgSource);

    var myDate:Date = new Date();
    var unixTime:Number = Math.round(myDate.getTime()/1000);

    var reqURL:String = parentApplication.imageDownloadScriptURL+unixTime+".jpg"; // imageDownloadScriptURL is the php file absolute path

    var header:URLRequestHeader = new URLRequestHeader("Content-type", "application/octet-stream");
    var jpgURLRequest:URLRequest = new URLRequest(reqURL);
    jpgURLRequest.requestHeaders.push(header);
    jpgURLRequest.method = URLRequestMethod.POST;
    jpgURLRequest.data = jpgStream;
    navigateToURL(jpgURLRequest, "_blank");
}

PHP file code for downloading flex screen shot:

<?php
if (isset($GLOBALS["HTTP_RAW_POST_DATA"]))
{
    // get bytearray
    $jpg = $GLOBALS["HTTP_RAW_POST_DATA"];

    // add headers for download dialog-box
    header('Content-Type: image/jpeg');
    header("Content-Disposition: attachment; filename=".$_GET['name']);
    echo $jpg;

    echo '<script TYPE="text/javascript">window.close();</script>';
}
?>

Since the data is binary, I don't know how I can debug this code. I do not know where exactly is the code failing. There cannot be any major error since this exact code was working till about 6 months back.

How do I debug this code? What can be the reason for the code not working?

1

There are 1 answers

0
Alex On

If it was working six months ago, have you checked your server settings for changes in the PHP version or security?

For testing the PHP, can you pass a binary into you it to verify that portion is working? For the flex side, I would setup the debugging version of flash player and then setup breakpoints and trace statements and just go through it and see if the flex debugging perspective and flash player give you any good debugging data to work with on narrowing down the culprit.