Question

Ages ago I found a script that took data from Flash and would save the Flash stage as an image... for some reason this script does not work any more and I don't know why as it hasn't been modified.

This is the script;

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;

} else echo 'An error occured.';

This is the ActionScript;

function createPNG(fileName:String) { var PNGSource:BitmapData = new BitmapData (stage.stageWidth, stage.stageHeight, true, 0); PNGSource.draw(Pimp_mc);

var PNGStream:ByteArray = PNGEncoder.encode(PNGSource); 

var header:URLRequestHeader = new URLRequestHeader ("Content-type", "application/octet-stream");

//Make sure to use the correct path to jpg_encoder_download.php
var PNGURLRequest:URLRequest = new URLRequest ("jpg_encoder_download.php?name=" + fileName + ".png");       
PNGURLRequest.requestHeaders.push(header);              
PNGURLRequest.method = URLRequestMethod.POST;               
PNGURLRequest.data = PNGStream;

var PNGURLLoader:URLLoader = new URLLoader();       
navigateToURL(PNGURLRequest, "_self");

}

Any help would be appreciated.

Was it helpful?

Solution 3

It seems to be a problem with the embedded Flash Player on Chrome, called pepper.

If you use the non-embedded plugin it works: Install the external plugin of flash for non-IE browsers, enable the official plugin and disable the embedded one on the plugins configuration on Chrome and you will see it works.

For disable the plugin you need to type about:plugins on the url bar and press on the disable link below the pepper one. Check this screenshot (it's on spanish sorry).

http://s22.postimg.org/er165otch/flash_players_on_chrome.gif

After the change close and open the browser an try another time. The attachment will appear as in Firefox.

I'm sure this it's not a solution for you because the users of the website should do it manually, but it proves the problem it's on Chrome, not in your code.

This it's the bug on the Google Code page:
https://code.google.com/p/chromium/issues/detail?id=277210

On the previous link there it's a comment saying you can call to: ExternalInterface.call("window.open",url);

OTHER TIPS

This is an issue in IE now that it's updated to Flash 13.0.0.214 so not just a Chrome issue and most likely an issue even with the workaround mentioned above.

We've got the same issue with an internal tool we've developed so going to test with ExternalInterface.call("window.open",url); as suggested above.

Regards Liam

Flash 13.0.0.214 broke navigateToURL() when sending header information. Try remove the headers. Ref: https://forums.adobe.com/message/6391632

(Don't think this fix work in IE11 with Flash 13.0.0.214 on Win 8.1 (unless developer tools is activated), but good results for Chrome, FF and other IE.)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top