﻿<?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>C++博客-教父的告白-随笔分类-AS3</title><link>http://www.cppblog.com/keigoliye/category/13129.html</link><description>一切都是纸老虎</description><language>zh-cn</language><lastBuildDate>Tue, 16 Mar 2010 13:33:59 GMT</lastBuildDate><pubDate>Tue, 16 Mar 2010 13:33:59 GMT</pubDate><ttl>60</ttl><item><title>AS3 event flow 事件冒泡机制</title><link>http://www.cppblog.com/keigoliye/archive/2010/03/15/109735.html</link><dc:creator>暗夜教父</dc:creator><author>暗夜教父</author><pubDate>Mon, 15 Mar 2010 07:03:00 GMT</pubDate><guid>http://www.cppblog.com/keigoliye/archive/2010/03/15/109735.html</guid><wfw:comment>http://www.cppblog.com/keigoliye/comments/109735.html</wfw:comment><comments>http://www.cppblog.com/keigoliye/archive/2010/03/15/109735.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/keigoliye/comments/commentRss/109735.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/keigoliye/services/trackbacks/109735.html</trackback:ping><description><![CDATA[<span  style="line-height: 22px; color: rgb(68, 68, 68); font-family: Verdana, Simsun; font-size: 13px; "><p style="line-height: 22px; margin-top: 0px; margin-right: 0px; margin-bottom: 1.35em; margin-left: 0px; ">大家好，今天亦乐首次为大家带来flash actionscript转载教程。首先声明出处（我自己是没时间写教程啦，要直接找我讨论还好）</p><table cellspacing="0" cellpadding="2" width="566" border="0" style="line-height: 22px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><tbody style="line-height: 22px; "><tr style="line-height: 22px; "><td valign="top" width="97" style="line-height: 22px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">&nbsp;</td><td valign="top" width="467" style="line-height: 22px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><a href="http://creativecommons.org/licenses/by/3.0/deed.zh" style="line-height: 22px; font-weight: inherit; text-decoration: none; color: rgb(39, 113, 179); cursor: pointer; "><font size="1" style="line-height: normal; "><em style="line-height: 20px; ">版权声明</em></font></a><font size="1" style="line-height: normal; "><em style="line-height: 20px; ">：转载时请以超链接形式标明文章原始出处和作者信息及</em></font><a href="http://bangzhuzhongxin.blogbus.com/logs/11205960.html" style="line-height: 22px; font-weight: inherit; text-decoration: none; color: rgb(39, 113, 179); cursor: pointer; "><font size="1" style="line-height: normal; "><em style="line-height: 20px; ">本声明</em></font></a><br style="line-height: 22px; "><a href="http://goday.blogbus.com/logs/14062836.html" style="line-height: 22px; font-weight: inherit; text-decoration: none; color: rgb(39, 113, 179); cursor: pointer; "><font size="1" style="line-height: normal; "><em style="line-height: 20px; ">http://goday.blogbus.com/logs/14062836.html</em></font></a></td></tr></tbody></table><p style="line-height: 22px; margin-top: 0px; margin-right: 0px; margin-bottom: 1.35em; margin-left: 0px; ">&nbsp;</p><p style="line-height: 22px; margin-top: 0px; margin-right: 0px; margin-bottom: 1.35em; margin-left: 0px; ">今天，我也正式宣布，开始成为闪客，以往对macromedia flash的许多头疼问题都被adobe解决了，以往一直否认我喜欢做flash，现在总算可以为adobe flash 自豪。非常有系统的developing方式。RIA 平台, on screen project就不这里说了。</p><p style="line-height: 22px; margin-top: 0px; margin-right: 0px; margin-bottom: 1.35em; margin-left: 0px; ">&nbsp;</p><p style="line-height: 22px; margin-top: 0px; margin-right: 0px; margin-bottom: 1.35em; margin-left: 0px; ">这期带来的是flash极重要元素之一，event事件。在游戏里就是所谓的Trigger. Adobe改良后的，大家谓称的&#8220;冒泡机制&#8221;。有问题欢迎发问指教。</p><p style="line-height: 22px; margin-top: 0px; margin-right: 0px; margin-bottom: 1.35em; margin-left: 0px; ">&nbsp;</p><p style="line-height: 22px; margin-top: 0px; margin-right: 0px; margin-bottom: 1.35em; margin-left: 0px; ">=思路大纲=</p><ol style="line-height: 22px; "><li style="line-height: 22px; margin-top: 0px; margin-right: 0px; margin-bottom: 3px; margin-left: 0px; ">ActionScript 2的问题</li><li style="line-height: 22px; margin-top: 0px; margin-right: 0px; margin-bottom: 3px; margin-left: 0px; ">AS3解决问题</li><li style="line-height: 22px; margin-top: 0px; margin-right: 0px; margin-bottom: 3px; margin-left: 0px; ">结合问题，说明&#8220;冒泡&#8221;</li><li style="line-height: 22px; margin-top: 0px; margin-right: 0px; margin-bottom: 3px; margin-left: 0px; ">冒泡的问题所在以及解决方法</li></ol><p align="left" style="line-height: 22px; margin-top: 0px; margin-right: 0px; margin-bottom: 1.35em; margin-left: 0px; "><br style="line-height: 22px; "><strong style="line-height: 22px; font-weight: bold; "><u style="line-height: 22px; ">1 - ActionScript 2的问题</u></strong></p><p align="left" style="line-height: 22px; margin-top: 0px; margin-right: 0px; margin-bottom: 1.35em; margin-left: 0px; ">stage里有一个mc，mc里有一个btn<br style="line-height: 22px; ">点选mc实现拖动mc，鼠标松开停止拖动<br style="line-height: 22px; ">点选mc实现mc隐藏。<br style="line-height: 22px; ">最容易想到的方法，代码如下：</p><blockquote style="line-height: 22px; "><p align="left" style="line-height: 22px; margin-top: 0px; margin-right: 0px; margin-bottom: 1.35em; margin-left: 0px; "><code style="line-height: 20px; "><font color="#0000ff" style="line-height: normal; ">mc.onPress = function() {<br style="line-height: 20px; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.startDrag();<br style="line-height: 20px; ">};<br style="line-height: 20px; ">mc.onRelease = function() {<br style="line-height: 20px; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.stopDrag();<br style="line-height: 20px; ">};<br style="line-height: 20px; ">mc.btn.onPress = function() {<br style="line-height: 20px; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; mc._visible=false<br style="line-height: 20px; ">};</font></code></p></blockquote><p style="line-height: 22px; margin-top: 0px; margin-right: 0px; margin-bottom: 1.35em; margin-left: 0px; ">表面来看，这个思路是正确的。（实际上没什么思路可言，很简单的方法。）<br style="line-height: 22px; ">实际怎么样？当然是不能实现。<br style="line-height: 22px; ">问题：点击btn，不能触发btn的动作！！！！<br style="line-height: 22px; ">解释:&nbsp; 因为btn处于mc内部，mc被加上了事件以后，按照as2的事件机制，mc内部的btn甚至是其他的元件都不能接受事件。或者可以认为mc的事件覆盖了mc中其他元件的事件。<br style="line-height: 22px; ">从非冒泡机制来说，在btn上点击鼠标，首先接受到点击事件的自然是btn的上一层（也就是mc），然后才是btn元件。Mc先接受到点击事件，触发相关的函数。然后呢？我们要实现的点击btn的效果没了。我们可以认为mc把我们的鼠标点击事件据为私有了，不再往下传递。（如果是冒泡机制的话，这个动作就回继续往下传递到btn，然后btn会执行。）那么这种效果在as2中还能实现么？答案自然是肯定的，不过方法就复杂了。<br style="line-height: 22px; ">这里就不讨论了。As3已经成为主流。<br style="line-height: 22px; ">但是as3中的冒泡机制，让我们可以简单的解决这样的难题。<br style="line-height: 22px; "></p><p style="line-height: 22px; margin-top: 0px; margin-right: 0px; margin-bottom: 1.35em; margin-left: 0px; "><u style="line-height: 22px; "><strong style="line-height: 22px; font-weight: bold; ">2 - AS3解决问题</strong></u></p><p style="line-height: 22px; margin-top: 0px; margin-right: 0px; margin-bottom: 1.35em; margin-left: 0px; ">下面来看as3中怎么实现。<br style="line-height: 22px; ">代码如下：</p><blockquote style="line-height: 22px; "><p style="line-height: 22px; margin-top: 0px; margin-right: 0px; margin-bottom: 1.35em; margin-left: 0px; "><code style="line-height: 20px; "><font color="#0000ff" style="line-height: normal; ">import flash.events.*;<br style="line-height: 20px; "></font></code><code style="line-height: 20px; "><font color="#0000ff" style="line-height: normal; ">mc.addEventListener(MouseEvent.CLICK,mcfunction);<br style="line-height: 20px; ">mc.btn.addEventListener(MouseEvent.CLICK,btnfucntion);</font></code></p></blockquote><code style="line-height: 20px; "><blockquote style="line-height: 20px; "><p style="line-height: 20px; margin-top: 0px; margin-right: 0px; margin-bottom: 1.35em; margin-left: 0px; "><font color="#0000ff" style="line-height: normal; ">function mcfunction(event:MouseEvent) {<br style="line-height: 20px; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; trace("mc click");<br style="line-height: 20px; ">}<br style="line-height: 20px; ">function btnfucntion(event:MouseEvent) {<br style="line-height: 20px; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; trace("btn click");<br style="line-height: 20px; ">}</font></p></blockquote></code><p style="line-height: 22px; margin-top: 0px; margin-right: 0px; margin-bottom: 1.35em; margin-left: 0px; "></p><p style="line-height: 22px; margin-top: 0px; margin-right: 0px; margin-bottom: 1.35em; margin-left: 0px; ">&nbsp;</p><p style="line-height: 22px; margin-top: 0px; margin-right: 0px; margin-bottom: 1.35em; margin-left: 0px; ">看看代码就觉得，好像没用什么特别的解决方法，就加两个侦听函数，就搞定了。<br style="line-height: 22px; ">这个代码自然的不能再自然了，就好像做flash 先的安装软件一样。<br style="line-height: 22px; ">但是如此自然的代码下面，使AS3的冒泡机制在提供支持。&nbsp;<br style="line-height: 22px; "><strong style="line-height: 22px; font-weight: bold; "><u style="line-height: 22px; "></u></strong></p><p style="line-height: 22px; margin-top: 0px; margin-right: 0px; margin-bottom: 1.35em; margin-left: 0px; "><strong style="line-height: 22px; font-weight: bold; "><u style="line-height: 22px; ">3 - 结合问题，说明冒泡机制：<br style="line-height: 22px; "></u></strong>Help中有一个冒泡机制的图，相信大家都已经看过了<br style="line-height: 22px; ">这里我联系实例，另外做一个图，帮助各位理解。</p><p style="line-height: 22px; margin-top: 0px; margin-right: 0px; margin-bottom: 1.35em; margin-left: 0px; "><a href="http://byfiles.storage.msn.com/y1p1A7N8RqJIngm92GLp9W6FrKW1yKzdP2G4YatVpHNcFyyqjbBvFWB-KoOmxqOWdcuKzr3jNEzmgQ?PARTNER=WRITER" style="line-height: 22px; font-weight: inherit; text-decoration: none; color: rgb(39, 113, 179); cursor: pointer; "><img height="259" alt="2D2D13C9009ACC1FF3AADD80E5C4FB85" src="http://byfiles.storage.msn.com/y1p1A7N8RqJInhZ59GIQZXXx5TkmqRKLXFqwo8L_eAEzF0ta9tgGyK4rt57nCP11bYZEqFL6VVLx10?PARTNER=WRITER" width="502" border="0" style="line-height: 22px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; border-right-style: initial; border-right-color: initial; border-top-style: initial; border-top-color: initial; border-left-style: initial; border-left-color: initial; border-bottom-style: initial; border-bottom-color: initial; "></a>&nbsp;<br style="line-height: 22px; "><img height="1" alt="" src="http://www.blogbus.com/user/?mm=Post&amp;aa=Edit&amp;blogid=1915&amp;id=14062836" width="1" border="0" style="line-height: 22px; "><br style="line-height: 22px; ">上图为as2中的执行原理<br style="line-height: 22px; ">下图为as3中的执行原理<br style="line-height: 22px; ">&nbsp;<a href="http://byfiles.storage.msn.com/y1p1A7N8RqJIni5P3Y6hEfQSN_85r-szrgORbGribq2vYsN83BBnZsLmpahMgKDscVGaqJY1vU-iGs?PARTNER=WRITER" style="line-height: 22px; font-weight: inherit; text-decoration: none; color: rgb(39, 113, 179); cursor: pointer; "><img height="258" alt="2D8D966808DAEEA2C9701B5E09B334FE" src="http://byfiles.storage.msn.com/y1p1A7N8RqJIngMlBMpb5cEUNMIJVrM5p7oot1SC13Wz1QC-Q-Fo-irjXXUBIteZS3VI5b4ycndJac?PARTNER=WRITER" width="499" border="0" style="line-height: 22px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; border-right-style: initial; border-right-color: initial; border-top-style: initial; border-top-color: initial; border-left-style: initial; border-left-color: initial; border-bottom-style: initial; border-bottom-color: initial; "></a>&nbsp;<br style="line-height: 22px; ">上图也就是在as3中实现我们文章开始提出的例子的工作原理。<br style="line-height: 22px; ">下面详细描述一下</p><blockquote style="line-height: 22px; "><p style="line-height: 22px; margin-top: 0px; margin-right: 0px; margin-bottom: 1.35em; margin-left: 0px; "><u style="line-height: 22px; ">捕获阶段：</u><br style="line-height: 22px; ">鼠标在btn上发出点击事件，首先捕捉到该事件的事stage.,然后事件往下传递到mc，再到btn..（如果鼠标事件发生在btn按钮中的一个label上，那么该事件还会继续向下传递，直到找到label元件。）AS2中，一旦找到了可以相应事件的函数，就停止了，不会往下传递。这个道理应该说明白了<br style="line-height: 22px; "><u style="line-height: 22px; ">目标阶段</u>：<br style="line-height: 22px; ">找到我们的鼠标最底层的目标，也就是btn以后，那么就开始执行btn的侦听函数了。<br style="line-height: 22px; ">&nbsp;&nbsp;&nbsp; 如果鼠标事件发生的所在位置，是mc中的btn中的一个label。那么将先执行label的侦听函数。（当然我们的例子中没有label）<br style="line-height: 22px; "><u style="line-height: 22px; ">冒泡阶段：<br style="line-height: 22px; "></u>执行了目标阶段的侦听函数以后，开始冒泡。<br style="line-height: 22px; ">换一个说法是，返回btn的父级元件mc，如果能找到相关的侦听函数，那么就执行，如果没有，就继续往上冒泡到btn的父级元件mc的父级元件stage。看能不能找到相关的侦听函数。</p></blockquote><p style="line-height: 22px; margin-top: 0px; margin-right: 0px; margin-bottom: 1.35em; margin-left: 0px; ">注意一个：首先执行的函数一定是目标对象的侦听函数。就像我们上面的例子一样，点击btn会先trace(&#8220;btn click&#8221;),然后冒泡到mc，执行trace(&#8220;mc click&#8221;)..然后继续往上，如果stage我们也加一个侦听函数，执行语句，那么还会继续执行 trace(&#8220;stage click&#8221;).<br style="line-height: 22px; ">到达stage顶层了，冒泡结束。<br style="line-height: 22px; ">说到这里，各位看官也应该明白了as3的冒泡究竟是干什么用的了<br style="line-height: 22px; "></p><p style="line-height: 22px; margin-top: 0px; margin-right: 0px; margin-bottom: 1.35em; margin-left: 0px; "><u style="line-height: 22px; "><strong style="line-height: 22px; font-weight: bold; ">4 - 冒泡的问题所在以及解决方法</strong></u><br style="line-height: 22px; ">&nbsp; 冒泡也有问题，并不是说它有缺陷，因为出现问题无法避免。<br style="line-height: 22px; ">&nbsp; 问题在于，<br style="line-height: 22px; ">&nbsp; 假如在上面的例子中，我们不想在点击btn冒泡阶段中执行mc的侦听函数，我们只想执行btn的侦听函数。怎么解决？<br style="line-height: 22px; ">同样的问题延伸出去，可以得到很多扩展和应用。<br style="line-height: 22px; ">那么我们需要阻止他的冒泡的时候执行相关的侦听函数。<br style="line-height: 22px; ">Chm中的方法有</p><blockquote style="line-height: 22px; ">stopImmediatePropagation():void<br style="line-height: 22px; ">防止对事件流中当前节点中和所有后续节点中的事件侦听器进行处理。<br style="line-height: 22px; ">stopPropagation():void<br style="line-height: 22px; ">防止对事件流中当前节点的后续节点中的所有事件侦听器进行处理。</blockquote><p style="line-height: 22px; margin-top: 0px; margin-right: 0px; margin-bottom: 1.35em; margin-left: 0px; ">用来修改我们上面的例子<br style="line-height: 22px; ">代码如下：</p><blockquote style="line-height: 22px; "><p style="line-height: 22px; margin-top: 0px; margin-right: 0px; margin-bottom: 1.35em; margin-left: 0px; "><code style="line-height: 20px; "><font color="#0000ff" style="line-height: normal; ">import flash.events.*;<br style="line-height: 20px; ">mc.addEventListener(MouseEvent.CLICK,mcfunction);<br style="line-height: 20px; ">mc.btn.addEventListener(MouseEvent.CLICK,btnfucntion);<br style="line-height: 20px; ">function mcfunction(event:MouseEvent) {<br style="line-height: 20px; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; trace("mc click");<br style="line-height: 20px; ">}<br style="line-height: 20px; ">function btnfucntion(event:MouseEvent) {<br style="line-height: 20px; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; trace("btn click");<br style="line-height: 20px; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; event.stopPropagation();//修改在此处。简单一句，解决问题<br style="line-height: 20px; ">}</font></code></p></blockquote><p style="line-height: 22px; margin-top: 0px; margin-right: 0px; margin-bottom: 1.35em; margin-left: 0px; ">现在可以试试，点击btn运行得到的结果就是</p><h6 style="line-height: 19px; font-weight: normal; margin-top: 0px; margin-right: 0px; margin-bottom: 5px; margin-left: 0px; color: rgb(68, 68, 68); font-size: 13px; ">代码:</h6><code style="line-height: 20px; ">btn click</code><p style="line-height: 22px; margin-top: 0px; margin-right: 0px; margin-bottom: 1.35em; margin-left: 0px; ">说明，已经防止了冒泡阶段中对mc侦听函数的处理。也就没有trace(&#8220;mc click&#8221;)了<br style="line-height: 22px; ">As3事件机制远远不像这里写的那么简单，还有很多东西需要研究。<br style="line-height: 22px; ">本文只为抛砖引玉，让各位能先了解一下冒泡机制。<br style="line-height: 22px; ">希望能多的朋友能提供相关的学习资料</p></span>
<img src ="http://www.cppblog.com/keigoliye/aggbug/109735.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/keigoliye/" target="_blank">暗夜教父</a> 2010-03-15 15:03 <a href="http://www.cppblog.com/keigoliye/archive/2010/03/15/109735.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>ActionScript 3中的类反射</title><link>http://www.cppblog.com/keigoliye/archive/2010/03/08/109230.html</link><dc:creator>暗夜教父</dc:creator><author>暗夜教父</author><pubDate>Mon, 08 Mar 2010 14:00:00 GMT</pubDate><guid>http://www.cppblog.com/keigoliye/archive/2010/03/08/109230.html</guid><wfw:comment>http://www.cppblog.com/keigoliye/comments/109230.html</wfw:comment><comments>http://www.cppblog.com/keigoliye/archive/2010/03/08/109230.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/keigoliye/comments/commentRss/109230.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/keigoliye/services/trackbacks/109230.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 什么是反射反射 (Reflection) 是指在程序在运行时 (run-time) 获取类信息的方式. 诸如实现动态创建类实例, 方法等. 在很语言中都有相关的的实现, 如 Java 和 c# 等反射有什么用在 as3 与 as2 不同, 类实例中任何元素, 如变量 (variable), 访问器 (accessor, 即 getter / setter), 方法 (method) 都是不可被 f...&nbsp;&nbsp;<a href='http://www.cppblog.com/keigoliye/archive/2010/03/08/109230.html'>阅读全文</a><img src ="http://www.cppblog.com/keigoliye/aggbug/109230.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/keigoliye/" target="_blank">暗夜教父</a> 2010-03-08 22:00 <a href="http://www.cppblog.com/keigoliye/archive/2010/03/08/109230.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>FAQs：新手怎样学习Flash及as脚本编程？</title><link>http://www.cppblog.com/keigoliye/archive/2010/02/24/108344.html</link><dc:creator>暗夜教父</dc:creator><author>暗夜教父</author><pubDate>Wed, 24 Feb 2010 06:27:00 GMT</pubDate><guid>http://www.cppblog.com/keigoliye/archive/2010/02/24/108344.html</guid><wfw:comment>http://www.cppblog.com/keigoliye/comments/108344.html</wfw:comment><comments>http://www.cppblog.com/keigoliye/archive/2010/02/24/108344.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.cppblog.com/keigoliye/comments/commentRss/108344.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/keigoliye/services/trackbacks/108344.html</trackback:ping><description><![CDATA[<span  style="font-family: Arial; font-size: 14px; line-height: 20px; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; "><p style="line-height: normal; "><strong style="line-height: normal; "><font color="#800000" style="line-height: normal; ">一、写这个文章的起因：</font></strong></p><p style="line-height: normal; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 经常遇到很多人想学习Flash，但是不知道从何学起，有的朋友甚至对于学会了Flash，能做些什么也很疑惑。</p><p style="line-height: normal; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 本人结合若干年Flash学习研究经验，给想学习Flash的朋友一些建议，也欢迎大家访问我的空间，<a href="http://hi.baidu.com/billypc" style="color: rgb(153, 153, 153); text-decoration: none; word-wrap: break-word; word-break: break-all; line-height: normal; ">http://hi.baidu.com/billypc</a>给我留言。如转载本文，希望多多宣传本空间，谢谢。</p><p style="line-height: normal; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 一般来说，Flash的学习主要有两个方向，一是专攻Flash动画，一是专攻Flash编程，当然也有动画和编程都学习的很到位的人，那是牛人。不过这里我主要分析一下Flash的这两种方向如何开始学习，如何快速掌握。</p><p style="line-height: normal; "><strong style="line-height: normal; "><font color="#800000" style="line-height: normal; ">二、FAQs</font></strong></p><p style="line-height: normal; "><strong style="line-height: normal; "><font color="#003366" style="line-height: normal; ">问：学习flash做动画需不需要美术基础啊？</font><br style="line-height: normal; "><font color="#333333" style="line-height: normal; ">答：<br style="line-height: normal; "></font></strong><font color="#333333" style="line-height: normal; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 首先，要说明的是，Flash动画也分为几种。</font></p><p style="line-height: normal; "><font color="#333333" style="line-height: normal; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 最重要的应用就是做动画片，比如早期的ShowGood三国，小小，现在的小破孩系列，开心驿站系列，燕尾蝶等。这些都是动画片制作，这一类的flash需要有很好的美术功底，需要有诸如手绘，视觉感，镜头感等相关的专业知识。这一类的动画制作基本上需要美术和动画的专业知识。而Flash只是作为一个动画制作的工具而已，一个动画片在从开始到结束，更多的需要的是美术及动画方面的专业知识。</font></p><p style="line-height: normal; "><font color="#333333" style="line-height: normal; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 另一类应用是Flash广告和Flash特效，这一类Flash大量应用于网络，从网站主页Flash动画，到网站内部的一些广告，一些吸引眼球的效果，都属于这一类应用。一般学习Flash的人，基本上都在做这样的东西。包括一些初学者在内，都认为这就是Flash，其实这只是Flash最简单的应用。制作这一类的Flash一般需要一些创意，有一定的视觉感，有美术基础的人会更加得心应手。有时候会需要掌握一些基础的flash as，比如制作flash菜单，flash跳转效果等。</font></p><p style="line-height: normal; "><font color="#333333" style="line-height: normal; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Flash在动画的制作过程中，主要扮演的是工具的角色，是目前动画制作中效率比较高的工具之一，而一个好的动画，并不依赖于你用什么工具，而依赖于你的专业程度。专业知识越扎实，创意越新颖，做出的动画就越好。而工具的学习仅仅是第一步。</font></p><p style="line-height: normal; "><font color="#333333" style="line-height: normal; "><strong style="line-height: normal; "><font color="#003366" style="line-height: normal; "><br style="line-height: normal; ">问：我也不知道应该学习哪个方向，动画和编程哪个好学啊？<br style="line-height: normal; "></font>答：<br style="line-height: normal; "></strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 学做动画，和学做编程，这样两个方向，其实不仅仅是做什么的不同，也是思维方式的不同。</font></p><p style="line-height: normal; "><font color="#333333" style="line-height: normal; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 一般来说，做动画受视觉因素影响，而编程主要受逻辑思维影响。从很宽泛的角度上来说，学动画，就是学感觉，学新思维。而学编程，就是学逻辑，学思维方式。美学不仅仅是能感觉到，还是一种创意思维，是感性的。而程序逻辑则完全是一种逆向思维，是理性的。</font></p><p style="line-height: normal; "><font color="#333333" style="line-height: normal; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 一般情况下，逻辑思维可以通过培训等，在短时间内锻炼出来，所以编程应该来说是人人都能学会的，而且是可以通过死记硬背在短时间内速成的。</font></p><p style="line-height: normal; "><font color="#333333" style="line-height: normal; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 而感性思维，或者说创造性思维，是很难一下子就养成的，就像我们学画画，没有个一年半载，根本画不出什么好的东西，而且很多画画好的都是从小开始培养的。所以学动画短时间内很难有一些突破，仅仅只能停留在一个较低的层面上，这也就是为什么很多人只会做flash广告，而做不了大于3分钟的动画，或者说做不出高质量的动画的原因了。</font></p><p style="line-height: normal; "><font color="#333333" style="line-height: normal; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 但是从入门的角度上来看，会用flash的人，一般都能从事简单flash动画的制作，其实这主要是依靠了FLASH这款工具的强大，并非代表着做动画很简单，或者你很聪明，一下子就学会了，入门也许很简单，但是越想提高一个层次就越困难，比如学会FLASH没多久，就会做flash主页，flash广告等，那是因为这个没有什么难度，所以综合看来，我认为，如果想在短时间内，从事flash工作的话，可以先掌握flash的应用，能制作简单flash动画，然后学习编程，短期内会很有效果。从长期来看，学习一些美术基础，对做动画会大有帮助。</font></p><p style="line-height: normal; "><font color="#333333" style="line-height: normal; "><strong style="line-height: normal; "><font color="#003366" style="line-height: normal; "><br style="line-height: normal; ">问：我最近想去学flash制作，在网上找了找，发现有很多制作软件，如flash MX,flash MX2004和flash cs3 Pro，哪款比较好啊？<br style="line-height: normal; "></font>答：<br style="line-height: normal; "></strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2000年 flash 5.0&nbsp;<br style="line-height: normal; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2002年 flash mx (就是flash 6.0)&nbsp;<br style="line-height: normal; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2004年 flash mx2004 (就是flash 7.0)&nbsp;<br style="line-height: normal; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2005年 flash 8.0&nbsp;<br style="line-height: normal; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2006年 flash cs3 (就是flash 9.0)&nbsp;<br style="line-height: normal; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2008年 flash cs4 (就是flash 10.0)</font></p><p style="line-height: normal; "><font color="#333333" style="line-height: normal; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 目前的最新版本是flash cs4 功能非常强大，不仅支持骨骼动画，还支持3维等等，verycd上有视频教程，可以去学习一下。</font></p><p style="line-height: normal; "><font color="#333333" style="line-height: normal; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 不过初学的话，个人建议你从flash cs3开始，以便今后玩flash cs4，因为他们的操作性很相似，Flash 8现在虽然还是很多人在用，但是已经渐渐被新软件的新功能所取代。</font></p><p style="line-height: normal; "><font color="#333333" style="line-height: normal; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; FLASH CS3的好用之处:：</font></p><p style="line-height: normal; "><font color="#333333" style="line-height: normal; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1.cs3是ADOBE收购micromedia后的大作，无论从动画设计上，还是程序语言上都有质的飞跃。比如钢笔功能更加强大，超级强大的绘图功能，这些都让矢量图制作者提高了效率，使用更方便。</font></p><p style="line-height: normal; "><font color="#333333" style="line-height: normal; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2.FLASH CS3引入了面向对象的AS3语言，使得AS不在是一个简简单单的脚本语言，而摇身变成一种强大的高级程序语言。另外，FLASH CS3也全面支持AS之前的版本，从AS1到AS2均支持。</font></p><p style="line-height: normal; "><font color="#333333" style="line-height: normal; ">&nbsp;&nbsp;&nbsp;&nbsp; 3.作为初学者，因为没有基础，不存在用惯一个版本的软件，用新版本时要重新熟悉的问题，所以应尽量选择最新版本的软件进行学习，因为时代是在进步的，老版本的软件，学完了也就淘汰了，再学新的，还得重新熟悉界面及操作习惯。</font></p><p style="line-height: normal; "><font color="#333333" style="line-height: normal; ">&nbsp;&nbsp;&nbsp;&nbsp; 4.目前由于flash cs4 10月份刚刚推出，目前CS4的教材并不多也不系统，所以建议以FLASH CS3作为学习的开始，而且FLASH CS4的界面和CS3差不多，只是加了些新功能。</font></p><p style="line-height: normal; "><font color="#333333" style="line-height: normal; "><font color="#003366" style="line-height: normal; "><strong style="line-height: normal; "><br style="line-height: normal; ">问：怎样学会flash编程，要有什么基础，要学c语言吗，哪里有教程啊？该怎么学啊？？</strong></font><br style="line-height: normal; "><strong style="line-height: normal; ">答：<br style="line-height: normal; "></strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 如果你只是了解一下，网上的视频教程很多，可以去看一看。</font></p><p style="line-height: normal; "><font color="#333333" style="line-height: normal; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 但是如果你是很想学会，那么我建议你，要学习一门知识，就必须看系统的教材。因此不推荐看视频教程，网上的视频教程虽然很多，但是都很难系统性的教会你代码的结构、编程的思想。所以我的建议是买书学习。最好不要看电子书，个人觉得，看电子书的人，都喜欢跳着看，这样看就失去了意义。这样看下来，好像学会了，其实什么原理都没搞懂。</font></p><p style="line-height: normal; "><font color="#333333" style="line-height: normal; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 要真正的买一本书，一页一页的翻着看，看一遍不够，一本书至少3遍甚至n遍。还要多加练习。学习编程，首先从hello world开始，然后就是要每天写，经常写，这样才有进步。</font></p><p style="line-height: normal; "><font color="#333333" style="line-height: normal; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 很多人也有这样的担心，怕自己没有语言基础，例如没有学习过C等。其实大可不必担心，语言只是一种工具而已，目前的主流语言就好象同素异形体一样，看似有区别，其实都差不多。这就好像你会使用WIN98,升级到了WIN XP，你也不会说，连怎么打开文件都要重头学习一样。学习编程的关键是学习编程的思想，所以好的书教你怎么理解编程思想，差的书只是叫你怎么写代码，其中区别很大。</font></p><p style="line-height: normal; "><font color="#333333" style="line-height: normal; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; AS2的书，这里不做推荐了，我也没看过什么好点的书，我学AS2完全就是看帮助学会的，主要是有JS基础。&nbsp;<br style="line-height: normal; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 这里推荐一本AS3的书：《action script3.0殿堂之路》</font></p><p style="line-height: normal; "><font color="#333333" style="line-height: normal; "><strong style="line-height: normal; "><font color="#003366" style="line-height: normal; "><br style="line-height: normal; ">问：我是老程序员了，对Javascript和Java都比较擅长，现在想学Flex，但不知道有什么经典一点的书籍？<br style="line-height: normal; "></font>答：<br style="line-height: normal; "></strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1.初学者，推荐《action script3.0殿堂之路》，也有人推荐《as3权威宝典》个人觉得那书写的不行。</font></p><p style="line-height: normal; "><font color="#333333" style="line-height: normal; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2.flex的话，推荐《flex第一步》</font></p><p style="line-height: normal; "><font color="#333333" style="line-height: normal; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 3.as3语言掌握的7788了以后，可以去看以下一些书籍</font></p><p style="line-height: normal; "><font color="#333333" style="line-height: normal; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 4.实用书籍：&nbsp;<br style="line-height: normal; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Action Script3.0 Cook Book —— 类似帮助手册的书籍&nbsp;<br style="line-height: normal; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Action Script3.0 设计模式 —— 一本讲述程序设计思想的书籍，强烈推荐</font></p><p style="line-height: normal; "><font color="#333333" style="line-height: normal; "><font color="#003366" style="line-height: normal; "><strong style="line-height: normal; "><br style="line-height: normal; ">问：flash as2.0 与 as3.0的本质区别？</strong></font><br style="line-height: normal; "><strong style="line-height: normal; ">答：<br style="line-height: normal; "></strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 首先说下as2,as2实际上是as1的升级版，引入一面向对象的概念，但并不是完全面向对象的语言，只是在编译过程中支持OOP语法。as2的面向对象虽然不全面，但是却是首次将OOP带到了FLASH，而AS3是一个完全基于OOP的标准化面向对象语言，最重要的就是as3不是as2的简单升级，而完全是两种思想的语言。可以说，as3全面采用了面向对象的思想，而as2则仍然停留在面向过程阶段，举个例子，就像VB和C#的对比。</font></p><p style="line-height: normal; "><font color="#333333" style="line-height: normal; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 所以as3绝不是as2的升级版，在as3里，可以看到java和c#的影子，确实，这三种语言大部分思想都是一致的，只有一些小的区别，比如as3引入了命名空间的概念，但是不支持比如委托,在包封装及外部访问上也引入了一些新概念。</font></p><p style="line-height: normal; "><font color="#333333" style="line-height: normal; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 在编译阶段，as2采用的是AVM1（actionScript vitual machine），而as3采用的是AVM2。新一代虚拟机采用了OOP思想，在执行速度上比起avm1也快了10倍。还提供了异常处理。以前我们在使用AS2时，一旦出错，AVM1选择的是静默失败，让人根本不知道什么地方出错了，会浪费大量的时间去查错，而AVM2与目前主流的编译器一样，会有异常处理，运行出错会输出错误提示，工作效率大大提高。如果做个对比，我想说，AVM1就是大刀长矛，而AVM2就是手枪，大刀和长矛也能杀敌，但是只在面对弱智的敌人才能发挥作用，面对一个大型项目，不用点现代化工具是不行滴。</font></p><p style="line-height: normal; "><font color="#333333" style="line-height: normal; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; as2与as3的部分区别，只说一些大的区别，小的不同太多，就不谈了：</font></p><p style="line-height: normal; "><font color="#333333" style="line-height: normal; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1.运行时异常机制处理，这个刚才说过了。</font></p><p style="line-height: normal; "><font color="#333333" style="line-height: normal; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2.事件机制，这也是很多人拿起as3就不知所措的原因，初学者会发现连一个按钮点击的方法都写不出来。实际上as3的事件机制采用的是监听的方式，和as2时代的onClipEvent不同，as3里所有的事件都是需要触发器，监听器，执行器三种结构的，这样做的好处就是使得这个语言非常的坚强，非常的标准化。不像as2,奇形怪状的代码漫天飞，可以这样写，也可以那样写，代码变得繁复难懂，可读性太差，执行效率也大大降低。要特别说明的是，as3的所有事件都直接继承event对象，而event是直接继承自大老板Object类,结构多么完美。所以在as3中，所有的事件都继承自相同的父亲，结构相同，提高了重用性。</font></p><p style="line-height: normal; "><font color="#333333" style="line-height: normal; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 3.封装性，这是as3与as2最大的不同，as3引入了封装的概念，使得程序安全性大大提高，各个对象之间的关系也通过封装，访问控制而得以确定，避免了不可靠的访问给程序带来的意外产生。</font></p><p style="line-height: normal; "><font color="#333333" style="line-height: normal; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 4.XML，我觉得这是最令人激动人心的改变，现在as3程序员可以很轻松也很自豪的说，我们是使用XML人群中最快乐的人。AS2时代对XML的存取仍然需要解析，而AS3则创新的将XML也视作一个对象，存取XML就像存取普通对象的属性一样方便，用点语法就可以，无疑大大提高了效率。</font></p><p style="line-height: normal; "><font color="#333333" style="line-height: normal; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 5.最关键的一点，容器的概念，AS3采用了容器的思想，告别了as2一个MovieClip打天下的局面。对于as2程序员来说，可能不能理解，我mc用的好好的，干嘛不让我用啊。但是当你真正的了解as3的思想的时候，当你真主的体会到OOP的好处的时候，你会觉得as3的容器的思想的完全正确的。as2时代，我们做什么都用mc,而as2时代的mc也是直接继承自object，这给了mc极大的权限，极其多的方法属性，而有时我们只需要放一个背景图，并不需要它动，这样做就造成了极大的浪费。说实在话as2和as3比起来就是浪费之神，所以as2编出的swf绝对比as3编译出来的swf要大上几倍。as3把所有你用到的显示对象都分开，mc的属性方法都被瓜分开来，举个例子，你去水果超市买水果，就肯定比直接去大型超市买要方便，更节约时间，时间就是金钱，那就是很大的节省。</font></p><p style="line-height: normal; "><font color="#333333" style="line-height: normal; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 当然还有许许多多的不同，比如程序执行机制，设计模式，结构框架等等，这里就不在一一赘述。</font></p><p style="line-height: normal; "><font color="#333333" style="line-height: normal; "><font color="#003366" style="line-height: normal; "><strong style="line-height: normal; "><br style="line-height: normal; ">问：怎么才能成为编程高手？</strong></font><br style="line-height: normal; "><strong style="line-height: normal; ">答：<br style="line-height: normal; "></strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 可以说，学会编程并不难，怎么才能写出好的程序，这是很多人所困惑的事情，我有时候也是左思右想，觉得自己写出来的东西太在是太垃圾了。那么真正的高手他们在做些什么呢？他们到底因为什么才能成为高手呢？</font></p><p style="line-height: normal; "><font color="#333333" style="line-height: normal; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 其实，我们很多人都仅仅停留在会写程序的阶段，并没有去研究，一个程序怎么写才算是合理的，什么样的结构，才是最完善的，什么样的布局才是可扩展的。什么样的代码才是最高效的。而这正是高手花功夫去研究的事情，也是为什么高手能做的更好的原因。</font></p><p style="line-height: normal; "><font color="#333333" style="line-height: normal; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 我总结了一下，觉得以下才是一个程序员应该思考的路：</font></p><p style="line-height: normal; "><font color="#333333" style="line-height: normal; ">&nbsp;&nbsp;&nbsp;&nbsp; 1.第一类人：会写程序，这没什么，人人都能办到。(70%的程序员都在这里)</font></p><p style="line-height: normal; "><font color="#333333" style="line-height: normal; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2.第二类人：有一定的结构思想，能做设计结构上的调整。能走到这一步，应该可以算真正入门了。(15%的程序员在这里，很不幸，本人也在这里。)</font></p><p style="line-height: normal; "><font color="#333333" style="line-height: normal; ">&nbsp;&nbsp;&nbsp;&nbsp; 3.第三类人：熟练应用各种设计模式，到了这里，才算涉足高级编程领域。这样的人才能算高手。（10%左右，我想黑羽同志应该属于这个级别）</font></p><p style="line-height: normal; "><font color="#333333" style="line-height: normal; ">&nbsp;&nbsp;&nbsp;&nbsp; 4.第四类人：有算法分析和创意思维，能做到这一步的人，写出来的程序就不叫程序了，叫伟大发明！（5%左右，微软和谷歌的专家们在这里）</font></p><p style="line-height: normal; "><font color="#333333" style="line-height: normal; ">&nbsp;&nbsp;&nbsp;&nbsp; 5.第五类人：这一类人是我不敢想象的，已经超出我的思考范畴了。（趋向0%）</font></p><p style="line-height: normal; "><font color="#333333" style="line-height: normal; ">最后，欢迎大家百度HI我，和我探讨相关的技术。<br style="line-height: normal; "></font><font color="#333333" style="line-height: normal; ">或者加入百度HI群：flash知道（1群）1051316、 flash知道（2群）1084144</font></p></span>
<img src ="http://www.cppblog.com/keigoliye/aggbug/108344.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/keigoliye/" target="_blank">暗夜教父</a> 2010-02-24 14:27 <a href="http://www.cppblog.com/keigoliye/archive/2010/02/24/108344.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>