Author Topic: Taking screenshot of the game  (Read 949 times)

rudystyle

  • Member
  • **
  • Posts: 19
  • Karma: +0/-0
    • View Profile
Taking screenshot of the game
« on: Thu, May 3, 2012 »
I used the following code to take a screenshot of he game.
Code: [Select]
var screenshotData:BitmapData = new BitmapData(600, 400);
screenshotData.draw(FlxG.stage);

The code works  fine on my local machine and I get the screenshot of the game, however when i upload it to any website it doesnt work. screenshotData.draw() doesnt get executed at all. What maybe the problem ?

photonstorm

  • Administrator
  • Key Contributor
  • *****
  • Posts: 1502
  • Karma: +1/-0
    • View Profile
    • Photon Storm
Re: Taking screenshot of the game
« Reply #1 on: Thu, May 3, 2012 »
There's nothing wrong with the code. draw() is perfectly valid no matter where the SWF is running. What's not allowed is using a FileReference to save the screen shot unless the call to that op came explicitly from a MouseEvent listener.
http://www.photonstorm.com



"Tell me and I will forget, show me and I might remember, involve me and I will understand" - Confucius

rudystyle

  • Member
  • **
  • Posts: 19
  • Karma: +0/-0
    • View Profile
Re: Taking screenshot of the game
« Reply #2 on: Fri, May 4, 2012 »
Thanks photonstorm . I am not saving the file , just posting it to another website. As you said draw()  should work and it does work on my local machine, just doesn't work when i upload it. Boggles me.

photonstorm

  • Administrator
  • Key Contributor
  • *****
  • Posts: 1502
  • Karma: +1/-0
    • View Profile
    • Photon Storm
Re: Taking screenshot of the game
« Reply #3 on: Fri, May 4, 2012 »
The only reason draw would fail when uploaded is if the stage contains elements not part of the local swf. I.e. you downloaded some external assets and put them on the stage. Then you're invoking sandbox security issues, so look at that.
http://www.photonstorm.com



"Tell me and I will forget, show me and I might remember, involve me and I will understand" - Confucius