﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>BlogJava-自由飞翔-随笔分类-flex</title><link>http://www.blogjava.net/GavinMiao/category/49325.html</link><description>我在仰望，java之上</description><language>zh-cn</language><lastBuildDate>Fri, 02 Mar 2012 10:55:40 GMT</lastBuildDate><pubDate>Fri, 02 Mar 2012 10:55:40 GMT</pubDate><ttl>60</ttl><item><title>flex入门知识</title><link>http://www.blogjava.net/GavinMiao/archive/2012/03/02/371137.html</link><dc:creator>GavinMiao</dc:creator><author>GavinMiao</author><pubDate>Fri, 02 Mar 2012 07:14:00 GMT</pubDate><guid>http://www.blogjava.net/GavinMiao/archive/2012/03/02/371137.html</guid><wfw:comment>http://www.blogjava.net/GavinMiao/comments/371137.html</wfw:comment><comments>http://www.blogjava.net/GavinMiao/archive/2012/03/02/371137.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/GavinMiao/comments/commentRss/371137.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/GavinMiao/services/trackbacks/371137.html</trackback:ping><description><![CDATA[<br />一、<br />1、下载flex SDK：<br /><div><a href="http://opensource.adobe.com/wiki/display/flexsdk/Flex+SDK">http://opensource.adobe.com/wiki/display/flexsdk/Flex+SDK</a>&nbsp;<br />2、将flexSDK_home/bin加入path环境变量<br />3、创建mxml文件<br />4、编译mxml文件：<br /><div>dos 命令：mxmlc --strict=true --file-specs exer.mxml<br />5、运行SWF文件：<br />用Adope flash player运行；<br /><br />注意：<br />要查看编译时生成as文件，可使用命令：<br /><div>mxmlc --keep-generated-actionscript --strict=true --file-specs exer.mxml</div>二、<br /></div></div><img src ="http://www.blogjava.net/GavinMiao/aggbug/371137.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/GavinMiao/" target="_blank">GavinMiao</a> 2012-03-02 15:14 <a href="http://www.blogjava.net/GavinMiao/archive/2012/03/02/371137.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Flex入门学习</title><link>http://www.blogjava.net/GavinMiao/archive/2011/12/29/367468.html</link><dc:creator>GavinMiao</dc:creator><author>GavinMiao</author><pubDate>Thu, 29 Dec 2011 02:34:00 GMT</pubDate><guid>http://www.blogjava.net/GavinMiao/archive/2011/12/29/367468.html</guid><wfw:comment>http://www.blogjava.net/GavinMiao/comments/367468.html</wfw:comment><comments>http://www.blogjava.net/GavinMiao/archive/2011/12/29/367468.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/GavinMiao/comments/commentRss/367468.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/GavinMiao/services/trackbacks/367468.html</trackback:ping><description><![CDATA[<br />第一步：看<a href="http://www.deepcast.net/wiki/flex">http://www.deepcast.net/wiki/flex</a>&nbsp;&nbsp;<br />第二步:看<a href="http://www.why100000.com/_articles/show_a_article.asp?tab=tabOtherLanguage&amp;autoid=5">http://www.why100000.com/_articles/show_a_article.asp?tab=tabOtherLanguage&amp;autoid=5</a>(Mcromedia Flex标记语言)<br />Flex学习网站：<br /><div>1.<div style="display: inline-block; "></div><span class="Apple-style-span" style="color: #333333; font-family: Arial; line-height: 26px; background-color: #ffffff; "><a href="http://examples.adobe.com/flex2/inproduct/sdk/explorer/explorer.html" target="_blank" style="color: #336699; text-decoration: none; ">Adobe Flex 2 Component Explorer</a>： 官方的，展示了各种组件的用法，入门必看。</span> &nbsp;&nbsp;<a href="http://examples.adobe.com/flex2/inproduct/sdk/explorer/explorer.html">http://examples.adobe.com/flex2/inproduct/sdk/explorer/explorer.html</a>&nbsp;<br />2.<div style="display: inline-block; "></div><span class="Apple-style-span" style="color: #333333; font-family: Arial; line-height: 26px; background-color: #ffffff; ">很好的一个Flex资源站点</span>&nbsp;<a href="http://www.cflex.net/">http://www.cflex.net/</a>&nbsp;主要看右边一栏<br />3.<a href="http://flexbox.mrinalwadhwa.com/">http://flexbox.mrinalwadhwa.com/</a>&nbsp;<div style="display: inline-block; "></div><span class="Apple-style-span" style="color: #333333; font-family: Arial; line-height: 26px; background-color: #ffffff; ">一个收集了网上很多开源组件的站点，是进阶学习的好帮手</span><br />4.<a href="http://code.google.com/p/flexlib/">http://code.google.com/p/flexlib/</a>&nbsp;<div style="display: inline-block; "></div><span class="Apple-style-span" style="color: #333333; font-family: Arial; line-height: 26px; background-color: #ffffff; ">也是一个开源Flex组件站点，不过与FlexBox不同的是，这个是原创，而FlexBox只是收集。</span><br />5.<a href="http://www.adobe.com/devnet/flex.html">http://www.adobe.com/devnet/flex.html</a>&nbsp;<div style="display: inline-block; "></div><span class="Apple-style-span" style="color: #333333; font-family: Arial; line-height: 26px; background-color: #ffffff; ">Adobe Flex开发者中心，经常会有一些好的教程出现。</span><br />6.<a href="http://labs.adobe.com/">http://labs.adobe.com/</a><br />7.<div style="display: inline-block; "></div><span class="Apple-style-span" style="color: #333333; font-family: Arial; line-height: 26px; background-color: #ffffff; ">Flex.org：<a href="http://www.flex.org/" target="_blank" style="color: #336699; text-decoration: none; ">http://www.flex.org/</a>&nbsp;&nbsp;官方的，基本上应有尽有。<br />8.</span><a href="http://examples.adobe.com/flex2/consulting/styleexplorer/Flex2StyleExplorer.html">http://examples.adobe.com/flex2/consulting/styleexplorer/Flex2StyleExplorer.html</a>&nbsp;<div style="display: inline-block; "></div><span class="Apple-style-span" style="color: #333333; font-family: Arial; line-height: 26px; background-color: #ffffff; ">用来设计程序样式风格的工具，很好用，现在源代码已经可以下载。<br />9.<a href="http://www.merhl.com/flex2_samples/filterExplorer/">http://www.merhl.com/flex2_samples/filterExplorer/</a>&nbsp;<div style="display: inline-block; "></div></span><span class="Apple-style-span" style="color: #333333; font-family: Arial; line-height: 26px; background-color: #ffffff; ">用来调节各种滤镜（filter），非官方的，源代码提供下载。</span><span class="Apple-style-span" style="color: #333333; font-family: Arial; line-height: 26px; background-color: #ffffff; "><br /></span><span class="Apple-style-span" style="color: #333333; font-family: Arial; line-height: 26px; background-color: #ffffff; ">10.<a href="http://wenku.baidu.com/view/739d962e453610661ed9f4c5.html">http://wenku.baidu.com/view/739d962e453610661ed9f4c5.html</a><br /><br /><br />参考文章：<a href="http://blog.csdn.net/microrain/article/details/1601303">http://blog.csdn.net/microrain/article/details/1601303</a><br /><br /><br /><br /><br /><br /></span></div><img src ="http://www.blogjava.net/GavinMiao/aggbug/367468.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/GavinMiao/" target="_blank">GavinMiao</a> 2011-12-29 10:34 <a href="http://www.blogjava.net/GavinMiao/archive/2011/12/29/367468.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>转载：在JavaScript中调用Flex方法</title><link>http://www.blogjava.net/GavinMiao/archive/2011/12/29/367460.html</link><dc:creator>GavinMiao</dc:creator><author>GavinMiao</author><pubDate>Wed, 28 Dec 2011 16:51:00 GMT</pubDate><guid>http://www.blogjava.net/GavinMiao/archive/2011/12/29/367460.html</guid><wfw:comment>http://www.blogjava.net/GavinMiao/comments/367460.html</wfw:comment><comments>http://www.blogjava.net/GavinMiao/archive/2011/12/29/367460.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/GavinMiao/comments/commentRss/367460.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/GavinMiao/services/trackbacks/367460.html</trackback:ping><description><![CDATA[<span class="Apple-style-span" style="font-family: 宋体; font-size: 15px; line-height: 22px; background-color: #ffffff; ">文章来源：<a href="http://www.cnblogs.com/liuzhong/archive/2011/06/27/2091294.html">http://www.cnblogs.com/liuzhong/archive/2011/06/27/2091294.html</a><br />一、在JavaScript中调用Flex方法<br /></span><span class="Apple-style-span" style="font-family: 宋体; font-size: 15px; line-height: 22px; background-color: #ffffff; ">在Flex中可以用ExternalInterface来调用Flex的方法，途径是<br /><span style="color: #ff0000; background-color: #ffffff; ">1.通过在Flex应用可调用方法列表中添加指定的公用方法。</span>&nbsp;<span style="color: #ff0000; background-color: #ffffff; ">在Flex应用中通过调用addCallback()可以把一个方法添加到此列表中。addCallback将一个ActionScript的方法注册为一个JavaScript和VBScript可以调用的方法。<br /></span></span><span class="Apple-style-span" style="font-family: 宋体; font-size: 15px; line-height: 22px; background-color: #ffffff; ">addCallback()函数的定义如下：<br /></span><span class="Apple-style-span" style="font-family: 宋体; font-size: 15px; line-height: 22px; background-color: #ffffff; ">addCallback(function_name:String, closure:Function):void<br /></span><span class="Apple-style-span" style="font-family: 宋体; font-size: 15px; line-height: 22px; background-color: #ffffff; ">function_name参数就是在Html页面中脚本调用的方法名。closure参数是要调用的本地方法，这个参数可以是一个方法也可以是对象实例。<br /><br /></span><span class="Apple-style-span" style="font-family: 宋体; font-size: 15px; line-height: 22px; background-color: #ffffff; ">举个例子：<br /></span><span class="Apple-style-span" style="font-family: 宋体; font-size: 15px; line-height: 22px; background-color: #ffffff; ">&lt;mx:Script&gt;<br /></span><span class="Apple-style-span" style="font-family: 宋体; font-size: 15px; line-height: 22px; background-color: #ffffff; ">&nbsp;&nbsp;&nbsp; import flash.external.*;<br /></span><span class="Apple-style-span" style="font-family: 宋体; font-size: 15px; line-height: 22px; background-color: #ffffff; ">&nbsp;&nbsp;&nbsp; public function myFunc():Number {<br /></span><span class="Apple-style-span" style="font-family: 宋体; font-size: 15px; line-height: 22px; background-color: #ffffff; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return 42;<br /></span><span class="Apple-style-span" style="font-family: 宋体; font-size: 15px; line-height: 22px; background-color: #ffffff; ">&nbsp;&nbsp;&nbsp; }<br /></span><span class="Apple-style-span" style="font-family: 宋体; font-size: 15px; line-height: 22px; background-color: #ffffff; ">&nbsp;&nbsp;&nbsp; public function initApp():void {<br /></span><span class="Apple-style-span" style="font-family: 宋体; font-size: 15px; line-height: 22px; background-color: #ffffff; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ExternalInterface.addCallback("myFlexFunction",myFunc);<br /></span><span class="Apple-style-span" style="font-family: 宋体; font-size: 15px; line-height: 22px; background-color: #ffffff; ">&nbsp;&nbsp;&nbsp; }<br /></span><span class="Apple-style-span" style="font-family: 宋体; font-size: 15px; line-height: 22px; background-color: #ffffff; ">&lt;/mx:Script&gt;<br /><br /></span><span class="Apple-style-span" style="font-family: 宋体; font-size: 15px; line-height: 22px; background-color: #ffffff; ">2.<span style="color: #ff0000; background-color: #ffffff; ">那么在Html页面中，先获得SWF对象的引用，也就是用&lt;object .../&gt;声明的Swf的Id属性</span>&nbsp;</span><span class="Apple-style-span" style="font-family: 宋体; font-size: 15px; line-height: 22px; background-color: #ffffff; ">，比如说是MyFlexApp。然后就可以用以下方式调用Flex中的方法。<br /></span><span class="Apple-style-span" style="font-family: 宋体; font-size: 15px; line-height: 22px; background-color: #ffffff; ">&lt;SCRIPT language='JavaScript' charset='utf-8'&gt;<br /></span><span class="Apple-style-span" style="font-family: 宋体; font-size: 15px; line-height: 22px; background-color: #ffffff; ">&nbsp;&nbsp;&nbsp; function callApp() {<br /><span style="color: #ff0000; background-color: #ffffff; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var x = MyFlexApp.myFlexFunction();</span>&nbsp;<br /></span><span class="Apple-style-span" style="font-family: 宋体; font-size: 15px; line-height: 22px; background-color: #ffffff; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; alert(x);<br /></span><span class="Apple-style-span" style="font-family: 宋体; font-size: 15px; line-height: 22px; background-color: #ffffff; ">&nbsp;&nbsp;&nbsp; }<br /></span><span class="Apple-style-span" style="font-family: 宋体; font-size: 15px; line-height: 22px; background-color: #ffffff; ">&lt;/SCRIPT&gt;<br /></span><span class="Apple-style-span" style="font-family: 宋体; font-size: 15px; line-height: 22px; background-color: #ffffff; ">&lt;button onclick="callApp()"&gt;Call App&lt;/button&gt;<br /><br /><br /><br /></span><span class="Apple-style-span" style="font-family: 宋体; font-size: 15px; line-height: 22px; background-color: #ffffff; ">二、在Flex中调用 JavaScript<br /></span><span class="Apple-style-span" style="font-family: 宋体; font-size: 15px; line-height: 22px; background-color: #ffffff; ">你可以调用Html页面中的JavaScript，通过与JavaScript的交互，可以改变Style，调用远程方法。还可以将数据传递给Html页面，处理后再返回给Flex，完成这样的功能主要有两种方法：ExternalInterface()和navigateToUrl()。<br /></span><span class="Apple-style-span" style="font-family: 宋体; font-size: 15px; line-height: 22px; background-color: #ffffff; ">在Flex中调用JavaScript最简单的方法是使用ExternalInterface()，可以使用此API调用任意JavaScript，传递参数，获得返回值，如果调用失败，Flex抛出一个异常。<br /></span><span class="Apple-style-span" style="font-family: 宋体; font-size: 15px; line-height: 22px; background-color: #ffffff; ">ExternalInterface封装了对浏览器支持的检查，可以用available属性来查看。<br /></span><span class="Apple-style-span" style="font-family: 宋体; font-size: 15px; line-height: 22px; background-color: #ffffff; ">ExternalInterface的使用非常简单，语法如下：<br /></span><span class="Apple-style-span" style="font-family: 宋体; font-size: 15px; line-height: 22px; background-color: #ffffff; ">flash.external.ExternalInterface.call(function_name: String[, arg1, ...]):Object;<br /></span><span class="Apple-style-span" style="font-family: 宋体; font-size: 15px; line-height: 22px; background-color: #ffffff; ">参数function_name是要调用的JavaScript的函数名，后面的参数是JavaScript需要的参数。<br /></span><span class="Apple-style-span" style="font-family: 宋体; font-size: 15px; line-height: 22px; background-color: #ffffff; ">举个例子说明如何调用JavaScript函数<br /></span><span class="Apple-style-span" style="font-family: 宋体; font-size: 15px; line-height: 22px; background-color: #ffffff; ">Flex应用中，添加如下方法：<br /></span><span class="Apple-style-span" style="font-family: 宋体; font-size: 15px; line-height: 22px; background-color: #ffffff; ">&lt;mx:Script&gt;<br /></span><span class="Apple-style-span" style="font-family: 宋体; font-size: 15px; line-height: 22px; background-color: #ffffff; ">&lt;?xml version="1.0" encoding="iso-8859-1"?&gt;<br /></span><span class="Apple-style-span" style="font-family: 宋体; font-size: 15px; line-height: 22px; background-color: #ffffff; ">&lt;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"&gt;<br /></span><span class="Apple-style-span" style="font-family: 宋体; font-size: 15px; line-height: 22px; background-color: #ffffff; ">&nbsp;&nbsp;&nbsp; &lt;mx:Script&gt;<br /></span><span class="Apple-style-span" style="font-family: 宋体; font-size: 15px; line-height: 22px; background-color: #ffffff; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; import flash.external.*;<br />&nbsp;&nbsp; &nbsp;<br /></span><span class="Apple-style-span" style="font-family: 宋体; font-size: 15px; line-height: 22px; background-color: #ffffff; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public function callWrapper():void {<br /></span><span class="Apple-style-span" style="font-family: 宋体; font-size: 15px; line-height: 22px; background-color: #ffffff; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var f:String = "changeDocumentTitle";<br /></span><span class="Apple-style-span" style="font-family: 宋体; font-size: 15px; line-height: 22px; background-color: #ffffff; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var m:String = ExternalInterface.call(f,"New Title");<br /></span><span class="Apple-style-span" style="font-family: 宋体; font-size: 15px; line-height: 22px; background-color: #ffffff; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; trace(m);&nbsp;<br /></span><span class="Apple-style-span" style="font-family: 宋体; font-size: 15px; line-height: 22px; background-color: #ffffff; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br /></span><span class="Apple-style-span" style="font-family: 宋体; font-size: 15px; line-height: 22px; background-color: #ffffff; ">&nbsp;&nbsp;&nbsp; &lt;/mx:Script&gt;<br /></span><span class="Apple-style-span" style="font-family: 宋体; font-size: 15px; line-height: 22px; background-color: #ffffff; ">&nbsp;&nbsp;&nbsp; &lt;mx:Button label="Change Document Title" click="callWrapper()"/&gt;<br /></span><span class="Apple-style-span" style="font-family: 宋体; font-size: 15px; line-height: 22px; background-color: #ffffff; ">&lt;/mx:Application&gt;<br /></span><span class="Apple-style-span" style="font-family: 宋体; font-size: 15px; line-height: 22px; background-color: #ffffff; ">Html页面中有如下函数定义：<br /></span><span class="Apple-style-span" style="font-family: 宋体; font-size: 15px; line-height: 22px; background-color: #ffffff; ">&lt;SCRIPT LANGUAGE="JavaScript"&gt;<br /></span><span class="Apple-style-span" style="font-family: 宋体; font-size: 15px; line-height: 22px; background-color: #ffffff; ">&nbsp;&nbsp;&nbsp; function changeDocumentTitle(a) {<br /></span><span class="Apple-style-span" style="font-family: 宋体; font-size: 15px; line-height: 22px; background-color: #ffffff; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; window.document.title=a;<br /></span><span class="Apple-style-span" style="font-family: 宋体; font-size: 15px; line-height: 22px; background-color: #ffffff; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return "successful";<br /></span><span class="Apple-style-span" style="font-family: 宋体; font-size: 15px; line-height: 22px; background-color: #ffffff; ">&nbsp;&nbsp;&nbsp; }<br /></span><span class="Apple-style-span" style="font-family: 宋体; font-size: 15px; line-height: 22px; background-color: #ffffff; ">&lt;/SCRIPT&gt;</span><img src ="http://www.blogjava.net/GavinMiao/aggbug/367460.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/GavinMiao/" target="_blank">GavinMiao</a> 2011-12-29 00:51 <a href="http://www.blogjava.net/GavinMiao/archive/2011/12/29/367460.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>