






















有些情况下,我们的应用程序可能不允许我们使用FelxPrintJob,下面的代码说明了在不使用FelxPrintJob的情况下,利用浏览器本身的打印功能,通过ExternalInterface调用直接进行打印。
首先需要准备下面这样的一段JavaScript脚本,放在index.template.html 的之前:
<script language="JavaScript">
function printPage(htmlPage)
{
var w = window.open("about:blank");
w.document.write(htmlPage);
w.print();
w.close();
}
</script>
接下去是利用ExternalInterface进行调用:
import mx.controls.Alert;
import flash.external.ExternalInterface;
public static function PrintHtmlPage(pHtmlPage:String):void
{
if (ExternalInterface.available)
{
try
{
ExternalInterface.call("printPage",pHtmlPage);
}
catch (error:SecurityError) { Alert.show("Security Error"); }
catch (error:Error) { Alert.show("Error");}
}
else { Alert.show("ExternalInterface not avalible");}
}
pHtmlPage是一串HTML标准的字符串,比如可以是这样:
<html><h1>Helo World</h1></html>
噢耶游戏是中国最大的轻社交游戏开发商,致力于手机页游的研发及推广业务。我们首创性地提出了HTML5游戏中心思路,在第三方App 中嵌入式休闲游戏,为开发者提供了全新的应用内游戏解决方案。
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。