﻿<?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-Thinking in MyLife-文章分类-Flex</title><link>http://www.blogjava.net/zhangzhong1018/category/16990.html</link><description>study ruby on rails</description><language>zh-cn</language><lastBuildDate>Wed, 04 Aug 2010 08:18:33 GMT</lastBuildDate><pubDate>Wed, 04 Aug 2010 08:18:33 GMT</pubDate><ttl>60</ttl><item><title>alert</title><link>http://www.blogjava.net/zhangzhong1018/articles/132351.html</link><dc:creator>leoli</dc:creator><author>leoli</author><pubDate>Wed, 25 Jul 2007 09:16:00 GMT</pubDate><guid>http://www.blogjava.net/zhangzhong1018/articles/132351.html</guid><wfw:comment>http://www.blogjava.net/zhangzhong1018/comments/132351.html</wfw:comment><comments>http://www.blogjava.net/zhangzhong1018/articles/132351.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/zhangzhong1018/comments/commentRss/132351.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/zhangzhong1018/services/trackbacks/132351.html</trackback:ping><description><![CDATA[你需要先导入Alert类： import mx.controls.Alert;<br><br>然后在想要弹出警告的时候使用：<br>Alert.show(&#8220;你确定要退出系统吗?&#8221;,&#8220;确认&#8221;,Alert.YES|Alert.NO,null,logout)<br><br>参数说明：第一个参数是要显示的文本，第二个参数是窗口的标题，这两个参数是最经常用的。第三个参数是按钮，默认是两个：YEW 和 NO，当然你也可以自定义，比如Alert.CANCEL，第四个参数是父窗口，默认为null。第五个参数是窗口关闭后调用的函数名，如果你想要在点击确定之后触发什么事件，就需要定义这个参数。这里我要调用logout，请注意，不要在这里写logout()。（没有括号）logout 函数如下：<br><br>private function logout(event:CloseEvent):void<br>{<br>&nbsp;&nbsp;&nbsp;&nbsp;if(event.detail == Alert.YES)<br>&nbsp;&nbsp;&nbsp;&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// 具体操作&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;}<br>}<br><br>因为这个函数是触发的，所以参数是一个CloseEvent 。&#8220;event.detail == Alert.YES&#8221; 这行代码判断点击的是不是确定按钮。CloseEvent 中的 detail 属性专门判断点击了哪个按钮，这样就可以用户的点击控制代码。
<img src ="http://www.blogjava.net/zhangzhong1018/aggbug/132351.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/zhangzhong1018/" target="_blank">leoli</a> 2007-07-25 17:16 <a href="http://www.blogjava.net/zhangzhong1018/articles/132351.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>flex 's bug (can't post data ie)</title><link>http://www.blogjava.net/zhangzhong1018/articles/132050.html</link><dc:creator>leoli</dc:creator><author>leoli</author><pubDate>Tue, 24 Jul 2007 07:10:00 GMT</pubDate><guid>http://www.blogjava.net/zhangzhong1018/articles/132050.html</guid><wfw:comment>http://www.blogjava.net/zhangzhong1018/comments/132050.html</wfw:comment><comments>http://www.blogjava.net/zhangzhong1018/articles/132050.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/zhangzhong1018/comments/commentRss/132050.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/zhangzhong1018/services/trackbacks/132050.html</trackback:ping><description><![CDATA[<p>I&#8217;ve found another bug in Flash. I wanted to POST to another site through getURL (I need open new window with some statistics, and must post data as input). I&#8217;m using FireFox, but this application must work in IE, so I&#8217;ve tested it in there and data was not POSTed. Through GET it works. So I&#8217;ve tried many possible solutions, and finally I&#8217;ve found, that this is problem of FRAMESET in IE. I&#8217;ve tested only IE and FireFox. If you can, please test it with another browsers, and let me know.</p>
<p><a href="http://www.franto.com/blog2/cant-post-data-in-internet-explorer">http://www.franto.com/blog2/cant-post-data-in-internet-explorer</a><br><a href="http://www.franto.com/blog2/cant-post-data-in-internet-explorer?pid=73&amp;rate=2">http://www.franto.com/blog2/cant-post-data-in-internet-explorer?pid=73&amp;rate=2</a><br><br></p>
<p>flex2.0&nbsp; <br>性能&nbsp; <br>改善性能&nbsp; <br>避免多层嵌套容器&nbsp; <br>一条好经验是避免容器的嵌套超过三层 <br>用 spacer 对象来填充不需要的空白 <br>绝对定位和缩放&nbsp; <br>每个容器及其子对象大小和位置的计算会占用大量资源 <br>对象位置固定编码&nbsp; <br>使用 Canvas 容器，其它类型的容器（如 Vbox）无法使用绝对位置 <br>将对象宽度和高度固定编码&nbsp; <br>可减轻相对布局管理器的处理负荷，从而加速容器和控件的创建 <br>避免的常见容器冗余&nbsp; <br>&lt;mx:Panel&gt; 标签中的 VBox 容器 <br>&lt;mx:Application&gt; 标签中的 VBox <br>容器作为 MXML 组件的顶层标签,能不用时可以舍弃 <br>MXML 组件外包上不必要的 VBox 容器来设置某些样式,可以在组件上设置样式 <br>重新评价对容器的选择 <br>改善性能感受&nbsp; <br>推迟实例化&nbsp; <br>在可以不必一个屏幕显示时可以使用 <br>Flex 中的导航条容器（ViewStack、Accordin、TabNavigator）中内置了推迟实例化,默认推迟实例化&nbsp; <br>creationPolicy="auto,all,none" <br>渐进式布局&nbsp; <br>需要一个屏幕显示,但重绘有效率低时 <br>使用运行时样式得到良好性能(不宜多用)&nbsp; <br>注意:第一次最好不要使用setStyle() 方法 <br>样式使用&nbsp; <br>&lt;mx:Style&gt; 块中(作为 MXML 标签的一个显式属性) <br>外部 CSS 样式表,(全局样式) <br>数据服务&nbsp; <br>flash 安全沙箱&nbsp; <br>由于 Flash Player 安全沙箱的存在，对 web 服务的请求只能到 加载 SWF 文件的同一个域。 <br>使用代理(不在同一主机或域)&nbsp; <br>useProxy="true"属性直接调用服务。 <br>不使用代理(在同一主机或域)&nbsp; <br>useProxy="false"属性直接调用服务。终端服务必须有 crossdomain.xml 文件。 <br>两种性能最好的发送数据方法是使用 HTTPService 的 XML 和使用 AMF 的 RemoteObject。 <br>Web 服务代理 &lt;mx:WebService&gt; <br>远程对象代理&lt;mx:RemoteObject&gt; <br>HTTP 服务&lt;mx:HTTPService&gt; <br>实施&nbsp; <br>预编译 MXML 页&nbsp; <br>预编译应用程序还能使开发者分发不带源码的应用程序。 <br>&nbsp; <br>flex&nbsp; <br>1.在 mx.swc 看原类中的一些函数 <br>2. cellRenderer,labelFunction&nbsp; <br>查看 CellRenderer API&nbsp; <br>3.Effect 使用 改变显示效果&lt;mx:Effect&gt;&nbsp; <br>mouseDownEffect&nbsp; <br>mouseOverEffect&nbsp; <br>mouseUpEffect&nbsp; <br>moveEffect&nbsp; <br>resizeEffect&nbsp; <br>showEffect&nbsp; <br>mouseOutEffect&nbsp; <br>hideEffect <br>3.其它技巧看 flexbook <br>&nbsp; <br>JavaScript&nbsp; <br>1.直接使用 getUrl 使用JavaScript&nbsp; <br>打开全屏窗口&nbsp; <br>getUrl(javascript:void(window.open('test.mxml','newwindow','fullscreen=yes,type=fullWindow,scrollbars=no,directories=no,status=no,menubar=no'))); <br>关闭当前窗口(无提示关闭)&nbsp; <br>getUrl(javascript:window.opener = 'dsg';window.close();); <br>2.在生成的html 文件中加入 JavaScript ,通过 getUrl使用 JavaScript <br></p>
<img src ="http://www.blogjava.net/zhangzhong1018/aggbug/132050.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/zhangzhong1018/" target="_blank">leoli</a> 2007-07-24 15:10 <a href="http://www.blogjava.net/zhangzhong1018/articles/132050.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>转 http://www.nshen.net/blog/article.asp?id=495  flex tip </title><link>http://www.blogjava.net/zhangzhong1018/articles/117548.html</link><dc:creator>leoli</dc:creator><author>leoli</author><pubDate>Tue, 15 May 2007 03:22:00 GMT</pubDate><guid>http://www.blogjava.net/zhangzhong1018/articles/117548.html</guid><wfw:comment>http://www.blogjava.net/zhangzhong1018/comments/117548.html</wfw:comment><comments>http://www.blogjava.net/zhangzhong1018/articles/117548.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/zhangzhong1018/comments/commentRss/117548.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/zhangzhong1018/services/trackbacks/117548.html</trackback:ping><description><![CDATA[<div class=textbox-title>
<h4>&nbsp;</h4>
</div>
<div class=textbox-content id=textboxContent><br>原文地址：<a title=http://www.kirupa.com/forum/showthread.php?t=223798 href="http://www.kirupa.com/forum/showthread.php?t=223798" target=_blank><u><font color=#800080>http://www.kirupa.com/forum/showthread.php?t=223798</font></u></a><br>原文作者：senocular<br><br><strong>原文目录：</strong><br><br>1. Change the frame rate of your movie<br>2. Abstract Classes<br>3. Deep Object Copies with ByteArray<br>4. Determine Instance Class or Superclass<br>5. Multiple Arguments in trace()<br>6. Loading Text and XML with URLLoader<br>7. Get Sound Spectrum Information<br>8. Garbage Collection: Reference Counting &amp; Mark and Sweep<br>9. Weak References<br>10. MXMLC: SWF Metadata Tag<br>11. TextField.appendText()<br>12. Access to stage and root<br>13. No More Color Class; Use ColorTransform<br>14. Array.indexOf (Array.lastIndexOf())<br>15. System.totalMemory<br>16. Closing Net Connections<br>17. AVM2 (AS3) to AVM1 (AS2/AS1) Communication via LocalConnection<br>18. Class member enumeration<br>19. Key.isDown in AS3<br>20. Scale and Alpha Ranges<br>21. Available ActionScript packages<br>22. Numeric Calculations: Number vs. int Speed<br>23. Getting Around globally accessible _root and _global<br>24. ActionScript 2 to ActionScript 3 Converter<br>25. Accessing FlashVars and HTML Parameters<br>26. ActionScript Speed Through Typing<br>27. LivePreview and the LivePreviewParent class<br>28. Flex Component Kit for Flash CS3<br>29. Loading URL encoded Variables<br>30. Interactive Masks<br>31. No _lockroot<br><br><strong>General:</strong><br><br><strong><span style="COLOR: maroon">1. 动态改变帧频：</span> </strong><br>
<div class=code>&nbsp;// change frame rate to 12 fps:<br>&nbsp;stage.frameRate = 12; </div>
<br><strong><span style="COLOR: maroon">2. Abstract Classes </span></strong><br><br>as3不支持抽象类，但有几个内置的抽象类 <br><br>DisplayObject <br>InteractiveObject <br>DisplayObjectContainer <br>Graphics <br><br>as3中这意味着不能实例化这些类，也不能继承他们 ,以下为错误操作： <br>
<div class=code>// 错误1 <br><br>var myObj:InteractiveObject = new InteractiveObject(); // ERROR </div>
<div class=code>// 错误2 <br><br>package {<br>&nbsp;import flash.display.DisplayObject;<br>&nbsp;public class MyDisplay extends DisplayObject{<br>&nbsp;public function MyDisplay (){<br>&nbsp;// ERROR<br>&nbsp;}<br>&nbsp;}<br>} </div>
<br><strong><span style="COLOR: maroon">3. Deep Object Copies with ByteArray</span> </strong><br><br>as3中很容易使用(flash.utils.ByteArray)类来进行对象的深拷贝，深拷贝不只拷贝引用，而是拷贝整个相关对象， <br><br>例如一个array里包含一个object引用，这个object也将被拷贝 <br><br>注意：这个方法通常用来拷贝一般的object <br><br>拷贝函数： <br>
<div class=code>function clone(source:Object):* {<br>&nbsp;var copier:ByteArray = new ByteArray();<br>&nbsp;copier.writeObject(source);<br>&nbsp;copier.position = 0;<br>&nbsp;return(copier.readObject());<br>} </div>
<br>使用方法： <br>
<div class=code>newObjectCopy = clone(originalObject); </div>
<br><strong><span style="COLOR: maroon">4. Determine Instance Class or Superclass </span></strong><br><br>as3中可以很容易的获取某个实例所属的类和父类的类名，使用这两个方法 <br><br>getQualifiedClassName (flash.utils.getQualifiedClassName). <br>getQualifiedSuperclassName (flash.utils.getQualifiedSuperclassName) <br>var sprite:Sprite = new Sprite();<br>trace(getQualifiedClassName(sprite)); // "flash.display::Sprite <br>trace(getQualifiedSuperclassName(sprite)); // "flash.display::DisplayObjectContainer" <br><br>你甚至可以由字符串获得类的引用，使用这个方法 <br><br>getDefinitionByName (flash.utils.getDefinitionByName). <br>getDefinitionByName("flash.display::Sprite")); // [class Sprite] <br><br><strong><span style="COLOR: maroon">5. Multiple Arguments in trace() </span></strong><br><br>as3 <br>trace(value1, value2, value3); <br>as1,as2 <br>trace([value1, value2, value3]); <br><br><strong><span style="COLOR: maroon">6. Loading Text and XML with URLLoader </span></strong><br>
<div class=code>var loader:URLLoader;<br>// ...<br>loader = new URLLoader();<br>loader.addEventListener(Event.COMPLETE, xmlLoaded);<br><br>var request:URLRequest = new URLRequest("file.xml");<br>loader.load(request);<br>//...<br>function xmlLoaded(event:Event):void {<br>&nbsp;var myXML:XML = new XML(loader.data);<br>&nbsp;//...<br>} </div>
<br><strong><span style="COLOR: maroon">7.Get Sound Spectrum Information</span></strong><br><br><br>(flash.media.SoundMixer)类的computeSpectrum静态方法可以把正在播放的声谱信息转成ByteArray，由此你可以想到办法把声谱可视化显示出来 <br>
<div class=code>// play sound...<br>var spectrumInfo:ByteArray = new ByteArray();<br>SoundMixer.computeSpectrum(spectrumInfo);<br>// spectrumInfo is now a byte array with sound spectrum info </div>
<br>具体可视化的方法可以看swfdong那里的教程 ：） <br><br><strong><span style="COLOR: maroon">8. Garbage Collection: Reference Counting &amp; Mark and Sweep</span></strong><br><br>垃圾回收机制包含两个关键： <br><br><span style="COLOR: maroon">（1）Reference Counting （引用数） ：</span><br><br>引用数就是在内存中引用同一个object的变量多少，每增加一个变量引用该object，引用数就+1 <br>var a:Object = new Object(); // new Object in memory given reference count of 1<br>var b:Object = a; // Object now has reference count of 2 <br>无论什么时候，当没有变量引用该object的时候，垃圾回收就会把他们回收了 <br>delete a; // Object has reference count of 1<br>delete b; // Object has reference count of 0, removed from memory <br>注意delete只能删除非成员变量，而且删除的是引用该object的变量而不是将object从内存中删除，那是垃圾回收器要做的事 <br>看下边这种情况： <br>var a:Object = new Object(); // reference(a) count 1<br>var b:Object = new Object(); // reference(b) count 1<br>a.b = b; // reference(b) count 2<br>b.a = a; // reference(a) count 2<br>delete a; // reference(a) count 1<br>delete b; // reference(b) count 1 <br>虽然a和b变量被删除了，而且我们再也不能用程序访问到他们了，但他们仍然存留在内存中~这种情况下垃圾回首器就没有办法了吗？错！这是记号清理要做的！ <br><br><span style="COLOR: maroon">（2）Mark and Sweep （记号清理）： </span><br><br>Mark and Sweep简单来说就是一种扫描机制，如下图，从root开始，扫到对象就mark一下，并扫描这个对象，等待全扫描完了，没有mark的自然是没有用的了，就会被从内存中删掉了. <br>[root] &lt;- scan...<br>[objectRef (marked)] &lt;- scan...<br>[objectRef (marked)] &lt;- scan...<br>[objectRef (marked)] &lt;- scan...<br>[objectRef (marked)] &lt;- scan...<br>[objectRef (marked)] &lt;- scan...<br>...<br>[delete all objects not marked] <br>当然这种扫描是昂贵的，需要很长时间才能发生一次，所以不要指望他了，编程的时候多注意引用数就可以了 <br><br><strong><span style="COLOR: maroon">9. Weak References </span></strong><br><br>使用弱引用来引用对象，不会被垃圾回收器视为有效的引用数。这样可以帮助垃圾回收器的工作 <br>所以使用弱引用这是一种比较好的编程习惯，使你不会在不经意间错误的引用到了某个object导致这个object不能被从内存中卸载~~~ <br>但不是哪里都可以使用弱引用的，as3中有两处可以使用： <br>（1）在Directionary类的构造函数中传入true <br>var dict:Dictionary = new Dictionary(true); // use weak references as keys <br>var obj:Object = new Object();<br>dict[obj] = true;<br>delete obj; // 虽然dict中有引用到obj，但并不是一个有效引用，所以obj仍然会被垃圾回收 <br><br>（2）在EventDispatcher的addEventListener 的第5个参数指定true <br>// addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void <br>addEventListener(MouseEvent.CLICK, clickHandler, false, 0 true); // use weak references <br><br><strong><span style="COLOR: maroon">10. MXMLC: SWF Metadata Tag </span></strong><br><br>如果你用mxmlc编译swf的话，可以使用swf metadata tag来指定swf的一些属性<br><br>支持以下属性： <br><br>width <br>height <br>frameRate <br>backgroundColor <br><br>例子：<br>
<div class=code>package {<br>&nbsp;[SWF(width="500", height="450", frameRate="24", backgroundColor="#FFFFFF")]<br>&nbsp;public class MyApp extends Sprite {<br><br>&nbsp;}<br>}</div>
<br><strong><span style="COLOR: maroon">11.TextField.appendText() </span></strong><br><br>(flash.text.TextField)类多了一个appendText()方法<br><br>var my_tf = new TextField();<br>my_tf.text = "Hello";<br>my_tf.appendText(" world!"); // my_tf.text == "Hello world!" <br><br>相当于以前的my_tf.text+=" world!" ,只是效率提高了<br><br><strong><span style="COLOR: maroon">12. Access to stage and root </span></strong><br><br>* 在as3中，当swf被loaded到player中时 stage object 是最顶端的容器，所有其他东西都在它里边，包括root在内<br><br>* 一个application中只有一个stage，却可以有若干个 root ，比如有外部内容被Loader类加载近来的时候<br><br>* 所有的DisplayObject (flash.display.DisplayObject)都有 stage 和 root 属性，但只有当他们被直接或间接的加入到display list 中的时候才有值，否则他们都为 null 。<br><br>* stage 属性 如果有值，那么他一直指向 stage 对象 ， root 却不同 ，具体哪不同，下边懒得翻引用原话 - -b<br><br>
<div class=quote>
<div class=quote-title>引用 <u></u></div>
<div class=quote-content>For the stage, root always references the stage<br>For the main timeline of the SWF and all display objects within it, root references the main timeline<br>If an object is added directly to the stage from any timeline, the root property for it and its children references the stage<br>For display objects in loaded SWF files, root references the main timeline of that SWF file<br>For loaded bitmap images, root references the Bitmap instance of the image loaded<br>Loader objects used to load external SWFs and images follow the rules of all other display objects within the SWF it is being used</div>
</div>
* 在as1 ,as 2中所有类都是在时间轴上创建的，这使的所有东东都能访问_root ，在as3中就不同了，如果你不是DisplayObject的话，访问root(或stage)会很困难，你需要一些技巧<br><br><span style="COLOR: maroon">技巧1：</span> 写一个TopLevel类，让Document类继承它，通过TopLevel类访问stage
<div class=code>&nbsp;package {<br>&nbsp;<br>&nbsp;import flash.display.DisplayObject;<br>&nbsp;import flash.display.MovieClip;<br>&nbsp;import flash.display.Stage;<br>&nbsp;<br>&nbsp;public class TopLevel extends MovieClip {<br>&nbsp;<br>&nbsp;public static var stage:Stage;<br>&nbsp;public static var root:DisplayObject;<br>&nbsp;<br>&nbsp;public function TopLevel() {<br>&nbsp;TopLevel.stage = this.stage;<br>&nbsp;TopLevel.root = this;<br>&nbsp;}<br>&nbsp;}<br>}</div>
<div class=code>package {<br>&nbsp;<br>&nbsp;public class MyDocumentClass extends TopLevel {<br>&nbsp;<br>&nbsp;public function MyDocumentClass() {<br>&nbsp;// code<br>&nbsp;}<br>&nbsp;}<br>}</div>
<div class=code>package {<br>&nbsp;<br>&nbsp;public class RandomClass {<br>&nbsp;<br>&nbsp;public function RandomClass() {<br>&nbsp;trace(TopLevel.stage); // [object Stage]<br>&nbsp;}<br>&nbsp;}<br>}</div>
<br>当然这很不oo也很不雅观~~~如果别人的Document类没继承TopLevel类就会有问题出现<br><br><span style="COLOR: maroon">技巧2 ：</span> 传递引用<br><br>类似这样通过构造函数将stage传进去<br>
<div class=code>package {<br>&nbsp;<br>&nbsp;import flash.display.Stage;<br><br>&nbsp;public class CustomObject {<br>&nbsp;<br>&nbsp;private var stage:Stage;<br>&nbsp;<br>&nbsp;public function CustomObject(stageRef:Stage) {<br>&nbsp;<br>&nbsp;// stage access through<br>&nbsp;// constructor argument<br>&nbsp;stage = stageRef;<br>&nbsp;}<br>&nbsp;}<br>}</div>
<br>作者给了一个 StageDetection 类<br>地址：<a title=http://www.senocular.com/flash/actionscript.php?file=ActionScript_3.0/com/senocular/events/StageDetection.as href="http://www.senocular.com/flash/actionscript.php?file=ActionScript_3.0/com/senocular/events/StageDetection.as" target=_blank><u><font color=#0000ff>http://www.senocular.com/flash/actionscript.php?file=ActionScript_3.0/com/senocular/events/StageDetection.as</font></u></a> <br><br>好象是用于检测某个display object 的 stage 或 root 属性是否存在，然后才能把stage的引用传给非display object<br><br><img alt=[exclaim] src="http://www.nshen.net/blog/styles/default/images/smilies/icon_exclaim.gif" border=0> （N神注：作者可能用的老版本flex？貌似现在的版本只要监听DisplayObject 的 addedToStage 或removedFromStage 事件就可以检查是stage和root的存在，不需要这个自定义的StageDetection 类吧...还请明人指点）<br><br><span style="COLOR: maroon"><strong>13. No More Color Class; Use ColorTransform </strong></span><br><br>as3 中彻底没了flash8就不推荐使用了的 Color类 改用 ColorTransform类<br><br>注意ColorTransform 的rgb属性已经改名为color<br>
<div class=code>// creates a red square<br>var square:Shape = new Shape();<br>square.graphics.beginFill(0x000000);<br>square.graphics.drawRect(0, 0, 100, 100);<br><br>var colorTransform:ColorTransform = square.transform.colorTransform;<br>colorTransform.color = 0xFF0000;<br>square.transform.colorTransform = colorTransform;<br><br>addChild(square);</div>
<br><strong><span style="COLOR: maroon">14. Array.indexOf (Array.lastIndexOf()) </span></strong><br><br>Array类多了两个方法 indexOf 和 lastIndexOf<br>
<div class=code>AS3 function indexOf(searchElement:*, fromIndex:int = 0):int<br>AS3 function lastIndexOf(searchElement:*, fromIndex:int = 0x7fffffff):int</div>
<br>跟String类的同名方法差不多 ，返回指定元素位置，如果没有返回 -1<br>
<div class=code>var sprite:Sprite = new Sprite();<br>var object:Object = new Object();<br>var boolean:Boolean = true;<br>var number:Number = 10;<br><br>var array:Array = new Array(sprite, object, number);<br>trace(array.indexOf(sprite)); // 0<br>trace(array.indexOf(number)); // 2<br>trace(array.indexOf(boolean)); // -1 </div>
<br><strong><span style="COLOR: maroon">15. System.totalMemory </span></strong><br><br>System 类 (flash.system.System) 有一个新属性叫做 totalMemory，返回当前flash player占用的内存<br>
<div class=code>var o:Object = new Object();<br>trace(System.totalMemory); // 4960256 </div>
<div class=code>var o:MovieClip = new MovieClip();<br>trace(System.totalMemory); // 4964352 </div>
<br><strong><span style="COLOR: maroon">16. Closing Net Connections </span></strong><br><br>as1,2时候，当loading开始后，你就不能关闭这个连接了，在as3世界里，即使loading开始了，你也可以停止它<br>
<div class=code>var loader:Loader = new Loader();<br>var request:URLRequest = new URLRequest("image.jpg");<br>loader.load(request);<br>addChild(loader);<br><br>// 如果3秒钟还没loading完，就关闭连接<br>var abortID:uint = setTimeout(abortLoader, 3000);<br><br>// abort the abort when loaded<br>loader.contentLoaderInfo.addEventListener(Event.COMPLETE, abortAbort);<br><br>function abortLoader(){<br>&nbsp;try {<br>&nbsp;loader.close();<br>&nbsp;}catch(error:Error) {} //注意这里有可能抛出IOError<br>}<br>function abortAbort(event:Event){<br>&nbsp;clearTimeout(abortID);<br>}</div>
<br><strong><span style="COLOR: maroon">17. AVM2 (AS3) to AVM1 (AS2/AS1) Communication via LocalConnection </span></strong><br><br>由于as3与as1,2虚拟机的不同导致as1,2 与as3不能直接沟通，如果需要的话必须要间接的使用<br><br>LocalConnection AS2 <br><a title="http://livedocs.macromedia.com/flash/8/main/00002338.html " href="http://livedocs.macromedia.com/flash/8/main/00002338.html" target=_blank><u><font color=#0000ff>http://livedocs.macromedia.com/flash/8/main/00002338.html </font></u></a><br><br>LocalConnection AS3 (flash.net.LocalConnection)<br><a title=http://livedocs.macromedia.com/flex/2/langref/flash/net/LocalConnection.html href="http://livedocs.macromedia.com/flex/2/langref/flash/net/LocalConnection.html" target=_blank><u><font color=#0000ff>http://livedocs.macromedia.com/flex/2/langref/flash/net/LocalConnection.html</font></u></a><br><br>在as2中
<div class=code>// ActionScript 2 file, AS2animation.fla<br>// one movie clip animation named animation_mc on the timeline<br><br>// local connection instance to receive events<br>var AVM_lc:LocalConnection = new LocalConnection();<br><br>// stopAnimation event handler<br>AVM_lc.stopAnimation = function(){<br>&nbsp;animation_mc.stop();<br>}<br><br>// listen for events for "AVM2toAVM1"<br>AVM_lc.connect("AVM2toAVM1");</div>
<br>as3中<br>
<div class=code>// ActionScript 3 file, AS3Loader.fla<br><br>// local connection instance to communicate to AVM1 movie<br>var AVM_lc:LocalConnection = new LocalConnection();<br><br>// loader loads AVM1 movie<br>var loader:Loader = new Loader();<br>loader.load(new URLRequest("AS2animation.swf"));<br>addChild(loader);<br><br>// when AVM1 movie is clicked, call stopPlayback<br>loader.addEventListener(MouseEvent.CLICK, stopPlayback);<br><br>function stopPlayback(event:MouseEvent):void {<br>&nbsp;// send stopAnimation event to "AVM2toAVM1" connection<br>&nbsp;AVM_lc.send("AVM2toAVM1", "stopAnimation");<br>}</div>
<br>as3 movie把as2的movie加载进来然后调用as2的stopAnimation<br><br><strong><span style="COLOR: maroon">18. Class member enumeration </span></strong><br><br>as3中只有dynamic class 中的dynamic definitions才可以被枚举（就是for in ），例如下边的class就没有可枚举的成员<br>
<div class=code>package {<br>&nbsp;<br>&nbsp;public class EnumerateClass {<br>&nbsp;<br>&nbsp;public var variable:String = "value";<br>&nbsp;public function method():void {}<br>&nbsp;}<br>}</div>
<div class=code>var example:EnumerateClass = new EnumerateClass();<br>for (var key:String in example) {<br>&nbsp;trace(key + ": " + example[key]); // 没有输出<br>}</div>
<br>即使上边的class改成dynamic的，也是没有输出，为什么呢？<br><br>因为里边的变量和方法是他们自己的，而并不是动态（dynamic）填加的，只有动态填加的属性可以被for in<br><br>Object类有个 setPropertyIsEnumerable方法，可以控制某个属性是否可枚举，但它只对dynamic属性有效<br>
<div class=code>package {<br>&nbsp;<br>&nbsp;public dynamic class EnumerateClass {<br>&nbsp;<br>&nbsp;public var variable:String = "value";<br>&nbsp;public function method():void {}<br>&nbsp;<br>&nbsp;public function EnumerateClass(){<br>&nbsp;this.dynamicVar = 1;<br>&nbsp;this.dynamicVar2 = 2;<br>&nbsp;this.setPropertyIsEnumerable("dynamicVar2", false);<br>&nbsp;}<br>&nbsp;}<br>}</div>
<br>上边的dynamic类有两个dynamic属性， dynamicVar 和 dynamicVar2 ，满足条件，都应该是可枚举的<br><br>但调用 setPropertyIsEnumerable("dynamicVar2", false);阻止了枚举 dynamicVar2<br>
<div class=code>var example:EnumerateClass = new EnumerateClass();<br>for (var key:String in example) {<br>&nbsp;trace(key + ": " + example[key]); // dynamicVar: 1<br>}</div>
<br>propertyIsEnumerable方法可以测试某一属性是否可枚举<br>
<div class=code>trace(example.propertyIsEnumerable("variable")); // false<br>trace(example.propertyIsEnumerable("dynamicVar")); // true<br>trace(example.propertyIsEnumerable("dynamicVar2")); // false </div>
<br><strong><span style="COLOR: maroon">19. Key.isDown in AS3 </span></strong><br><br>在as1，2时代，尤其是游戏中经常会用到 Key.isDown ，但到了as3，Key类已经不存在了，但我们可以通过些技巧实现这个类<br>
<div class=code>&nbsp;<br>package {<br>&nbsp;<br>&nbsp;import flash.display.Stage;<br>&nbsp;import flash.events.Event;<br>&nbsp;import flash.events.KeyboardEvent;<br>&nbsp;<br>&nbsp;/**<br>&nbsp;* The Key class recreates functionality of<br>&nbsp;* Key.isDown of ActionScript 1 and 2. Before using<br>&nbsp;* Key.isDown, you first need to initialize the<br>&nbsp;* Key class with a reference to the stage using<br>&nbsp;* its Key.initialize() method. For key<br>&nbsp;* codes use the flash.ui.Keyboard class.<br>&nbsp;*<br>&nbsp;* Usage:<br>&nbsp;* Key.initialize(stage);<br>&nbsp;* if (Key.isDown(Keyboard.LEFT)) {<br>&nbsp;* // Left key is being pressed<br>&nbsp;* }<br>&nbsp;*/<br>&nbsp;public class Key {<br>&nbsp;<br>&nbsp;private static var initialized:Boolean = false; // marks whether or not the class has been initialized<br>&nbsp;private static var keysDown:Object = new Object(); // stores key codes of all keys pressed<br>&nbsp;<br>&nbsp;/**<br>&nbsp;* Initializes the key class creating assigning event<br>&nbsp;* handlers to capture necessary key events from the stage<br>&nbsp;*/<br>&nbsp;public static function initialize(stage:Stage) {<br>&nbsp;if (!initialized) {<br>&nbsp;// assign listeners for key presses and deactivation of the player<br>&nbsp;stage.addEventListener(KeyboardEvent.KEY_DOWN, keyPressed);<br>&nbsp;stage.addEventListener(KeyboardEvent.KEY_UP, keyReleased);<br>&nbsp;stage.addEventListener(Event.DEACTIVATE, clearKeys);<br>&nbsp;<br>&nbsp;// mark initialization as true so redundant<br>&nbsp;// calls do not reassign the event handlers<br>&nbsp;initialized = true;<br>&nbsp;}<br>&nbsp;}<br>&nbsp;<br>&nbsp;/**<br>&nbsp;* Returns true or false if the key represented by the<br>&nbsp;* keyCode passed is being pressed<br>&nbsp;*/<br>&nbsp;public static function isDown(keyCode:uint):Boolean {<br>&nbsp;if (!initialized) {<br>&nbsp;// throw an error if isDown is used<br>&nbsp;// prior to Key class initialization<br>&nbsp;throw new Error("Key class has yet been initialized.");<br>&nbsp;}<br>&nbsp;return Boolean(keyCode in keysDown);<br>&nbsp;}<br>&nbsp;<br>&nbsp;/**<br>&nbsp;* Event handler for capturing keys being pressed<br>&nbsp;*/<br>&nbsp;private static function keyPressed(event:KeyboardEvent):void {<br>&nbsp;// create a property in keysDown with the name of the keyCode<br>&nbsp;keysDown[event.keyCode] = true;<br>&nbsp;}<br>&nbsp;<br>&nbsp;/**<br>&nbsp;* Event handler for capturing keys being released<br>&nbsp;*/<br>&nbsp;private static function keyReleased(event:KeyboardEvent):void {<br>&nbsp;if (event.keyCode in keysDown) {<br>&nbsp;// delete the property in keysDown if it exists<br>&nbsp;delete keysDown[event.keyCode];<br>&nbsp;}<br>&nbsp;}<br>&nbsp;<br>&nbsp;/**<br>&nbsp;* Event handler for Flash Player deactivation<br>&nbsp;*/<br>&nbsp;private static function clearKeys(event:Event):void {<br>&nbsp;// clear all keys in keysDown since the player cannot<br>&nbsp;// detect keys being pressed or released when not focused<br>&nbsp;keysDown = new Object();<br>&nbsp;}<br>&nbsp;}<br>}</div>
<br><strong><span style="COLOR: maroon">20.Scale and Alpha Ranges</span></strong><br><br>值得注意一下的是，as3中好多属性值的范围变化了，有些值原来范围是0 到 100 ，现在变成了0 到 1 ，例如下边几个，要留心一下<br>
<div class=code>ActionScript 2.0 | ActionScript 3.0<br>_xscale: 0 - 100 | scaleX: 0 - 1<br>_yscale: 0 - 100 | scaleY: 0 - 1<br>_alpha: 0 - 100 | alpha: 0 - 1</div>
<br><strong><span style="COLOR: maroon">21. Available ActionScript packages </span></strong><br><br>AS3 package 概要<br><br>* flash 包 (player的核心类包，永远可用)<br>* mx 包 (flex 专用类包，flex 的组件们需要)<br>* fl 包 (flash 专用类包，flash组件等)<br>* adobe 包 (flash 专用类包，绘图工具扩展等)<br><br>更多详细包内容，看文档<br><br>Flex: <a title=http://livedocs.adobe.com/flex/201/langref/ href="http://livedocs.adobe.com/flex/201/langref/" target=_blank><u><font color=#0000ff>http://livedocs.adobe.com/flex/201/langref/</font></u></a><br>Flash: <a title=http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/ href="http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/" target=_blank><u><font color=#0000ff>http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/</font></u></a><br>Apollo: <a title=http://livedocs.adobe.com/apollo/1.0/aslr/ href="http://livedocs.adobe.com/apollo/1.0/aslr/" target=_blank><u><font color=#0000ff>http://livedocs.adobe.com/apollo/1.0/aslr/</font></u></a><br><br>注意： Apollo相关的类在 flash和mx包里<br><br><strong><span style="COLOR: maroon">22. Numeric Calculations: Number vs. int Speed </span></strong><br><br>比较Number类型和新出现的int类型速度<br><br>*只有在用到 bitwise operations (&lt;&lt;, &gt;&gt;, &amp;, ^, and |) 的时候 int 类型比较快，例如<br>
<div class=code>var valueN:Number = 10;<br>result = valueN &lt;&lt; 2; // not so fast<br><br>var valueI:int = 10;<br>reesult = valueI &lt;&lt; 2; // Fast! </div>
<br>*其他情况下声明为Number比较快<br><br><strong><span style="COLOR: maroon">23. Getting Around globally accessible _root and _global </span></strong><br><br>as1 ,2中任何地方都能访问到_root ,_global ，这样可以很简单的保存变量或函数到这里，但在as3中已经没有_global了，root 也只有Disobject在显示列表里时才会得到，如果你非要这么做的话，应该自己写一个glo类，里边用一个静态变量bal指向一个Object，下边是代码<br>
<div class=code>package {<br>&nbsp;public class glo {<br>&nbsp;public static var bal:Object = new Object();<br>&nbsp;}<br>}</div>
<br>现在可以把 gol.bal 当成以前的_root或_global用了<br>
<div class=code>trace(glo.bal.foo); // undefined<br>glo.bal.foo = "bar";<br>trace(glo.bal.foo); // bar</div>
<br><br><strong><span style="COLOR: maroon">24. ActionScript 2 to ActionScript 3 Converter </span></strong><br><br>Patrick Mineault（<a title=http://www.5etdemi.com/blog/） href="http://www.5etdemi.com/blog/）" target=_blank><u><font color=#0000ff>http://www.5etdemi.com/blog/）</font></u></a> 用php写了一个as2 --&gt;as3 转换器，不是百分之百准确但也不错<br><br>online 版本 ：<a title=http://www.5etdemi.com/convert href="http://www.5etdemi.com/convert" target=_blank><u><font color=#0000ff>http://www.5etdemi.com/convert</font></u></a><br><br>下载 ：<a title=http://www.5etdemi.com/convert/convert.zip href="http://www.5etdemi.com/convert/convert.zip" target=_blank><u><font color=#0000ff>http://www.5etdemi.com/convert/convert.zip</font></u></a><br><br><strong><span style="COLOR: maroon">25. Accessing FlashVars and HTML Parameters</span></strong><br><br>你可以用HTML中的 object/embed 代码向镶入的SWF传递变量。<br><br>有两种方法：<br><br>1。在swf的url后边加变量（query string）<br>
<div class=code>&lt;!-- URL Variables --&gt;<br>&lt;object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="640" height="500" align="middle"&gt;<br>&nbsp;&nbsp;&lt;param name="allowScriptAccess" value="sameDomain" /&gt;<br>&nbsp;&nbsp;&lt;param name="movie" value="flashMovie.swf?myVar=1" /&gt;<br>&nbsp;&nbsp;&lt;param name="quality" value="high" /&gt;<br>&nbsp;&nbsp;&lt;param name="bgcolor" value="#EFF7F6" /&gt;<br>&nbsp;&nbsp;&lt;embed src="flashMovie.swf?myVar=1" quality="high" bgcolor="#EFF7F6" width="640" height="500" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /&gt;<br>&lt;/object&gt;</div>
<br>2.使用FlashVars<br>
<div class=code>&lt;!-- FlashVars --&gt;<br>&lt;object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="550" height="400" align="middle"&gt;<br>&nbsp;&nbsp;&lt;param name="allowScriptAccess" value="sameDomain" /&gt;<br>&nbsp;&nbsp;&lt;param name="movie" value="flashMovie.swf" /&gt;<br>&nbsp;&nbsp;&lt;param name="quality" value="high" /&gt;<br>&nbsp;&nbsp;&lt;param name="bgcolor" value="#FFFFFF" /&gt;<br>&nbsp;&nbsp;&lt;param name="FlashVars" value="myVar=1" /&gt;&nbsp;&nbsp;<br>&nbsp;&nbsp;&lt;embed src="flashMovie.swf" FlashVars="myVar=1" quality="high" bgcolor="#FFFFFF" width="550" height="400" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /&gt;<br>&lt;/object&gt;</div>
<br>在as2中这些变量会被简单的声明到_root上，但在as3中有所改变。现在这些变量被放到了root下的parameters对象下，上边HTML传的值可以这样访问：
<div class=code>root.loaderInfo.parameters.myVar;</div>
<br><strong><span style="COLOR: maroon">26. ActionScript Speed Through Typing </span></strong><br><br>考虑到效率，尽量把你的变量声明类型，如果可能的话避免使用dynamic class<br><br><strong><span style="COLOR: maroon">27. LivePreview and the LivePreviewParent class</span> </strong><br><br>as2 的组件使用_global下的isLivePreview属性来判断是否是在Flash IDE中预览，as3中这个属性不见了，取而代之的是你可以检查这个组件的parent是否为 LivePreviewParent 类的实例<br>
<div class=code>var isLivePreview:Boolean = (parent != null &amp;&amp; getQualifiedClassName(parent) == "fl.livepreview::LivePreviewParent");</div>
<br>（ <img alt=[exclaim] src="http://www.nshen.net/blog/styles/default/images/smilies/icon_exclaim.gif" border=0> N神注：as2时代的isLivePreview这个属性偶也没用过，不清楚这个翻译的对不对 - -b ）<br><br><strong><span style="COLOR: maroon">28. Flex Component Kit for Flash CS3</span></strong><br><br>Flex Component Kit for Flash CS3（在Adobe Labs里） 允许把flash中做的交互内容，在Flex中当成Flex comonnet来用<br><br>现在可以很容易的使Flash symbol继承我们的新 UIMovieClip 类<br>从而使<br>* flash 组件放在一个Flex container里，所有layout会很好的工作<br>* flash 的帧标签被完全转换为 Flex 的state和 transition<br>* 只要简单的填加个 SWC 到 library path里Flex Builder就可以有flash组件的语法提示了<br>* Simple JSFL commands are available to set up new documents as well as publish the Flex-enabled SWC （这句没看明白- -b）<br><br><strong><span style="COLOR: maroon">29. Loading URL encoded Variables</span> </strong><br><br>URLLoader类(flash.net.URLLoader) 在as3中用来读外部文本文件.当一个外部文件被load后，它的内容会被存储在URLLoader实例的data属性里，一般情况下无论外部文件是什么格式，都会被以raw text形似读取，如果读变量可能需要改一下dataFormat属性<br><br>URLLoader类的dataFormat属性决定被加载数据的格式。 dataFormat属性的可选值在 URLLoaderDataFormat 类中(flash.net.URLLoaderDataFormat)<br><br>可选值为:<br><br>BINARY - 指定按2禁止数据接受<br>TEXT - 指定当成文本接受<br>VARIABLES - 指定当作 URL-encoded变量接受<br><br>指定URLLoaderDataFormat.VARIABLES 作为 URLLoader的 dataFormat属性, 被加载的数据将被当作一组变量，而不是字符串<br>data属性将为包含被加载变量的一个 URLVariables 类 (flash.net.URLVariables)的实例<br><br>ActionScript 代码:<br>
<div class=code>var loader:URLLoader = new URLLoader();<br><br>// specify format as being variables<br>loader.dataFormat = URLLoaderDataFormat.VARIABLES;<br><br>loader.addEventListener(Event.COMPLETE, varsLoaded);<br><br>// vars.txt contents: foo=bar&amp;foo2=bar2<br>loader.load(new URLRequest("vars.txt")); <br><br>function varsLoaded (event:Event):void {<br>&nbsp;trace(loader.data is URLVariables); // true<br>&nbsp;trace(loader.data.foo); // bar<br>&nbsp;trace(loader.data.foo2); // bar2<br>}</div>
<br><strong><span style="COLOR: maroon">30. Interactive Masks</span> </strong><br><br>默认情况下，当一个对象 mask 另一个对象的时候，前者（这个遮照）将失去它的交互性，例如，一个sprite有一个 click事件，但当这个sprite成为一个遮照的时候，这个click事件就不起作用了<br><br>如果你想让一个对象作为遮照的时候也拥有交互性，就指定它的buttonMode属性为true<br><br>ActionScript Code:
<div class=code>maskInstance.buttonMode = true;</div>
<br><strong><span style="COLOR: maroon">31. No _lockroot </span></strong><br><br>ActionScript 3 没有 _lockroot属性了. <br>_lockroot 属性是在Flash Player 7 引入近来的，_lockroot属性原本用来确保被load进来的movie的_root属性始终引用它自己而不是主swf在 ActionScript 3 中, 所有的root引用永远指向文件本身的root 就像_lockroot已经在那了一样。（ <img alt=[exclaim] src="http://www.nshen.net/blog/styles/default/images/smilies/icon_exclaim.gif" border=0> N神注：想引用原来主swf的root应该用stage了）
<div class=editmark>[最后编辑于 N神, at 2007-05-13 13:09:08] </div>
</div>
<img src ="http://www.blogjava.net/zhangzhong1018/aggbug/117548.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/zhangzhong1018/" target="_blank">leoli</a> 2007-05-15 11:22 <a href="http://www.blogjava.net/zhangzhong1018/articles/117548.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>flex dateForm</title><link>http://www.blogjava.net/zhangzhong1018/articles/117287.html</link><dc:creator>leoli</dc:creator><author>leoli</author><pubDate>Mon, 14 May 2007 03:27:00 GMT</pubDate><guid>http://www.blogjava.net/zhangzhong1018/articles/117287.html</guid><wfw:comment>http://www.blogjava.net/zhangzhong1018/comments/117287.html</wfw:comment><comments>http://www.blogjava.net/zhangzhong1018/articles/117287.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/zhangzhong1018/comments/commentRss/117287.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/zhangzhong1018/services/trackbacks/117287.html</trackback:ping><description><![CDATA[&lt;?xml version="1.0" encoding="utf-8"?&gt;<br>&lt;mx:Form initialize="oninit()" xmlns:mx="<a href="http://www.adobe.com/2006/mxml"><font color=#444444>http://www.adobe.com/2006/mxml</font></a>" height="22" paddingBottom="0" paddingLeft="0" paddingRight="0" paddingTop="0" maxHeight="22" minHeight="22" minWidth="120"&gt;<br>&nbsp;&lt;mx:PopUpButton id="selectdate" width="100%" height="100%"/&gt;<br>&nbsp;&lt;mx:Form width="340" height="270" paddingBottom="6" paddingLeft="6" paddingRight="6" paddingTop="6" fontSize="12" id="frmData" backgroundColor="#e3e3e3" backgroundAlpha="1.0" borderStyle="solid" cornerRadius="11" alpha="1.0" borderThickness="4" borderColor="#808080"&gt;<br>&nbsp;&nbsp;&lt;mx:ApplicationControlBar width="100%" paddingLeft="14" paddingRight="0" fillColors="[#ffffff, #8080c0]" borderColor="#8080c0" themeColor="#8080c0" fillAlphas="[1.0, 1.0]" paddingBottom="2" paddingTop="2"&gt;<br>&nbsp;&nbsp;&nbsp;&lt;mx:ComboBox change="yearchange()" rowCount="10" width="70" height="24" useHandCursor="true" id="cmdPYears"&gt;&lt;/mx:ComboBox&gt;<br>&nbsp;&nbsp;&nbsp;&lt;mx:ComboBox change="monthchange()" rowCount="10" width="58" id="cmdmonth"&gt;&lt;/mx:ComboBox&gt;<br>&nbsp;&nbsp;&lt;/mx:ApplicationControlBar&gt;<br>&nbsp;&nbsp;&lt;mx:ControlBar width="100%" paddingBottom="0" paddingLeft="14" paddingRight="0" paddingTop="0"&gt;<br>&nbsp;&nbsp;&nbsp;&lt;mx:Label text="日" textAlign="center" width="35" height="24" fontWeight="bold"/&gt;<br>&nbsp;&nbsp;&nbsp;&lt;mx:Label text="一" textAlign="center" width="35" height="24" fontWeight="bold"/&gt;<br>&nbsp;&nbsp;&nbsp;&lt;mx:Label text="二" textAlign="center" width="35" height="24" fontWeight="bold"/&gt;<br>&nbsp;&nbsp;&nbsp;&lt;mx:Label text="三" textAlign="center" width="35" height="24" fontWeight="bold"/&gt;<br>&nbsp;&nbsp;&nbsp;&lt;mx:Label text="四" textAlign="center" width="35" height="24" fontWeight="bold"/&gt;<br>&nbsp;&nbsp;&nbsp;&lt;mx:Label text="五" textAlign="center" width="35" height="24" fontWeight="bold"/&gt;<br>&nbsp;&nbsp;&nbsp;&lt;mx:Label text="六" textAlign="center" width="35" height="24" fontWeight="bold"/&gt;<br>&nbsp;&nbsp;&lt;/mx:ControlBar&gt;<br>&nbsp;&nbsp;&lt;mx:Form width="100%" height="180" paddingBottom="0" paddingLeft="0" paddingRight="0" id="frmdates" paddingTop="0"&gt;<br>&nbsp;&nbsp;&lt;/mx:Form&gt;<br>&nbsp;&lt;/mx:Form&gt;<br>&nbsp;&lt;mx:Script&gt;<br>&nbsp;&lt;![CDATA[<br>&nbsp;//Copyright (c) 2005-2006 JianHan Fan&nbsp;<br>&nbsp;//Mail:henryfan@msn.com<br>&nbsp;//All rights reserved.<br>&nbsp;//-------------------------------------<br>&nbsp;&nbsp;import mx.containers.ControlBar;<br>&nbsp;&nbsp;import mx.controls.Button;<br>&nbsp;&nbsp;import mx.events.IndexChangedEvent;<br>&nbsp;&nbsp;import mx.controls.Alert;<br>&nbsp;&nbsp;private var mDateValue:Date =new Date();<br>&nbsp;&nbsp;function oninit():void<br>&nbsp;&nbsp;{<br>&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;ViewDate(DateValue);<br>&nbsp;&nbsp;&nbsp;__CreateControls();<br>&nbsp;&nbsp;&nbsp;var b:Button = new Button();<br>&nbsp;&nbsp;&nbsp;removeChild(frmData);<br>&nbsp;&nbsp;&nbsp;selectdate.popUp= frmData;<br>&nbsp;&nbsp;}<br>&nbsp;&nbsp;<br>&nbsp;&nbsp;public function set DateValue(value:Date)<br>&nbsp;&nbsp;{<br>&nbsp;&nbsp;&nbsp;mDateValue = value;<br>&nbsp;&nbsp;&nbsp;ViewDate(value);<br>&nbsp;&nbsp;}<br>&nbsp;&nbsp;public function get DateValue():Date<br>&nbsp;&nbsp;{<br>&nbsp;&nbsp;&nbsp;return mDateValue;<br>&nbsp;&nbsp;}<br>&nbsp;&nbsp;private function ViewDate(value:Date):void<br>&nbsp;&nbsp;{<br>&nbsp;&nbsp;&nbsp;selectdate.label= value.fullYear.toString()+"年"<br>&nbsp;&nbsp;&nbsp;+(value.month+1).toString()+"月"+ value.date.toString()+"日";<br>&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;}<br>&nbsp;&nbsp;private function __CreateControls():void<br>&nbsp;&nbsp;{<br>&nbsp;&nbsp;&nbsp;SetSelectYears(DateValue.fullYear);<br>&nbsp;&nbsp;&nbsp;createDate(DateValue);<br>&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;}<br>&nbsp;&nbsp;private function createDate(value:Date):void<br>&nbsp;&nbsp;{<br>&nbsp;&nbsp;&nbsp;frmdates.removeAllChildren();<br>&nbsp;&nbsp;&nbsp;var towmonth:int=0;<br>&nbsp;&nbsp;&nbsp;var buttons:Array = new Array();<br>&nbsp;&nbsp;&nbsp;var item:Button;<br>&nbsp;&nbsp;&nbsp;if((value.fullYear%4==0 &amp;&amp; value.fullYear%100 !=0) || value.fullYear%400==0)<br>&nbsp;&nbsp;&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;towmonth=29;<br>&nbsp;&nbsp;&nbsp;}<br>&nbsp;&nbsp;&nbsp;else<br>&nbsp;&nbsp;&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;towmonth = 28;<br>&nbsp;&nbsp;&nbsp;}<br>&nbsp;&nbsp;&nbsp;var monthdays:Array= new Array(<br>&nbsp;&nbsp;&nbsp;31,towmonth,31,30,31,30,31,31,30,31,30,31);<br>&nbsp;&nbsp;&nbsp;//生成本月第一天<br>&nbsp;&nbsp;&nbsp;var nd:Date = new Date(value.fullYear,value.month,1);<br>&nbsp;&nbsp;&nbsp;var pmdays:int;//上一个月的日数<br>&nbsp;&nbsp;&nbsp;if(nd.month==0)<br>&nbsp;&nbsp;&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;pmdays= monthdays[11];<br>&nbsp;&nbsp;&nbsp;}<br>&nbsp;&nbsp;&nbsp;else<br>&nbsp;&nbsp;&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;pmdays = monthdays[(nd.month-1)];<br>&nbsp;&nbsp;&nbsp;}<br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;for(var i:int=(pmdays-nd.day+1);i&lt;=pmdays;i++)<br>&nbsp;&nbsp;&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;item = new Button();<br>&nbsp;&nbsp;&nbsp;&nbsp;item.label = i.toString();<br>&nbsp;&nbsp;&nbsp;&nbsp;item.setStyle("fillColors",[0x808080, 0x808080]);<br>&nbsp;&nbsp;&nbsp;&nbsp;if(nd.month==0)<br>&nbsp;&nbsp;&nbsp;&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;item.data =new Date(nd.fullYear-1,11,i);<br>&nbsp;&nbsp;&nbsp;&nbsp;}<br>&nbsp;&nbsp;&nbsp;&nbsp;else<br>&nbsp;&nbsp;&nbsp;&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;item.data = new Date(nd.fullYear,nd.month-1,i);<br>&nbsp;&nbsp;&nbsp;&nbsp;}<br>&nbsp;&nbsp;&nbsp;&nbsp;buttons.push(item);<br>&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;}<br>&nbsp;&nbsp;&nbsp;for(var i:int=1;i&lt;=monthdays[nd.month];i++)<br>&nbsp;&nbsp;&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;item = new Button();<br>&nbsp;&nbsp;&nbsp;&nbsp;item.label = i.toString();<br>&nbsp;&nbsp;&nbsp;&nbsp;item.data = new Date(nd.fullYear,nd.month,i);<br>&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;item.visible= true;<br>&nbsp;&nbsp;&nbsp;&nbsp;buttons.push(item);<br>&nbsp;&nbsp;&nbsp;}<br>&nbsp;&nbsp;&nbsp;//生成本月最后一天<br>&nbsp;&nbsp;&nbsp;nd = new Date(value.fullYear,value.month,monthdays[nd.month]);<br>&nbsp;&nbsp;&nbsp;var nday:int=1;//下一个月的日期<br>&nbsp;&nbsp;&nbsp;for(var i:int= nd.day+1;i&lt;7;i++)<br>&nbsp;&nbsp;&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;item = new Button();<br>&nbsp;&nbsp;&nbsp;&nbsp;item.label = nday.toString();<br>&nbsp;&nbsp;&nbsp;&nbsp;item.setStyle("fillColors",[0x808080, 0x808080]);<br>&nbsp;&nbsp;&nbsp;&nbsp;if(nd.month==11)<br>&nbsp;&nbsp;&nbsp;&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;item.data =new Date(nd.fullYear+1,0,nday);<br>&nbsp;&nbsp;&nbsp;&nbsp;}<br>&nbsp;&nbsp;&nbsp;&nbsp;else<br>&nbsp;&nbsp;&nbsp;&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;item.data =new Date(nd.fullYear,nd.month+1,nday);<br>&nbsp;&nbsp;&nbsp;&nbsp;}<br>&nbsp;&nbsp;&nbsp;&nbsp;buttons.push(item);<br>&nbsp;&nbsp;&nbsp;&nbsp;nday++;<br>&nbsp;&nbsp;&nbsp;}<br>&nbsp;&nbsp;&nbsp;var panel:ControlBar;<br>&nbsp;&nbsp;&nbsp;var row:int=0;<br>&nbsp;&nbsp;&nbsp;for(var i:int =0;i&lt; buttons.length;i++)<br>&nbsp;&nbsp;&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;buttons[i].width =35;<br>&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;(buttons[i] as Button).addEventListener("click",onclick);<br>&nbsp;&nbsp;&nbsp;&nbsp;if(i==0 || (i+1)%7==1)<br>&nbsp;&nbsp;&nbsp;&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;panel = new ControlBar();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;panel.width=new Number("100%");<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;panel.setStyle("paddingBottom",1);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;panel.setStyle("paddingLeft",14);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;panel.setStyle("paddingRight",1);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;panel.setStyle("paddingTop",1);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;row++;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;panel.label=i.toString();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;frmdates.addChild(panel);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;}<br>&nbsp;&nbsp;&nbsp;&nbsp;panel.addChild(buttons[i] as DisplayObject)<br>&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;}<br>&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;}<br>&nbsp;&nbsp;private function onclick(event:Event)<br>&nbsp;&nbsp;{<br>&nbsp;&nbsp;&nbsp;DateValue= (event.currentTarget.data as Date);<br>&nbsp;&nbsp;}<br>&nbsp;&nbsp;private function SetSelectYears(year:Number):void<br>&nbsp;&nbsp;{<br>&nbsp;&nbsp;&nbsp;var nyears:Array = new Array();<br>&nbsp;&nbsp;&nbsp;var start:Number = year-50;<br>&nbsp;&nbsp;&nbsp;var end:Number = year+50;<br>&nbsp;&nbsp;&nbsp;var months:Array = new Array();<br>&nbsp;&nbsp;&nbsp;for(var i:Number=start;i&lt;end;i++)<br>&nbsp;&nbsp;&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;nyears.push({label:i,data:i});<br>&nbsp;&nbsp;&nbsp;}<br>&nbsp;&nbsp;&nbsp;for(var k:int=1;k&lt;13;k++)<br>&nbsp;&nbsp;&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;months.push({label:k,data:k});<br>&nbsp;&nbsp;&nbsp;}<br>&nbsp;&nbsp;&nbsp;cmdPYears.dataProvider= nyears;<br>&nbsp;&nbsp;&nbsp;cmdPYears.selectedIndex=50;<br>&nbsp;&nbsp;&nbsp;cmdmonth.dataProvider= months;<br>&nbsp;&nbsp;&nbsp;cmdmonth.selectedIndex = DateValue.month;<br>&nbsp;&nbsp;}<br>&nbsp;&nbsp;private function yearchange()<br>&nbsp;&nbsp;{<br>&nbsp;&nbsp;&nbsp;var d:Date = new Date(<br>&nbsp;&nbsp;&nbsp;cmdPYears.selectedItem.data,<br>&nbsp;&nbsp;&nbsp;cmdmonth.selectedItem.data-1,1);<br>&nbsp;&nbsp;&nbsp;createDate(d);<br>&nbsp;&nbsp;}<br>&nbsp;&nbsp;private function monthchange()<br>&nbsp;&nbsp;{<br>&nbsp;&nbsp;&nbsp;var d:Date = new Date(<br>&nbsp;&nbsp;&nbsp;cmdPYears.selectedItem.data,<br>&nbsp;&nbsp;&nbsp;cmdmonth.selectedItem.data-1,1);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;createDate(d);<br>&nbsp;&nbsp;}<br>&nbsp;]]&gt;<br>&lt;/mx:Script&gt;
<p>&lt;/mx:Form&gt;</p>
<img src ="http://www.blogjava.net/zhangzhong1018/aggbug/117287.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/zhangzhong1018/" target="_blank">leoli</a> 2007-05-14 11:27 <a href="http://www.blogjava.net/zhangzhong1018/articles/117287.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>flex 大赛 获奖</title><link>http://www.blogjava.net/zhangzhong1018/articles/116662.html</link><dc:creator>leoli</dc:creator><author>leoli</author><pubDate>Fri, 11 May 2007 01:53:00 GMT</pubDate><guid>http://www.blogjava.net/zhangzhong1018/articles/116662.html</guid><wfw:comment>http://www.blogjava.net/zhangzhong1018/comments/116662.html</wfw:comment><comments>http://www.blogjava.net/zhangzhong1018/articles/116662.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/zhangzhong1018/comments/commentRss/116662.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/zhangzhong1018/services/trackbacks/116662.html</trackback:ping><description><![CDATA[<p><font size=2><strong>从</strong>EverythingFlex那里看到的，转载过来，就不翻译成中文了，大家一起欣赏下这些获奖作品吧。</font></p>
<p><font size=4><strong>Winner Product Configurators/Self-Service Guided Applications</strong><br></font><a href="http://www.asfusion.com/apps/homelocator/" target=_blank><strong>Home Locator</strong></a>—(Flash Player 9 Required) Home Locator is an intuitive real estate searching application. It lets users search by area by clicking on a US map and then filter the results by price, number of bedrooms, bathrooms and other relevant criteria. For each property, detailed information is shown and actual location is plotted on a map, all in one screen. Users can see pictures for a property, helping them determine whether or not they want to visit the property. They can also save properties as favorites to be reviewed at a later time and can let other people see their favorite list. As a bonus, it also includes an administration to edit properties. <a href="http://www.asfusion.com/" target=_blank><strong></strong></a><strong><br><br></strong></p>
<div align=center><strong><img alt="" src="http://www.everythingflex.com/blog/images/homeLocator.jpg"><br><br></strong>
<div align=left><strong>Technology Flex 2.0<br>Developer <a href="http://www.asfusion.com/" target=_blank><strong>Nahuel Foronda</strong></a></strong></div>
</div>
<hr>
<strong><br><font size=4><strong>Winner Components and Gadgets</strong></font><br><strong><a href="http://www.kevinkaz.com/flex2/" target=_blank>SQLAdmin</a></strong>—(Flash Player 9 Required)<br>SQLAdmin is an online version of query analyzer for Microsoft SQL Server. Features include a graphical execution plan, syntax highlighting, live table editing, tabbed query windows, an object browser and more. Click on a table name from the object browser to popup a menu to generate select, insert, update, or delete scripts or to open the table for live data editing.<br><br></strong>
<div align=center><strong><a title=在新窗口打开图片 href="http://www.everythingflex.com/blog/images/sqlBrowser.jpg" target=_blank><img alt="" src="http://www.everythingflex.com/blog/images/sqlBrowser.jpg" width=500></a></strong></div>
<strong><br>Technology Flex 2.0<br>Developer <strong><a href="http://www.kevinkaz.com/" target=_blank>Kevin Kazmierczak</a></strong> <br>Kevin Kazmierczak is the senior software developer for Citynet, a telecommunications company in Bridgeport, West Virginia. He graduated from Alfred University with a Bachelors in Computer Science and a Masters in Business Administration and spends most of his time programming in ColdFusion. He's a Certified Advanced ColdFusion Developer and has written an article published in the ColdFusion Developers Journal. <br><br></strong>
<hr>
<strong><br></strong>
<div align=left><strong><strong><font size=4>Winner Data Dashboards </font></strong><br></strong></div>
<strong><strong><a href="http://www.statpods.com/derby" target=_blank>StatPods</a></strong>—(Flash Player 9 Required)<br>StatPods is a dashboard for the visualization of web visits, page views, session tracking, and browser/platform properties information. StatPods allows for multiple days or months of datasets to be loaded for comparison views. StatPods was written with Flex 2 beta 3 with a Cairngorm 2 framework and uses ColdFusion MX7 for data retrieval as well as pdf, flash paper, and excel data exports. StatPods takes advantage of many new features of Flex 2 including state management, print views, effects, and more. Now updated with Yahoo! Mapping.<br><br></strong>
<div align=center><strong><a title=在新窗口打开图片 href="http://www.everythingflex.com/blog/images/statpods.jpg" target=_blank><img alt="" src="http://www.everythingflex.com/blog/images/statpods.jpg" width=500></a></strong></div>
<strong><br>Technology Flex 2.0<br>Developer <strong><a href="http://www.everythingflex.com/blog" target=_blank>Rich Tretola</a></strong> <br>Rich Tretola has been an internet applications developer since 2000. He began his career as a ColdFusion developer and since the original Royale beta (prior to the release of Flex 1.0) has spent the majority of his time as a Flex/Java &amp; ColdFusion developer. Rich is a featured author at <a href="http://www.ifbin.com/" target=_blank>IFBIN.com</a> and runs a Flex weblog at <a href="http://www.everythingflex.com/" target=_blank>EverythingFlex.com</a><br><br></strong>
<hr>
<strong><br><font size=4><strong>Winner Mashups</strong></font><br><strong><a href="http://www.amitgupta.info/E41ST/GUI/gmc/e41st.html" target=_blank>E41ST</a>—(Flash Player 9 Required)</strong><br>E41ST is a mashup between Amazon.com and the Public Library system. Its objective to provide an an integrated interface wherein book lovers can get an enriched browsing experience based on Amazon.com's content, but at the same time have the ability to seamlessly lookup selected book's availability in their library. Currently about a dozen of the largest public libraries are integrated into E41ST, but almost any library with a website that allows searches by ISBN number can be integrated easily &amp; quickly.<br><br></strong>
<div align=center><strong><a title=在新窗口打开图片 href="http://www.everythingflex.com/blog/images/e41.jpg" target=_blank><img alt="" src="http://www.everythingflex.com/blog/images/e41.jpg" width=500></a></strong></div>
<strong><br>Technology Flex 2.0<br>Developer <strong><a href="http://www.amitgupta.info/E41ST/" target=_blank>Amit Gupta</a><br></strong><br></strong>
<hr>
<strong><strong>&nbsp;<br></strong><font size=4><strong>Winner Communication/Collaboration</strong></font><strong><br><a href="http://flexderby.ntara.com/" target=_blank>Lesson Builder Tool</a></strong>—(Flash Player 9 Required) The Lesson Builder Tool, code-named "Project nGrain", serves as a practical, rich-internet solution that enables a group of content editors to collaborate in the creation of Flash-based training modules. The application includes a check-in/check-out system that prevents users from overwriting changes made by other members of their team. The training modules, or Lessons, are XML driven and fully dynamic. After Lessons have been created, the user is able to preview their changes. Once the user is happy with the final content, they may download the zipped module (to be loaded into the offline player) through the "Pack and Download" feature. Other features of the application include: User Management, Edit Profile, drag-n-drop Slide Re-ordering, Image Upload, Voice-Over Upload, Multiple Slide Types, Preview by Lesson, Preview by Slide, Collaboration Notes, Lesson Categories. <br><br></strong>
<div align=center><strong><a title=在新窗口打开图片 href="http://www.everythingflex.com/blog/images/lessonBuilder.jpg" target=_blank><img alt="" src="http://www.everythingflex.com/blog/images/lessonBuilder.jpg" width=500></a></strong></div>
<strong><br>Technology Flex 2.0 <br>Developer <strong><a href="http://www.ntara.com/" target=_blank>Tim McLeod </a><br></strong><br></strong>
<hr>
<strong><br><font size=4><strong>Winner </strong><strong>Just Freakin&#8217; Cool (aka Wild Card)</strong></font><br><strong><a href="http://codeazur.com.br/stuff/fc64_final/" target=_blank>FC64</a></strong>—(Flash Player 9 Required)<br>FC64 is a Commodore 64 Emulator written in ActionScript 3 for Flash Player 9. The original hardware of the Commodore 64 has been re-created in software to allow the Flash Player to be used just like an original Commdore 64. FC64 is not feature complete yet, but enough of the system works for it to be usable. You can write Commodore BASIC programs (e.g. POKE 53280, 2), and even run game ROMs that have been loaded into memory. A Flex user interface has been provided allowing you to load and play some public-domain games from Llamasoft. To play the games use the SPACE key to first and the arrow keys on the number pad act as the joystick (8 is UP, 4 is LEFT, etc).<br><br></strong>
<div align=center><strong><a title=在新窗口打开图片 href="http://www.everythingflex.com/blog/images/c64.jpg" target=_blank><img alt="" src="http://www.everythingflex.com/blog/images/c64.jpg" width=500></a></strong></div>
<strong>
<p><br>Technology Flex 2.0<br>Developer <strong><a href="http://www.darronschall.com/" target=_blank>Darron Schall</a></strong> </p>
</strong>
<img src ="http://www.blogjava.net/zhangzhong1018/aggbug/116662.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/zhangzhong1018/" target="_blank">leoli</a> 2007-05-11 09:53 <a href="http://www.blogjava.net/zhangzhong1018/articles/116662.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Modular</title><link>http://www.blogjava.net/zhangzhong1018/articles/116660.html</link><dc:creator>leoli</dc:creator><author>leoli</author><pubDate>Fri, 11 May 2007 01:43:00 GMT</pubDate><guid>http://www.blogjava.net/zhangzhong1018/articles/116660.html</guid><wfw:comment>http://www.blogjava.net/zhangzhong1018/comments/116660.html</wfw:comment><comments>http://www.blogjava.net/zhangzhong1018/articles/116660.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/zhangzhong1018/comments/commentRss/116660.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/zhangzhong1018/services/trackbacks/116660.html</trackback:ping><description><![CDATA[<p>简单的说,Modular(模块)和Shell(壳)就象DLL(动态链接库)和EXE(可执行程序)之间的关系一样.例如我们在写WINDOWS的应用程序的时候可以调用大量的MICROSOFT提供的DLL里的方法(我们称之为API).同样的,我们也可以自己把功能相同或者同类的方法抽象成为动态链接库以方便我们的后续开发,升级,团队开发等等. 因此显然,Modular的推出更有利于我们开发程序的模块化.可能有人会说,这样的功能我们同样可以采用编译多个可执行SWF,然后用Loader载入不就行了?的确我不反对这样的做法,事实证明,这也可以被正确实施于未更新的版本的.不一样的是. </p>
<p style="MARGIN-LEFT: 11pt">1.例如我们在模块中包含Application的标签,大家可以去看一下它的依赖关系就知道为什么只写一个Helloworld就会生成&gt;100K的原因了.而事实,这些东西我们在主程序中其实是包含了这些类的.类的重复被编译导致文件变得更大. </p>
<p style="MARGIN-LEFT: 11pt">2.Application标签是可以被运行的,简单的说,Application编译的SWF可以直接运行,这样我们的编程似乎就成了EXE和EXE的嵌套,似乎有点奇怪? 而Modular本身是不可执行的,就象DLL一样,里面可以包含很多方法也可以包含许多窗体,但事实自身是不可被运行的.而这些好处在Modular里可以轻松的实现. </p>
<p>&nbsp;</p>
<p>好的,现在我们来直接一点吧,看一下例子. </p>
<p>&nbsp;</p>
<p>代码下载: <a href="http://res.ezse.com/Howto/ModularDemo.rar">http://res.ezse.com/Howto/ModularDemo.rar</a> </p>
<p>&nbsp;</p>
<p>我们在FLEX BUILDER里建立三个项目,一个专门放MODULARS,一个为SHELL,最后一个是Interface.当然,视需要我们也可以建立多个项目. </p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;当然,Shell<em>(ModularMain)</em>就是我们的主程序,相当于我们的EXE文件; </p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Modulars<em>(Modulars)</em>就是我们的DLL文件的聚集地<span style="FONT-FAMILY: Wingdings">J</span> 当然合适的建立模块,可以使得我们的程序更具扩展性和部署. </p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Interface<em>(UserModularsInterface)</em>这不是必须的,但我建议在团队合作和大型程序开发的时候采用接口.接口的具体功能我就不在这里说了,可以找本OOD书看一下.简单的说就是模块之间混合编程所统一的必须的方法或属性.接口没有具体的实现方法,只是声明了方法或属性. </p>
<p>&nbsp;&nbsp;&nbsp;&nbsp; </p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;在这个例子中,我们建立了三个Modular,一个是在Shell项目中的InnerModular.mxml . 另一个是在Modulars中的OuterModular.mxml . 这个Modular和InnerModular相似. 最后一个是在Modulars中的OuterModularWithInterface.mxml . 这个Modular和前两个区别不大,仅仅是使用了Interface(<span style="COLOR: red">推荐使用这种方式</span>). </p>
<p>&nbsp;</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;首先我们看一下Inner Modular. 为什么取名为Inner Modular是因为这个Modular是和Shell在同一个Project中. </p>
<p>&nbsp;</p>
<p><span style="BACKGROUND-COLOR: yellow">InnerModular.mxml</span> </p>
<p style="MARGIN-LEFT: 11pt">&lt;?xml version="1.0" encoding="utf-8"?&gt; </p>
<p style="MARGIN-LEFT: 11pt">&lt;mx:<span style="COLOR: red">Module</span> xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"&gt; </p>
<p style="MARGIN-LEFT: 11pt">&lt;mx:Script&gt; </p>
<p style="MARGIN-LEFT: 11pt">&nbsp;&nbsp;&nbsp;&nbsp;&lt;![CDATA[ </p>
<p style="MARGIN-LEFT: 11pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[Bindable] </p>
<p style="MARGIN-LEFT: 11pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;public var textValue:String = "(default inner text value)"; </p>
<p style="MARGIN-LEFT: 11pt">&nbsp;&nbsp;&nbsp;&nbsp;]]&gt; </p>
<p style="MARGIN-LEFT: 11pt">&lt;/mx:Script&gt; </p>
<p style="MARGIN-LEFT: 11pt">&nbsp;&nbsp;&nbsp;&nbsp;&lt;mx:Label text="{textValue}"/&gt; </p>
<p style="MARGIN-LEFT: 11pt">&lt;/mx:<span style="COLOR: red">Module</span>&gt; </p>
<p style="MARGIN-LEFT: 11pt">&nbsp;</p>
<p style="MARGIN-LEFT: 11pt">在源程序中,唯一要注意的就是我们新建一个Application的时候,红色标记部分是引用的Application标签.把它改为Module即可. </p>
<p style="MARGIN-LEFT: 11pt">&nbsp;</p>
<p style="MARGIN-LEFT: 11pt">引用中,<span style="BACKGROUND-COLOR: yellow">ModularMain.mxml</span>中 </p>
<p style="MARGIN-LEFT: 11pt">&nbsp;</p>
<p style="MARGIN-LEFT: 22pt">&lt;?xml version="1.0" encoding="utf-8"?&gt; </p>
<p style="MARGIN-LEFT: 22pt">&lt;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="init()"&gt; </p>
<p style="MARGIN-LEFT: 22pt">&lt;mx:Script&gt; </p>
<p style="MARGIN-LEFT: 22pt">&nbsp;&nbsp;&nbsp;&nbsp;&lt;![CDATA[ </p>
<p style="MARGIN-LEFT: 22pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;import mx.modules.*; </p>
<p style="MARGIN-LEFT: 22pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;import mx.events.ModuleEvent; </p>
<p style="MARGIN-LEFT: 22pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </p>
<p style="MARGIN-LEFT: 22pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="COLOR: red">private var mdInnerModular:Object; </span></p>
<p style="MARGIN-LEFT: 22pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;private function init():void </p>
<p style="MARGIN-LEFT: 22pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ </p>
<p style="MARGIN-LEFT: 22pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="COLOR: red">mdInner.addEventListener(ModuleEvent.READY,onInnerModularLoaded); </span></p>
<p style="MARGIN-LEFT: 22pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} </p>
<p style="MARGIN-LEFT: 22pt"><span style="COLOR: red">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;private function onInnerModularLoaded(evt:ModuleEvent):void </span></p>
<p style="MARGIN-LEFT: 22pt"><span style="COLOR: red">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ </span></p>
<p style="MARGIN-LEFT: 22pt"><span style="COLOR: red">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;mdInnerModular = mdInner.child; </span></p>
<p style="MARGIN-LEFT: 22pt"><span style="COLOR: red">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;mdInnerModular.textValue = "Inner Modular"; </span></p>
<p style="MARGIN-LEFT: 22pt"><span style="COLOR: red">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} </span></p>
<p style="MARGIN-LEFT: 22pt"><span style="COLOR: #f79646">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;private function CallIOuterModularFunction():void </span></p>
<p style="MARGIN-LEFT: 22pt"><span style="COLOR: #f79646">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ </span></p>
<p style="MARGIN-LEFT: 22pt"><span style="COLOR: #f79646">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var iOuter:IOuterModular = mdOuterWithInterface.child as IOuterModular; </span></p>
<p style="MARGIN-LEFT: 22pt"><span style="COLOR: #f79646">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;iOuter.SetText("IOuter Called"); </span></p>
<p style="MARGIN-LEFT: 22pt"><span style="COLOR: #f79646">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} </span></p>
<p style="MARGIN-LEFT: 22pt">&nbsp;&nbsp;&nbsp;&nbsp;]]&gt; </p>
<p style="MARGIN-LEFT: 22pt">&lt;/mx:Script&gt; </p>
<p style="MARGIN-LEFT: 22pt">&nbsp;&nbsp;&nbsp;&nbsp;<span style="COLOR: red">&lt;mx:ModuleLoader id="mdInner" url="InnerModular.swf"/&gt; </span></p>
<p style="MARGIN-LEFT: 22pt"><span style="COLOR: #4f81bd">&nbsp;&nbsp;&nbsp;&nbsp;&lt;mx:ModuleLoader id="mdOuter" url="assets/OuterModular.swf" y="20"/&gt; </span></p>
<p style="MARGIN-LEFT: 22pt"><span style="COLOR: #4f81bd">&nbsp;&nbsp;&nbsp;&nbsp;&lt;mx:Button label="Set Outer Modular Value" click="(mdOuter.child as Object).textValue = 'Outer Modular'" y="40"/&gt; </span></p>
<p style="MARGIN-LEFT: 22pt"><span style="COLOR: #4f81bd">&nbsp;&nbsp;&nbsp;&nbsp;&lt;mx:Button label="Call Outer Modular Function" click="(mdOuter.child as Object).testFunction()" y="70"/&gt; </span></p>
<p style="MARGIN-LEFT: 22pt"><span style="COLOR: #f79646">&nbsp;&nbsp;&nbsp;&nbsp;&lt;mx:ModuleLoader id="mdOuterWithInterface" url="assets/OuterModularWithInterface.swf" y="90"/&gt; </span></p>
<p style="MARGIN-LEFT: 22pt"><span style="COLOR: #f79646">&nbsp;&nbsp;&nbsp;&nbsp;&lt;mx:Button label="Call Outer Modular Function" click="CallIOuterModularFunction()" y="120"/&gt; </span></p>
<p style="MARGIN-LEFT: 22pt">&lt;/mx:Application&gt; </p>
<p>&nbsp;</p>
<p>Shell中的有红色部分是对InnerModular的操作.注意的就是要执行Modular中的方法或者更改属性必须等ModularLoader触发了ModuleEvent.READY 后才能执行. </p>
<p>&nbsp;</p>
<p><span style="BACKGROUND-COLOR: yellow">OuterModular.mxml:</span> </p>
<p style="MARGIN-LEFT: 11pt">&lt;?xml version="1.0" encoding="utf-8"?&gt; </p>
<p style="MARGIN-LEFT: 11pt">&lt;mx:Module xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"&gt; </p>
<p style="MARGIN-LEFT: 11pt">&lt;mx:Script&gt; </p>
<p style="MARGIN-LEFT: 11pt">&nbsp;&nbsp;&nbsp;&nbsp;&lt;![CDATA[ </p>
<p style="MARGIN-LEFT: 11pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[Bindable] </p>
<p style="MARGIN-LEFT: 11pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;public var textValue:String = "(default outer text value)"; </p>
<p style="MARGIN-LEFT: 11pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;public function testFunction():void </p>
<p style="MARGIN-LEFT: 11pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ </p>
<p style="MARGIN-LEFT: 11pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;this.textValue = "Outer Function Called"; </p>
<p style="MARGIN-LEFT: 11pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} </p>
<p style="MARGIN-LEFT: 11pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </p>
<p style="MARGIN-LEFT: 11pt">&nbsp;&nbsp;&nbsp;&nbsp;]]&gt; </p>
<p style="MARGIN-LEFT: 11pt">&lt;/mx:Script&gt; </p>
<p style="MARGIN-LEFT: 11pt">&nbsp;&nbsp;&nbsp;&nbsp;&lt;mx:Label text="{textValue}" /&gt; </p>
<p style="MARGIN-LEFT: 11pt">&lt;/mx:Module&gt; </p>
<p style="MARGIN-LEFT: 11pt">&nbsp;</p>
<p>内容和InnerModular一样.不一样的是放在了另一个Project中. </p>
<p>&nbsp;</p>
<p>而我推荐的是使用Interface.下面我们就看一下使用了Interface的操作方法. </p>
<ol>
    <li>
    <div style="TEXT-ALIGN: justify">首先我们要定义Interface文件,为了方便,我们新建立一个Lib Project.这样编译后会生成一个swc的可被引用的代码包. </div>
    <li>
    <div style="TEXT-ALIGN: justify">在Shell和Modular的Project中添加引用. </div>
    <li>
    <div style="TEXT-ALIGN: justify">在Modular中实现具体的接口中定义的方法或属性. </div>
    </li>
</ol>
<p>&nbsp;</p>
<p><span style="BACKGROUND-COLOR: yellow">IOuterModular.as</span> </p>
<p style="MARGIN-LEFT: 11pt">package </p>
<p style="MARGIN-LEFT: 11pt">{ </p>
<p style="MARGIN-LEFT: 11pt">&nbsp;&nbsp;&nbsp;&nbsp;import flash.events.IEventDispatcher; </p>
<p style="MARGIN-LEFT: 11pt">&nbsp;&nbsp;&nbsp;&nbsp;public interface IOuterModular extends IEventDispatcher </p>
<p style="MARGIN-LEFT: 11pt">&nbsp;&nbsp;&nbsp;&nbsp;{ </p>
<p style="MARGIN-LEFT: 11pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;function SetText(val:String):void; </p>
<p style="MARGIN-LEFT: 11pt">&nbsp;&nbsp;&nbsp;&nbsp;} </p>
<p style="MARGIN-LEFT: 11pt">} </p>
<p>&nbsp;</p>
<p>在接口中,我们定义了SetText这个方法.于是我们在Modular中先实现这方法: </p>
<p><span style="BACKGROUND-COLOR: yellow">OuterModularWithInterface.mxml</span> </p>
<p style="MARGIN-LEFT: 11pt">&lt;?xml version="1.0" encoding="utf-8"?&gt; </p>
<p style="MARGIN-LEFT: 11pt">&lt;mx:Module xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" <span style="COLOR: red">implements="IOuterModular"</span>&gt; </p>
<p style="MARGIN-LEFT: 11pt">&lt;mx:Script&gt; </p>
<p style="MARGIN-LEFT: 11pt">&nbsp;&nbsp;&nbsp;&nbsp;&lt;![CDATA[ </p>
<p style="MARGIN-LEFT: 11pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[Bindable] </p>
<p style="MARGIN-LEFT: 11pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;public var textValue:String = "(default outer(with interface) text value)"; </p>
<p style="MARGIN-LEFT: 11pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </p>
<p style="MARGIN-LEFT: 11pt"><span style="COLOR: #1f497d">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;public function SetText(val:String):void </span></p>
<p style="MARGIN-LEFT: 11pt"><span style="COLOR: #1f497d">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ </span></p>
<p style="MARGIN-LEFT: 11pt"><span style="COLOR: #1f497d">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;this.textValue = val; </span></p>
<p style="MARGIN-LEFT: 11pt"><span style="COLOR: #1f497d">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} </span></p>
<p style="MARGIN-LEFT: 11pt">&nbsp;&nbsp;&nbsp;&nbsp;]]&gt; </p>
<p style="MARGIN-LEFT: 11pt">&lt;/mx:Script&gt; </p>
<p style="MARGIN-LEFT: 11pt">&nbsp;&nbsp;&nbsp;&nbsp;&lt;mx:Label text="{textValue}" /&gt; </p>
<p style="MARGIN-LEFT: 11pt">&lt;/mx:Module&gt; </p>
<p>&nbsp;</p>
<p>其中红色部分标记了此Modular为接口IOuterModular的实现. 蓝色部分则是具体实现的方法. </p>
<p>&nbsp;</p>
<p>在<span style="BACKGROUND-COLOR: yellow">ModularMain.mxml</span>的橙色部分则是它的使用方法. </p>
<p>&nbsp;</p>
<p style="MARGIN-LEFT: 22pt">和不用接口不一样的地方是:<span style="COLOR: #f79646"> var iOuter:IOuterModular = mdOuterWithInterface.child as IOuterModular;</span>新建一个实体,此实体正是ModularLoader的child.这里可能<span style="COLOR: #f2f2f2; BACKGROUND-COLOR: red">要注意一下</span>,这个child可能是Flex的Bug,这个child是一个DisplayObject,例如我们这样写mdOuterModular.child.SomeFunction().编译无法通过,提示是DisplayObject没有这个方法(废话).但是在调试模式下可以看到,这个child并非一个DisplayObject. 因此很郁闷,必须把这个child 设置成Object才能执行里面的方法. </p>
<p style="MARGIN-LEFT: 22pt">用接口还有一个好处,那就是可以直接看到Modular中的方法和属性.而在前两个例子中是没有这种功能的. </p>
<p>&nbsp;</p>
<p><span style="COLOR: #f2f2f2; BACKGROUND-COLOR: red">另一个要注意的地方是</span>,如果我们的Modular的Width,Height设置成的是100%, 而在ModularLoader中设置了Width和Height为绝对值的时候,会发现,事实上,Modular并没有填充这个固定区域! 做实验的话可以在Modular中设置一个Canvas.引用后会发现大小是0x0.所以我们可能在写这种高宽不定的时候,可能要建立一个方法,在Modular Ready后执行方法来重设置它的大小. </p>
<p>&nbsp;</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;现在我们可以看到程序可以正常的被执行了,但是Modular生成出来的swf个个都是100多K! 当然,因为我们还没有对Modulars Project进行裁剪尺寸. 这个裁减过程的原理就是我们的主程序中已经编译了的类,在Modular中就不再编译了.而如何设置呢?在Shell的Project中的编译器的附加参数里设置为-locale en_US -link-report=d:/testreport.xml 这样在编译的时候会生成一个关于Shell里所引用过的类库列表在d:/testreport.xml的文件中. 在Modulars中的编译器的附加参数里设置为-locale en_US -load-externs=d:/testreport.xml 这样,在编译Modulars的时候,载入Shell已经编译过的类库.在编译的时候就跳过这些类库.再编译一看,大小豁然小了100K,变成了10多k. </p>
<p>&nbsp;</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;在Dreamer的Blog上也有一篇翻译的文章大家也可以去看一下: <a href="http://www.zhuoqun.net/article.asp?id=382">http://www.zhuoqun.net/article.asp?id=382</a> </p>
<img src ="http://www.blogjava.net/zhangzhong1018/aggbug/116660.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/zhangzhong1018/" target="_blank">leoli</a> 2007-05-11 09:43 <a href="http://www.blogjava.net/zhangzhong1018/articles/116660.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Coloring the Background of Cells</title><link>http://www.blogjava.net/zhangzhong1018/articles/116409.html</link><dc:creator>leoli</dc:creator><author>leoli</author><pubDate>Thu, 10 May 2007 02:36:00 GMT</pubDate><guid>http://www.blogjava.net/zhangzhong1018/articles/116409.html</guid><wfw:comment>http://www.blogjava.net/zhangzhong1018/comments/116409.html</wfw:comment><comments>http://www.blogjava.net/zhangzhong1018/articles/116409.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/zhangzhong1018/comments/commentRss/116409.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/zhangzhong1018/services/trackbacks/116409.html</trackback:ping><description><![CDATA[原文地址：<a href="http://weblogs.macromedia.com/pent/archives/2007/02/coloring_the_ba.cfm" target=_blank><u><font color=#0000ff>http://weblogs.macromedia.com/pent/archives/2007/02/coloring_the_ba.cfm</font></u></a>
<img src ="http://www.blogjava.net/zhangzhong1018/aggbug/116409.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/zhangzhong1018/" target="_blank">leoli</a> 2007-05-10 10:36 <a href="http://www.blogjava.net/zhangzhong1018/articles/116409.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>flex metadata tag</title><link>http://www.blogjava.net/zhangzhong1018/articles/116400.html</link><dc:creator>leoli</dc:creator><author>leoli</author><pubDate>Thu, 10 May 2007 02:07:00 GMT</pubDate><guid>http://www.blogjava.net/zhangzhong1018/articles/116400.html</guid><wfw:comment>http://www.blogjava.net/zhangzhong1018/comments/116400.html</wfw:comment><comments>http://www.blogjava.net/zhangzhong1018/articles/116400.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/zhangzhong1018/comments/commentRss/116400.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/zhangzhong1018/services/trackbacks/116400.html</trackback:ping><description><![CDATA[<p><strong></strong>&nbsp;</p>
<p>Flex 2.0 裡面有許多的 Metadata<br>有些是給 AS 編譯器看的<br>有些是給 MXML 編譯器看的<br>使用者也可以自行定義 Metadata</p>
<p>官方文件內只有說明一部分的 Metadata Tag<br>還有很多不知道其功能為何</p>
<p>以下是粗略的整理，包含 Metadata Tag 名稱與幾個簡單的例子</p>
<p>文件上有記載的</p>
<p>http://livedocs.macromedia.com/flex/2/docs/00001651.html </p>
<pre>	[ArrayElementType]<br>		[ArrayElementType("mx.states.Transition")]<br>		[ArrayElementType("mx.states.State")]<br>	<br>	[Bindable]<br>		[Bindable("errorStringChanged")]<br>		[Bindable("toolTipChanged")]<br>		[Bindable("currentStateChange")]<br>		[Bindable("verticalScrollPolicyChanged")]<br>	<br>	[DefaultProperty]<br>		[DefaultProperty("dataProvider")]<br>		[DefaultProperty("children")]<br>	<br>	[Effect]<br>		[Effect(name="hideDataEffect", event="hideData")]<br>		[Effect(name="moveEffect", event="move")]<br><br>	[Embed]<br>		[Embed(source="Beep.mp3")]<br>	<br>	[Event]<br>		[Event(name="itemClick", type="mx.charts.events.LegendMouseEvent")]<br>		[Event(name="hide", type="mx.events.FlexEvent")]<br>	<br>	[IconFile]<br>		[IconFile("Repeater.png")]<br>		[IconFile("AreaChart.png")]<br>	<br>	[Inspectable]<br>		[Inspectable(defaultValue="true")]<br>		[Inspectable(environment="none")]<br>		[Inspectable(category="Data")]<br>		[Inspectable(category="General", enumeration="overlaid,stacked,100%", defaultValue="overlaid")]<br><br>	<br>	[InstanceType]<br>		[InstanceType("mx.controls.Label")]<br>		public var topRow:IDeferredInstance;<br>	<br>	[NonCommittingChangeEvent]<br>		[NonCommittingChangeEvent("change")]<br>	<br>	[Style]<br>		[Style(name="axisStroke", type="mx.graphics.IStroke", inherit="no")]<br>		[Style(name="fontWeight", type="String", enumeration="normal,bold", inherit="yes")]<br>		[Style(name="barWidthRatio", type="Number", inherit="no")]<br><br><br></pre>
文件上沒記載的
<pre>	[SWF]<br>		[SWF(width="300", height="200", frameRate="18", backgroundColor="#FFFFFF")]<br>	<br>	[RemoteClass]<br>		[RemoteClass(alias="flex.messaging.io.ArrayCollection")]<br>		[RemoteClass(alias="flex.messaging.io.ArrayList")]<br>	<br>	[Frame]<br>		<a href="http://blog.xuite.net/ticore/blog2/11396728"><font color=#0000ff>[Frame(factoryClass="mx.managers.SystemManager")]<br>		[Frame(factoryClass="mx.core.FlexApplicationBootstrap")]</font></a><br><br>		<a href="http://blog.xuite.net/ticore/blog2/9344138" target=_blank><font color=#0000ff>[Frame(extraClass="Obj")]</font></a>
[ExcludeClass]
[DefaultBindingProperty]
[DefaultBindingProperty(destination="dataProvider")]
[DefaultTriggerEvent]
[DefaultTriggerEvent("itemClick")]
[DefaultTriggerEvent("scroll")]
[Exclude]
[Exclude(name="defaultButton", kind="property")]
[Exclude(name="horizontalScrollPolicy", kind="property")]
[Exclude(name="icon", kind="property")]
[Exclude(name="label", kind="property")]
[Exclude(name="tileHeight", kind="property")]
[ResourceBundle]
[ResourceBundle("validators")]
[ResourceBundle("SharedResources")]
[ResourceBundle("foo")]
[PercentProxy]
[PercentProxy("percentHeight")]
[RequiresDataBinding]
[RequiresDataBinding(true)]
[CollapseWhiteSpace]
[MaxChildren]
[MaxChildren(0)]
[AccessibilityClass]
[AccessibilityClass(implementation="mx.accessibility.PanelAccImpl")]
[AccessibilityClass(implementation="mx.accessibility.TitleWindowAccImpl")]
<a href="http://blog.xuite.net/ticore/blog2/9451126" target=_blank><font color=#0000ff>[Transient]</font></a>
</pre>
<img src ="http://www.blogjava.net/zhangzhong1018/aggbug/116400.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/zhangzhong1018/" target="_blank">leoli</a> 2007-05-10 10:07 <a href="http://www.blogjava.net/zhangzhong1018/articles/116400.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Flex Datagrid 's tooltip using the itemRollOut event</title><link>http://www.blogjava.net/zhangzhong1018/articles/115998.html</link><dc:creator>leoli</dc:creator><author>leoli</author><pubDate>Tue, 08 May 2007 09:20:00 GMT</pubDate><guid>http://www.blogjava.net/zhangzhong1018/articles/115998.html</guid><wfw:comment>http://www.blogjava.net/zhangzhong1018/comments/115998.html</wfw:comment><comments>http://www.blogjava.net/zhangzhong1018/articles/115998.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/zhangzhong1018/comments/commentRss/115998.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/zhangzhong1018/services/trackbacks/115998.html</trackback:ping><description><![CDATA[<h3 class=entry-header>Flex Datagrid 's tooltip using the itemRollOut event</h3>
<div class=entry-content>
<div class=entry-body>
<p>Datagrid Flex component is a very powerful tool to display data. For an enterprise application we're trying to create a tooltip only if the content of the row data is bigger than the width of the row.<br>We solved the problem using the itemRenderer, but I had some strange behaviours using the <em>itemRollOver.</em><br>The itemRollOver is an event of the&nbsp; ListBase class, the base class for controls that represent lists of items that can have one or more selected and can scroll through the items.<br>This is the MXML code :</p>
<p>&lt;myComp:DataGrid <br>&nbsp; &nbsp;&nbsp; id="myDG"<br>&nbsp; &nbsp;&nbsp; dataProvider="{commandList.command}"<br>&nbsp; &nbsp;&nbsp; itemRollOut="destroyBigTip(event)"<br>&nbsp; &nbsp;&nbsp; itemRollOver="createBigTip(event)"&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;<br>&nbsp; &nbsp;&nbsp; editable="true"<br>&nbsp; &nbsp;&nbsp; width="290"/&gt;</p>
<p>These are the two event handler functions :<br><br>&nbsp; &nbsp;<em> public function createBigTip(event:Object):void {<br>&nbsp; &nbsp; <br>&nbsp; &nbsp; var s:String = "Over"<br>var label:Label = new Label;<br>label.text = s;<br>label.setVisible(true);<br>label.x = 10;<br>label.y = 10;<br><br>addChild(label);<br>&nbsp; &nbsp;&nbsp; <br>&nbsp; &nbsp;}</em><br>&nbsp; &nbsp;<br>&nbsp; <em>&nbsp; public function destroyBigTip(event:Object):void {<br>&nbsp; &nbsp; <br>&nbsp; &nbsp; var s:String = "Out"<br>var label:Label = new Label;<br>label.text = s;<br>label.setVisible(true);<br>label.x = 10;<br>label.y = 10;<br><br>addChild(label);<br>&nbsp; &nbsp;&nbsp; <br>&nbsp; &nbsp;}</em></p>
<p>All that works just for the first row of the Datagrid ! </p>
</div>
</div>
<img src ="http://www.blogjava.net/zhangzhong1018/aggbug/115998.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/zhangzhong1018/" target="_blank">leoli</a> 2007-05-08 17:20 <a href="http://www.blogjava.net/zhangzhong1018/articles/115998.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>export to excel from flex</title><link>http://www.blogjava.net/zhangzhong1018/articles/115984.html</link><dc:creator>leoli</dc:creator><author>leoli</author><pubDate>Tue, 08 May 2007 08:41:00 GMT</pubDate><guid>http://www.blogjava.net/zhangzhong1018/articles/115984.html</guid><wfw:comment>http://www.blogjava.net/zhangzhong1018/comments/115984.html</wfw:comment><comments>http://www.blogjava.net/zhangzhong1018/articles/115984.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/zhangzhong1018/comments/commentRss/115984.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/zhangzhong1018/services/trackbacks/115984.html</trackback:ping><description><![CDATA[<span class=NEWSBODY>&nbsp;
<p><font face=verdana>Clever solution to the "How can I export to Excel?" problem, by bdeen, as posted on MM Flex forum.</font></p>
<p>I know we all have users asking "Can I Export/Import to Excel?". Apparently Excel is the best thing to come along to the user community since large amounts of RAM. I personally have used Excel maybe 3 times in my life, but I always try to help out the user. So this is about exporting DataGrid information into Excel.<br><br>A few things to realize about this solution.<br>1) It should be able to run in all the Flash Players. <br>2) I only tested the output in Excel 2003.<br>3) I added IE specific javascript (which you don't need to have to still get this functionality) which will open Excel and populate it with the data in the DataGrid.<br>4) This solution uses basic html styles and table.<br>5) I populate the styles with background colors however Excel only has a handful of allowable colors and it might assign odd colors to an unodd color in Flash. so light blue might come out as lavendar. soft shades of gray/grey come out as white. Dark colors are seen as purple. However if you paste the result of this into an html file and have IE or FireFox render it, it comes out very much like the look and feel you have in Flex.<br>6) Font's seem to translate well, as well as sizes of fonts. I didn't do anything other than font family and font size, if you want more you can add it yourself, it's rather easy.<br>7) I added widths (which again looks great in a Browser) but Excel seems to ignore them.<br>8) I use labelFunctions and then columnNames, if you define the labelFunction then the copied content will reflect what the labelFunction produces, as well as the String version of the columnName</p>
<p>Code:</p>
<pre>// ACTION SCRIPT FOR YOUR FLEX APP
function doCopy(dg)
{
var font = dg.getStyle('fontFamily');
var size = dg.getStyle('fontSize');
var hcolor ;
if(dg.getStyle("headerColor") != undefined) hcolor = [dg.getStyle("headerColor")];
else hcolor = dg.getStyle("headerColors");
var str:String = '&lt;html&gt;&lt;body&gt;&lt;table width="'+dg.width+'"&gt;&lt;thead&gt;&lt;tr width="'+<br>         dg.width+'" style="background-color:#' +Number((hcolor[0])).toString(16)+'"&gt;';
for(var i=0;i&lt;dg.__columns.length;i++)
{
var colors = dg.getStyle("themeColor");
var style = 'style="font-family:'+font+';font-size:'+size+'pt;"';
if(dg.__columns[i].headerText != undefined)
{
str+="&lt;th "+style+"&gt;"+dg.__columns[i].headerText+"&lt;/th&gt;";
}
else
{
str+= "&lt;th "+style+"&gt;"+dg.__columns[i].columnName+"&lt;/th&gt;";
}
}
str += "&lt;/tr&gt;&lt;/thead&gt;&lt;tbody&gt;";
var colors = dg.getStyle("alternatingRowColors");
for(var j=0;j&lt;dg.length;j++)
{
str+="&lt;tr width=\""+Math.ceil(dg.width)+"\" style='background-color:#" +Number((colors[j%colors.length])).toString(16)+"'&gt;";
var style = 'style="font-family:'+font+';font-size:'+size+'pt;"';
for(var i=0;i&lt;dg.__columns.length;i++)
{
if(dg.getItemAt(j) != undefined &amp;&amp; dg.getItemAt(j) != null)
if(dg.__columns[i].labelFunction != undefined)
str += "&lt;td width=\""+Math.ceil(dg.__columns[i].width)+"\" "+style+"&gt;"+<br>dg.__columns[i].labelFunction(dg.getItemAt(j),dg.__columns[i].columnName)+"&lt;/td&gt;";
else
str += "&lt;td width=\""+Math.ceil(dg.__columns[i].width)+"\" "+style+"&gt;"+<br>dg.getItemAt(j)[dg.__columns[i].columnName]+"&lt;/td&gt;";
}
str += "&lt;/tr&gt;";
}
str+="&lt;/tbody&gt;&lt;/table&gt;&lt;/body&gt;&lt;/html&gt;";
System.setClipboard(str);
}
function handleOnKeyUp()
{
if(Key.isDown(Key.CONTROL) &amp;&amp;Key.getCode() ==67)
{
mx.managers.CursorManager.setBusyCursor();
doCopy(grid);  <br>                  // exchange 'grid' with the id of your datagrid you want copied
mx.managers.CursorManager.removeBusyCursor();
}
}
// only register interest if you want ctrl-c to process a copy of a datagrid. <br>// it's also ctrl + c (on key up, not down)
var obj:Object;
function registerKeyInterest()
{
if(obj == undefined)
{
obj = new Object();
obj.onKeyUp = mx.utils.Delegate.create(this,handleOnKeyUp);
}
Key.addListener(obj);
}
function removeKeyInterest()
{
Key.removeListener(obj);
}
function copyAndOpen(grid)
{
doCopy(grid);
getUrl("javascript:openExcel();");
}
// JAVASCRIPT for your HTML PAGE
&lt;SCRIPT Language="JavaScript1.2"&gt;
var excel = null;
function openExcel()
{
try
{
if(excel == null)
{
excel = new ActiveXObject("Excel.Application");
}
var workbook = excel.Workbooks.Add();
workbook.Activate();
var worksheet = workbook.Worksheets("Sheet1");
worksheet.Activate();
worksheet.Paste();
excel.visible=true;
}catch(exception)
{
window.alert("Now you may Paste into an Excel SpreadSheet");
}
}
&lt;/SCRIPT&gt;</pre>
</span>
<img src ="http://www.blogjava.net/zhangzhong1018/aggbug/115984.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/zhangzhong1018/" target="_blank">leoli</a> 2007-05-08 16:41 <a href="http://www.blogjava.net/zhangzhong1018/articles/115984.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>不用Cell Renderer如何在ComboBox里加入自定义ICO </title><link>http://www.blogjava.net/zhangzhong1018/articles/109827.html</link><dc:creator>leoli</dc:creator><author>leoli</author><pubDate>Wed, 11 Apr 2007 02:20:00 GMT</pubDate><guid>http://www.blogjava.net/zhangzhong1018/articles/109827.html</guid><wfw:comment>http://www.blogjava.net/zhangzhong1018/comments/109827.html</wfw:comment><comments>http://www.blogjava.net/zhangzhong1018/articles/109827.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/zhangzhong1018/comments/commentRss/109827.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/zhangzhong1018/services/trackbacks/109827.html</trackback:ping><description><![CDATA[<h4 class=logtitle>&nbsp;</h4>
<div class=info_u><span class=logtools><a class="z_edit userz" title=编辑日志 onclick=editblog(128438)>&nbsp;</a> <a class="z_del userz" title=删除日志 onclick=delblog(128438)>&nbsp;</a> <a class=z_showall title=全屏正常切换 onclick=showall(this)>&nbsp;</a> </span><span class=category><a href="http://blog.5d.cn/user7/luhui/category/33818.html"><u><font color=#0000ff>FLEX</font></u></a></span> <span class=ptime>2005-7-27 15:59</span> </div>
<div class=text>
<div class=fitimg id=cl128438>//转自：http://www.richinternetapps.com/index.html<br><br>My first thought was to suggest the creation of a custom cell renderer, an example of which ships with Flex. However, I then remembered that the List control in Flex has an iconField property, which can be used to specify an image that will appear next to each item in the control. An example MXML file using the iconField property with the List control is as follows:<br><br>&lt;?xml version="1.0" encoding="utf-8"?&gt;<br>&lt;mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml" &gt;<br><br>&lt;mx:Script&gt;<br>[Embed(source="one.png")]<br>var iconSymbol1:String;<br>[Embed(source="two.png")]<br>var iconSymbol2:String;<br>[Embed(source="three.png")]<br>var iconSymbol3:String;<br>&lt;/mx:Script&gt;<br><br>&lt;mx:List iconField="icon" &gt;<br>&lt;mx:dataProvider&gt;<br>&lt;mx:Array&gt;<br>&lt;mx:Object label="One" icon="{ iconSymbol1 }" /&gt;<br>&lt;mx:Object label="Two" icon="{ iconSymbol2 }" /&gt;<br>&lt;mx:Object label="Three" icon="{ iconSymbol3 }" /&gt;<br>&lt;/mx:Array&gt;<br>&lt;/mx:dataProvider&gt;<br>&lt;/mx:List&gt;<br><br>&lt;/mx:Application&gt;<br><br>The above MXML uses the iconField property of the List control to retrieve the icon property from each item in the control's data provider, and produces the following List control (image only):<br><br><br><br>图片如下：<br><a href="http://blog.5d.cn/user7/luhui/upload/2005-07/27_593.gif" target=_blank><img src="http://blog.5d.cn/user7/luhui/upload/2005-07/27_593.gif" onload=fitSize(this) border=0></a><br><br>But (and isn't there always a but?), the poster to FlexCoders wanted the icons not in a List, but in a ComboBox and, such is fate, the Flex ComboBox does not have an iconField property.<br><br>However, those who have looked into the Flex components in any detail will know that the ComboBox control uses the List control internally, to display its own drop down portion. So, I delved into the classes to see what I could find and the result of that find was as follows: <br><br>&lt;?xml version="1.0" encoding="utf-8"?&gt;<br>&lt;mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml" &gt;<br><br><br>&lt;mx:Script&gt;<br>[Embed(source="one.png")]<br>var iconSymbol1:String;<br>[Embed(source="two.png")]<br>var iconSymbol2:String;<br>[Embed(source="three.png")]<br>var iconSymbol3:String;<br>&lt;/mx:Script&gt;<br><br>&lt;mx:ComboBox id="theCombo" <br>creationComplete="theCombo.getDropdown().iconField='icon'" &gt;<br>&lt;mx:dataProvider&gt;<br>&lt;mx:Array&gt;<br>&lt;mx:Object label="One" icon="{ iconSymbol1 }" /&gt;<br>&lt;mx:Object label="Two" icon="{ iconSymbol2 }" /&gt;<br>&lt;mx:Object label="Three" icon="{ iconSymbol3 }" /&gt;<br>&lt;/mx:Array&gt;<br>&lt;/mx:dataProvider&gt;<br>&lt;/mx:ComboBox&gt;<br><br>&lt;/mx:Application&gt;<br><br><br><br>图片如下：<br><a href="http://blog.5d.cn/user7/luhui/upload/2005-07/27_305.gif" target=_blank><img src="http://blog.5d.cn/user7/luhui/upload/2005-07/27_305.gif" onload=fitSize(this) border=0></a><br><br>Simple! The highlighted code shows that we can get the List portion of the ComboBox control using the getDropdown() method of the ComboBox, and set its iconField property in the same manner as we did with the List control previously. For those that haven't yet investigated Flex in any detail, the creationComplete property allows us to define a handler that will run when the component instance has been created.<br><br>There is one further point worth noting - the original poster wanted to be able to change the icon at runtime - the solution above does allow that. We can add the following to our MXML file so that when the user presses the button, the icons are rotated through the items in the dropdown.<br><br>&lt;mx:Button label="Rotate Icons" click="rotate();" /&gt;<br><br>&lt;mx:Script&gt;<br><br>&lt;![CDATA[<br><br>public function rotate() : Void<br>{<br>var firstIcon = theCombo.dataProvider[0].icon;<br>for ( var i = 1; i &lt; theCombo.dataProvider.length; i++ )<br>{<br>theCombo.dataProvider[i-1].icon = theCombo.dataProvider[i].icon;<br>}<br><br>theCombo.dataProvider[theCombo.dataProvider.length-1].icon = firstIcon;<br><br>theCombo.bLabelFieldChanged = true;<br>theCombo.invalidate();<br><br>theCombo.dispatchEvent({type:"labelFieldChanged"});<br>}<br>]]&gt;<br><br>&lt;/mx:Script&gt;<br><br>The for loop in the rotate() method is self-explanatory, but the last three lines in the method need further explanation. Because we are changing the underlying List component of the ComboBox, the ComboBox icons are not updated when we update the data provider. By including those three lines (which are what are called when the labelField property of the ComboBox is changed), the ComboBox is tricked into redrawing its drop down items. This is a quick and dirty way to get it working - I'm going to investigate a better solution.<br><br>After the user has pressed the button (which is hidden under the drop down portion of the control), the ComboBox looks as follows, with the icons having moved:<br><br><br><br>图片如下：<br><a href="http://blog.5d.cn/user7/luhui/upload/2005-07/27_766.gif" target=_blank><img src="http://blog.5d.cn/user7/luhui/upload/2005-07/27_766.gif" onload=fitSize(this) border=0></a><br><br>The obvious next step in the development of the above is to extract the code to a new component, which could then be used within any application. We'll show how that can be done in a future blog entry.<br><br>This example does show the power of Flex,</div>
</div>
<img src ="http://www.blogjava.net/zhangzhong1018/aggbug/109827.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/zhangzhong1018/" target="_blank">leoli</a> 2007-04-11 10:20 <a href="http://www.blogjava.net/zhangzhong1018/articles/109827.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>比较好的 flex 网站</title><link>http://www.blogjava.net/zhangzhong1018/articles/108026.html</link><dc:creator>leoli</dc:creator><author>leoli</author><pubDate>Mon, 02 Apr 2007 10:00:00 GMT</pubDate><guid>http://www.blogjava.net/zhangzhong1018/articles/108026.html</guid><wfw:comment>http://www.blogjava.net/zhangzhong1018/comments/108026.html</wfw:comment><comments>http://www.blogjava.net/zhangzhong1018/articles/108026.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/zhangzhong1018/comments/commentRss/108026.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/zhangzhong1018/services/trackbacks/108026.html</trackback:ping><description><![CDATA[<li><a title="AFR Access" href="http://afraccess.com/" target=_blank><font color=#0000ff><u>AFR Access</u></font></a><br>
<li><a title="The Australian Financial Review" href="http://www.afr.com/" target=_blank><font color=#0000ff><u>The Australian Financial Review</u></font></a><br>
<li><a title="Sony Ericsson Phone and Accessories selector" href="http://www.sonyericsson.com/spg.jsp?cc=au&amp;lc=en&amp;ver=4000&amp;template=pp1&amp;zone=pp&amp;view=phones#view=phones&amp;cdl=0&amp;detail=0&amp;cmp=0&amp;acc_cid=0&amp;cid=0&amp;acc_pid=0&amp;pid=0" target=_blank><font color=#800080><u>Sony Ericsson Phone Selector</u></font></a><br>
<li><a title="Flex Store sample application" href="http://www.adobe.com/devnet/flex/samples/flex_store/" target=_blank><font color=#0000ff><u>Adobe Flex Store</u></font></a><br>
<li><a title="Kodak EasyShare Gallery" href="http://www.kodakgallery.com/" target=_blank><font color=#0000ff><u>Kodak EasyShare Gallery</u></font></a><br>
<li><a title="NOMOS Online - Noise Monitoring System" href="http://194.229.29.150/nomos/main.mxml" target=_blank><font color=#800080><u>NOMOS Online</u></font></a><br>
<li><a title="Flex Data Services" href="http://www.adobe.com/products/flex/dataservices/" target=_blank><font color=#0000ff><u>Flex Data Services</u></font></a><br>
<li><a title=Pikeo href="http://www.pikeo.com/" target=_blank><font color=#0000ff><u>Pikeo</u></font></a><br>
<li><a title="Motionbox videos" href="http://www.motionbox.com/" target=_blank><strong><font color=#800080><u>Motionbox</u></font></strong></a><br>
<li><a title="Trenitalia - Viaggia Treno" href="http://www.viaggiatreno.it/viaggiatreno/vt.html" target=_blank><u><font color=#0000ff>Trenitalia - </font></u></a><br>
<li><a title="Fidelity Labs" href="http://www.fidelitylabs.com/" target=_blank><u><font color=#0000ff>Fidelity Labs</font></u></a><br>
<li><a title="Fidelity Labs" href="http://www.fidelitylabs.com/" target=_blank><u><font color=#0000ff>www.fidelitylabs.com</font></u></a><br>
<li><a title="Belgacom TV Portal" href="http://www.belgacomtv.be/" target=_blank><strong><u><font color=#0000ff>Belgacom TV Portal</font></u></strong></a><br>
<li><a title="ESRI ArcWeb Explorer" href="http://www.arcwebservices.com/awx/index.jsp" target=_blank><strong><u><font color=#0000ff>ESRI ArcWeb Explorer</font></u></strong></a><br>
<li><a title="ArcWeb Services" href="http://www.esri.com/software/arcwebservices/" target=_blank><u><font color=#0000ff>services</font></u></a><br>
<li><a title="Harley-Davidson Customizer" href="http://www.harley-davidson.com/pr/gm/customizer/launchCustomizer.asp" target=_blank><strong><u><font color=#0000ff>Harley-Davidson Customizer</font></u></strong></a><br>
<li><a title="Intelligent Finance" href="http://www.if.com/" target=_blank><strong><u><font color=#0000ff>Intelligent Finance Mortgage Offset Calculator</font></u></strong></a><br>
<li><a title="Yahoo! Maps" href="http://maps.yahoo.com/" target=_blank><u><font color=#0000ff>Yahoo! Maps</font></u></a></li>
<p>&nbsp;</p>
<img src ="http://www.blogjava.net/zhangzhong1018/aggbug/108026.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/zhangzhong1018/" target="_blank">leoli</a> 2007-04-02 18:00 <a href="http://www.blogjava.net/zhangzhong1018/articles/108026.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>flex 参数</title><link>http://www.blogjava.net/zhangzhong1018/articles/104764.html</link><dc:creator>leoli</dc:creator><author>leoli</author><pubDate>Mon, 19 Mar 2007 08:50:00 GMT</pubDate><guid>http://www.blogjava.net/zhangzhong1018/articles/104764.html</guid><wfw:comment>http://www.blogjava.net/zhangzhong1018/comments/104764.html</wfw:comment><comments>http://www.blogjava.net/zhangzhong1018/articles/104764.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/zhangzhong1018/comments/commentRss/104764.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/zhangzhong1018/services/trackbacks/104764.html</trackback:ping><description><![CDATA[
		<h4 class="TextColor1" id="subjcns!CB766359597D2BE7!1369" style="MARGIN-BOTTOM: 0px">flash使用FlashVars接收html参数</h4>
		<div id="msgcns!CB766359597D2BE7!1369">
				<div>本教程主要介绍HTML网页如何取得形如test.html?foo=mytest的foo参数，以及在HTML网页中如何向swf传递参数。<br /><br />一、在HTML网页中使用js获取参数。<br />我们知道HTML页面是在客户端执行的，这样要获取参数必须使用客户端脚本（如JavaScript），在这点上不同于服务器端脚本获取参数方式。<br />下面的这段js代码获取HTML网页形如"test.html?foo=mytest&amp;program=flash" "?"后所有参数。<br /><pre>&lt;script language=javascript&gt;<br />&lt;!--<br />var hrefstr,pos,parastr;<br />hrefstr = window.location.href;<br />pos = hrefstr.indexOf("?");<br />parastr = hrefstr.substring(pos+1);<br />if (pos&gt;0){<br />	document.write("所有参数："+parastr);<br />} else {<br />	document.write("无参数");<br />}<br />//--&gt;<br />&lt;/script&gt;</pre><br /><br />下面的这段js代码则可以更加细化获取HTML网页某一参数<br /><pre>&lt;script language=javascript&gt;<br />&lt;!--<br />function getparastr(strname) {<br />	var hrefstr,pos,parastr,para,tempstr;<br />	hrefstr = window.location.href;<br />	pos = hrefstr.indexOf("?")<br />	parastr = hrefstr.substring(pos+1);<br /><br />	para = parastr.split("&amp;");<br />	tempstr="";<br />	for(i=0;i&lt;para.length;i++)<br />	{<br />  tempstr = para[i];<br />  pos = tempstr.indexOf("=");<br />  if(tempstr.substring(0,pos) == strname) {<br />  	return tempstr.substring(pos+1);<br />  }<br />	}<br />	return null;<br />}<br />// 获取program参数<br />var programstr = getparastr("program");<br />document.write(programstr);<br />//--&gt;<br />&lt;/script&gt;</pre><br /><br />二、在HTML网页中向swf传递参数。<br />方法一：在网页中使用js，SetVariable设置flashobject中的变量，代码如：<br /><pre>// "HtmlToSwf"为网页中的flashobject ID<br />HtmlToSwf.SetVariable("_root.info_str","Happy Newyear");</pre><br />方法二：路径参数，如test.swf?foo=happy2005<br />方法三：使用FlashVars，以下主要介绍FlashVars的用法。使用FlashVars后嵌入HTML的flashobject代码如下：<br /><pre>&lt;object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="550" height="400" id="FlashVars" align="middle"&gt;<br />&lt;param name="allowScriptAccess" value="sameDomain" /&gt;<br />&lt;param name="movie" value="FlashVars.swf" /&gt;<br />&lt;param name="FlashVars" value="foo=happy2005&amp;program=flash&amp;language=简体中文-中国" /&gt;<br />&lt;param name="quality" value="high" /&gt;<br />&lt;param name="bgcolor" value="#ffffff" /&gt;<br />&lt;embed src="FlashVars.swf" quality="high" bgcolor="#ffffff" width="550" height="400" name="FlashVars" align="middle" allowScriptAccess="sameDomain" FlashVars="foo=happy2005&amp;program=flash&amp;language=简体中文-中国" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /&gt;</pre><br /><br />通过上面的代码，在SWF(FlashVars.swf)中就可以直接获取foo、program、language变量数据。FlashVars.fla获取FlashVars参数的代码如下：<br /><pre>// 创建三个文本字段<br />_root.createTextField("foo_txt",1,0,0,16,16);<br />_root.createTextField("program_txt",2,0,32,16,16);<br />_root.createTextField("language_txt",3,0,64,16,16);<br />foo_txt.autoSize = true;<br />foo_txt.border = true;<br />program_txt.autoSize = true;<br />program_txt.border = true;<br />language_txt.autoSize = true;<br />language_txt.border = true;<br />// 获取FlashVars变量<br />foo_txt.text = "HTML中的foo参数："+foo;<br />program_txt.text = "HTML中的program参数："+program;<br />language_txt.text = "HTML中的language参数："+language;</pre><br /><br />三、两者的有效结合。<br />在HTML网页中使用js获取参数，然后将获取的参数作为FlashVars写入flashobject传递给swf。代码如下：<br /><pre>&lt;script language=javascript&gt;<br />&lt;!--<br />function writeflashobject(parastr) {<br />	document.write("&lt;object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" codebase=\"http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0\" width=\"550\" height=\"400\" id=\"FlashVars\" align=\"middle\"\&gt;\n");<br />	document.write("&lt;param name=\"allowScriptAccess\" value=\"sameDomain\" /\&gt;\n");<br />	document.write("&lt;param name=\"movie\" value=\"FlashVars.swf\" /\&gt;\n");<br />	document.write("&lt;param name=\"FlashVars\" value=\""+ parastr +"\" /\&gt;\n");<br />	document.write("&lt;param name=\"quality\" value=\"high\" /\&gt;\n");<br />	document.write("&lt;param name=\"bgcolor\" value=\"#ffffff\" /\&gt;\n");<br />	document.write("&lt;embed src=\"FlashVars.swf\" quality=\"high\" bgcolor=\"#ffffff\" width=\"550\" height=\"400\" name=\"FlashVars\" align=\"middle\" allowScriptAccess=\"sameDomain\" FlashVars=\""+ parastr +"\" type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" /\&gt;");<br />	document.write("&lt;/object\&gt;");<br />}<br />function getparastr() {<br />	var hrefstr,pos,parastr,para,tempstr1;<br />	hrefstr = window.location.href;<br />	pos = hrefstr.indexOf("?")<br />	parastr = hrefstr.substring(pos+1);<br />	return parastr;<br />}<br />var parastr = getparastr();<br />writeflashobject(parastr);<br />//--&gt;<br />&lt;/script&gt;</pre></div>
		</div>
<img src ="http://www.blogjava.net/zhangzhong1018/aggbug/104764.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/zhangzhong1018/" target="_blank">leoli</a> 2007-03-19 16:50 <a href="http://www.blogjava.net/zhangzhong1018/articles/104764.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Flex2 官方学习资料(转载)http://www.killflash.net/blog/article.asp?id=108</title><link>http://www.blogjava.net/zhangzhong1018/articles/86040.html</link><dc:creator>leoli</dc:creator><author>leoli</author><pubDate>Thu, 07 Dec 2006 03:27:00 GMT</pubDate><guid>http://www.blogjava.net/zhangzhong1018/articles/86040.html</guid><wfw:comment>http://www.blogjava.net/zhangzhong1018/comments/86040.html</wfw:comment><comments>http://www.blogjava.net/zhangzhong1018/articles/86040.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/zhangzhong1018/comments/commentRss/86040.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/zhangzhong1018/services/trackbacks/86040.html</trackback:ping><description><![CDATA[帮助文档是学习一个软件最好的途径。<br /><br />下面是ADOBE公司提供的学习FLEX2的文档下载地址：<br /><br />安装Flex 2<br />介绍安装Flex 2 包括对Flex Builder 2, Flex Data Services 2, Flex 2 SDK, 和Flex Charting 2的指导和配置.<br />地址：<a href="http://www.adobe.com/support/documentation/en/flex/2/install.html" target="_blank">http://www.adobe.com/support/documentation/en/flex/2/install.html</a><br /><br /><br />Flex 2 初级体验<br />针对那些第一次体验Flex的开发者，给予了他们一个对特色和性能总览的认识。本书包括了一系列的教程来帮助你快速学习Flex Builder 2 和 Flex 2 SDK 的基础<br />PDF文件, 4.3MB： <a href="http://www.adobe.com/go/flex2_gettingstarted_pdf" target="_blank">http://www.adobe.com/go/flex2_gettingstarted_pdf</a><br />在线版：<a href="http://www.adobe.com/go/flex2_gettingstarted" target="_blank">http://www.adobe.com/go/flex2_gettingstarted</a><br /><br /><br /><br />使用Flex Builder 2<br />介绍如何快书建立Flex应用程序的方法。<br /> PDF文件, 2.6MB：<a href="http://www.adobe.com/go/flexbuilder2_using_pdf" target="_blank">http://www.adobe.com/go/flexbuilder2_using_pdf</a><br /> 在线版：<a href="http://www.adobe.com/go/flexbuilder2_using" target="_blank">http://www.adobe.com/go/flexbuilder2_using</a><br /><br /><br /><br />Flex 2 手册<br />本手册给出了Flex ActionScript 和 MXML 编程的参考。Flex2 框架包括了类库，MXML语法，方式，属性，风格。ActionScript API包括函数，表达式，操作符和类库。<br /><br />地址：<a href="http://www.adobe.com/go/flex2_apiref" target="_blank">http://www.adobe.com/go/flex2_apiref</a><br /><br />Flex 2 开发指南<br /><br />关于建立应用程序，使用组件，数据模型，错误处理。也包括了Flex Charting 2 和Flex Data Services 2. <br /><br />PDF文件, 10.5MB：<a href="http://www.adobe.com/go/flex2_devapps_pdf" target="_blank">http://www.adobe.com/go/flex2_devapps_pdf</a><br />在线版：<a href="http://www.adobe.com/go/flex2_devapps" target="_blank">http://www.adobe.com/go/flex2_devapps</a><br /><br /><br />建立并扩展 Flex 2 组件<br />使用 MXML 和ActionScript建立并扩展Flex2组件<br /><br />PDF文件, 1.3MB：<a href="http://www.adobe.com/go/flex2_components_pdf" target="_blank">http://www.adobe.com/go/flex2_components_pdf</a><br /> 在线版：<a href="http://www.adobe.com/go/flex2_components" target="_blank">http://www.adobe.com/go/flex2_components</a><br /><br /><br />建立并配布 Flex 2 应用<br />描述建立并配布Flex 2 应用的过程. 包括安全，运行效率，日志，播放器检测，编译器。<br /><br />PDF文件, 2.7MB：<a href="http://www.adobe.com/go/flex2_building_pdf" target="_blank">http://www.adobe.com/go/flex2_building_pdf</a><br />在线版：<a href="http://www.adobe.com/go/flex2_building" target="_blank">http://www.adobe.com/go/flex2_building</a><br /><br /><br />ActionScript 3.0 编程<br />描述了ActionScript 3.0 的编程基础概念。包括了语言，事件处理，面向对象变成，数据类型，正则表达式，XML（E4X），网络和Flash Player安全。<br /><br />PDF文件, 3.8MB：<a href="http://www.adobe.com/go/programmingAS3_pdf" target="_blank">http://www.adobe.com/go/programmingAS3_pdf</a><br />在线版： <a href="http://www.adobe.com/go/programmingAS3" target="_blank">http://www.adobe.com/go/programmingAS3</a><br /><br /><br />移植应用到 Flex 2上<br />描述了如何移植Flex 1.5的程序到 Flex2上。<br /><br />PDF文件, 900KB：<a href="http://www.adobe.com/go/flex2_migrating_pdf" target="_blank">http://www.adobe.com/go/flex2_migrating_pdf</a><br /><br /> <br />Flex 2 Quick Starts   Flex Developer Center 文本打包<br />包括Flex 2 使用说明的PDF文档和HTML格式的Flex 2 手册和Flex Data Services 2 文档。<br /><br />下载 (.zip, 45.5MB)<a href="http://www.adobe.com/go/flex_documentation_zip" target="_blank">http://www.adobe.com/go/flex_documentation_zip</a><br /><br /><img src ="http://www.blogjava.net/zhangzhong1018/aggbug/86040.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/zhangzhong1018/" target="_blank">leoli</a> 2006-12-07 11:27 <a href="http://www.blogjava.net/zhangzhong1018/articles/86040.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>flex2 + jsp +mysql sample</title><link>http://www.blogjava.net/zhangzhong1018/articles/83831.html</link><dc:creator>leoli</dc:creator><author>leoli</author><pubDate>Mon, 27 Nov 2006 08:58:00 GMT</pubDate><guid>http://www.blogjava.net/zhangzhong1018/articles/83831.html</guid><wfw:comment>http://www.blogjava.net/zhangzhong1018/comments/83831.html</wfw:comment><comments>http://www.blogjava.net/zhangzhong1018/articles/83831.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/zhangzhong1018/comments/commentRss/83831.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/zhangzhong1018/services/trackbacks/83831.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 数据库表这个sql是用pd生成的，具体内容大家自己看一下好了，很简单，数据也自己填充一下。标题上说是用mysql，其实无所谓用啥数据库了，这里我推荐Postgresql，现在有for win平台了，不用cygwin来模拟unix环境，这个Postgresql一来小巧，二来功能齐全，看起来有点象Oracle，当然速度也很快了。																											...&nbsp;&nbsp;<a href='http://www.blogjava.net/zhangzhong1018/articles/83831.html'>阅读全文</a><img src ="http://www.blogjava.net/zhangzhong1018/aggbug/83831.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/zhangzhong1018/" target="_blank">leoli</a> 2006-11-27 16:58 <a href="http://www.blogjava.net/zhangzhong1018/articles/83831.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>ActionScript语言函数重载</title><link>http://www.blogjava.net/zhangzhong1018/articles/79773.html</link><dc:creator>leoli</dc:creator><author>leoli</author><pubDate>Wed, 08 Nov 2006 02:10:00 GMT</pubDate><guid>http://www.blogjava.net/zhangzhong1018/articles/79773.html</guid><wfw:comment>http://www.blogjava.net/zhangzhong1018/comments/79773.html</wfw:comment><comments>http://www.blogjava.net/zhangzhong1018/articles/79773.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/zhangzhong1018/comments/commentRss/79773.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/zhangzhong1018/services/trackbacks/79773.html</trackback:ping><description><![CDATA[
		<div style="MARGIN-TOP: 1px; MARGIN-LEFT: 15px">
				<b>关键字:</b>        </div>
		<div style="MARGIN-TOP: 10px; MARGIN-LEFT: 15px">
				<table width="100%">
						<tbody>
								<tr>
										<td>
												<p>ActionScript与JavaScript类似，都是符合ECMAScript语言规范的语言。ActionScript 3.0更是向<b>面向对象</b>语言靠近了一大步。相对而言，JavaScript则在停留在<b>基于对象</b>的层次上（曾经看到一份资料，说Firefox对JavaScript的支持有一个时间表，大概到07年春季就能支持JavaScript2.0,目前也就是1.5左右）。</p>
												<p>抛开ActionScript与JavaScript的版本不谈，让我们探讨一些以下几个问题： <br />1.ActionScript 3.0 是<b>面向对象</b>的吗？ <br />2.ActionScript 3.0 为什么不支持<b>函数重载</b>？</p>
												<p>首先，官方对ActionScript3.0的描述如下： <br />ActionScript 3.0 offers a robust programming model that will be familiar to developers with a basic knowledge of object-oriented programming. </p>
												<p>Because of ActionScript's roots as a scripting language, ActionScript 3.0 OOP support is optional. This affords programmers flexibility in choosing the best approach for projects of varying scope and complexity. For small tasks, you may find that using ActionScript with a procedural programming paradigm is all you need. For larger projects, applying OOP principles can make your code easier to understand, maintain, and extend.</p>
												<p>从上述叙述来看，ActionScript的确是支持面向对象语言的，但它不是<b>作为一个面向对象语言来设计</b>的。它源自脚本语言，并支持对象的概念。引入面向对象机制是为了克服脚本语言面对大型软件开发的重用、维护及扩展的难题。实际上，脱离应用和历史，谈论某种语言的面向对象机制的纯粹性毫无意义可言（就像论坛经常就C++或Java孰优孰劣论战一样毫无意义）。</p>
												<p>其次，ActionScript语言为什么不支持函数重载。</p>
												<p>照我的理解，函数重载（Function Override）从来不是面向对象语言的核心。因此，ActionScript语言是否支持函数重载不应该成为人们批评或质疑它的原因之一，是否实现函数重载完全取决于你的应用。</p>
												<p>曾经遇到一个问题，Java语言的某个类接口要映射要ActionScript类，由于该类的接口有函数重载的现象，导致ActionScript无法声明相应的接口。例如： <br />//Java类 <br />interface PetStoreFacade{ <br />Account getAccount(String username); <br />Account getAccount(String username, String password); <br />//... <br />}</p>
												<p>//ActionScript类 <br />interface PetStoreFacade{ <br />function getAccount(username:String):Account; <br />function getAccount(username:String, password:String):Account;//<span style="COLOR: red">ERROR,ActionScript不支持</span><br />}</p>
												<p>从此例，大家可以看出，讨论ActionScript是否支持函数重载的来源了（这大概是其中之一，即与支持函数重载的语言配合工作，或者要从支持函数重载的语言迁移到ActionScript就可能会遇到函数重载的问题）。</p>
												<p>关于ActionScript支持函数重载的文章很多，通过ActionScript提供的语言机制和变通的手法，可以让ActionScript支持函数重载。示例如下：</p>
												<p>class PetStoreFacadeImpl{ <br />function getAccount(obj:*):Account{ <br />if(arguments.length==1){ <br />if(arguments[0] typeof 'String'){ <br />//do getAccount(username:String) <br />} <br />} <br />else if(arguments.length==2){ <br />if(arguments[0] typeof 'String' &amp;&amp; arguments[1] typeof 'String'){ <br />//do getAccount(username:String,password:String) <br />} <br />} <br />} <br />}</p>
												<p>通过arguments的判断比较，实现了函数重载，只需调用时传入合适的参数即可。不过我们仍然要问，为什么ActionScript不能直接支持函数重载。语言内部的实现机制是怎么样的？仔细查阅了一些资料之后，发现这个问题其实很简单。原来，这跟ActionScript语言的内部设计实现有关。我们给出几个重要的概念，有助于理解上述问题。</p>
												<p>（一）<b><span style="COLOR: blue">函数也是对象</span></b><br />ActionScript语言所谓的函数实际上也是对象（即Function），而且函数也是对象。函数可以依附于任何对象，它是自由的。而面向对象语言例如Java，函数是和类实例绑定在一起的（静态函数可以脱离类实例，但绑定于类，仍然不能自由访问）。</p>
												<p>（二）<b><span style="COLOR: blue">对象是关联数组</span></b><br />ActionScript语言的所谓对象，实际上是一个属性和函数<b><span style="COLOR: blue">关联数组</span></b>。你可以定义一个类，包含若干属性和函数。例如上述PetStoreFacadeImpl类。假设它包含一个String类型的属性attribute，可以通过.操作符访问属性，如: <br />PetStoreFacade facade = new PetStoreFacadeImpl(); <br />var attr:String = facade.attribute;</p>
												<p>访问函数，通过 facade.getAccount(username)调用函数。实际上，还可以这样： <br />var attr:String = facade['attribute'];//数组 <br />facade['getAccount'].call(null,username) //数组 <br />或者 <br />facade['getAccount'].call(null,username,password) //数组</p>
												<p>看来，属性和函数标识是作为其对象访问时的唯一主键，因此也就没办法直接支持编码式的函数重载了。 </p>
										</td>
								</tr>
						</tbody>
				</table>
		</div>
<img src ="http://www.blogjava.net/zhangzhong1018/aggbug/79773.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/zhangzhong1018/" target="_blank">leoli</a> 2006-11-08 10:10 <a href="http://www.blogjava.net/zhangzhong1018/articles/79773.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>