最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

html - Javascript take screenshot of flash object - Stack Overflow

programmeradmin2浏览0评论

basically what i want to do is this:

I have a flash game on a page (pacman for example)

I want to be able to take a print screen of that game using javascript

Is it possible? I know i can include the game swf in a nother swf and capture the screenshot using flash but i need it to be done in javascript. is this possible?

basically what i want to do is this:

I have a flash game on a page (pacman for example)

I want to be able to take a print screen of that game using javascript

Is it possible? I know i can include the game swf in a nother swf and capture the screenshot using flash but i need it to be done in javascript. is this possible?

Share Improve this question asked Oct 20, 2010 at 1:08 OzzyOzzy 10.7k28 gold badges98 silver badges140 bronze badges 2
  • Javascript cannot take a screen shot. – Prescott Commented Oct 20, 2010 at 1:37
  • Hello Ozzy, I am dealing with similar problem. You say it's possible to include swf in another swf. Can you point me to some example ? – Skuta Commented Jun 2, 2012 at 14:26
Add a ment  | 

2 Answers 2

Reset to default 3

If you control both the host page and the flash movie, then you can generate the screenshot in flash, and simply send it to javaScript, and then do whatever you need with it in javaScript.

In ActionScript:

import flash.external.ExternalInterface;
ExternalInterface.call("showBase64Image", generateBase64Screenshot());
// see this Mario Klingenmann's file for ideas how to do that http://www.quasimondo./archives/000572.php

And then in javaScript:

function showBase64Image(base64data) {
    var img = document.createElement('img');
    img.src = base64data;
    document.body.appendChild(img);
}

P.S. don't forget to allowScriptAccess for embedded Flash, to allow Flash movie to access the javaScript on your page (which is definitely not wise if the Flash movie is made by a 3rd party).

On the other hand, if you do not control the flash movie (for instance if you wanna make a website that'll host 3rd party Flash games) then you're out of luck, and what you need is not doable with javaScript alone, and it can only be achieved through use of browser plugins/extensions.

If it is your game and your website (in other words if you can modify both) try this:

http://danielmclaren/2008/03/use-javascript-to-take-a-screenshot-of-a-flash-movie

发布评论

评论列表(0)

  1. 暂无评论