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

<channel>
	<title>阿平的程序收藏集 &#187; 资源下载</title>
	<atom:link href="http://www.ppzhao.net/index.php/archives/category/download/feed" rel="self" type="application/rss+xml" />
	<link>http://www.ppzhao.net</link>
	<description>FLASH FLEX AS3 WEB UI ...</description>
	<lastBuildDate>Thu, 08 Apr 2010 08:14:29 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Imageprocessing Library:一个图象滤镜库</title>
		<link>http://www.ppzhao.net/index.php/archives/353</link>
		<comments>http://www.ppzhao.net/index.php/archives/353#comments</comments>
		<pubDate>Tue, 19 Jan 2010 02:05:17 +0000</pubDate>
		<dc:creator>阿平</dc:creator>
				<category><![CDATA[FLASH/FLEX开发]]></category>
		<category><![CDATA[资源下载]]></category>

		<guid isPermaLink="false">http://www.ppzhao.net/?p=353</guid>
		<description><![CDATA[Imageprocessing Library是一个基于as3的简单高效的图像滤镜库。里面包含了五十多种对图片的处理方法。（官方介绍，没有验证）
我是在deface的官方示例中发现这个包的，简单看了一下，发现功能强大，但不是开源的。
官方博客地址：http://blog.joa-ebert.com/imageprocessing-library/
最新版本的swc地址：http://je2050.de/files/source/as3/ImageProcessing.zip
文档地址：http://je2050.de/imageprocessing/
几个示例：
仿PS的曲线工具：http://je2050.de/showroom.php?file=curves
结合pv3d做的一个示例：http://je2050.de/showroom.php?file=roto&#38;f=1
还有一个扩展示例，说不出来的酷：http://www.sephiroth.it/test/flex/2/mixer_papervision/Main.html
]]></description>
			<content:encoded><![CDATA[<p>Imageprocessing Library是一个基于as3的简单高效的图像滤镜库。里面包含了五十多种对图片的处理方法。（官方介绍，没有验证）</p>
<p>我是在deface的官方示例中发现这个包的，简单看了一下，发现功能强大，但不是开源的。</p>
<p>官方博客地址：<a href="http://blog.joa-ebert.com/imageprocessing-library/">http://blog.joa-ebert.com/imageprocessing-library/</a></p>
<p>最新版本的swc地址：<a href="http://je2050.de/files/source/as3/ImageProcessing.zip">http://je2050.de/files/source/as3/ImageProcessing.zip</a></p>
<p>文档地址：<a href="http://je2050.de/imageprocessing/">http://je2050.de/imageprocessing/</a></p>
<p>几个示例：</p>
<p>仿PS的曲线工具：<a href="http://je2050.de/showroom.php?file=curves">http://je2050.de/showroom.php?file=curves</a></p>
<p>结合pv3d做的一个示例：<a href="http://je2050.de/showroom.php?file=roto&amp;f=1">http://je2050.de/showroom.php?file=roto&amp;f=1</a></p>
<p>还有一个扩展示例，说不出来的酷：<a href="http://www.sephiroth.it/test/flex/2/mixer_papervision/Main.html">http://www.sephiroth.it/test/flex/2/mixer_papervision/Main.html</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.ppzhao.net/index.php/archives/353/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ZamfBrowser:不错的ZendAMF调试工具</title>
		<link>http://www.ppzhao.net/index.php/archives/340</link>
		<comments>http://www.ppzhao.net/index.php/archives/340#comments</comments>
		<pubDate>Wed, 13 Jan 2010 02:03:13 +0000</pubDate>
		<dc:creator>阿平</dc:creator>
				<category><![CDATA[FLASH/FLEX开发]]></category>
		<category><![CDATA[资源下载]]></category>
		<category><![CDATA[puremvc]]></category>
		<category><![CDATA[ZamfBrowser]]></category>
		<category><![CDATA[zendamf]]></category>

		<guid isPermaLink="false">http://www.ppzhao.net/?p=340</guid>
		<description><![CDATA[事实证明,经常看看那些开源项目的网站,总是会好处的.我今天逛puremvc的网站就有了一个惊喜,发现了一个基于puremvc的开源东东叫:ZamfBrowser.用这个工具,可以方便的对ZendAMF的php端程序进行测试和调试.
官方网站:http://www.zamfbrowser.org/
项目的SVN地址:http://svn.riaforge.org/zamfbrowser/
从SVN当下来的代码有两个部分,air和php.
air部分的代码,需要在flex中建一个air项目,把puremvc的代码链进来,就可以进行编译了.可以release一个版本出来,自个安装一下.注意:要air运行环境哦.
php部分的代码里面有个示例代码的zip包,实际上用到的只是sourse目录中的ZendAmfServiceBrowser.php文件.
具体使用方法如下:
1)rowser拷到你的项目中.
2)修改你的gateway.php文件.添加如下代码

require_once&#40; &#34;browser/ZendAmfServiceBrowser.php&#34; &#41;;
$server-&#62;setClass&#40; &#34;ZendAmfServiceBrowser&#34; &#41;;
ZendAmfServiceBrowser::$ZEND_AMF_SERVER = $server;

下面就是启动你刚刚装好的的air程序,添加一个服务,第一个框中随便填个名称,第二个框中填gateway.php的地址,就OK了.
下面你就可以对你项目中各个类中的各个方法进行测试了,设定传入的参数,查看传回的结果.
爽吧?
具体的使用帮助,请看官网的:
http://www.zamfbrowser.org/documentation.html
]]></description>
			<content:encoded><![CDATA[<p>事实证明,经常看看那些开源项目的网站,总是会好处的.我今天逛puremvc的网站就有了一个惊喜,发现了一个基于puremvc的开源东东叫:ZamfBrowser.用这个工具,可以方便的对ZendAMF的php端程序进行测试和调试.</p>
<p>官方网站:<a href="http://www.zamfbrowser.org/">http://www.zamfbrowser.org/</a></p>
<p>项目的SVN地址:<a href="http://svn.riaforge.org/zamfbrowser/">http://svn.riaforge.org/zamfbrowser/</a></p>
<p>从SVN当下来的代码有两个部分,air和php.</p>
<p>air部分的代码,需要在flex中建一个air项目,把puremvc的代码链进来,就可以进行编译了.可以release一个版本出来,自个安装一下.注意:要air运行环境哦.</p>
<p>php部分的代码里面有个示例代码的zip包,实际上用到的只是sourse目录中的ZendAmfServiceBrowser.php文件.</p>
<p>具体使用方法如下:</p>
<p>1)rowser拷到你的项目中.</p>
<p>2)修改你的gateway.php文件.添加如下代码</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">require_once</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">&quot;browser/ZendAmfServiceBrowser.php&quot;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$server</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setClass</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">&quot;ZendAmfServiceBrowser&quot;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
ZendAmfServiceBrowser<span style="color: #339933;">::</span><span style="color: #000088;">$ZEND_AMF_SERVER</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$server</span><span style="color: #339933;">;</span></pre></div></div>

<p>下面就是启动你刚刚装好的的air程序,添加一个服务,第一个框中随便填个名称,第二个框中填gateway.php的地址,就OK了.<br />
下面你就可以对你项目中各个类中的各个方法进行测试了,设定传入的参数,查看传回的结果.<br />
爽吧?<br />
具体的使用帮助,请看官网的:<br />
<a href="http://www.zamfbrowser.org/documentation.html">http://www.zamfbrowser.org/documentation.html</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.ppzhao.net/index.php/archives/340/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>一个声音光谱效果的源码</title>
		<link>http://www.ppzhao.net/index.php/archives/330</link>
		<comments>http://www.ppzhao.net/index.php/archives/330#comments</comments>
		<pubDate>Thu, 07 Jan 2010 02:47:32 +0000</pubDate>
		<dc:creator>阿平</dc:creator>
				<category><![CDATA[FLASH/FLEX开发]]></category>
		<category><![CDATA[资源下载]]></category>

		<guid isPermaLink="false">http://www.flashcs4.com.cn/?p=330</guid>
		<description><![CDATA[偶然发现了这个效果,只有一个类,效果狂好.奉上源码
点击下面的[flash]开始欣赏.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
package
&#123;
	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import flash.display.Shape;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.geom.ColorTransform;
	import flash.geom.Matrix;
	import flash.geom.Rectangle;
	import flash.media.Microphone;
	import flash.media.Sound;
	import flash.media.SoundMixer;
	import flash.utils.ByteArray;
&#160;
	&#91;SWF&#40; backgroundColor='0', frameRate='35', height='400', width='400'&#41;&#93;
&#160;
	public class Main extends Sprite
	&#123;
&#160;
		private var mic: Microphone;
		private var sound: Sound;
		private var bytes: ByteArray;
&#160;
		private var output: BitmapData;
		private var peaks: BitmapData;
		private var displace: Matrix;
		private var rect: Rectangle;
		private var gradient: Array;
		private var darken: ColorTransform;
&#160;
       [...]]]></description>
			<content:encoded><![CDATA[<p>偶然发现了这个效果,只有一个类,效果狂好.奉上源码</p>
<p>点击下面的[<a href="http://www.flashcs4.com.cn/wp-content/uploads/2010/01/main.swf" target="_blank">flash</a>]开始欣赏.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
</pre></td><td class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #9900cc; font-weight: bold;">package</span>
<span style="color: #000000;">&#123;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.display</span>.<span style="color: #004993;">Bitmap</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.display</span>.<span style="color: #004993;">BitmapData</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.display</span>.<span style="color: #004993;">Shape</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.display</span>.<span style="color: #004993;">Sprite</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.events</span>.<span style="color: #004993;">Event</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.events</span>.<span style="color: #004993;">MouseEvent</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.geom</span>.<span style="color: #004993;">ColorTransform</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.geom</span>.<span style="color: #004993;">Matrix</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.geom</span>.<span style="color: #004993;">Rectangle</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.media</span>.<span style="color: #004993;">Microphone</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.media</span>.<span style="color: #004993;">Sound</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.media</span>.<span style="color: #004993;">SoundMixer</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.utils</span>.<span style="color: #004993;">ByteArray</span>;
&nbsp;
	<span style="color: #000000;">&#91;</span>SWF<span style="color: #000000;">&#40;</span> <span style="color: #004993;">backgroundColor</span>=<span style="color: #990000;">'0'</span>, <span style="color: #004993;">frameRate</span>=<span style="color: #990000;">'35'</span>, <span style="color: #004993;">height</span>=<span style="color: #990000;">'400'</span>, <span style="color: #004993;">width</span>=<span style="color: #990000;">'400'</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span>
&nbsp;
	<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> Main extends <span style="color: #004993;">Sprite</span>
	<span style="color: #000000;">&#123;</span>
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> mic<span style="color: #000000; font-weight: bold;">:</span> <span style="color: #004993;">Microphone</span>;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> sound<span style="color: #000000; font-weight: bold;">:</span> <span style="color: #004993;">Sound</span>;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> bytes<span style="color: #000000; font-weight: bold;">:</span> <span style="color: #004993;">ByteArray</span>;
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> output<span style="color: #000000; font-weight: bold;">:</span> <span style="color: #004993;">BitmapData</span>;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> peaks<span style="color: #000000; font-weight: bold;">:</span> <span style="color: #004993;">BitmapData</span>;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> displace<span style="color: #000000; font-weight: bold;">:</span> <span style="color: #004993;">Matrix</span>;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> <span style="color: #004993;">rect</span><span style="color: #000000; font-weight: bold;">:</span> <span style="color: #004993;">Rectangle</span>;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> gradient<span style="color: #000000; font-weight: bold;">:</span> <span style="color: #004993;">Array</span>;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> darken<span style="color: #000000; font-weight: bold;">:</span> <span style="color: #004993;">ColorTransform</span>;
&nbsp;
        <span style="color: #000000;">&#91;</span>Embed<span style="color: #000000;">&#40;</span><span style="color: #004993;">source</span>=<span style="color: #990000;">&quot;song.mp3&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span>
        <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #6699cc; font-weight: bold;">var</span> soundClass<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Class</span>;
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> Main<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
		<span style="color: #000000;">&#123;</span>
			sound = <span style="color: #0033ff; font-weight: bold;">new</span> soundClass <span style="color: #0033ff; font-weight: bold;">as</span> <span style="color: #004993;">Sound</span>;
			<span style="color: #004993;">stage</span>.<span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">MouseEvent</span>.<span style="color: #004993;">CLICK</span>,onStageClicked<span style="color: #000000;">&#41;</span>;
&nbsp;
			bytes = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">ByteArray</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
&nbsp;
			output = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">BitmapData</span><span style="color: #000000;">&#40;</span> <span style="color: #004993;">stage</span>.<span style="color: #004993;">stageWidth</span>, <span style="color: #004993;">stage</span>.<span style="color: #004993;">stageHeight</span>, <span style="color: #0033ff; font-weight: bold;">true</span>, <span style="color: #000000; font-weight:bold;">0</span> <span style="color: #000000;">&#41;</span>;
			peaks = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">BitmapData</span><span style="color: #000000;">&#40;</span> <span style="color: #004993;">stage</span>.<span style="color: #004993;">stageWidth</span>, <span style="color: #004993;">stage</span>.<span style="color: #004993;">stageHeight</span>, <span style="color: #0033ff; font-weight: bold;">true</span>, <span style="color: #000000; font-weight:bold;">0</span> <span style="color: #000000;">&#41;</span>;
&nbsp;
			displace = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Matrix</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
			displace.<span style="color: #004993;">tx</span> = <span style="color: #000000; font-weight:bold;">2</span>;
			displace.<span style="color: #004993;">ty</span> = <span style="color: #000000; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">1</span>;
&nbsp;
			darken = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">ColorTransform</span><span style="color: #000000;">&#40;</span> <span style="color: #000000; font-weight:bold;">1</span>, <span style="color: #000000; font-weight:bold;">1</span>, <span style="color: #000000; font-weight:bold;">1</span>, <span style="color: #000000; font-weight:bold;">1</span>, <span style="color: #000000; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">2</span>, <span style="color: #000000; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">2</span>, <span style="color: #000000; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">2</span>, <span style="color: #000000; font-weight:bold;">0</span> <span style="color: #000000;">&#41;</span>;
&nbsp;
			<span style="color: #004993;">rect</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Rectangle</span><span style="color: #000000;">&#40;</span> <span style="color: #000000; font-weight:bold;">0</span>, <span style="color: #000000; font-weight:bold;">0</span>, <span style="color: #000000; font-weight:bold;">1</span>, <span style="color: #000000; font-weight:bold;">0</span> <span style="color: #000000;">&#41;</span>;
&nbsp;
			<span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span> <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Bitmap</span><span style="color: #000000;">&#40;</span> output <span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#41;</span>;
			<span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span> <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Bitmap</span><span style="color: #000000;">&#40;</span> peaks <span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#41;</span>;
&nbsp;
			<span style="color: #004993;">stage</span>.<span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span> <span style="color: #004993;">Event</span>.<span style="color: #004993;">ENTER_FRAME</span>, onEnterFrame <span style="color: #000000;">&#41;</span>;
&nbsp;
			<span style="color: #004993;">graphics</span>.<span style="color: #004993;">beginFill</span><span style="color: #000000;">&#40;</span> <span style="color: #000000; font-weight:bold;">0</span> <span style="color: #000000;">&#41;</span>;
			<span style="color: #004993;">graphics</span>.<span style="color: #004993;">drawRect</span><span style="color: #000000;">&#40;</span> <span style="color: #000000; font-weight:bold;">0</span>, <span style="color: #000000; font-weight:bold;">0</span>, <span style="color: #004993;">stage</span>.<span style="color: #004993;">stageWidth</span>, <span style="color: #004993;">stage</span>.<span style="color: #004993;">stageHeight</span> <span style="color: #000000;">&#41;</span>;
			<span style="color: #004993;">graphics</span>.<span style="color: #004993;">endFill</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
&nbsp;
			gradient = createRainbowGradientArray<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> onStageClicked<span style="color: #000000;">&#40;</span> event<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">MouseEvent</span> <span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span> <span style="color: #0033ff; font-weight: bold;">void</span>
		<span style="color: #000000;">&#123;</span>
			sound.<span style="color: #004993;">play</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #004993;">stage</span>.<span style="color: #004993;">removeEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">MouseEvent</span>.<span style="color: #004993;">CLICK</span>,onStageClicked<span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> onEnterFrame<span style="color: #000000;">&#40;</span> event<span style="color: #000000; font-weight: bold;">:</span> <span style="color: #004993;">Event</span> <span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span> <span style="color: #0033ff; font-weight: bold;">void</span>
		<span style="color: #000000;">&#123;</span>
			peaks.<span style="color: #004993;">fillRect</span><span style="color: #000000;">&#40;</span> peaks.<span style="color: #004993;">rect</span>, <span style="color: #000000; font-weight:bold;">0</span> <span style="color: #000000;">&#41;</span>;
&nbsp;
			<span style="color: #004993;">SoundMixer</span>.<span style="color: #004993;">computeSpectrum</span><span style="color: #000000;">&#40;</span> bytes, <span style="color: #0033ff; font-weight: bold;">true</span>, <span style="color: #000000; font-weight:bold;">0</span> <span style="color: #000000;">&#41;</span>;
&nbsp;
			<span style="color: #6699cc; font-weight: bold;">var</span> <span style="color: #004993;">value</span><span style="color: #000000; font-weight: bold;">:</span> <span style="color: #004993;">Number</span>;
			<span style="color: #6699cc; font-weight: bold;">var</span> <span style="color: #004993;">height</span><span style="color: #000000; font-weight: bold;">:</span> <span style="color: #004993;">Number</span>;
&nbsp;
			<span style="color: #6699cc; font-weight: bold;">var</span> smooth<span style="color: #000000; font-weight: bold;">:</span> <span style="color: #004993;">Number</span>;
&nbsp;
			<span style="color: #0033ff; font-weight: bold;">for</span><span style="color: #000000;">&#40;</span> <span style="color: #6699cc; font-weight: bold;">var</span> i<span style="color: #000000; font-weight: bold;">:</span> <span style="color: #004993;">int</span> = <span style="color: #000000; font-weight:bold;">0</span> ; i <span style="color: #000000; font-weight: bold;">&lt;</span> <span style="color: #000000; font-weight:bold;">256</span> ; i<span style="color: #000000; font-weight: bold;">++</span> <span style="color: #000000;">&#41;</span>
			<span style="color: #000000;">&#123;</span>
				<span style="color: #004993;">value</span> = bytes.<span style="color: #004993;">readFloat</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
&nbsp;
				<span style="color: #0033ff; font-weight: bold;">if</span><span style="color: #000000;">&#40;</span> i == <span style="color: #000000; font-weight:bold;">0</span> <span style="color: #000000;">&#41;</span> smooth = <span style="color: #004993;">value</span>;
				<span style="color: #0033ff; font-weight: bold;">else</span> smooth <span style="color: #000000; font-weight: bold;">+</span>= <span style="color: #000000;">&#40;</span> <span style="color: #004993;">value</span> <span style="color: #000000; font-weight: bold;">-</span> smooth <span style="color: #000000;">&#41;</span> <span style="color: #000000; font-weight: bold;">/</span> <span style="color: #000000; font-weight:bold;">8</span>;
&nbsp;
				<span style="color: #004993;">height</span> = <span style="color: #000000; font-weight:bold;">2</span> <span style="color: #000000; font-weight: bold;">+</span> smooth <span style="color: #000000; font-weight: bold;">*</span> 0xf0;
&nbsp;
				<span style="color: #004993;">rect</span>.<span style="color: #004993;">x</span> = <span style="color: #000000; font-weight:bold;">8</span> <span style="color: #000000; font-weight: bold;">+</span> i;
				<span style="color: #004993;">rect</span>.<span style="color: #004993;">y</span> = <span style="color: #000000; font-weight:bold;">320</span> <span style="color: #000000; font-weight: bold;">+</span> <span style="color: #000000;">&#40;</span> i <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #000000; font-weight:bold;">2</span> <span style="color: #000000;">&#41;</span> <span style="color: #000000; font-weight: bold;">-</span> <span style="color: #004993;">height</span>;
				<span style="color: #004993;">rect</span>.<span style="color: #004993;">height</span> = <span style="color: #004993;">height</span>;
&nbsp;
				peaks.<span style="color: #004993;">setPixel32</span><span style="color: #000000;">&#40;</span> <span style="color: #004993;">rect</span>.<span style="color: #004993;">x</span>, <span style="color: #004993;">rect</span>.<span style="color: #004993;">y</span>, 0xffffffff <span style="color: #000000;">&#41;</span>;
&nbsp;
				output.<span style="color: #004993;">fillRect</span><span style="color: #000000;">&#40;</span> <span style="color: #004993;">rect</span>, 0xff000000 <span style="color: #000000; font-weight: bold;">|</span> gradient<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span> <span style="color: #000000;">&#41;</span>;
			<span style="color: #000000;">&#125;</span>
&nbsp;
			output.<span style="color: #004993;">draw</span><span style="color: #000000;">&#40;</span> output, displace, darken, <span style="color: #0033ff; font-weight: bold;">null</span>, <span style="color: #0033ff; font-weight: bold;">null</span>, <span style="color: #0033ff; font-weight: bold;">true</span> <span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> createRainbowGradientArray<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span> <span style="color: #004993;">Array</span>
		<span style="color: #000000;">&#123;</span>
			<span style="color: #6699cc; font-weight: bold;">var</span> gradient<span style="color: #000000; font-weight: bold;">:</span> <span style="color: #004993;">Array</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Array</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
&nbsp;
			<span style="color: #6699cc; font-weight: bold;">var</span> shape<span style="color: #000000; font-weight: bold;">:</span> <span style="color: #004993;">Shape</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Shape</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #6699cc; font-weight: bold;">var</span> bmp<span style="color: #000000; font-weight: bold;">:</span> <span style="color: #004993;">BitmapData</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">BitmapData</span><span style="color: #000000;">&#40;</span> <span style="color: #000000; font-weight:bold;">256</span>, <span style="color: #000000; font-weight:bold;">1</span>, <span style="color: #0033ff; font-weight: bold;">false</span>, <span style="color: #000000; font-weight:bold;">0</span> <span style="color: #000000;">&#41;</span>;
&nbsp;
			<span style="color: #6699cc; font-weight: bold;">var</span> <span style="color: #004993;">colors</span><span style="color: #000000; font-weight: bold;">:</span> <span style="color: #004993;">Array</span> = <span style="color: #000000;">&#91;</span> <span style="color: #000000; font-weight:bold;">0</span>, 0xff0000, 0xffff00, 0x00ff00, 0x00ffff <span style="color: #000000;">&#93;</span>;
			<span style="color: #6699cc; font-weight: bold;">var</span> <span style="color: #004993;">alphas</span><span style="color: #000000; font-weight: bold;">:</span> <span style="color: #004993;">Array</span> = <span style="color: #000000;">&#91;</span> <span style="color: #000000; font-weight:bold;">100</span>, <span style="color: #000000; font-weight:bold;">100</span>, <span style="color: #000000; font-weight:bold;">100</span>, <span style="color: #000000; font-weight:bold;">100</span>, <span style="color: #000000; font-weight:bold;">100</span> <span style="color: #000000;">&#93;</span>;
			<span style="color: #6699cc; font-weight: bold;">var</span> <span style="color: #004993;">ratios</span><span style="color: #000000; font-weight: bold;">:</span> <span style="color: #004993;">Array</span> = <span style="color: #000000;">&#91;</span> <span style="color: #000000; font-weight:bold;">0</span>, <span style="color: #000000; font-weight:bold;">16</span>, <span style="color: #000000; font-weight:bold;">128</span>, <span style="color: #000000; font-weight:bold;">192</span>, <span style="color: #000000; font-weight:bold;">255</span> <span style="color: #000000;">&#93;</span>;
&nbsp;
			<span style="color: #6699cc; font-weight: bold;">var</span> <span style="color: #004993;">matrix</span><span style="color: #000000; font-weight: bold;">:</span> <span style="color: #004993;">Matrix</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Matrix</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
&nbsp;
			<span style="color: #004993;">matrix</span>.<span style="color: #004993;">createGradientBox</span><span style="color: #000000;">&#40;</span> <span style="color: #000000; font-weight:bold;">256</span>, <span style="color: #000000; font-weight:bold;">1</span>, <span style="color: #000000; font-weight:bold;">0</span>, <span style="color: #000000; font-weight:bold;">0</span>, <span style="color: #000000; font-weight:bold;">0</span> <span style="color: #000000;">&#41;</span>;
&nbsp;
			shape.<span style="color: #004993;">graphics</span>.<span style="color: #004993;">beginGradientFill</span><span style="color: #000000;">&#40;</span> <span style="color: #990000;">'linear'</span>, <span style="color: #004993;">colors</span>, <span style="color: #004993;">alphas</span>, <span style="color: #004993;">ratios</span>, <span style="color: #004993;">matrix</span> <span style="color: #000000;">&#41;</span>;
			shape.<span style="color: #004993;">graphics</span>.<span style="color: #004993;">drawRect</span><span style="color: #000000;">&#40;</span> <span style="color: #000000; font-weight:bold;">0</span>, <span style="color: #000000; font-weight:bold;">0</span>, <span style="color: #000000; font-weight:bold;">256</span>, <span style="color: #000000; font-weight:bold;">1</span> <span style="color: #000000;">&#41;</span>;
			shape.<span style="color: #004993;">graphics</span>.<span style="color: #004993;">endFill</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
&nbsp;
			bmp.<span style="color: #004993;">draw</span><span style="color: #000000;">&#40;</span> shape <span style="color: #000000;">&#41;</span>;
&nbsp;
			<span style="color: #0033ff; font-weight: bold;">for</span><span style="color: #000000;">&#40;</span> <span style="color: #6699cc; font-weight: bold;">var</span> i<span style="color: #000000; font-weight: bold;">:</span> <span style="color: #004993;">int</span> = <span style="color: #000000; font-weight:bold;">0</span> ; i <span style="color: #000000; font-weight: bold;">&lt;</span> <span style="color: #000000; font-weight:bold;">256</span> ; i<span style="color: #000000; font-weight: bold;">++</span> <span style="color: #000000;">&#41;</span>
			<span style="color: #000000;">&#123;</span>
				gradient<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span> = bmp.<span style="color: #004993;">getPixel</span><span style="color: #000000;">&#40;</span> i, <span style="color: #000000; font-weight:bold;">0</span> <span style="color: #000000;">&#41;</span>;
			<span style="color: #000000;">&#125;</span>
&nbsp;
			<span style="color: #0033ff; font-weight: bold;">return</span> gradient;
		<span style="color: #000000;">&#125;</span>
	<span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.ppzhao.net/index.php/archives/330/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>一个一百多行代码的开关灯游戏</title>
		<link>http://www.ppzhao.net/index.php/archives/314</link>
		<comments>http://www.ppzhao.net/index.php/archives/314#comments</comments>
		<pubDate>Thu, 24 Dec 2009 13:14:02 +0000</pubDate>
		<dc:creator>阿平</dc:creator>
				<category><![CDATA[FLASH/FLEX开发]]></category>
		<category><![CDATA[资源下载]]></category>

		<guid isPermaLink="false">http://www.flashcs4.com.cn/?p=314</guid>
		<description><![CDATA[试着关闭所有的灯:

今天在flashandmath.com上闲逛,发现了这个小游戏,前前后后只有一百多行代码.蛮有意思.
用flash cs3创建一个fla文件,然后在场景上放个按钮,起名:btnNewGame
然后贴入下面的代码:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
function setupGame&#40;&#41;:void &#123;
	tbDoneText.text = &#34;&#34;;
	addGameBoard&#40;&#41;;
	drawBoxes&#40;&#41;;
&#125;
&#160;
function newGame&#40;evt:MouseEvent&#41;:void &#123;
	removeGameBoard&#40;&#41;;
	setupGame&#40;&#41;;
&#125;
&#160;
// add a listener for the &#34;New Game&#34; button
btnNewGame.addEventListener&#40;MouseEvent.CLICK,newGame&#41;;
&#160;
var boxHeight:int = 40;
var boxWidth:int = 40;
var boxXSpace:int = 10;
var boxYSpace:int = 10;
&#160;
function addGameBoard&#40;&#41;:void &#123;
	// create a board to display all of the square buttons on
	var gb:Sprite = new Sprite&#40;&#41;;
	gb.graphics.beginFill&#40;0xFFFFFF&#41;;
&#160;
	// since the entire grid is at most 6x6, make enough [...]]]></description>
			<content:encoded><![CDATA[<p>试着关闭所有的灯:<br />
<object width="550" height="400" data="http://www.flashcs4.com.cn/wp-content/uploads/2009/12/lightsout.swf" type="application/x-shockwave-flash"><param name="src" value="http://www.flashcs4.com.cn/wp-content/uploads/2009/12/lightsout.swf" /></object></p>
<p>今天在flashandmath.com上闲逛,发现了这个小游戏,前前后后只有一百多行代码.蛮有意思.</p>
<p>用flash cs3创建一个fla文件,然后在场景上放个按钮,起名:btnNewGame</p>
<p>然后贴入下面的代码:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
</pre></td><td class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #339966; font-weight: bold;">function</span> setupGame<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span>
	tbDoneText.<span style="color: #004993;">text</span> = <span style="color: #990000;">&quot;&quot;</span>;
	addGameBoard<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
	drawBoxes<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
<span style="color: #000000;">&#125;</span>
&nbsp;
<span style="color: #339966; font-weight: bold;">function</span> newGame<span style="color: #000000;">&#40;</span>evt<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">MouseEvent</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span>
	removeGameBoard<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
	setupGame<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
<span style="color: #000000;">&#125;</span>
&nbsp;
<span style="color: #009900;">// add a listener for the &quot;New Game&quot; button</span>
btnNewGame.<span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">MouseEvent</span>.<span style="color: #004993;">CLICK</span>,newGame<span style="color: #000000;">&#41;</span>;
&nbsp;
<span style="color: #6699cc; font-weight: bold;">var</span> boxHeight<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">int</span> = <span style="color: #000000; font-weight:bold;">40</span>;
<span style="color: #6699cc; font-weight: bold;">var</span> boxWidth<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">int</span> = <span style="color: #000000; font-weight:bold;">40</span>;
<span style="color: #6699cc; font-weight: bold;">var</span> boxXSpace<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">int</span> = <span style="color: #000000; font-weight:bold;">10</span>;
<span style="color: #6699cc; font-weight: bold;">var</span> boxYSpace<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">int</span> = <span style="color: #000000; font-weight:bold;">10</span>;
&nbsp;
<span style="color: #339966; font-weight: bold;">function</span> addGameBoard<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span>
	<span style="color: #009900;">// create a board to display all of the square buttons on</span>
	<span style="color: #6699cc; font-weight: bold;">var</span> gb<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Sprite</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Sprite</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
	gb.<span style="color: #004993;">graphics</span>.<span style="color: #004993;">beginFill</span><span style="color: #000000;">&#40;</span>0xFFFFFF<span style="color: #000000;">&#41;</span>;
&nbsp;
	<span style="color: #009900;">// since the entire grid is at most 6x6, make enough room</span>
	gb.<span style="color: #004993;">graphics</span>.<span style="color: #004993;">drawRect</span><span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">0</span>,<span style="color: #000000; font-weight:bold;">0</span>,<span style="color: #000000; font-weight:bold;">6</span><span style="color: #000000; font-weight: bold;">*</span>boxWidth<span style="color: #000000; font-weight: bold;">+</span><span style="color: #000000; font-weight:bold;">7</span><span style="color: #000000; font-weight: bold;">*</span>boxXSpace,<span style="color: #000000; font-weight:bold;">6</span><span style="color: #000000; font-weight: bold;">*</span>boxHeight<span style="color: #000000; font-weight: bold;">+</span><span style="color: #000000; font-weight:bold;">7</span><span style="color: #000000; font-weight: bold;">*</span>boxYSpace<span style="color: #000000;">&#41;</span>;
	gb.<span style="color: #004993;">graphics</span>.<span style="color: #004993;">endFill</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
&nbsp;
	gb.<span style="color: #004993;">name</span> = <span style="color: #990000;">&quot;gameBoard&quot;</span>
	gb.<span style="color: #004993;">x</span> = <span style="color: #000000; font-weight:bold;">20</span>;
	gb.<span style="color: #004993;">y</span> = <span style="color: #000000; font-weight:bold;">20</span>;
&nbsp;
	<span style="color: #0033ff; font-weight: bold;">this</span>.<span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span>gb<span style="color: #000000;">&#41;</span>;
<span style="color: #000000;">&#125;</span>
&nbsp;
<span style="color: #339966; font-weight: bold;">function</span> removeGameBoard<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span>
&nbsp;
	<span style="color: #009900;">// remove the game board and all of the squares on it</span>
	<span style="color: #6699cc; font-weight: bold;">var</span> gb<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Sprite</span>=<span style="color: #004993;">Sprite</span><span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">this</span>.<span style="color: #004993;">getChildByName</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;gameBoard&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;
	<span style="color: #6699cc; font-weight: bold;">var</span> thisClip<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Sprite</span>;
&nbsp;
	<span style="color: #0033ff; font-weight: bold;">while</span><span style="color: #000000;">&#40;</span>gb.numChildren<span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span>
		thisClip=<span style="color: #004993;">Sprite</span><span style="color: #000000;">&#40;</span>gb.<span style="color: #004993;">getChildAt</span><span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;
		thisClip.<span style="color: #004993;">graphics</span>.<span style="color: #004993;">clear</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
		gb.<span style="color: #004993;">removeChild</span><span style="color: #000000;">&#40;</span>thisClip<span style="color: #000000;">&#41;</span>;
	<span style="color: #000000;">&#125;</span>
	gb.<span style="color: #004993;">graphics</span>.<span style="color: #004993;">clear</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
	<span style="color: #0033ff; font-weight: bold;">this</span>.<span style="color: #004993;">removeChild</span><span style="color: #000000;">&#40;</span>gb<span style="color: #000000;">&#41;</span>;
<span style="color: #000000;">&#125;</span>
&nbsp;
<span style="color: #6699cc; font-weight: bold;">var</span> onColor = 0xFF3333;
<span style="color: #6699cc; font-weight: bold;">var</span> offColor = 0x333333;
<span style="color: #6699cc; font-weight: bold;">var</span> numberOfRows<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">int</span>;
<span style="color: #6699cc; font-weight: bold;">var</span> numberOfColumns<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">int</span>;
<span style="color: #6699cc; font-weight: bold;">var</span> states<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Array</span>;
&nbsp;
<span style="color: #339966; font-weight: bold;">function</span> drawBoxes<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span>
	<span style="color: #009900;">// create the squares on the game board</span>
	<span style="color: #6699cc; font-weight: bold;">var</span> gb<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Sprite</span> = <span style="color: #004993;">Sprite</span><span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">this</span>.<span style="color: #004993;">getChildByName</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;gameBoard&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;
	<span style="color: #6699cc; font-weight: bold;">var</span> square<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Sprite</span>;
&nbsp;
	<span style="color: #009900;">// create 3 to 6 rows and 3 to 6 columns</span>
	numberOfRows = <span style="color: #004993;">Math</span>.<span style="color: #004993;">floor</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">Math</span>.<span style="color: #004993;">random</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">*</span><span style="color: #000000; font-weight:bold;">4</span><span style="color: #000000; font-weight: bold;">+</span><span style="color: #000000; font-weight:bold;">3</span><span style="color: #000000;">&#41;</span>;
	numberOfColumns = <span style="color: #004993;">Math</span>.<span style="color: #004993;">floor</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">Math</span>.<span style="color: #004993;">random</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">*</span><span style="color: #000000; font-weight:bold;">4</span><span style="color: #000000; font-weight: bold;">+</span><span style="color: #000000; font-weight:bold;">3</span><span style="color: #000000;">&#41;</span>;
&nbsp;
	<span style="color: #009900;">//create the states array, which has the same number of</span>
	<span style="color: #009900;">//&quot;rows&quot; and &quot;columns&quot; as our grid of squares</span>
	states = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Array</span><span style="color: #000000;">&#40;</span>numberOfRows<span style="color: #000000;">&#41;</span>;
&nbsp;
	<span style="color: #0033ff; font-weight: bold;">for</span> <span style="color: #000000;">&#40;</span><span style="color: #6699cc; font-weight: bold;">var</span> i<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">int</span> = <span style="color: #000000; font-weight:bold;">0</span>; i <span style="color: #000000; font-weight: bold;">&lt;</span> numberOfRows; i<span style="color: #000000; font-weight: bold;">++</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
	<span style="color: #009900;">// i = row number</span>
&nbsp;
		states<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Array</span><span style="color: #000000;">&#40;</span>numberOfColumns<span style="color: #000000;">&#41;</span>;
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">for</span> <span style="color: #000000;">&#40;</span><span style="color: #6699cc; font-weight: bold;">var</span> j<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">int</span> = <span style="color: #000000; font-weight:bold;">0</span>; j <span style="color: #000000; font-weight: bold;">&lt;</span> numberOfColumns; j<span style="color: #000000; font-weight: bold;">++</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
		<span style="color: #009900;">// j = column number</span>
&nbsp;
			<span style="color: #009900;">// create a square, which is by default 'off'</span>
			square = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Sprite</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
			square.<span style="color: #004993;">graphics</span>.<span style="color: #004993;">lineStyle</span><span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">2</span>, 0x000000<span style="color: #000000;">&#41;</span>;
			square.<span style="color: #004993;">graphics</span>.<span style="color: #004993;">beginFill</span><span style="color: #000000;">&#40;</span>offColor<span style="color: #000000;">&#41;</span>;
			square.<span style="color: #004993;">graphics</span>.<span style="color: #004993;">drawRect</span><span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">0</span>,<span style="color: #000000; font-weight:bold;">0</span>,boxWidth,boxHeight<span style="color: #000000;">&#41;</span>;
			square.<span style="color: #004993;">graphics</span>.<span style="color: #004993;">endFill</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
			states<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span><span style="color: #000000;">&#91;</span>j<span style="color: #000000;">&#93;</span> = <span style="color: #0033ff; font-weight: bold;">false</span>;
			gb.<span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span>square<span style="color: #000000;">&#41;</span>;
&nbsp;
			<span style="color: #009900;">// position the square in the correct location</span>
			square.<span style="color: #004993;">x</span> = <span style="color: #000000;">&#40;</span>j<span style="color: #000000; font-weight: bold;">+</span><span style="color: #000000; font-weight:bold;">1</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">*</span>boxXSpace <span style="color: #000000; font-weight: bold;">+</span> j<span style="color: #000000; font-weight: bold;">*</span>boxWidth;
			square.<span style="color: #004993;">y</span> = <span style="color: #000000;">&#40;</span>i<span style="color: #000000; font-weight: bold;">+</span><span style="color: #000000; font-weight:bold;">1</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">*</span>boxYSpace <span style="color: #000000; font-weight: bold;">+</span> i<span style="color: #000000; font-weight: bold;">*</span>boxHeight;
			square.<span style="color: #004993;">name</span> = <span style="color: #990000;">&quot;square&quot;</span> <span style="color: #000000; font-weight: bold;">+</span> <span style="color: #004993;">String</span><span style="color: #000000;">&#40;</span>i<span style="color: #000000;">&#41;</span> <span style="color: #000000; font-weight: bold;">+</span> <span style="color: #004993;">String</span><span style="color: #000000;">&#40;</span>j<span style="color: #000000;">&#41;</span>;
&nbsp;
			<span style="color: #009900;">// add a dynamically created listener for this square</span>
			square.<span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">MouseEvent</span>.<span style="color: #004993;">CLICK</span>,createListener<span style="color: #000000;">&#40;</span>i,j<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
	<span style="color: #000000;">&#125;</span>
	randomizeGameBoard<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
<span style="color: #000000;">&#125;</span>
&nbsp;
<span style="color: #339966; font-weight: bold;">function</span> createListener<span style="color: #000000;">&#40;</span>a<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">int</span>, <span style="color: #004993;">b</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">int</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Function</span> <span style="color: #000000;">&#123;</span>
	<span style="color: #009900;">// dynamically create a listener for the square in position (a,b)</span>
	<span style="color: #009900;">// that switches the box at (a,b) and the adjacent boxes, and</span>
	<span style="color: #009900;">// then checks to see if you are done</span>
	<span style="color: #6699cc; font-weight: bold;">var</span> foo<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Function</span> = <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #000000;">&#40;</span>evt<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">MouseEvent</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span>
		switchAt<span style="color: #000000;">&#40;</span>a,<span style="color: #004993;">b</span><span style="color: #000000;">&#41;</span>;
		<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>checkDone<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
			tbDoneText.<span style="color: #004993;">text</span> = <span style="color: #990000;">&quot;Good job!&quot;</span>;
		<span style="color: #000000;">&#125;</span>
	<span style="color: #000000;">&#125;</span>
	<span style="color: #0033ff; font-weight: bold;">return</span> foo;
<span style="color: #000000;">&#125;</span>
&nbsp;
<span style="color: #339966; font-weight: bold;">function</span> invertState<span style="color: #000000;">&#40;</span>row<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">int</span>, col<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">int</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span>
	<span style="color: #009900;">// lookup the square located at (row, col)</span>
	<span style="color: #6699cc; font-weight: bold;">var</span> gb<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Sprite</span> = <span style="color: #004993;">Sprite</span><span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">this</span>.<span style="color: #004993;">getChildByName</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;gameBoard&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;
	<span style="color: #6699cc; font-weight: bold;">var</span> thisClip<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Sprite</span> = <span style="color: #004993;">Sprite</span><span style="color: #000000;">&#40;</span>gb.<span style="color: #004993;">getChildByName</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;square&quot;</span> <span style="color: #000000; font-weight: bold;">+</span> row<span style="color: #000000;">&#41;</span> <span style="color: #000000; font-weight: bold;">+</span> col<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;
&nbsp;
	<span style="color: #009900;">// if the square is off, turn it on, and vice versa</span>
&nbsp;
	<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>states<span style="color: #000000;">&#91;</span>row<span style="color: #000000;">&#93;</span><span style="color: #000000;">&#91;</span>col<span style="color: #000000;">&#93;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
		thisClip.<span style="color: #004993;">graphics</span>.<span style="color: #004993;">beginFill</span><span style="color: #000000;">&#40;</span>offColor<span style="color: #000000;">&#41;</span>;
		thisClip.<span style="color: #004993;">graphics</span>.<span style="color: #004993;">drawRect</span><span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">0</span>,<span style="color: #000000; font-weight:bold;">0</span>,boxWidth,boxHeight<span style="color: #000000;">&#41;</span>;
		thisClip.<span style="color: #004993;">graphics</span>.<span style="color: #004993;">endFill</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
	<span style="color: #000000;">&#125;</span>
	<span style="color: #0033ff; font-weight: bold;">else</span> <span style="color: #000000;">&#123;</span>
		thisClip.<span style="color: #004993;">graphics</span>.<span style="color: #004993;">beginFill</span><span style="color: #000000;">&#40;</span>onColor<span style="color: #000000;">&#41;</span>;
		thisClip.<span style="color: #004993;">graphics</span>.<span style="color: #004993;">drawRect</span><span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">0</span>,<span style="color: #000000; font-weight:bold;">0</span>,boxWidth,boxHeight<span style="color: #000000;">&#41;</span>;
		thisClip.<span style="color: #004993;">graphics</span>.<span style="color: #004993;">endFill</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
	<span style="color: #000000;">&#125;</span>
	<span style="color: #009900;">// reverse the state of the square</span>
	states<span style="color: #000000;">&#91;</span>row<span style="color: #000000;">&#93;</span><span style="color: #000000;">&#91;</span>col<span style="color: #000000;">&#93;</span> = <span style="color: #000000; font-weight: bold;">!</span>states<span style="color: #000000;">&#91;</span>row<span style="color: #000000;">&#93;</span><span style="color: #000000;">&#91;</span>col<span style="color: #000000;">&#93;</span>;
<span style="color: #000000;">&#125;</span>
&nbsp;
<span style="color: #339966; font-weight: bold;">function</span> switchAt<span style="color: #000000;">&#40;</span>row<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">int</span>, col<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">int</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span>
	<span style="color: #009900;">// switch the square that was clicked on</span>
	invertState<span style="color: #000000;">&#40;</span>row,col<span style="color: #000000;">&#41;</span>;
&nbsp;
	<span style="color: #009900;">// switch the squares adjacent to the clicked square</span>
	<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>row <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
		invertState<span style="color: #000000;">&#40;</span>row<span style="color: #000000; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">1</span>,col<span style="color: #000000;">&#41;</span>;
	<span style="color: #000000;">&#125;</span>
	<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>row <span style="color: #000000; font-weight: bold;">&lt;</span> numberOfRows <span style="color: #000000; font-weight: bold;">-</span> <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
		invertState<span style="color: #000000;">&#40;</span>row<span style="color: #000000; font-weight: bold;">+</span><span style="color: #000000; font-weight:bold;">1</span>,col<span style="color: #000000;">&#41;</span>;
	<span style="color: #000000;">&#125;</span>
	<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>col <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
		invertState<span style="color: #000000;">&#40;</span>row,col<span style="color: #000000; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">1</span><span style="color: #000000;">&#41;</span>;
	<span style="color: #000000;">&#125;</span>
	<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>col <span style="color: #000000; font-weight: bold;">&lt;</span> numberOfColumns <span style="color: #000000; font-weight: bold;">-</span> <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
		invertState<span style="color: #000000;">&#40;</span>row,col<span style="color: #000000; font-weight: bold;">+</span><span style="color: #000000; font-weight:bold;">1</span><span style="color: #000000;">&#41;</span>;
	<span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span>
&nbsp;
<span style="color: #339966; font-weight: bold;">function</span> checkDone<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Boolean</span> <span style="color: #000000;">&#123;</span>
	<span style="color: #009900;">// check to see if all the lights are off</span>
	<span style="color: #6699cc; font-weight: bold;">var</span> bool<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Boolean</span> = <span style="color: #0033ff; font-weight: bold;">true</span>;
	<span style="color: #6699cc; font-weight: bold;">var</span> i,j<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">int</span>;
&nbsp;
	<span style="color: #0033ff; font-weight: bold;">for</span> <span style="color: #000000;">&#40;</span>i = <span style="color: #000000; font-weight:bold;">0</span>; i <span style="color: #000000; font-weight: bold;">&lt;</span> numberOfRows; i<span style="color: #000000; font-weight: bold;">++</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
		<span style="color: #0033ff; font-weight: bold;">for</span> <span style="color: #000000;">&#40;</span>j = <span style="color: #000000; font-weight:bold;">0</span>; j <span style="color: #000000; font-weight: bold;">&lt;</span> numberOfColumns; j<span style="color: #000000; font-weight: bold;">++</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
			bool = bool <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #000000; font-weight: bold;">!</span>states<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span><span style="color: #000000;">&#91;</span>j<span style="color: #000000;">&#93;</span>;
		<span style="color: #000000;">&#125;</span>
	<span style="color: #000000;">&#125;</span>
	<span style="color: #0033ff; font-weight: bold;">return</span><span style="color: #000000;">&#40;</span>bool<span style="color: #000000;">&#41;</span>;
<span style="color: #000000;">&#125;</span>
&nbsp;
<span style="color: #339966; font-weight: bold;">function</span> randomizeGameBoard<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span>
	<span style="color: #009900;">// randomly click the game board a random number of times</span>
	<span style="color: #009900;">// this ensures the game is solvable</span>
	<span style="color: #6699cc; font-weight: bold;">var</span> r<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">int</span> = <span style="color: #004993;">Math</span>.<span style="color: #004993;">floor</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">Math</span>.<span style="color: #004993;">random</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">*</span><span style="color: #000000; font-weight:bold;">5</span><span style="color: #000000; font-weight: bold;">+</span><span style="color: #000000; font-weight:bold;">5</span><span style="color: #000000;">&#41;</span>;
	<span style="color: #6699cc; font-weight: bold;">var</span> row<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">int</span>, col<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">int</span>, i<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">int</span>;
&nbsp;
	<span style="color: #0033ff; font-weight: bold;">for</span> <span style="color: #000000;">&#40;</span>i = <span style="color: #000000; font-weight:bold;">0</span>; i <span style="color: #000000; font-weight: bold;">&lt;</span> r; i<span style="color: #000000; font-weight: bold;">++</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
		row = <span style="color: #004993;">Math</span>.<span style="color: #004993;">floor</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">Math</span>.<span style="color: #004993;">random</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000; font-weight: bold;">*</span> numberOfRows<span style="color: #000000;">&#41;</span>;
		col = <span style="color: #004993;">Math</span>.<span style="color: #004993;">floor</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">Math</span>.<span style="color: #004993;">random</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000; font-weight: bold;">*</span> numberOfColumns<span style="color: #000000;">&#41;</span>;
		switchAt<span style="color: #000000;">&#40;</span>row,col<span style="color: #000000;">&#41;</span>;
	<span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span>
&nbsp;
setupGame<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;</pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.ppzhao.net/index.php/archives/314/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>带拼音的汉语拼音程序源码共享</title>
		<link>http://www.ppzhao.net/index.php/archives/310</link>
		<comments>http://www.ppzhao.net/index.php/archives/310#comments</comments>
		<pubDate>Thu, 19 Nov 2009 07:47:50 +0000</pubDate>
		<dc:creator>阿平</dc:creator>
				<category><![CDATA[FLASH/FLEX开发]]></category>
		<category><![CDATA[资源下载]]></category>

		<guid isPermaLink="false">http://www.flashcs4.com.cn/?p=310</guid>
		<description><![CDATA[最近总是有朋友询问我在flash中实现自动识别汉字发音的发音的方法。
我想了想，还是把以前写的那个demo的源码共享出来吧，供大家交流。
源码下载地址：e5a3b0e8b083e6b189e8afade68bbce99fb3e6ba90e7a081
DEMO演示地址：/index.php/archives/181
]]></description>
			<content:encoded><![CDATA[<p>最近总是有朋友询问我在flash中实现自动识别汉字发音的发音的方法。</p>
<p>我想了想，还是把以前写的那个demo的源码共享出来吧，供大家交流。</p>
<p>源码下载地址：<a href="http://www.flashcs4.com.cn/wp-content/uploads/2009/11/e5a3b0e8b083e6b189e8afade68bbce99fb3e6ba90e7a081.rar">e5a3b0e8b083e6b189e8afade68bbce99fb3e6ba90e7a081</a></p>
<p>DEMO演示地址：<a href="/index.php/archives/181">/index.php/archives/181</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.ppzhao.net/index.php/archives/310/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Deface,一个很不错的图像分析类包</title>
		<link>http://www.ppzhao.net/index.php/archives/306</link>
		<comments>http://www.ppzhao.net/index.php/archives/306#comments</comments>
		<pubDate>Fri, 30 Oct 2009 03:18:16 +0000</pubDate>
		<dc:creator>阿平</dc:creator>
				<category><![CDATA[FLASH/FLEX开发]]></category>
		<category><![CDATA[资源下载]]></category>

		<guid isPermaLink="false">http://www.flashcs4.com.cn/?p=306</guid>
		<description><![CDATA[现在国外流行的那个在线化妆的程序就是基于这个类库做的。
演示地址：http://makeover.dailymakeover.com/virtual-makeover/
该项目是开源的，在google code上有下载地址：http://code.google.com/p/deface/
该类库可以根据xml的样本数据定义，找到图片中匹配的内容，比如官方提供的两个demo就是可以找到图片中人物的脸部所在。和在脸部正确的位置安上胡子。
不过通过http下载的代码好像有些旧，通过SVN可以下载到新的代码：http://deface.googlecode.com/svn/trunk/
新的代码作了优化，由于用了fp10支持Vector等新的高效处理方法，代替了以前的Array的遍历，效率上有很大提高。需要FLEX SDK 4.0.0以上版本支持，或者Flash CS4支持。
很不错，大家试试。
]]></description>
			<content:encoded><![CDATA[<p>现在国外流行的那个在线化妆的程序就是基于这个类库做的。</p>
<p>演示地址：<a href="http://makeover.dailymakeover.com/virtual-makeover/">http://makeover.dailymakeover.com/virtual-makeover/</a></p>
<p>该项目是开源的，在google code上有下载地址：<a href="http://code.google.com/p/deface/">http://code.google.com/p/deface/</a></p>
<p>该类库可以根据xml的样本数据定义，找到图片中匹配的内容，比如官方提供的两个demo就是可以找到图片中人物的脸部所在。和在脸部正确的位置安上胡子。</p>
<p>不过通过http下载的代码好像有些旧，通过SVN可以下载到新的代码：<span style="font-family: Courier New;"><strong><em><a href="http://deface.googlecode.com/svn/trunk/">http</a>://deface.googlecode.com/svn/trunk/</em></strong></span></p>
<p><span style="font-family: Courier New;">新的代码作了优化，由于用了fp10支持Vector等新的高效处理方法，代替了以前的Array的遍历，效率上有很大提高。需要FLEX SDK 4.0.0以上版本支持，或者Flash CS4支持。</span></p>
<p><span style="font-family: Courier New;">很不错，大家试试。</span></p>
]]></content:encoded>
			<wfw:commentRss>http://www.ppzhao.net/index.php/archives/306/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>as3图片万能切割类[下载]</title>
		<link>http://www.ppzhao.net/index.php/archives/303</link>
		<comments>http://www.ppzhao.net/index.php/archives/303#comments</comments>
		<pubDate>Fri, 23 Oct 2009 05:52:21 +0000</pubDate>
		<dc:creator>阿平</dc:creator>
				<category><![CDATA[FLASH/FLEX开发]]></category>
		<category><![CDATA[资源下载]]></category>

		<guid isPermaLink="false">http://www.flashcs4.com.cn/?p=303</guid>
		<description><![CDATA[最近在做一个图像处理的东西，需要对图片进行随意的切割，于是在网上发现了这样一个类包。
这个类包里面把对图片的简单操作都实现了，包括切图，包括对图片的滤镜效果，图片的色相、饱和度、明暗等等。很不错的东东。
源文件下载：bmpcuter
]]></description>
			<content:encoded><![CDATA[<p>最近在做一个图像处理的东西，需要对图片进行随意的切割，于是在网上发现了这样一个类包。</p>
<p>这个类包里面把对图片的简单操作都实现了，包括切图，包括对图片的滤镜效果，图片的色相、饱和度、明暗等等。很不错的东东。</p>
<p>源文件下载：<a href="http://www.flashcs4.com.cn/wp-content/uploads/2009/10/bmpcuter.rar">bmpcuter</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.ppzhao.net/index.php/archives/303/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>利用SampleDataEvent模拟出的8位机音乐源码示例</title>
		<link>http://www.ppzhao.net/index.php/archives/284</link>
		<comments>http://www.ppzhao.net/index.php/archives/284#comments</comments>
		<pubDate>Fri, 11 Sep 2009 02:48:03 +0000</pubDate>
		<dc:creator>阿平</dc:creator>
				<category><![CDATA[FLASH/FLEX开发]]></category>
		<category><![CDATA[资源下载]]></category>

		<guid isPermaLink="false">http://www.flashcs4.com.cn/?p=284</guid>
		<description><![CDATA[最近在国外的一个网站上看到一个示例,只有2K大小的一个swf文件播放出了长达十分钟左右的游戏音乐。很是惊讶。于是仔细研究了下源码，发现是用的fp10中的新功能。在fp10新的API中有个SampleDataEvent的类，结合Sound对象可以播放出动态的音乐。
比如下面这段代码就可以播放出简单的正弦波。在FLEX SDK3.2以上版本，或者Flash CS4中可以测试。

var mySound:Sound = new Sound&#40;&#41;;
function sineWaveGenerator&#40;event:SampleDataEvent&#41;:void &#123;
    for &#40; var c:int=0; c&#60;8192; c++ &#41; &#123;
        event.data.writeFloat&#40;Math.sin&#40;&#40;Number&#40;c+event.position&#41;/Math.PI/2&#41;&#41;*0.25&#41;;
        event.data.writeFloat&#40;Math.sin&#40;&#40;Number&#40;c+event.position&#41;/Math.PI/2&#41;&#41;*0.25&#41;;
    &#125;
&#125;
&#160;
mySound.addEventListener&#40;SampleDataEvent.SAMPLE_DATA,sineWaveGenerator&#41;;
mySound.play&#40;&#41;;

Adobe官方中文手册中关于这个类的介绍：
http://livedocs.adobe.com/flex/3_cn/langref/flash/events/SampleDataEvent.html
下面的是这个牛B的8位机音乐源码：8位机音乐源码下载
]]></description>
			<content:encoded><![CDATA[<p>最近在国外的一个网站上看到一个示例,只有2K大小的一个swf文件播放出了长达十分钟左右的游戏音乐。很是惊讶。于是仔细研究了下源码，发现是用的fp10中的新功能。在fp10新的API中有个SampleDataEvent的类，结合Sound对象可以播放出动态的音乐。<br />
比如下面这段代码就可以播放出简单的正弦波。在FLEX SDK3.2以上版本，或者Flash CS4中可以测试。</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #6699cc; font-weight: bold;">var</span> mySound<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Sound</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Sound</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
<span style="color: #339966; font-weight: bold;">function</span> sineWaveGenerator<span style="color: #000000;">&#40;</span>event<span style="color: #000000; font-weight: bold;">:</span>SampleDataEvent<span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span>
    <span style="color: #0033ff; font-weight: bold;">for</span> <span style="color: #000000;">&#40;</span> <span style="color: #6699cc; font-weight: bold;">var</span> <span style="color: #004993;">c</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">int</span>=<span style="color: #000000; font-weight:bold;">0</span>; c<span style="color: #000000; font-weight: bold;">&lt;</span><span style="color: #000000; font-weight:bold;">8192</span>; <span style="color: #004993;">c</span><span style="color: #000000; font-weight: bold;">++</span> <span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
        event.<span style="color: #004993;">data</span>.<span style="color: #004993;">writeFloat</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">Math</span>.<span style="color: #004993;">sin</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">Number</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">c</span><span style="color: #000000; font-weight: bold;">+</span>event.<span style="color: #004993;">position</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #004993;">Math</span>.<span style="color: #004993;">PI</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000; font-weight:bold;">2</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">*</span><span style="color: #000000; font-weight:bold;">0.25</span><span style="color: #000000;">&#41;</span>;
        event.<span style="color: #004993;">data</span>.<span style="color: #004993;">writeFloat</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">Math</span>.<span style="color: #004993;">sin</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">Number</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">c</span><span style="color: #000000; font-weight: bold;">+</span>event.<span style="color: #004993;">position</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #004993;">Math</span>.<span style="color: #004993;">PI</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000; font-weight:bold;">2</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">*</span><span style="color: #000000; font-weight:bold;">0.25</span><span style="color: #000000;">&#41;</span>;
    <span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span>
&nbsp;
mySound.<span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span>SampleDataEvent.SAMPLE_DATA,sineWaveGenerator<span style="color: #000000;">&#41;</span>;
mySound.<span style="color: #004993;">play</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;</pre></div></div>

<p>Adobe官方中文手册中关于这个类的介绍：</p>
<p>http://livedocs.adobe.com/flex/3_cn/langref/flash/events/SampleDataEvent.html</p>
<p>下面的是这个牛B的8位机音乐源码：<a href='http://www.flashcs4.com.cn/wp-content/uploads/2009/09/trymusic.rar'>8位机音乐源码下载</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.ppzhao.net/index.php/archives/284/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>TimelineWatcher类的使用示例</title>
		<link>http://www.ppzhao.net/index.php/archives/275</link>
		<comments>http://www.ppzhao.net/index.php/archives/275#comments</comments>
		<pubDate>Mon, 24 Aug 2009 02:56:12 +0000</pubDate>
		<dc:creator>阿平</dc:creator>
				<category><![CDATA[FLASH/FLEX开发]]></category>
		<category><![CDATA[资源下载]]></category>
		<category><![CDATA[TimelineWatcher]]></category>

		<guid isPermaLink="false">http://www.flashcs4.com.cn/?p=275</guid>
		<description><![CDATA[今天在论坛上闲逛时发现了这个好东西，TimelineWatcher:一个不错的工具类。
用这个类可以做到侦听一个MovieClip播放情况，比如可以做到让MovieClip播放到哪个桢，派发事件等等。很实用。
收集到网上的示例源码，提供下载，服务于大众：
点击下载：timelinewatcher
这个示例上是个左右移动的小球，左上角的一个文本可以实时显示这个小球动画播放到的桢标签，以及循环的次数。
]]></description>
			<content:encoded><![CDATA[<p>今天在论坛上闲逛时发现了这个好东西，TimelineWatcher:一个不错的工具类。</p>
<p>用这个类可以做到侦听一个MovieClip播放情况，比如可以做到让MovieClip播放到哪个桢，派发事件等等。很实用。</p>
<p>收集到网上的示例源码，提供下载，服务于大众：</p>
<p>点击下载：<a href="http://www.flashcs4.com.cn/wp-content/uploads/2009/08/timelinewatcher.rar">timelinewatcher</a></p>
<p>这个示例上是个左右移动的小球，左上角的一个文本可以实时显示这个小球动画播放到的桢标签，以及循环的次数。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ppzhao.net/index.php/archives/275/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Flash预览本地图片，简单源文件示例</title>
		<link>http://www.ppzhao.net/index.php/archives/265</link>
		<comments>http://www.ppzhao.net/index.php/archives/265#comments</comments>
		<pubDate>Tue, 11 Aug 2009 06:42:47 +0000</pubDate>
		<dc:creator>阿平</dc:creator>
				<category><![CDATA[FLASH/FLEX开发]]></category>
		<category><![CDATA[资源下载]]></category>

		<guid isPermaLink="false">http://www.flashcs4.com.cn/?p=265</guid>
		<description><![CDATA[最近要做个flash上传图片的东东，其中有个效果是先让用户在本地预览一下图片，然后再点击上传。
本来想当然的以为这个功能很简单就能实现，用UILoader直接Load一下本地的图片就行了。后来再一想，不对！有两个难点：1.FileRefrence只能拿到File的name,拿不到File的Path。2.即便是拿出了File的Path,在网页上运行的File也不可能跨过安全沙箱访问本地的文件。
但是我的确看到有人做出来过的，这是怎么回事呢？
Baidu了一下后知道了，原来可以利用FlashPlayer10中的新东东，FileRefrence.load()和FileRefrence.data，把图片数据以二进制的形式读入Flash，然后直接用Loader.loadBytes()方法读入二进制数据，直接显示到界面上。
这里面有个问题要注意，由于这是Flash Player 10新支持的东东，如果是用Flash开发的，需要用Flash CS4开发，并将Flash Player选成10的版本，如果是用Flex开发，需要SDK  4.0以上版本。
一个简单的例子及源文件：

示例源文件下载
]]></description>
			<content:encoded><![CDATA[<p>最近要做个flash上传图片的东东，其中有个效果是先让用户在本地预览一下图片，然后再点击上传。</p>
<p>本来想当然的以为这个功能很简单就能实现，用UILoader直接Load一下本地的图片就行了。后来再一想，不对！有两个难点：1.FileRefrence只能拿到File的name,拿不到File的Path。2.即便是拿出了File的Path,在网页上运行的File也不可能跨过安全沙箱访问本地的文件。</p>
<p>但是我的确看到有人做出来过的，这是怎么回事呢？</p>
<p>Baidu了一下后知道了，原来可以利用FlashPlayer10中的新东东，FileRefrence.load()和FileRefrence.data，把图片数据以二进制的形式读入Flash，然后直接用Loader.loadBytes()方法读入二进制数据，直接显示到界面上。</p>
<p>这里面有个问题要注意，由于这是Flash Player 10新支持的东东，如果是用Flash开发的，需要用Flash CS4开发，并将Flash Player选成10的版本，如果是用Flex开发，需要SDK  4.0以上版本。</p>
<p>一个简单的例子及源文件：</p>
<p><object width="550" height="400" data="http://www.flashcs4.com.cn/wp-content/uploads/2009/08/picview.swf" type="application/x-shockwave-flash"><param name="src" value="http://www.flashcs4.com.cn/wp-content/uploads/2009/08/picview.swf" /></object></p>
<p><a href="http://www.flashcs4.com.cn/wp-content/uploads/2009/08/picview.fla">示例源文件下载</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.ppzhao.net/index.php/archives/265/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
