截图并发送
如何以编程方式截取 Flash 应用程序的屏幕截图,并将位图发送到服务器? - 不使用 javascript,仅使用 Actionscript
How do you programmatically take a screenshot of a Flash app, and send the bitmap to server? - without using javascript, just Actionscript
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
截取屏幕截图就像绘制到
BitmapData
对象中一样简单。类似于:将
this.stage
替换为您想要绘制的任何DisplayObject
。查看BitmapData
文档:http ://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/BitmapData.html#draw()将其发送到服务器取决于您连接到服务器的方式。如果它可以接受来自 BitmapData 的原始数据,那么就接受它。否则,使用 as3corelib 中的
JPEGEncoder
或PNGEncoder
对其进行编码:https://github .com/mikechambers/as3corelib。您可以通过 PHP 上传它,或者将图像中的
ByteArray
数据写入URLRequest
。这里写起来有点复杂(它涉及多部分/表单数据)。了解其工作原理的最简单方法是查看 Facebook AS3 API,其中可以进行图像上传:http: //code.google.com/p/facebook-actionscript-api/(查看FacebookRequest
类中的call()
函数)Taking a screenshot is as simple as drawing into a
BitmapData
object. Something like:Replace
this.stage
with whateverDisplayObject
you want to draw. Check out theBitmapData
docs: http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/BitmapData.html#draw()Sending it to the server depends on how you're connecting to the server. If it can accept the raw data from BitmapData, then go with it. Otherwise, encode it with
JPEGEncoder
orPNGEncoder
from the the as3corelib: https://github.com/mikechambers/as3corelib.You can probably upload it through PHP, or by writing the
ByteArray
data from the image to aURLRequest
. How that works is a bit more complicated to write here (it involves multipart/form-data). The easiest way to see how it works is to check out the Facebook AS3 API where they have image uploading working: http://code.google.com/p/facebook-actionscript-api/ (check out thecall()
function in theFacebookRequest
class)