<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>中文Flex例子 &#187; ExternalInterface</title>
	<atom:link href="http://blog.minidx.com/tag/externalinterface/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.minidx.com</link>
	<description>中文Adobe Flex例子,Flex实例教程,RIA资源,全文检索技术,算法和数据结构</description>
	<lastBuildDate>Thu, 31 Mar 2011 03:22:33 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Flex中不使用FelxPrintJob通过ExternalInterface直接调用JavaScript利用浏览器本身的功能进行打印</title>
		<link>http://blog.minidx.com/2008/11/01/1599.html</link>
		<comments>http://blog.minidx.com/2008/11/01/1599.html#comments</comments>
		<pubDate>Sat, 01 Nov 2008 05:28:22 +0000</pubDate>
		<dc:creator>Minidxer</dc:creator>
				<category><![CDATA[Adobe其他]]></category>
		<category><![CDATA[ExternalInterface]]></category>
		<category><![CDATA[FelxPrintJob]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[打印]]></category>

		<guid isPermaLink="false">http://blog.minidx.com/?p=1599</guid>
		<description><![CDATA[有些情况下，我们的应用程序可能不允许我们使用FelxPrintJob，下面的代码说明了在不使用FelxPrintJob的情况下，利用浏览器本身的打印功能，通过ExternalInterface调用直接进行打印。








首先需要准备下面这样的一段JavaScript脚本，放在index.template.html 的之前：
&#60;script language=&#34;JavaScript&#34;&#62;
&#160; &#160; function&#160;printPage(htmlPage)
&#160; &#160; {
&#160; &#160; &#160; &#160; var&#160;w = window.open(&#34;about:blank&#34;);
&#160; &#160; &#160; &#160; w.document.write(htmlPage);
&#160; &#160; &#160; &#160; w.print();
&#160; &#160; &#160; &#160; w.close();
&#160; &#160; }
&#60;/script&#62;
接下去是利用ExternalInterface进行调用：
import mx.controls.Alert;
import&#160;flash.external.ExternalInterface;&#160;&#160; 
&#160;
public&#160;static function PrintHtmlPage(pHtmlPage:String):void
{
&#160; &#160; if&#160;(ExternalInterface.available)
&#160; &#160; {
&#160; &#160; &#160; &#160; try&#160; 
&#160; &#160; &#160; &#160; {
&#160; &#160; &#160; &#160; &#160; &#160; &#160; ExternalInterface.call(&#34;printPage&#34;,pHtmlPage);
&#160; &#160; &#160; &#160; }
&#160; [...]]]></description>
		<wfw:commentRss>http://blog.minidx.com/2008/11/01/1599.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Flex中利用ExternalInterface API从JavaScript中获取内容并在Flex应用中使用的例子</title>
		<link>http://blog.minidx.com/2008/04/12/706.html</link>
		<comments>http://blog.minidx.com/2008/04/12/706.html#comments</comments>
		<pubDate>Sat, 12 Apr 2008 05:35:14 +0000</pubDate>
		<dc:creator>Minidxer</dc:creator>
				<category><![CDATA[Flex]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[CALL]]></category>
		<category><![CDATA[ExternalInterface]]></category>
		<category><![CDATA[HTML模板]]></category>
		<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://blog.minidx.com/2008/04/12/706.html</guid>
		<description><![CDATA[在之前的文章中，关于ExternalInterface API的使用已经有不少了：    Flex中利用ExternalInterface的API调用JavaScript函数的例子     Flex中检查是否支持ExternalInterface API的例子     Flex中利用ExternalInterface API从HTML模板(HTML templates)中调用ActionScript函数的例子     Flex应用中利用ExternalInterface API取得JavaScript返回值的例子
都说明了ExternalInterface相关的用法。接下来的例子，演示了如何利用ExternalInterface API，不需要写一行JavaScript代码或者编辑HTML模板，从JavaScript中获取内容并在Flex应用中使用。
让我们先来看一下Demo（可以右键View Source或点击这里察看源代码）：









下面是完整代码(或点击这里察看)：
Download: main.mxml&#60;?xml version=&#34;1.0&#34; encoding=&#34;utf-8&#34;?&#62;
&#60;mx:Application&#160;xmlns:mx=&#34;http://www.adobe.com/2006/mxml&#34;
&#160; &#160; &#160; &#160; layout=&#34;vertical&#34;
&#160; &#160; &#160; &#160; verticalAlign=&#34;middle&#34;
&#160; &#160; &#160; &#160; backgroundColor=&#34;white&#34;
&#160; &#160; &#160; &#160; creationComplete=&#34;init();&#34;&#62;
&#160;
&#160; &#160; &#60;mx:Script&#62;
&#160; &#160; &#160; &#160; &#60;![CDATA[
&#160; &#160; &#160; &#160; [...]]]></description>
		<wfw:commentRss>http://blog.minidx.com/2008/04/12/706.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Flex应用中利用ExternalInterface API取得JavaScript返回值的例子</title>
		<link>http://blog.minidx.com/2008/03/12/569.html</link>
		<comments>http://blog.minidx.com/2008/03/12/569.html#comments</comments>
		<pubDate>Wed, 12 Mar 2008 12:47:20 +0000</pubDate>
		<dc:creator>Minidxer</dc:creator>
				<category><![CDATA[Flex]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[ExternalInterface]]></category>
		<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://blog.minidx.com/2008/03/12/569.html</guid>
		<description><![CDATA[在前面的Flex中利用ExternalInterface的API调用JavaScript函数的例子中，我们了解到了Flex应用中调用JavaScript函数。
接下来的例子展示了Flex应用中如何调用JavaScript函数并且使用返回值。
下面是具体的例子以及源代码：








Download: main.mxml&#60;?xml version=&#34;1.0&#34; encoding=&#34;utf-8&#34;?&#62;
&#60;!-- http://blog.flexexamples.com/2008/03/11/returning-values-from-javascript-in-your-flex-applications-using-the-externalinterface-api/ --&#62;
&#60;mx:Application&#160;xmlns:mx=&#34;http://www.adobe.com/2006/mxml&#34;
&#160; &#160; &#160; &#160; layout=&#34;vertical&#34;
&#160; &#160; &#160; &#160; verticalAlign=&#34;middle&#34;
&#160; &#160; &#160; &#160; backgroundColor=&#34;white&#34;&#62;
&#160;
&#160; &#160; &#60;mx:Script&#62;
&#160; &#160; &#160; &#160; &#60;![CDATA[
&#160; &#160; &#160; &#160; &#160; &#160; import&#160;mx.utils.ObjectUtil;
&#160;
&#160; &#160; &#160; &#160; &#160; &#160; private&#160;function callJavaScript():void {
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; var&#160;keys:Array = &#34;appCodeName,appName,appVersion,cookieEnabled,language,platform,systemLanguage,userAgent,userLanguage&#34;.split(&#34;,&#34;);
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; [...]]]></description>
		<wfw:commentRss>http://blog.minidx.com/2008/03/12/569.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Flex中利用ExternalInterface API从HTML模板(HTML templates)中调用ActionScript函数的例子</title>
		<link>http://blog.minidx.com/2008/03/12/568.html</link>
		<comments>http://blog.minidx.com/2008/03/12/568.html#comments</comments>
		<pubDate>Wed, 12 Mar 2008 11:25:10 +0000</pubDate>
		<dc:creator>Minidxer</dc:creator>
				<category><![CDATA[Flex]]></category>
		<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[addCallback]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[ExternalInterface]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[templates]]></category>
		<category><![CDATA[模板]]></category>

		<guid isPermaLink="false">http://blog.minidx.com/2008/03/12/568.html</guid>
		<description><![CDATA[在前面的Flex中利用ExternalInterface的API调用JavaScript函数的例子中，我们了解到了Flex应用中，如何利用静态事件ExternalInterface.call()调用JavaScript函数。
接下来的例子展示了Flex应用中如何利用静态ExternalInterface.addCallback()事件和JavaScript中的比特（bit），调用ActionScript函数。
下面是具体的例子以及源代码：








Download: main.mxml&#60;?xml version=&#34;1.0&#34; encoding=&#34;utf-8&#34;?&#62;
&#60;!-- http://blog.flexexamples.com/2008/03/11/calling-actionscript-functions-from-your-html-templates-using-the-externalinterface-api/ --&#62;
&#60;mx:Application&#160;xmlns:mx=&#34;http://www.adobe.com/2006/mxml&#34;
&#160; &#160; &#160; &#160; layout=&#34;vertical&#34;
&#160; &#160; &#160; &#160; verticalAlign=&#34;middle&#34;
&#160; &#160; &#160; &#160; backgroundColor=&#34;white&#34;
&#160; &#160; &#160; &#160; creationComplete=&#34;init();&#34;&#62;
&#160;
&#160; &#160; &#60;mx:Script&#62;
&#160; &#160; &#160; &#160; &#60;![CDATA[
&#160; &#160; &#160; &#160; &#160; &#160; import&#160;mx.controls.Alert;
&#160;
&#160; &#160; &#160; &#160; &#160; &#160; private&#160;var alert:Alert;
&#160;
&#160; &#160; &#160; &#160; &#160; &#160; private&#160;function init():void {
&#160; &#160; &#160; &#160; &#160; &#160; &#160; [...]]]></description>
		<wfw:commentRss>http://blog.minidx.com/2008/03/12/568.html/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Flex中检查是否支持ExternalInterface API的例子</title>
		<link>http://blog.minidx.com/2008/03/11/563.html</link>
		<comments>http://blog.minidx.com/2008/03/11/563.html#comments</comments>
		<pubDate>Tue, 11 Mar 2008 06:47:16 +0000</pubDate>
		<dc:creator>Minidxer</dc:creator>
				<category><![CDATA[Flex]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[Container]]></category>
		<category><![CDATA[ExternalInterface]]></category>
		<category><![CDATA[容器]]></category>

		<guid isPermaLink="false">http://blog.minidx.com/2008/03/11/563.html</guid>
		<description><![CDATA[下面的例子展示了如何检查Flex应用的容器(container) 是否支持ExternalInterface API。
下面是具体的例子以及源代码：








Download: main.mxml&#60;?xml version=&#34;1.0&#34; encoding=&#34;utf-8&#34;?&#62;
&#60;!-- http://blog.flexexamples.com/2008/03/10/checking-to-see-if-the-externalinterface-api-is-available-in-flex/ --&#62;
&#60;mx:Application&#160;xmlns:mx=&#34;http://www.adobe.com/2006/mxml&#34;
&#160; &#160; &#160; &#160; layout=&#34;vertical&#34;
&#160; &#160; &#160; &#160; verticalAlign=&#34;middle&#34;
&#160; &#160; &#160; &#160; backgroundColor=&#34;white&#34;
&#160; &#160; &#160; &#160; creationComplete=&#34;init();&#34;&#62;
&#160;
&#160; &#160; &#60;mx:Script&#62;
&#160; &#160; &#160; &#160; &#60;![CDATA[
&#160; &#160; &#160; &#160; &#160; &#160; import&#160;mx.controls.Alert;
&#160;
&#160; &#160; &#160; &#160; &#160; &#160; private&#160;function init():void {
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; if&#160;(ExternalInterface.available) {
&#160; &#160; &#160; [...]]]></description>
		<wfw:commentRss>http://blog.minidx.com/2008/03/11/563.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk
Page Caching using disk (enhanced)
Database Caching 2/21 queries in 0.977 seconds using disk
Object Caching 452/834 objects using disk

Served from: blog.minidx.com @ 2012-02-10 00:50:26 -->
