Air HTML 组件和 HTML_RENDER 事件
我们目前正在使用 mx:HTML 组件来渲染复杂的 HTML 页面(这非常令人不安..:))。由于某些原因,我们需要在渲染 HTML 时捕获所显示页面的图像。所以我使用以下代码来执行此操作:
在初始化时:
frameHtml.addEventListener(Event.HTML_RENDER, cacheFrameHTML);
和cacheFrameHTML函数:
private function cacheFrameHTML(event:*):void {
...
cacheImage.source = new Bitmap( ImageSnapshot.captureBitmapData(frameHtml));
...
}
由于某些未知的原因,结果图像有时完全是空白的。 HTML_RENDER 事件和 HTML 组件的有效渲染之间似乎存在短暂的延迟。我尝试使用计时器来延迟图像捕获,这似乎有效,但这并不是很干净。
所以我的问题是: - 有谁知道只有在 HTML 框架有效显示时才触发捕获的技巧吗? - 至少,有没有办法测试结果 BitmapData 是否为空或只有白色像素?:b
非常感谢
Antoine
We are currently using the mx:HTML component to render complex HTML pages (which was pretty disturbing..:)). For some reasons, we need, when the HTML is rendered, to capture an image of the displayed page. So i use the following code to do this :
on initialization :
frameHtml.addEventListener(Event.HTML_RENDER, cacheFrameHTML);
and the cacheFrameHTML function :
private function cacheFrameHTML(event:*):void {
...
cacheImage.source = new Bitmap( ImageSnapshot.captureBitmapData(frameHtml));
...
}
For some unknown reason, the result image is sometime completly blank. It seems that there is a short delay between HTML_RENDER event and effective rendering of the HTML component. I tried to delay the image capture with a timer which seems to work, but that is not pretty clean.
So my question is :
- is there anyone who know a trick to only trigger the capture when the HTML frame is effectivly displayed?
- at least, is there anyway to test if the result BitmapData is blank or have only white pixels?:b
Thanks a lot
Antoine
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您是否尝试过使用 callLater 方法?
Have you tried to use the callLater method?