<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title><![CDATA[向东博客 专注WEB应用 构架之美 --- 构架之美，在于尽态极妍 | 应用之美，在于药到病除]]></title> 
<link>http://www.jackxiang.com/index.php</link> 
<description><![CDATA[赢在IT，Playin' with IT,Focus on Killer Application,Marketing Meets Technology.]]></description> 
<language>zh-cn</language> 
<copyright><![CDATA[向东博客 专注WEB应用 构架之美 --- 构架之美，在于尽态极妍 | 应用之美，在于药到病除]]></copyright>
<item>
<link>http://www.jackxiang.com/post//</link>
<title><![CDATA[AS3-学习笔记-flashdevelop平台-搭建-配置,Flash调用Js或者相反之Js调Flash的demo。]]></title> 
<author>jack &lt;xdy108@126.com&gt;</author>
<category><![CDATA[WEB2.0]]></category>
<pubDate>Thu, 09 Jul 2009 07:45:01 +0000</pubDate> 
<guid>http://www.jackxiang.com/post//</guid> 
<description>
<![CDATA[ 
	背景：在Flash里直接在浏览器关闭时实现上报数据（Get;/Post;），发现有些浏览器不支持，调用Js实现也有这样的一个问题，记录在：<br/>http://jackxiang.com/post/6084/<br/><br/>chrome浏览器支持onbeforeunload事件吗？<br/>Chrome Safari 在调用 document.write、document.open、document.close 方法以及 &quot;javascipt:&quot; 伪协议时，不会触发 onbeforeunload 事件。<br/><br/>http://w3help.org/zh-cn/causes/BX2047<br/><br/><br/>于是我就自己也试了一把这个Js调用Flash，Flash再调用Js的一个过程，记录如下：<br/>这一篇文章是最好的实践方法，尤其是对Js调用Flash里的函数不同浏览器的不同方法：<br/>http://www.imququ.com/post/39.html<br/>再就是在使用FlashDevelop时新建时默认要用ActionScript AS3 Project，默认的AS3才行。<br/><br/>核心：http://www.imququ.com/post/39.html<br/>结果，除了IE之外，其他浏览器都不会工作，会提示找不到hello这个方法。这个问题困扰了我比较久。最后发现：在非IE浏览器里，flash提供的方法是加在embed上的，我们要得到object下的embed对象，调用embed上的方法才会成功！<br/><br/>1）Html代码如下，index.html：<br/><textarea name="code" class="JS" rows="15" cols="100">
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
&lt;head&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot; /&gt;
&lt;title&gt;JS Call Flash&lt;/title&gt;
&lt;script src=&quot;http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js&quot;&gt;&lt;/script&gt;
&lt;script&gt;!window.jQuery &amp;&amp; document.write(&#039;&lt;script src=&quot;js/jquery-1.4.2.min.js&quot;&gt;&lt;&#92;/script&gt;&#039;)  
&lt;/script&gt;
&lt;script language=&quot;javascript&quot;&gt;
function getFlashMovieObject(movieName)&#123;
&nbsp;&nbsp;if (window.document[movieName])&#123;
&nbsp;&nbsp;&nbsp;&nbsp;return window.document[movieName];
&nbsp;&nbsp;&#125;else if (navigator.appName.indexOf(&quot;Microsoft&quot;)==-1)&#123;
&nbsp;&nbsp;&nbsp;&nbsp;if (document.embeds &amp;&amp; document.embeds[movieName])
&nbsp;&nbsp;&nbsp;&nbsp;return document.embeds[movieName];
&nbsp;&nbsp;&#125;else&#123;
&nbsp;&nbsp;&nbsp;&nbsp;return document.getElementById(movieName);
&nbsp;&nbsp;&#125;
&#125;

function callExternal() &#123;
&nbsp;&nbsp;getFlashMovieObject(&quot;test&quot;).sendToActionScript()
&#125;

function isReady()&#123;
&nbsp;&nbsp;alert(&quot;isReady Called by Flash..。&quot;);
&#125;
&lt;/script&gt;
&lt;/head&gt;

&lt;body&gt;
&nbsp;&nbsp;
&nbsp;&nbsp;
&lt;object classid=&quot;clsid:d27cdb6e-ae6d-11cf-96b8-444553540000&quot; codebase=&quot;http://download.macromedia.com/pub/shockwave/cabs /flash/swflash.cab#version=10,0,0,0&quot; width=&quot;730&quot; height=&quot;520&quot; id=&quot;test&quot; align=&quot;middle&quot;&gt;
&lt;param name=&quot;allowScriptAccess&quot; value=&quot;sameDomain&quot; /&gt;
&lt;param name=&quot;allowFullScreen&quot; value=&quot;false&quot; /&gt;
&lt;param name=&quot;movie&quot; value=&quot;./flashcallJs.swf&quot; /&gt;
&lt;param name=&quot;quality&quot; value=&quot;high&quot; /&gt;
&lt;param name=&quot;bgcolor&quot; value=&quot;#ffffff&quot; /&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&lt;embed src=&quot;./flashcallJs.swf&quot; quality=&quot;high&quot; bgcolor=&quot;#ffffff&quot;
&nbsp;&nbsp;&nbsp;&nbsp;width=&quot;730&quot; height=&quot;520&quot; name=&quot;test&quot; align=&quot;middle&quot;
&nbsp;&nbsp;&nbsp;&nbsp;allowScriptAccess=&quot;always&quot; allowFullScreen=&quot;false&quot;
&nbsp;&nbsp;&nbsp;&nbsp;type=&quot;application/x-shockwave-flash&quot;
&nbsp;&nbsp;&nbsp;&nbsp;pluginspage=&quot;http://www.adobe.com/go/getflashplayer_cn&quot;
&nbsp;&nbsp;&nbsp;&nbsp; /&gt;
&lt;/object&gt;

&lt;input type=&quot;button&quot; onClick=&quot;callExternal()&quot; value=&quot;调用flash中的方法&quot;&gt;
&lt;/body&gt;
&lt;/html&gt;


</textarea><br/><br/><br/>2）Flash的代码如下，Main.as：<br/><textarea name="code" class="java" rows="15" cols="100">
package 
&#123;
&nbsp;&nbsp;import flash.display.Sprite;
&nbsp;&nbsp;import flash.events.Event;
&nbsp;&nbsp;import flash.external.*;
&nbsp;&nbsp;
&nbsp;&nbsp;
&nbsp;&nbsp;/**
&nbsp;&nbsp; * ...
&nbsp;&nbsp; * @author Jackxiang
&nbsp;&nbsp; */
&nbsp;&nbsp;public class Main extends Sprite 
&nbsp;&nbsp;&#123;
&nbsp;&nbsp;&nbsp;&nbsp;public function Main():void 
&nbsp;&nbsp;&nbsp;&nbsp;&#123;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (stage) init();
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else addEventListener(Event.ADDED_TO_STAGE, init);
&nbsp;&nbsp;&nbsp;&nbsp;&#125;
&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;private function init(e:Event = null):void 
&nbsp;&nbsp;&nbsp;&nbsp;&#123;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ExternalInterface.addCallback(&quot;sendToActionScript&quot;, receivedFromJavaScript); 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;trace(&quot;wwwwwwwwwwwwwwwwwwwzcl&quot;);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;removeEventListener(Event.ADDED_TO_STAGE, init);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// entry point
&nbsp;&nbsp;&nbsp;&nbsp;&#125;
&nbsp;&nbsp;&nbsp;&nbsp;public function receivedFromJavaScript() &#123;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;trace(&quot;wwwwwwwwwwwwwwwwwwwzcl&quot;);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ExternalInterface.call(&quot;isReady&quot;);
&nbsp;&nbsp;&nbsp;&nbsp;&#125;
&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&#125;
&nbsp;&nbsp;
&#125;
</textarea><br/><br/><br/><br/>http://www.qilei.org/200810/flashdevelop-build-up/<br/><br/>试着安装了一下：<br/>Tools -&gt; Programe Settings 设置AS3context 下的 flex sdk 的地址为 上面你保存的地址路径<br/>特别注意：<br/>AS3 Classpath: Library&#92;AS3&#92;intrinsic&nbsp;&nbsp; （这项得注意）<br/>Flex_SDK_Location : D:&#92;sdks&#92;sdks<br/><br/><br/><br/>flashdevelop trace结果在哪儿??<br/>o(∩_∩)o&nbsp;&nbsp;两种情况哦：<br/>第一种在是一般情况下，是因为 flashplayer或者flex builder没有使用debug版本，这种情况下，只需下载一个debug版本，在flashdevelop中设置，Tools -&gt;program settings-&gt;FlashViewer-&gt;Extermal Player Path设置flashdebug版本的路径。<br/>flex builder的话，一般不存在这种问题，他在自己的安装目录里自带了debug版本。<br/>（下载地址如下：http://download.macromedia.com/pub/flashplayer/updaters/9/flashplayer_9_ax_debug.exe ，<br/>安装完以后，在IE中打开flash,在右键菜单中，若看到“调试器”则安装成功。<br/>）<br/><br/>第二种情况，我们使用了debug版本的flashplayer，并且在flashdevelop中设置了FlashViewer的路径，但是还不出trace，并且flex builder也出现了相同问题，不出trace。那么问题在哪呢？<br/>在运行出来的flash player点击右键，选择调试器，看看选项是否在本地主机上，如果不是（选择了其他机器，这就是问题所在），那么就改到本地主机上，这样，trace就可以正常输出了。<br/>第三个应该是桌面版本<br/>Download the Windows Flash Player 10.2 Projector content debugger (EXE, 6.36MB)<br/>&nbsp;&nbsp;到底是用IE还是firefox可以在window-&gt; preference -&gt;General-&gt;Web Browser 里选择合适的浏览。<br/>我安装了chrome firefox ie，但选择里面没有chrome。但要用chrome来调试swf，也需要安装 for Netscape-compatible browsers 这个插件就行了。<br/><br/>FlashDevelop配置下载：<br/><a href="attachment.php?fid=175">点击这里下载文件</a><br/><br/>参考：http://bvu.iteye.com/blog/310653<br/><br/>第一个是IE的插件，<br/>Download the Windows Flash Player 10.2 ActiveX control content debugger (for IE) (EXE, 2.99MB)<br/>第二个是firefox的插件，<br/>Download the Windows Flash Player 10.2 Plugin content debugger (for Netscape-compatible browsers) (EXE, 2.95MB)<br/>安装了以上2个插件后，便可以用IE和firefox调试了。<br/>FlashPlayer Debuger：<br/>http://www.adobe.com/support/flashplayer/downloads.html<br/><br/>单步调试程序：<br/>有一个叫做fdbPlugin的插件可以在flashdevelop里实现单步调试。<br/>http://www.flashdevelop.org/community/viewtopic.php?f=4&amp;t=2958<br/>DownLoad：<br/>http://orange.zero.jp/zbn39616.pine/download/download.html<br/><br/><br/>配置动画：http://flash7783.iteye.com/blog/731456<br/><br/>调试程序：<br/><textarea name="code" class="JS" rows="15" cols="100">

package &#123;
&nbsp;&nbsp;import flash.display.sprite;
&nbsp;&nbsp;public class Main extends Sprite
&nbsp;&nbsp;&#123;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;public function Main():Void
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#123;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;trace(&quot;helo wold!&quot;);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#125;
&nbsp;&nbsp;&#125;
&nbsp;&nbsp;
&nbsp;&nbsp;
&nbsp;&nbsp;&#125;
</textarea><br/><br/><textarea name="code" class="JS" rows="15" cols="100">
package&nbsp;&nbsp;
&#123;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;import com.hexagonstar.util.debug.Debug;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp;&nbsp;import flash.display.Sprite;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;import flash.text.engine.EastAsianJustifier;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp;&nbsp;public class ASDemo extends Sprite&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&#123;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public function ASDemo()&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#123;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var obj:Object=new Object();&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; obj.name=&quot;张三&quot;;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; obj.sex=&quot;男&quot;;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; obj.age=&quot;18&quot;;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for each(var o:Object in obj)&#123;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Debug.trace(o.toString());&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#125;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#125;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&#125;&nbsp;&nbsp;
&#125;&nbsp;&nbsp;
</textarea><br/><br/>JS与FLASH相互调用：http://wenku.baidu.com/view/83c4203d5727a5e9856a618f.html<br/>http://wenku.baidu.com/view/2e27e220aaea998fcc220ef8.html<br/><br/><br/>更多参考：http://blog.sina.com.cn/s/blog_8a18c33d010127y1.html<br/><br/>实践如下之Flash调用Js或者相反之Js调Flash的demo：<br/>以下来自：http://reedgu.blog.163.com/blog/static/16229804120115735440787/<br/><br/>flash使用的actionscript跟javascript是非常相通的，下面描述如何互相调用函数:<br/>1:javascript调用flash中的函数<br/>在flash的脚本中增加<br/>代码:import flash.external.ExternalInterface;<br/>假定要调用的函数是hello，as代码如下<br/>代码:function hello()&#123;<br/>&nbsp;&nbsp; return &quot;hello&quot;;<br/>&#125;<br/>ExternalInterface.addCallback(&quot;hello&quot;, this, hello);<br/>//第一个参数为导出函数名，第三个参数为as的函数名<br/>这样就可以在js中调用as的hello函数了<br/>2：flash调用js的函数<br/>ExternalInterface.call(&quot;hello2&quot;, &quot;jacky&quot;);<br/>//第一个参数是js的函数名，后面的是js函数的参数<br/>3：如何互相调用<br/><br/>html代码如下：<br/>代码:&lt;object type=&quot;application/x-shockwave-flash&quot; data=&quot;test.swf&quot; width=&quot;525&quot; height=&quot;390&quot; name=&quot;test&quot;&gt;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;param name=&quot;allowScriptAccess&quot; value=&quot;sameDomain&quot; /&gt;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;param name=&quot;movie&quot; value=&quot;test.swf&quot; /&gt;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;param name=&quot;quality&quot; value=&quot;high&quot; /&gt;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;param name=&quot;scale&quot; value=&quot;noScale&quot; /&gt;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;param name=&quot;wmode&quot; value=&quot;transparent&quot; /&gt;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br/>&lt;/object&gt;<br/><br/>function callFromFlash() &#123;<br/>&nbsp;&nbsp;&nbsp;&nbsp;var a=thisMovie(&quot;test&quot;).hello();<br/>&nbsp;&nbsp;&nbsp;&nbsp;alert(a);<br/>&#125;<br/><br/>function thisMovie(movieName) &#123;<br/>&nbsp;&nbsp;&nbsp;&nbsp;if (navigator.appName.indexOf(&quot;Microsoft&quot;) != -1) &#123;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return window[movieName]<br/>&nbsp;&nbsp;&nbsp;&nbsp;&#125;<br/>&nbsp;&nbsp;&nbsp;&nbsp;else &#123;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return document[movieName]<br/>&nbsp;&nbsp;&nbsp;&nbsp;&#125;<br/>&#125;<br/><br/>最近开发网站时遇到一个问题，如何与FLASH里的AS脚本进行交互？<br/><br/>需要在Flash里读取网页JavaScript里的值，用于控制两个Flash协同显示内容。<br/><br/>最后终于在Flash找到了ExternalInterface类，要求环境：AS 1.0，Flash Player 8.0以上<br/><br/>一、在网页中通过JavaScript调用Flash里的ActionScript：<br/>可以通过ExternalInterface的addCallback方法，在Flash里注册一个可以供网页上的JavaScript或ActiveX调用的方法，具体代码如下：<br/>程序代码<br/><br/>import flash.external.*;<br/>var methodName:String = &quot;PlayBB&quot;;<br/>var instance:Object = null;<br/>var method:Function = playB;<br/>var ws:Boolean = ExternalInterface.addCallback(methodName, instance, method);<br/><br/>在JavaScript中调用时，需要为Flash所在的Object标签设置一个ID，并且设置allowScriptAccess属性，示例代码如下：<br/>程序代码<br/>import flash.external.*;<br/>var methodName:String = &quot;PlayBB&quot;;<br/>var instance:Object = null;<br/>var method:Function = playB;<br/>var ws:Boolean = ExternalInterface.addCallback(methodName, instance, method);<br/><br/>在JavaScript中调用时，需要为Flash所在的Object标签设置一个ID，并且设置allowScriptAccess属性，示例代码如下：<br/>程序代码<br/><br/>&lt;object id=&quot;topFlash&quot; name=&quot;topFlash&quot; classid=&quot;clsid:D27CDB6E-AE6D-11cf-96B8-444553540000&quot; codebase=&quot;http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0&quot; width=&quot;686&quot; height=&quot;101&quot;&gt;<br/>&nbsp;&nbsp;&nbsp;&nbsp; &lt;param name=&quot;movie&quot; value=&quot;_top.swf&quot; /&gt;<br/>&nbsp;&nbsp;&nbsp;&nbsp; &lt;param name=&quot;quality&quot; value=&quot;high&quot; /&gt;<br/>&nbsp;&nbsp;&nbsp;&nbsp; &lt;param name=&quot;allowScriptAccess&quot; value=&quot;always&quot; /&gt;<br/>&nbsp;&nbsp;&nbsp;&nbsp; &lt;embed allowScriptAccess=&quot;always&quot; src=&quot;_top.swf&quot; quality=&quot;high&quot; pluginspage=&quot;http://www.macromedia.com/go/getflashplayer&quot; type=&quot;application/x-shockwave-flash&quot; width=&quot;686&quot; height=&quot;101&quot;&gt;&lt;/embed&gt;<br/>&lt;/object&gt;<br/><br/>网页中的JavaScript具体的调用示例：<br/>程序代码<br/><br/>function thisMovie(movieName) &#123;<br/>&nbsp;&nbsp;&nbsp;&nbsp; if (navigator.appName.indexOf(&quot;Microsoft&quot;) != -1) &#123;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return window[movieName]<br/>&nbsp;&nbsp;&nbsp;&nbsp; &#125;<br/>&nbsp;&nbsp;&nbsp;&nbsp; else &#123;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return document[movieName]<br/>&nbsp;&nbsp;&nbsp;&nbsp; &#125;<br/>&#125;<br/>(&quot;topFlash&quot;).PlayBB();<br/><br/><br/><br/>二、在Flash的ActionScript中调用网页里的JavaScript：<br/>直接使用ExternalInterface的Call方法就可以了，示例代码如下：<br/>程序代码<br/><br/>import flash.external.*;<br/>var obj:Object = ExternalInterface.Call(&quot;JavaScript方法&quot;, &quot;参数&quot;);<br/><br/>参数可以是任何As中的类型，在调用时Flash会自动封装，多参数使用,分隔。 <br/><br/>使用externalInterface.addCallback()容易犯的两个错误：<br/>ExternalInterface类是实现Javascript与ActionScript之间通信的编程接口，其中addCallback()方法使用最广泛，该方法将ActionScript方法注册为可从容器调用。如果浏览器不支持调用或无权访问的安全沙箱，将引发错误，大家可以参考帮助解决这些常见问题。本文讲述的实际应用中使用addCallback()方法容易犯的其它两个错误。<br/><br/>1. 错误：对象不支持此属性或方法。这是因为ActionScript方法还没注册成功就在容器中调用。最简单的解决方法是在注册ActionScript方法后，使用call()方法调用JS函数来检验注册状态，再在该函数体中调用ActionScript方法。<br/><br/>在本实例中，如果使用&lt;body onload=”selectCatalog(1)”&gt;就会出现上述错误。如果在注册addCallback()方法后，调用isReady()函数。因为这两句ActionScript是顺序执行的，所以再在该Javascript函数中调用selectCatalog(1)函数就没有问题了。<br/><br/>2. 错误：在IE成功中调用addCallback()，而在Firefox中却没有反应。这是因为它们对swf对象的引用语法不一样，IE中用window[movieName]，而Firefox中使用document[movieName]，需要判断一下浏览器的类型再分别处理，或者用document.getElementById(“movieName”)。<br/><br/>在本实例中，如果使用Main.getSongList(data)就会出现上述错误，我们使用thisMovie()函数解决了这一问题。<br/><br/><br/>解决FlashDevelop调试不输出trace信息：<br/>刚一安装FD就碰到一个超严重的问题，trace不出。安装和配置时我可是按说明一步步来的，debug版的flash player也安装了。可是NND就是不输出trace信息。到群里面提问也是莫名奇妙。不过还好我天生聪明，找了两小时总算解决了。(啦啦啦……)<br/>下面是方法：<br/>1.打开FD(flashDevelop简称)<br/>2.在菜单栏找 Tools-&gt;Program Settings<br/>3.在Plugins框里面找到FlashViewer，然后在右边的External Player Path设置flash player的路径（*注意，这个路径是调版的flash player的路径，在flash cs*的安装目录中找到Players文件夹，然后在Debug文件里面就能找到debug版的flash player）<br/>4.问题解决，可以trace啦！！！<br/><br/>把以下测试代码放上去看看。<br/><br/><br/><br/>package <br/>&#123;<br/>&nbsp;&nbsp;import flash.display.Sprite;<br/>&nbsp;&nbsp;<br/>&nbsp;&nbsp;/**<br/>&nbsp;&nbsp; * ...<br/>&nbsp;&nbsp; * @author Pelephone<br/>&nbsp;&nbsp; */<br/>&nbsp;&nbsp;public class Main extends Sprite <br/>&nbsp;&nbsp;&#123;&nbsp;&nbsp;<br/>&nbsp;&nbsp;&nbsp;&nbsp;public function Main():void <br/>&nbsp;&nbsp;&nbsp;&nbsp;&#123;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;trace(&quot;HelloWorld!&quot;);<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;trace(&quot;HelloWorld!&quot;);<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;trace(&quot;求求你，HelloWorld!&quot;);<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;trace(&quot;他妈的，快给我HelloWorld!&quot;);<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;trace(&quot;再不HelloWorld我就把你卸载了!&quot;);<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;trace(&quot;再不HelloWorld我就砸了你!&quot;);<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&#125;&nbsp;&nbsp;&nbsp;&nbsp;<br/>&nbsp;&nbsp;&#125;<br/>&#125;<br/><br/>来源：http://www.cnblogs.com/pelephone/archive/2009/04/15/flashdevelop-debug-trace.html
]]>
</description>
</item><item>
<link>http://www.jackxiang.com/post//#blogcomment</link>
<title><![CDATA[[评论] AS3-学习笔记-flashdevelop平台-搭建-配置,Flash调用Js或者相反之Js调Flash的demo。]]></title> 
<author> &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Thu, 01 Jan 1970 00:00:00 +0000</pubDate> 
<guid>http://www.jackxiang.com/post//#blogcomment</guid> 
<description>
<![CDATA[ 
	
]]>
</description>
</item>
</channel>
</rss>