<?xml version="1.0" encoding="gb2312"?>
<rss version="2.0">
<channel>
<title><![CDATA[Construction]]></title>
        <image>
        <title>http://hi.baidu.com</title>
        <link>http://hi.baidu.com</link>
        <url>http://img.baidu.com/img/logo-hi.gif</url>
        </image>
<description><![CDATA[]]></description>
<link>http://hi.baidu.com/3tion</link>
<language>zh-cn</language>
<generator>www.baidu.com</generator>
<ttl>5</ttl>


<item>
        <title><![CDATA[[原创]Chrome浏览器对于flash渲染的一个特点]]></title>
        <link><![CDATA[http://hi.baidu.com/3tion/blog/item/afb7703fc4ed5ee655e723c0.html]]></link>
        <description><![CDATA[
		
		公司营运那边反应，目前我们的游戏，跳出率高达60%，根据营运提供的情报，分析可能是由于用户点击游戏的时候，在加载10K的swfobject.js和50K的Main.swf的时候，我们这边没有任何提示性质的语言，导致如果网络堵塞的时候，用户以为没有任何东西，就会关闭页面，导致跳出率的产生。<br>
我们的页面加载swf是用的swfobject这个js库。因为有50K的swf需要加载，swfobject只检测用户的flash客户端版本是否符合填写的参数，但是swfobject只能监视文档对象是否建立，没有办法监视swf中的对象是否加载完成，所以我修改了Main.swf的代码，在init的时候，会回调一个js函数。<br>
我在swfobject加载swf的时候，先将swf容器的display样式设置为none，并在屏幕中间显示一段提示”正在加载Loader，请稍后“，然后等收到swf在init的时候触发的js回调函数后，将容器的display设置为block，并把提示给去掉。<br>
swfobject.embedSWF(&quot;Main.swf&quot;, &quot;altContent&quot;, &quot;100%&quot;, &quot;100%&quot;, &quot;10.0.0&quot;,null,{}, params, attributes,callBack);<br>
<br>
function callBack()<br>
{<br>
if ( !isComplete)<br>
{<br>
var tip = document.getElementById(&quot;tip&quot;);<br>
tip.style.top = ( document.documentElement.offsetHeight&#160; - 80) / 2 + &quot;px&quot;;<br>
tip.style.left = ( document.documentElement.offsetWidth - 320) / 2 + &quot;px&quot;;<br>
tip.style.display = &quot;block&quot;;<br>
swfobject.getObjectById(&quot;Main&quot;).style.display= &quot;none&quot;;<br>
}<br>
}<br>
<br>
function completeCallBack()<br>
{<br>
isComplete = true;<br>
document.getElementById(&quot;tip&quot;).style.display = &quot;none&quot;;<br>
swfobject.getObjectById(&quot;Main&quot;).style.display= &quot;block&quot;;<br>
}<br>
修改好js脚本后，测试FF，IE，Opera，Safira，都正常，<br>
不过Chrome不正常了，始终显示那段提示文字，无法收到回调函数。<br>
我推测，swf很可能并未真正被加载。<br>
于是我尝试用visibility样式来隐藏swf，果然和我猜测的一样，<font color="#ff0000"><strong>Chrome可能对flash这样的plugin做了优化，当display为none的时候，根本不会去执行flash，这种情况下，只能放弃用display来控制隐藏/显示，而应该改用visibility样式来控制。</strong></font><br> <a href="http://hi.baidu.com/3tion/blog/item/afb7703fc4ed5ee655e723c0.html">阅读全文</a>
		
		<br/><b>类别：</b><a href="http://hi.baidu.com/3tion/blog/category/%BD%C5%B1%BE%BC%BC%CA%F5%26%2347%3Bjavascript%26%2347%3Bflash">脚本技术&#47;javascript&#47;flash</a>&nbsp;<a href="http://hi.baidu.com/3tion/blog/item/afb7703fc4ed5ee655e723c0.html#comment">查看评论</a>]]></description>
        <pubDate>2009-09-25  15:12</pubDate>
        <category><![CDATA[脚本技术&#47;javascript&#47;flash]]></category>
        <author><![CDATA[3tion]]></author>
		<guid>http://hi.baidu.com/3tion/blog/item/afb7703fc4ed5ee655e723c0.html</guid>
</item>

<item>
        <title><![CDATA[[原创]Red5流媒体服务基于域的安全策略]]></title>
        <link><![CDATA[http://hi.baidu.com/3tion/blog/item/9ce3e219fdd4be4f43a9adb5.html]]></link>
        <description><![CDATA[
		
		公司出于业务扩展的考虑，准备把原先基于FMS为后台的程序，改为用开源的Red5作为视频音频服务，而由Socket作为数据交换服务。<br>
公司服务端的人忙着处理其他事情，于是公司安排我做Red5的架设工作。在网上找了些资料，Red5配置起来还是比较简单的。网上的教程有一堆，这里就不累述了。<br>
因为flash客户端用NetConnection连接Red5的时候，是不需要像连接socket或者是http那样要提交一个&lt;request-policy-file/&gt;的请求去请求一个crossdomain的字符串。<br>
而视频，音频服务在我们整个服务中所占的IO是最大的。如果Red5服务没有做任何连接的验证，其他人通过反编我们的swf文件，得到我们的red5服务的地址后，就很容易让其他人来使用我们的服务器。<br>
对于这种问题，通常可以使用连接Red5时，要求客户端提交一个由服务端生成的密钥来做验证，但是这样就涉及到Red5和Socket直接的通信问题（或者是通过查询临时表等方法），无疑会给本来已经事情很多的服务端的同事们增加麻烦。<br>
于是我采取通过检测flash客户端的swf文件URL这种基于域的检测方式。<br>
首先，需要自己先写一个Red5的应用，并且把WEB-INF中red5-web.xml里面&lt;bean id=&quot;web.handler&quot; class=&quot;xxx.xxx.xxxx&quot; /&gt;的class指定为你写的这个应用。<br>
让你的应用继承ApplicationAdapter，然后重写connect<br>
我在应用的根目录放置了一个crossdomain.properties文件。<br>
<img border="0" class="blogimg" small="0" src="http://hiphotos.baidu.com/3tion/pic/item/019d8507756a23e67a894716.jpg"><br>
<br>
package com._3tion.live;<br>
<br>
import java.io.IOException;<br>
import java.util.Arrays;<br>
import java.util.Map;<br>
import java.util.Properties;<br>
import org.red5.server.adapter.ApplicationAdapter;<br>
import org.red5.server.api.IConnection;<br>
import org.red5.server.api.IScope;<br>
import org.springframework.core.io.Resource;<br>
<br>
<br>
/**<br>
* @author 3tion<br>
*<br>
*/<br>
public class Application extends ApplicationAdapter {<br>
private static String swfUrl[];<br>
<br>
//域检测文件名<br>
private static final String CROSS_DOMAIN_FILE_NAME = &quot;crossdomain.properties&quot;;<br>
<br>
private static final String SEPARATOR = &quot;;&quot;;<br>
<br>
<br>
@Override<br>
public synchronized boolean connect(IConnection conn, IScope scope,<br>
Object[] params) {<br>
<br>
if( swfUrl == null )<br>
{<br>
//检查策略文件<br>
Resource resource = getResource(CROSS_DOMAIN_FILE_NAME);//resource的目录结构是从当前应用的根目录开始<br>
if(resource.exists())<br>
{<br>
Properties props = new Properties();<br>
try {<br>
props.load(resource.getInputStream());<br>
swfUrl = props.getProperty(&quot;swfUrl&quot;).toLowerCase().split(SEPARATOR);<br>
} catch (IOException e) {<br>
e.printStackTrace();<br>
}<br>
<br>
}<br>
else //如果没有域安全文件，则视为所有域都允许通过<br>
{<br>
swfUrl = new String[1];<br>
swfUrl[0] = &quot;*&quot;;<br>
}<br>
}<br>
<br>
Map&lt;String,Object&gt; map = conn.getConnectParams();<br>
//检查连接参数中swfUrl的地址是否在安全文件中<br>
if( Arrays.binarySearch(swfUrl,&quot;*&quot;) &gt; -1 || Arrays.binarySearch(swfUrl, map.get(&quot;swfUrl&quot;).toString().toLowerCase()) &gt; -1 )<br>
{<br>
return super.connect(conn, scope, params);<br>
}<br>
else<br>
{<br>
return false;<br>
}<br>
}<br>
}<br>
<br>
这样，就可以在crossdomain.properties中控制你red5应用允许访问的文件了，如果写*，就允许任意文件访问。<br>
允许http://test/Main.swf和http://test1/Main.swf访问。<br>
则crossdomain.properties：<br>
swfUrl&#160;&#160;&#160; =&#160;&#160;&#160; http\://test/Main.swf;\<br>
http\://test1/Main.swf<br>
<br>
<br> <a href="http://hi.baidu.com/3tion/blog/item/9ce3e219fdd4be4f43a9adb5.html">阅读全文</a>
		
		<br/><b>类别：</b><a href="http://hi.baidu.com/3tion/blog/category/flex%26%2347%3Bflash">flex&#47;flash</a>&nbsp;<a href="http://hi.baidu.com/3tion/blog/item/9ce3e219fdd4be4f43a9adb5.html#comment">查看评论</a>]]></description>
        <pubDate>2009-09-14  10:17</pubDate>
        <category><![CDATA[flex&#47;flash]]></category>
        <author><![CDATA[3tion]]></author>
		<guid>http://hi.baidu.com/3tion/blog/item/9ce3e219fdd4be4f43a9adb5.html</guid>
</item>

<item>
        <title><![CDATA[[研究][原创]flash的socket连接安全策略文件(cross-domain)的相关研究]]></title>
        <link><![CDATA[http://hi.baidu.com/3tion/blog/item/ed7d5b4665816e006a63e53b.html]]></link>
        <description><![CDATA[
		
		最近公司做压力测试的时候，发现了一个问题。flash的socket客户端向服务端请求安全策略文件的时候，服务端负责回发策略文件的端口能连接上，但是没有响应，没有向flash客户端回发任何内容。最终会导致flash客户端加载不到策略文件。<br>
然而，<font color="#ff0000">即便是负责回发策略文件的端口恢复正常</font>，能回发策略文件了，flash客户端在不刷新的情况下，仍然无法通过flash的安全机制，和主socket服务端连接。<br>
<br>
于是我自己用.net写了个服务端做了比较详尽的测试。<br>
我们的flash客户端原本使用的单一的socket实例，当发现有安全错误以后，会提示客户端重新连接，重连的时候，仍然是调用的原有实例的connect方法。<br>
于是我测试了把客户端改成每次重连的时候，创建新的socket实例。<br>
测试后发现，这样的操作，并不会使flash客户端去重新向提供策略文件服务的端口去做请求。<br>
<br>
然后，我做了另外一个测试，当遇到安全错误的时候，重新设置一个新的策略文件对应的端口，看flash是否会像新的端口请求。与此同时，我在服务端做了3个提供安全策略服务的端口。<br>
结果我发现，flash客户端也不会重新向新的端口做任何请求。<br>
<br>
翻阅adobe网站关于flash player的buglist，早在一年前，就有人提出了这个问题。<br>
http://bugs.adobe.com/jira/browse/FP-67<br>
不过adobe没有做任何改动。<br>
<br>
通过我进一步试验，发现flash客户端在向服务端的安全策略服务提交请求失败以后，会向socket服务的主端口也会去发出一个&quot;&lt;policy-file-request/&gt;\0&quot;，并且这个请求是在没有得到安全许可的情况下，每次连接都会发此请求的。<br>
所以只要socket服务的主端口做安全策略的认证，这样就不怕出现，主服务是ok的，但是策略服务出现问题在不刷新浏览器的情况下无法访问主socket服务的问题。<br>
<br>
PS：测试还发现一点，一旦flash客户端获得了安全许可，即便我服务端关闭，然后把安全策略服务停掉，再开启服务端，客户端依然能正常连接socket服务端。<br>
<br> <a href="http://hi.baidu.com/3tion/blog/item/ed7d5b4665816e006a63e53b.html">阅读全文</a>
		
		<br/><b>类别：</b><a href="http://hi.baidu.com/3tion/blog/category/flex%26%2347%3Bflash">flex&#47;flash</a>&nbsp;<a href="http://hi.baidu.com/3tion/blog/item/ed7d5b4665816e006a63e53b.html#comment">查看评论</a>]]></description>
        <pubDate>2009-08-24  15:16</pubDate>
        <category><![CDATA[flex&#47;flash]]></category>
        <author><![CDATA[3tion]]></author>
		<guid>http://hi.baidu.com/3tion/blog/item/ed7d5b4665816e006a63e53b.html</guid>
</item>

<item>
        <title><![CDATA[FP10：使用Pixel Bender 和Shader Job来处理普通数据运算 [翻译]]]></title>
        <link><![CDATA[http://hi.baidu.com/3tion/blog/item/10ae677a6f9736e42e73b380.html]]></link>
        <description><![CDATA[
		
		<p>虽然Pixel Bender主要是用来处理图形任务，但他还有一个强大的用法-处理普通数据（generic number crunching)。Pixel  Bender核心和ActionScript在不同的进程中运行，你可以利用这个特点来避免界面的假死（无响应）。提高复杂运算的速度。例如，我们在处理一个很大规模的数据集合，需要对每个数据进行复杂的数学计算（3D，声音引擎等等）。你可以使用Pixel  Bender kernal来处理这些数据，最后再将处理好的数据交给AS代码，效果好的甚至会超过优化的很好的AS代码。</p>
<p>下面是个非常简单的例子，Pixel Bender kernel接受一个数组，然后返回一个包含源数组的平方根的新数组。</p>
<div class="syntax_hilite"><span class="langName">
<div class="syntax_hilite"><span class="langName">CODE:</span><br>
<div>
<div class="code">
<ol>
    <li style="font-style: normal;  color: rgb(0, 102, 102); font-weight: bold;">
    <div style=" font-weight: normal;">&lt;languageVersion  : <span style="color: rgb(0, 102, 102);">1</span>.<span style="color: rgb(0, 102, 102);">0</span>;&gt;</div>
    </li>
    <li style="font-style: normal;  color: rgb(0, 102, 102); font-weight: bold;">
    <div style=" font-weight: normal;"> </div>
    </li>
    <li style="font-style: normal;  color: rgb(0, 102, 102); font-weight: bold;">
    <div style=" font-weight: normal;">kernel  NumberCruncher</div>
    </li>
    <li style="font-style: normal;  color: rgb(0, 102, 102); font-weight: bold;">
    <div style=" font-weight: normal;">&lt;    </div>
    </li>
    <li style="font-style: normal;  color: rgb(0, 102, 102); font-weight: bold;">
    <div style=" font-weight: normal;">     namespace : <span style="color: rgb(0, 102, 153);">&quot;AIF&quot;</span>;</div>
    </li>
    <li style="font-style: normal;  color: rgb(0, 102, 102); font-weight: bold;">
    <div style=" font-weight: normal;">     vendor : <span style="color: rgb(0, 102, 153);">&quot;Ryan Taylor&quot;</span>;</div>
    </li>
    <li style="font-style: normal;  color: rgb(0, 102, 102); font-weight: bold;">
    <div style=" font-weight: normal;">     version : <span style="color: rgb(0, 102, 102);">1</span>;</div>
    </li>
    <li style="font-style: normal;  color: rgb(0, 102, 102); font-weight: bold;">
    <div style=" font-weight: normal;">     description : <span style="color: rgb(0, 102, 153);">&quot;Basic example of a generic  number cruncher.&quot;</span>;</div>
    </li>
    <li style="font-style: normal;  color: rgb(0, 102, 102); font-weight: bold;">
    <div style=" font-weight: normal;">&gt;</div>
    </li>
    <li style="font-style: normal;  color: rgb(0, 102, 102); font-weight: bold;">
    <div style=" font-weight: normal;"><span style="color: rgb(0, 102, 0); font-weight: bold;">{</span></div>
    </li>
    <li style="font-style: normal;  color: rgb(0, 102, 102); font-weight: bold;">
    <div style=" font-weight: normal;">     input image1 src;</div>
    </li>
    <li style="font-style: normal;  color: rgb(0, 102, 102); font-weight: bold;">
    <div style=" font-weight: normal;">     output pixel3 result;</div>
    </li>
    <li style="font-style: normal;  color: rgb(0, 102, 102); font-weight: bold;">
    <div style=" font-weight: normal;">    </div>
    </li>
    <li style="font-style: normal;  color: rgb(0, 102, 102); font-weight: bold;">
    <div style=" font-weight: normal;">     void evaluatePixel<span style="color: rgb(0, 102, 0); font-weight: bold;">(</span><span style="color: rgb(0, 102, 0); font-weight: bold;">)</span></div>
    </li>
    <li style="font-style: normal;  color: rgb(0, 102, 102); font-weight: bold;">
    <div style=" font-weight: normal;">     <span style="color: rgb(0, 102, 0); font-weight: bold;">{</span></div>
    </li>
    <li style="font-style: normal;  color: rgb(0, 102, 102); font-weight: bold;">
    <div style=" font-weight: normal;">         pixel1 value = pixel1<span style="color: rgb(0, 102, 0); font-weight: bold;">(</span>sqrt<span style="color: rgb(0, 102, 0); font-weight: bold;">(</span>sample<span style="color: rgb(0, 102, 0); font-weight: bold;">(</span>src, outCoord<span style="color: rgb(0, 102, 0); font-weight: bold;">(</span><span style="color: rgb(0, 102, 0); font-weight: bold;">)</span><span style="color: rgb(0, 102, 0); font-weight: bold;">)</span><span style="color: rgb(0, 102, 0); font-weight: bold;">)</span><span style="color: rgb(0, 102, 0); font-weight: bold;">)</span>;</div>
    </li>
    <li style="font-style: normal;  color: rgb(0, 102, 102); font-weight: bold;">
    <div style=" font-weight: normal;">         result = pixel3<span style="color: rgb(0, 102, 0); font-weight: bold;">(</span>value, <span style="color: rgb(0, 102, 102);">0</span>.<span style="color: rgb(0, 102, 102);">0</span>, <span style="color: rgb(0, 102, 102);">0</span>.<span style="color: rgb(0, 102, 102);">0</span><span style="color: rgb(0, 102, 0); font-weight: bold;">)</span>;</div>
    </li>
    <li style="font-style: normal;  color: rgb(0, 102, 102); font-weight: bold;">
    <div style=" font-weight: normal;">     <span style="color: rgb(0, 102, 0); font-weight: bold;">}</span></div>
    </li>
    <li style="font-style: normal;  color: rgb(0, 102, 102); font-weight: bold;">
    <div style=" font-weight: normal;"><span style="color: rgb(0, 102, 0); font-weight: bold;">}</span></div>
    </li>
</ol>
</div>
</div>
</div>
<div style=" font-weight: normal;"><font color="#000000">首先，注意结果是通过一个三元的pixel值返回回来的。当输出值低于三元的时候，目前版本的Pixel  Bender工具，会抛出一个错误，并且拒绝生成字节码。Pixel  Bender细则中描述是支持pixel1,pixel2,pixel3,pixel4输出的，所以这可能是一个Pixel  Bender工具的bug。为了解决这个问题，我将后两个元素设置为0。</font></div>
<div style=" font-weight: normal;">同样，输入的类型必须为image1。</div>
<div style=" font-weight: normal;"> </div>
<div style=" font-weight: normal;">在AS段，需要如下处理：</div>
<div style=" font-weight: normal;">1.创建一个ByteArray对象，使用writeFloat方法来天津每个数据，确保endian设置为little  endian。细则中虽说Vector.&lt;Number&gt;类型可以作为shader的输入数据，但是在使用这种方法的时候同样也出现了bug。</div>
<div style=" font-weight: normal;">2.创建一个Shader实例来接受Pixel  Bender的字节码。宽度根据你的数据数组的长度来获取。在ByteArray中，你需要将数组长度除以4。高度你只需要设置为1。input必须为一个集合。</div>
<div style=" font-weight: normal;">3.创建一个ByteArray来储存shader计算的结果。同样确保endian为little  endian。</div>
<div style=" font-weight: normal;">4.创建一个ShaderJob实例类接受shader,设置好输入，高度，宽度几个参数，添加一个&quot;complete&quot;的监听，等Shader计算结束后，来处理输出的ByteArray。然后你可以使用start方法来执行shader。</div>
<div style=" font-weight: normal;">这是as的代码示例：</div>
<div style=" font-weight: normal;">
<div class="syntax_hilite"><br>
<div>
<div class="actionscript">
<ol>
    <li style="font-style: normal;  color: rgb(0, 102, 102); font-weight: bold;">
    <div style=" font-weight: normal;">package</div>
    </li>
    <li style="font-style: normal;  color: rgb(0, 102, 102); font-weight: bold;">
    <div style=" font-weight: normal;"><span style="color: rgb(0, 102, 102);">{</span></div>
    </li>
    <li style="font-style: normal;  color: rgb(0, 102, 102); font-weight: bold;">
    <div style=" font-weight: normal;">     <span style="color: rgb(73, 144, 0);">import</span> flash.<span style="color: rgb(0, 102, 102);">display</span>.<span style="color: rgb(0, 102, 102);">Shader</span>;</div>
    </li>
    <li style="font-style: normal;  color: rgb(0, 102, 102); font-weight: bold;">
    <div style=" font-weight: normal;">     <span style="color: rgb(73, 144, 0);">import</span> flash.<span style="color: rgb(0, 102, 102);">display</span>.<span style="color: rgb(0, 102, 102);">ShaderJob</span>;</div>
    </li>
    <li style="font-style: normal;  color: rgb(0, 102, 102); font-weight: bold;">
    <div style=" font-weight: normal;">     <span style="color: rgb(73, 144, 0);">import</span> flash.<span style="color: rgb(0, 102, 102);">display</span>.<span style="color: rgb(0, 102, 102);">Sprite</span>;</div>
    </li>
    <li style="font-style: normal;  color: rgb(0, 102, 102); font-weight: bold;">
    <div style=" font-weight: normal;">     <span style="color: rgb(73, 144, 0);">import</span> flash.<span style="color: rgb(0, 102, 102);">events</span>.<span style="color: rgb(0, 102, 102);">Event</span>;</div>
    </li>
    <li style="font-style: normal;  color: rgb(0, 102, 102); font-weight: bold;">
    <div style=" font-weight: normal;">     <span style="color: rgb(73, 144, 0);">import</span> flash.<span style="color: rgb(0, 102, 102);">utils</span>.<span style="color: rgb(0, 102, 102);">ByteArray</span>;</div>
    </li>
    <li style="font-style: normal;  color: rgb(0, 102, 102); font-weight: bold;">
    <div style=" font-weight: normal;">     <span style="color: rgb(73, 144, 0);">import</span> flash.<span style="color: rgb(0, 102, 102);">utils</span>.<span style="color: rgb(0, 102, 102);">Endian</span>;</div>
    </li>
    <li style="font-style: normal;  color: rgb(0, 102, 102); font-weight: bold;">
    <div style=" font-weight: normal;"> </div>
    </li>
    <li style="font-style: normal;  color: rgb(0, 102, 102); font-weight: bold;">
    <div style=" font-weight: normal;">     <span style="color: rgb(73, 144, 0);">public</span> <span style="color: rgb(73, 144, 0);">class</span> Main <span style="color: rgb(73, 144, 0);">extends</span> Sprite</div>
    </li>
    <li style="font-style: normal;  color: rgb(0, 102, 102); font-weight: bold;">
    <div style=" font-weight: normal;">     <span style="color: rgb(0, 102, 102);">{</span></div>
    </li>
    <li style="font-style: normal;  color: rgb(0, 102, 102); font-weight: bold;">
    <div style=" font-weight: normal;">         protected <span style="color: rgb(73, 144, 0);">var</span>  _shader:Shader;</div>
    </li>
    <li style="font-style: normal;  color: rgb(0, 102, 102); font-weight: bold;">
    <div style=" font-weight: normal;">        </div>
    </li>
    <li style="font-style: normal;  color: rgb(0, 102, 102); font-weight: bold;">
    <div style=" font-weight: normal;">         protected <span style="color: rgb(73, 144, 0);">var</span>  _shaderJob:ShaderJob;</div>
    </li>
    <li style="font-style: normal;  color: rgb(0, 102, 102); font-weight: bold;">
    <div style=" font-weight: normal;">        </div>
    </li>
    <li style="font-style: normal;  color: rgb(0, 102, 102); font-weight: bold;">
    <div style=" font-weight: normal;">         protected <span style="color: rgb(73, 144, 0);">var</span>  _input:ByteArray;</div>
    </li>
    <li style="font-style: normal;  color: rgb(0, 102, 102); font-weight: bold;">
    <div style=" font-weight: normal;">        </div>
    </li>
    <li style="font-style: normal;  color: rgb(0, 102, 102); font-weight: bold;">
    <div style=" font-weight: normal;">         protected <span style="color: rgb(73, 144, 0);">var</span>  _output:ByteArray;</div>
    </li>
    <li style="font-style: normal;  color: rgb(0, 102, 102); font-weight: bold;">
    <div style=" font-weight: normal;">        </div>
    </li>
    <li style="font-style: normal;  color: rgb(0, 102, 102); font-weight: bold;">
    <div style=" font-weight: normal;">         <span style="color: rgb(0, 102, 102);">[</span>Embed<span style="color: rgb(0, 102, 102);">(</span>source=<span style="color: rgb(0, 102, 153);">&quot;/../assets/filters/NumberCruncher.pbj&quot;</span>,  mimeType=<span style="color: rgb(0, 102, 153);">&quot;application/octet-stream&quot;</span><span style="color: rgb(0, 102, 102);">)</span><span style="color: rgb(0, 102, 102);">]</span></div>
    </li>
    <li style="font-style: normal;  color: rgb(0, 102, 102); font-weight: bold;">
    <div style=" font-weight: normal;">         protected <span style="color: rgb(73, 144, 0);">var</span>  NumberCruncher:<span style="color: rgb(73, 144, 0);">Class</span>;</div>
    </li>
    <li style="font-style: normal;  color: rgb(0, 102, 102); font-weight: bold;">
    <div style=" font-weight: normal;">        </div>
    </li>
    <li style="font-style: normal;  color: rgb(0, 102, 102); font-weight: bold;">
    <div style=" font-weight: normal;">         <span style="color: rgb(73, 144, 0);">public</span> <span style="color: rgb(73, 144, 0);">function</span> Main<span style="color: rgb(0, 102, 102);">(</span><span style="color: rgb(0, 102, 102);">)</span></div>
    </li>
    <li style="font-style: normal;  color: rgb(0, 102, 102); font-weight: bold;">
    <div style=" font-weight: normal;">         <span style="color: rgb(0, 102, 102);">{</span></div>
    </li>
    <li style="font-style: normal;  color: rgb(0, 102, 102); font-weight: bold;">
    <div style=" font-weight: normal;">             init<span style="color: rgb(0, 102, 102);">(</span><span style="color: rgb(0, 102, 102);">)</span>;</div>
    </li>
    <li style="font-style: normal;  color: rgb(0, 102, 102); font-weight: bold;">
    <div style=" font-weight: normal;">         <span style="color: rgb(0, 102, 102);">}</span></div>
    </li>
    <li style="font-style: normal;  color: rgb(0, 102, 102); font-weight: bold;">
    <div style=" font-weight: normal;">        </div>
    </li>
    <li style="font-style: normal;  color: rgb(0, 102, 102); font-weight: bold;">
    <div style=" font-weight: normal;">         protected <span style="color: rgb(73, 144, 0);">function</span> init<span style="color: rgb(0, 102, 102);">(</span><span style="color: rgb(0, 102, 102);">)</span>:<span style="color: rgb(73, 144, 0);">void</span></div>
    </li>
    <li style="font-style: normal;  color: rgb(0, 102, 102); font-weight: bold;">
    <div style=" font-weight: normal;">         <span style="color: rgb(0, 102, 102);">{</span></div>
    </li>
    <li style="font-style: normal;  color: rgb(0, 102, 102); font-weight: bold;">
    <div style=" font-weight: normal;">             _input = <span style="color: rgb(73, 144, 0);">new</span> ByteArray<span style="color: rgb(0, 102, 102);">(</span><span style="color: rgb(0, 102, 102);">)</span>;</div>
    </li>
    <li style="font-style: normal;  color: rgb(0, 102, 102); font-weight: bold;">
    <div style=" font-weight: normal;">             _input.<span style="color: rgb(0, 102, 102);">endian</span> =  Endian.<span style="color: rgb(0, 102, 102);">LITTLE_ENDIAN</span>;</div>
    </li>
    <li style="font-style: normal;  color: rgb(0, 102, 102); font-weight: bold;">
    <div style=" font-weight: normal;">             _input.<span style="color: rgb(0, 102, 102);">writeFloat</span><span style="color: rgb(0, 102, 102);">(</span><span style="color: rgb(0, 102, 102);">4</span><span style="color: rgb(0, 102, 102);">)</span>;</div>
    </li>
    <li style="font-style: normal;  color: rgb(0, 102, 102); font-weight: bold;">
    <div style=" font-weight: normal;">             _input.<span style="color: rgb(0, 102, 102);">writeFloat</span><span style="color: rgb(0, 102, 102);">(</span><span style="color: rgb(0, 102, 102);">16</span><span style="color: rgb(0, 102, 102);">)</span>;</div>
    </li>
    <li style="font-style: normal;  color: rgb(0, 102, 102); font-weight: bold;">
    <div style=" font-weight: normal;">             _input.<span style="color: rgb(0, 102, 102);">writeFloat</span><span style="color: rgb(0, 102, 102);">(</span><span style="color: rgb(0, 102, 102);">100</span><span style="color: rgb(0, 102, 102);">)</span>;</div>
    </li>
    <li style="font-style: normal;  color: rgb(0, 102, 102); font-weight: bold;">
    <div style=" font-weight: normal;">             _input.<span style="color: rgb(0, 102, 102);">writeFloat</span><span style="color: rgb(0, 102, 102);">(</span><span style="color: rgb(0, 102, 102);">400</span><span style="color: rgb(0, 102, 102);">)</span>;</div>
    </li>
    <li style="font-style: normal;  color: rgb(0, 102, 102); font-weight: bold;">
    <div style=" font-weight: normal;">             _input.<span style="color: rgb(73, 144, 0);">position</span> = <span style="color: rgb(0, 102, 102);">0</span>;</div>
    </li>
    <li style="font-style: normal;  color: rgb(0, 102, 102); font-weight: bold;">
    <div style=" font-weight: normal;">            </div>
    </li>
    <li style="font-style: normal;  color: rgb(0, 102, 102); font-weight: bold;">
    <div style=" font-weight: normal;">             <span style="color: rgb(73, 144, 0);">var</span> <span style="color: rgb(73, 144, 0);">width</span>:<span style="color: rgb(73, 144, 0);">int</span> = _input.<span style="color: rgb(73, 144, 0);">length</span> &gt;&gt; <span style="color: rgb(0, 102, 102);">2</span>;</div>
    </li>
    <li style="font-style: normal;  color: rgb(0, 102, 102); font-weight: bold;">
    <div style=" font-weight: normal;">             <span style="color: rgb(73, 144, 0);">var</span> <span style="color: rgb(73, 144, 0);">height</span>:<span style="color: rgb(73, 144, 0);">int</span> = <span style="color: rgb(0, 102, 102);">1</span>;</div>
    </li>
    <li style="font-style: normal;  color: rgb(0, 102, 102); font-weight: bold;">
    <div style=" font-weight: normal;">            </div>
    </li>
    <li style="font-style: normal;  color: rgb(0, 102, 102); font-weight: bold;">
    <div style=" font-weight: normal;">             _shader = <span style="color: rgb(73, 144, 0);">new</span> Shader<span style="color: rgb(0, 102, 102);">(</span><span style="color: rgb(73, 144, 0);">new</span> NumberCruncher<span style="color: rgb(0, 102, 102);">(</span><span style="color: rgb(0, 102, 102);">)</span><span style="color: rgb(0, 102, 102);">)</span>;</div>
    </li>
    <li style="font-style: normal;  color: rgb(0, 102, 102); font-weight: bold;">
    <div style=" font-weight: normal;">             _shader.<span style="color: rgb(73, 144, 0);">data</span>.<span style="color: rgb(0, 102, 102);">src</span>.<span style="color: rgb(73, 144, 0);">width</span> = <span style="color: rgb(73, 144, 0);">width</span>;</div>
    </li>
    <li style="font-style: normal;  color: rgb(0, 102, 102); font-weight: bold;">
    <div style=" font-weight: normal;">             _shader.<span style="color: rgb(73, 144, 0);">data</span>.<span style="color: rgb(0, 102, 102);">src</span>.<span style="color: rgb(73, 144, 0);">height</span> = <span style="color: rgb(73, 144, 0);">height</span>;</div>
    </li>
    <li style="font-style: normal;  color: rgb(0, 102, 102); font-weight: bold;">
    <div style=" font-weight: normal;">             _shader.<span style="color: rgb(73, 144, 0);">data</span>.<span style="color: rgb(0, 102, 102);">src</span>.<span style="color: rgb(0, 102, 102);">input</span> = _input;</div>
    </li>
    <li style="font-style: normal;  color: rgb(0, 102, 102); font-weight: bold;">
    <div style=" font-weight: normal;">            </div>
    </li>
    <li style="font-style: normal;  color: rgb(0, 102, 102); font-weight: bold;">
    <div style=" font-weight: normal;">             _output = <span style="color: rgb(73, 144, 0);">new</span> ByteArray<span style="color: rgb(0, 102, 102);">(</span><span style="color: rgb(0, 102, 102);">)</span>;</div>
    </li>
    <li style="font-style: normal;  color: rgb(0, 102, 102); font-weight: bold;">
    <div style=" font-weight: normal;">             _output.<span style="color: rgb(0, 102, 102);">endian</span> =  Endian.<span style="color: rgb(0, 102, 102);">LITTLE_ENDIAN</span>;</div>
    </li>
    <li style="font-style: normal;  color: rgb(0, 102, 102); font-weight: bold;">
    <div style=" font-weight: normal;">            </div>
    </li>
    <li style="font-style: normal;  color: rgb(0, 102, 102); font-weight: bold;">
    <div style=" font-weight: normal;">             _shaderJob = <span style="color: rgb(73, 144, 0);">new</span>  ShaderJob<span style="color: rgb(0, 102, 102);">(</span>_shader, _output, <span style="color: rgb(73, 144, 0);">width</span>, <span style="color: rgb(73, 144, 0);">height</span><span style="color: rgb(0, 102, 102);">)</span>;</div>
    </li>
    <li style="font-style: normal;  color: rgb(0, 102, 102); font-weight: bold;">
    <div style=" font-weight: normal;">             _shaderJob.<span style="color: rgb(0, 102, 102);">addEventListener</span><span style="color: rgb(0, 102, 102);">(</span>Event.<span style="color: rgb(0, 102, 102);">COMPLETE</span>, onShaderJobComplete, <span style="color: rgb(73, 144, 0);">false</span>, <span style="color: rgb(0, 102, 102);">0</span>, <span style="color: rgb(73, 144, 0);">true</span><span style="color: rgb(0, 102, 102);">)</span>;</div>
    </li>
    <li style="font-style: normal;  color: rgb(0, 102, 102); font-weight: bold;">
    <div style=" font-weight: normal;">             _shaderJob.<span style="color: rgb(73, 144, 0);">start</span><span style="color: rgb(0, 102, 102);">(</span><span style="color: rgb(0, 102, 102);">)</span>;</div>
    </li>
    <li style="font-style: normal;  color: rgb(0, 102, 102); font-weight: bold;">
    <div style=" font-weight: normal;">         <span style="color: rgb(0, 102, 102);">}</span></div>
    </li>
    <li style="font-style: normal;  color: rgb(0, 102, 102); font-weight: bold;">
    <div style=" font-weight: normal;">        </div>
    </li>
    <li style="font-style: normal;  color: rgb(0, 102, 102); font-weight: bold;">
    <div style=" font-weight: normal;">         protected <span style="color: rgb(73, 144, 0);">function</span>  onShaderJobComplete<span style="color: rgb(0, 102, 102);">(</span>event:Event<span style="color: rgb(0, 102, 102);">)</span>:<span style="color: rgb(73, 144, 0);">void</span></div>
    </li>
    <li style="font-style: normal;  color: rgb(0, 102, 102); font-weight: bold;">
    <div style=" font-weight: normal;">         <span style="color: rgb(0, 102, 102);">{</span></div>
    </li>
    <li style="font-style: normal;  color: rgb(0, 102, 102); font-weight: bold;">
    <div style=" font-weight: normal;">             _output.<span style="color: rgb(73, 144, 0);">position</span> = <span style="color: rgb(0, 102, 102);">0</span>;</div>
    </li>
    <li style="font-style: normal;  color: rgb(0, 102, 102); font-weight: bold;">
    <div style=" font-weight: normal;">            </div>
    </li>
    <li style="font-style: normal;  color: rgb(0, 102, 102); font-weight: bold;">
    <div style=" font-weight: normal;">             <span style="color: rgb(73, 144, 0);">var</span> <span style="color: rgb(73, 144, 0);">length</span>:<span style="color: rgb(73, 144, 0);">int</span> = _output.<span style="color: rgb(73, 144, 0);">length</span>;</div>
    </li>
    <li style="font-style: normal;  color: rgb(0, 102, 102); font-weight: bold;">
    <div style=" font-weight: normal;">            </div>
    </li>
    <li style="font-style: normal;  color: rgb(0, 102, 102); font-weight: bold;">
    <div style=" font-weight: normal;">             <span style="color: rgb(73, 144, 0);">for</span><span style="color: rgb(0, 102, 102);">(</span><span style="color: rgb(73, 144, 0);">var</span> i:<span style="color: rgb(73, 144, 0);">int</span> = <span style="color: rgb(0, 102, 102);">0</span>; i &lt; <span style="color: rgb(73, 144, 0);">length</span>; i += <span style="color: rgb(0, 102, 102);">4</span><span style="color: rgb(0, 102, 102);">)</span></div>
    </li>
    <li style="font-style: normal;  color: rgb(0, 102, 102); font-weight: bold;">
    <div style=" font-weight: normal;">             <span style="color: rgb(0, 102, 102);">{</span></div>
    </li>
    <li style="font-style: normal;  color: rgb(0, 102, 102); font-weight: bold;">
    <div style=" font-weight: normal;">                 <span style="color: rgb(73, 144, 0);">var</span> output:<span style="color: rgb(73, 144, 0);">Number</span> = _output.<span style="color: rgb(0, 102, 102);">readFloat</span><span style="color: rgb(0, 102, 102);">(</span><span style="color: rgb(0, 102, 102);">)</span>;</div>
    </li>
    <li style="font-style: normal;  color: rgb(0, 102, 102); font-weight: bold;">
    <div style=" font-weight: normal;">                </div>
    </li>
    <li style="font-style: normal;  color: rgb(0, 102, 102); font-weight: bold;">
    <div style=" font-weight: normal;">                 <span style="color: rgb(73, 144, 0);">if</span><span style="color: rgb(0, 102, 102);">(</span>i % <span style="color: rgb(0, 102, 102);">3</span> == <span style="color: rgb(0, 102, 102);">0</span><span style="color: rgb(0, 102, 102);">)</span></div>
    </li>
    <li style="font-style: normal;  color: rgb(0, 102, 102); font-weight: bold;">
    <div style=" font-weight: normal;">                     <span style="color: rgb(73, 144, 0);">trace</span><span style="color: rgb(0, 102, 102);">(</span><span style="color: rgb(0, 102, 153);">&quot;value  -&gt; &quot;</span> + output<span style="color: rgb(0, 102, 102);">)</span>;</div>
    </li>
    <li style="font-style: normal;  color: rgb(0, 102, 102); font-weight: bold;">
    <div style=" font-weight: normal;">             <span style="color: rgb(0, 102, 102);">}</span></div>
    </li>
    <li style="font-style: normal;  color: rgb(0, 102, 102); font-weight: bold;">
    <div style=" font-weight: normal;">         <span style="color: rgb(0, 102, 102);">}</span></div>
    </li>
    <li style="font-style: normal;  color: rgb(0, 102, 102); font-weight: bold;">
    <div style=" font-weight: normal;">     <span style="color: rgb(0, 102, 102);">}</span></div>
    </li>
    <li style="font-style: normal;  color: rgb(0, 102, 102); font-weight: bold;">
    <div style=" font-weight: normal;"><span style="color: rgb(0, 102, 102);">}</span></div>
    </li>
</ol>
</div>
</div>
</div>
<p>为了解决我早先提到的三通道输出的问题，我使用了取模的运算，在&ldquo;onShaderJobComplete&rdquo;方法中，最终结果是所有输入数字的平方根。</p>
<p>所以那是很好的。可以想象，等这些bug都消除以后，这江是个非常有用的东西。</p>
</div>
</span></div> <a href="http://hi.baidu.com/3tion/blog/item/10ae677a6f9736e42e73b380.html">阅读全文</a>
		
		<br/><b>类别：</b><a href="http://hi.baidu.com/3tion/blog/category/flex%26%2347%3Bflash">flex&#47;flash</a>&nbsp;<a href="http://hi.baidu.com/3tion/blog/item/10ae677a6f9736e42e73b380.html#comment">查看评论</a>]]></description>
        <pubDate>2009-07-27  15:04</pubDate>
        <category><![CDATA[flex&#47;flash]]></category>
        <author><![CDATA[3tion]]></author>
		<guid>http://hi.baidu.com/3tion/blog/item/10ae677a6f9736e42e73b380.html</guid>
</item>

<item>
        <title><![CDATA[[原创]flash效果，碎玻璃效果]]></title>
        <link><![CDATA[http://hi.baidu.com/3tion/blog/item/b39b852ac5febd9c023bf6ed.html]]></link>
        <description><![CDATA[
		
		前段时间看同事用的linux，窗体最小化，还原，以及打开的时候，都会有不同的效果，其中有个类似破碎的玻璃，重新组合的效果。<br>
<br>
要做这个效果，首先需要将窗体截图，然后将截图随机分解成n个小三角形区域。<br>
最先我考虑的方法是在图片的范围内随机生成几个点，然后让点两两相连，连成三角形，并且在连接的时候检测线条不能和其他线相交。<br>
这样就需要有一个三角形数组，每画一条新的线段的时候，就要遍历这个三角形数组，来检测线段是否和三角形中的线相交。<br>
同时，这样做在检查是否有某些部分没有被画上三角形也比较困难。<br>
总之这种方法会消耗很多的资源，并且有可能有遗漏的地方。<br>
<br>
于是我思考有没有简单切分随机三角形的方法。<br>
<br>
三角形其实可以被认为是四边形，连上一条对角线而产生的。<br>
那么只要将图形，先分成多个四边形即可。<br>
只要确保，横，纵坐标的点数量一致，便可以画出四边形，然后分解成三角形。<br>
<div forimg="1"><img border="0" src="http://hiphotos.baidu.com/3tion/pic/item/a54cd38b3c9e92cdfc1f1031.jpg" small="0" class="blogimg"></div>
转换成代码即为：<br>
bmp为视图对象<br>
_point为点的数组<br>
<br>
_avgDist为四边形边长的平均值<br>
<br>
for(var i:uint = 0;i&lt;=row;i++)<br>
&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  {<br>
&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  _point[i] = [];<br>
<br>
&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  for(var j:uint = 0;j&lt;col;j++)<br>
&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  {<br>
&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  if( i==row )<br>
&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  {<br>
&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  _point[i][j] = {x:x,y:bmp.height};<br>
&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  }<br>
&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  else<br>
&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  {<br>
&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  _point[i][j] = {x:x,y:y};<br>
&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  }<br>
&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  x +=  (_avgDist/2*(Math.random()-0.5) + _avgDist );<br>
&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  }<br>
&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  _point[i][j] = {x:bmp.width,y:y};<br>
&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  y +=  (_avgDist/2*(Math.random()-0.5) + _avgDist );<br>
&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  x = 0;<br>
&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  }<br>
<br>
<br>
<br>
<br>
然后就是如何将原来的图像渲染的问题了。<br>
只要使用graphics.beginBitmapFill，然后以面板的截图作为参数即可。<br>
<br>
面板截图的方法可以使用BitmapData类的draw来画出。<br>
实际上，每一行<br>
<div forimg="1"><img border="0" src="http://hiphotos.baidu.com/3tion/pic/item/9e4c003d3d1963f03c6d9707.jpg" small="0" class="blogimg"></div>
就是n个小四边形组成，而每个小四边形则由两个三角形组成，渲染上原图，变成代码以后就是<br>
<br>
<br>
<br>
&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  var shape:Shape;<br>
&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  for( i = 0; i&lt;row;i++)<br>
&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  {<br>
&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  for(j=0;j&lt;col;j++)<br>
&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  {<br>
&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  shape = new Shape();<br>
&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  shape.graphics.beginBitmapFill(bmp.bitmapData);<br>
&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  shape.graphics.moveTo(_point[i][j].x,_point[i][j].y);<br>
&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  shape.graphics.lineTo(_point[i][j+1].x,_point[i][j+1].y);<br>
&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  shape.graphics.lineTo(_point[i+1][j].x,_point[i+1][j].y);<br>
&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  shape.graphics.lineTo(_point[i][j].x,_point[i][j].y);<br>
&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  _triangles.push(shape);<br>
<br>
&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  shape = new Shape();<br>
&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  shape.graphics.beginBitmapFill(bmp.bitmapData);<br>
&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  shape.graphics.moveTo(_point[i+1][j].x,_point[i+1][j].y);<br>
&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  shape.graphics.lineTo(_point[i+1][j+1].x,_point[i+1][j+1].y);<br>
&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  shape.graphics.lineTo(_point[i][j+1].x,_point[i][j+1].y);<br>
&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  shape.graphics.lineTo(_point[i+1][j].x,_point[i+1][j].y);<br>
&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  _triangles.push(shape);<br>
<br>
&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  }<br>
&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  }<br>
其中_triangles是用来保存三角形的数组。<br>
<br>
<br>
这样就将一张完整的图片，分解成了大小不等的n个小三角形。<br>
<br>
然后就是破碎效果了。<br>
<br>
首先我让每个三角形的x，y坐标在图形大小的两倍范围内随机分布。alpha初始值为0，<br>
rotation则为0~360度中的一个随机值。<br>
<br>
然后使用TweenLite让其最终能回到0,0坐标，alpha回复为1。<br>
<br>
写成代码则为：<br>
&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  var len:uint = _triangles.length;<br>
&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  for(var i:uint=0;i&lt;len;i++)<br>
&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  {<br>
&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  var triangle:Shape = _triangles[i] as Shape;<br>
&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  triangle.x = width*2*(Math.random() - 0.5 ) + width;<br>
&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  triangle.y = height*2*(Math.random() - 0.5 ) + width;<br>
&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  triangle.rotation = 360*Math.random();<br>
&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  triangle.alpha = 0;<br>
&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  addChild(triangle);<br>
&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  TweenLite.to( triangle , 0.5 , {x:25,y:25,rotation:0, alpha:1});<br>
&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  }<br>
<br>
<br>
最终破碎的图形会在0.5秒之后，组合成为一个整图。<br>
但是面板上原来可能是有按钮的，在效果开始前，需要先隐藏面板，效果结束后，需要将所有三角形移除，并且将面板显示出来。<br>
<br>
这样就需要将 TweenLite.to( triangle , 0.5 , {x:25,y:25,rotation:0, alpha:1});<br>
改为：<br>
 TweenLite.to( triangle , 0.5 , {x:25,y:25,rotation:0, alpha:1,onComplete:tweenCompleteHandler});<br>
<br>
通过tweenCompleteHandler这个函数来处理效果结束后的事件。<br>
<br>
&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  private var _c:uint;<br>
&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  <br>
&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  private function tweenCompleteHandler():void<br>
&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  {<br>
&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  var len:uint =  _triangles.length;<br>
&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  if(++_c == len)<br>
&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  {<br>
&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  bmp.visible = true;<br>
&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  for(var i:uint=0;i&lt;len;i++)<br>
&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  {<br>
&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  removeChild(_triangles[i]);<br>
&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  delete _triangles[i];<br>
&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  }<br>
&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  }<br>
&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  <br>
&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  }<br>
<br>
其中_c是用来记录次数，当次数达到和三角形的数量一致时，说明所有三角形都到达正确的位置。<br>
<br>
<br>
<br>
<br>
<br> <a href="http://hi.baidu.com/3tion/blog/item/b39b852ac5febd9c023bf6ed.html">阅读全文</a>
		
		<br/><b>类别：</b><a href="http://hi.baidu.com/3tion/blog/category/%C4%AC%C8%CF%B7%D6%C0%E0">默认分类</a>&nbsp;<a href="http://hi.baidu.com/3tion/blog/item/b39b852ac5febd9c023bf6ed.html#comment">查看评论</a>]]></description>
        <pubDate>2009-01-02  01:41</pubDate>
        <category><![CDATA[默认分类]]></category>
        <author><![CDATA[3tion]]></author>
		<guid>http://hi.baidu.com/3tion/blog/item/b39b852ac5febd9c023bf6ed.html</guid>
</item>

<item>
        <title><![CDATA[[原创]flash人脸抓取技术，半成品]]></title>
        <link><![CDATA[http://hi.baidu.com/3tion/blog/item/8986b82464a2ca064c088d9e.html]]></link>
        <description><![CDATA[
		
		这几天，通过晨会，知道同事正在做一个贺卡的项目。<br>
需要用户选择一张照片，然后将头像放大，缩小并移动到一个64×64的范围。<br>
这些功能都通过javascript实现，然后上传到服务端，然后在flash端，将用户上传的头像，放置在一个头部容器中，这样，卡片中人物的头像就会随着预先设定的舞蹈运动。<br>
<br>
但是通过指定64×64的方格而选定的头像是没有办法将背景去除的，我想到以前我做.NET项目的时候，用到的一个被称为木刻的算法，会将图像极端化，处 理成只有黑和白的两种颜色。而在人像摄影中，脸部的边缘部分会因为阴影的原因产生一个比较大的色差，最后使用木刻算法会有一个明显的边缘。那么我是否可以 利用这种算法，将人脸的轮廓取出呢？<br>
<br>
带着这个问题，我开始了我的测试。<br>
<br>
首先说说木刻算法：由于24位图片的储存规格实际是一个宽×长的矩阵，其中每个点储存的是一个24位颜色值，可以转化为红(Red)，绿(Green)，蓝(Blue)三个颜色的分量。<br>
每个分量是个8bit值，即能保存0~255(2的8次方)种值。<br>
而木刻算法就是通过找到R,G,B三个分量中最大值和最小值，然后得到(最大值+最小值)/2之后的中间值（还有一种算法是直接找到R,G,B三个分量的平均值）。<br>
此中间值大于我们预先定义的一个阀值，则让颜色值为0xffffff（即白色），否则让颜色值为0（即黑色）。<br>
以前我是用C#写的，现在需要先修改成AS3的代码：<br>
<br>
&nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    private function WoodCarving(bmpData:BitmapData):BitmapData<br>
&nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    {<br>
&nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    var newData:BitmapData = new BitmapData(bmpData.width,bmpData.height,false);<br>
&nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    for(var y:int = 0;y&lt;bmpData.height;y++)<br>
&nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    {<br>
&nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    for(var x:int = 0;x&lt;bmpData.width;x++)<br>
&nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    {<br>
&nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    //取得颜色值<br>
&nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    var color:uint = bmpData.getPixel(x,y);<br>
&nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    //取得RGB分量<br>
&nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    var r:uint &nbsp;&nbsp;&nbsp;    = color&gt;&gt;16;<br>
&nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    var g:uint &nbsp;&nbsp;&nbsp;    = color&gt;&gt;8 &amp; 0xff;<br>
&nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    var b:uint&nbsp;&nbsp;&nbsp;    = color &amp; 0xff;<br>
&nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    <br>
&nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    var min:uint = r;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    var max:uint = r;<br>
&nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    <br>
&nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    if (g &lt; min)<br>
&nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;    min = g;<br>
&nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;    if (b &lt; min)<br>
&nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;    min = b;<br>
&nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;    if (g &gt; max)<br>
&nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;    max = g;<br>
&nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;    if (b &gt; max)<br>
&nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;    max = b;<br>
&nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    //获取中间值<br>
&nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;    var gr:uint = (int)((min + max) / 2);<br>
&nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;    if (gr &lt; _value)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    gr = 0;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    else<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    gr = 0xffffff;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;    newData.setPixel(x,y,gr);<br>
&nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    }<br>
&nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    }&nbsp;&nbsp;&nbsp;    <br>
&nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    return newData;<br>
&nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    }<br>
<br>
这可以将<br>
<div forimg="1"><img border="0" src="http://hiphotos.baidu.com/3tion/pic/item/5f5c44cec5fd5c24b700c867.jpg" small="0" class="blogimg"></div>
<br>
转换为<br>
<div forimg="1"><img border="0" src="http://hiphotos.baidu.com/3tion/pic/item/6568e58fa1641df3f11f3660.jpg" small="0" class="blogimg"></div>
<br>
<br>
然后我的思路是建立一个3*3的矩阵（除去中间点的8个点）。<br>
var arr:Array &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    = [[0,-1],[1,-1],[1,0],[1,1],[0,1],[-1,1],[-1,0],[-1,-1]];<br>
让检测点为中心点，探测每一个黑色（颜色值为0）的像素周围的8个点中，如果白色点超过2个以上，我将该点视为边缘点。<br>
bmpData为木刻效果之后的图像数据：<br>
var shapeData:BitmapData = new BitmapData(bmpData.width,bmpData.height,false,0xffffff);<br>
var xPixel:Array = [];<br>
for(var y:int = 0;y&lt;bmpData.height;y++)<br>
&nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    {<br>
&nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    for(var x:int = 0;x&lt;bmpData.width;x++)<br>
&nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    {<br>
&nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    var tt:uint = bmpData.getPixel(x,y);<br>
&nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    if( tt == 0 )<br>
&nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    {<br>
&nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    var blackCount:uint = 0;<br>
&nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    var whiteCount:uint = 0;<br>
&nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    for each( var zz:Array in arr )<br>
&nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    {<br>
&nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    if( bmpData.getPixel(x + zz[0],y+zz[1]) == 0 )<br>
&nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    {<br>
&nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    blackCount++;<br>
&nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    }<br>
&nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    else<br>
&nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    {<br>
&nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    whiteCount++;<br>
&nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    }<br>
&nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    }<br>
&nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    var dis:uint = blackCount &gt; whiteCount ? (blackCount - whiteCount) : (whiteCount - blackCount);<br>
&nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    if( whiteCount &gt; 2 )<br>
&nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    {<br>
&nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    xPixel.push(x);<br>
&nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    shapeData.setPixel(x,y,0xff);<br>
&nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    }<br>
&nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    }<br>
&nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    }<br>
&nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    }<br>
我将数据保存在shapeData这个新的bitmapData中。<br>
将x坐标保存到xPixel中。<br>
<br>
先将可能的轮廓点找到：<br>
得到这个图像：<br>
<div forimg="1"><img border="0" src="http://hiphotos.baidu.com/3tion/pic/item/66a96b291cc769e398250a62.jpg" small="0" class="blogimg"></div>
<br>
<br>
创建左数组var leftPixel:Array = [];<br>
以及右数组var rightPixel:Array = [];<br>
<br>
先找到图像的中心：<br>
xPixel.sort(Array.NUMERIC);<br>
var middleX:Number = (middleX[0] + middleX[openPixel.length-1])/2;<br>
以保证leftPixel数组中保存的都是在middleX左边的坐标，而rightPixel数组中保存的都是在middleX右边的坐标。<br>
<br>
获取leftPixel和rightPixel的数据信息：<br>
<br>
&nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    var lastPoint:Object;<br>
&nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    for(y = 0;y&lt;shapeData.height;y++)<br>
&nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    {<br>
&nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    if(lastPoint )<br>
&nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    {<br>
&nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    if( lastPoint.x &gt; middleX )<br>
&nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    rightPixel.push(lastPoint);<br>
&nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    }<br>
&nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    var count:uint = 0;<br>
&nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    for( x=0;x&lt;shapeData.width;x++)<br>
&nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    {<br>
&nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    if( shapeData.getPixel(x,y) == 0xff )<br>
&nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    {<br>
&nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    if( !count )<br>
&nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    {<br>
&nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    if( x &lt; middleX )<br>
&nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    leftPixel.push({x:x,y:y});<br>
&nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    }<br>
&nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    lastPoint = {x:x,y:y};<br>
&nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    count++;<br>
&nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    }<br>
&nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    }<br>
&nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    }<br>
<br>
最终使用画线的方法将需要做遮罩的区域绘制成黑色。<br>
&nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    var shape:Shape = new Shape();<br>
&nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    shape.graphics.beginFill(0,1);<br>
&nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    shape.graphics.lineStyle(1,1);<br>
&nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    for( var txx:int = 0;txx&lt;rightPixel.length;txx++)<br>
&nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    {<br>
&nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    if( txx==0)<br>
&nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    {<br>
&nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    shape.graphics.moveTo(rightPixel[txx].x,rightPixel[txx].y);<br>
&nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    }<br>
&nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    else<br>
&nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    {<br>
&nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    shape.graphics.lineTo(rightPixel[txx].x,rightPixel[txx].y);<br>
&nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    }<br>
&nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    } <br>
&nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    <br>
&nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    for( txx = leftPixel.length-1;txx&gt;=0;txx--)<br>
&nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    {<br>
&nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    shape.graphics.lineTo(leftPixel[txx].x,leftPixel[txx].y);<br>
&nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    } <br>
&nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;    shape.graphics.endFill();<br>
并将其作为图像的遮罩：<br>
最终效果：<br>
<div forimg="1"><a href="http://hiphotos.baidu.com/3tion/pic/item/95f929f0660526de7831aa6c.jpg" target="_blank">
<div forimg="1"><img border="0" src="http://hiphotos.baidu.com/3tion/pic/item/95f929f0660526de7831aa6c.jpg" small="0" class="blogimg"></div>
<br>
</a></div>
我的方法在最终绘制的时候还存在一定问题，按我想象应该是可以采取顺时针找点的方式，但是我始终没有研究出确实的算法，所以人脸抓取只能算个半成品吧。<br>
<br>
头像为公司一帅哥Eric，单身，收入稳定，有意者请于本人联系<img src="http://img.baidu.com/hi/ldw/w_0005.gif"> <a href="http://hi.baidu.com/3tion/blog/item/8986b82464a2ca064c088d9e.html">阅读全文</a>
		
		<br/><b>类别：</b><a href="http://hi.baidu.com/3tion/blog/category/flex%26%2347%3Bflash">flex&#47;flash</a>&nbsp;<a href="http://hi.baidu.com/3tion/blog/item/8986b82464a2ca064c088d9e.html#comment">查看评论</a>]]></description>
        <pubDate>2008-12-14  16:26</pubDate>
        <category><![CDATA[flex&#47;flash]]></category>
        <author><![CDATA[3tion]]></author>
		<guid>http://hi.baidu.com/3tion/blog/item/8986b82464a2ca064c088d9e.html</guid>
</item>

<item>
        <title><![CDATA[上海帮]]></title>
        <link><![CDATA[http://hi.baidu.com/3tion/blog/item/c4d08116b4b4ef1f962b432a.html]]></link>
        <description><![CDATA[
		
		<img border="0" class="blogimg" small="0" src="http://hiphotos.baidu.com/3tion/pic/item/32742c1ed7faffe81ad576d0.jpg"><br>
离开大学已经3年多，几经辗转来到了上海工作。大学同学中，读研究生的也基本上都毕业，天南海北分散到各个省市。留在武汉的有不少，去北京的有一对刚刚完成了婚礼。南下广东，广西，福建的也有不少。而我则脱离武汉帮，加入了上海帮。<br>
现在在上海的，除我以外就有4人。佩佩还在同济继续深造。小上海则毕业以后便回到了自己的故乡上海，现在从事着游戏3D建模的工作。秀萍刚刚硕士毕业，被聘用到了一家在南京路上有一栋大楼，拥有全甲资质的公司上班。Abla Wolf现在也在一家游戏公司做策划工作。<br>
由于我们大学的专业是园林设计，而上海植物园离秀萍还有Abla Wolf的住所只有5分钟的步行距离，于是小上海便邀约我们一起去植物园玩。<br>
<div forimg="1"><br>
<div forimg="1"><img border="0" class="blogimg" small="0" src="http://hiphotos.baidu.com/3tion/pic/item/08e75eb316c5b3bbd8335ad0.jpg"><br>
一进2号门没多远就会看到由水杉做行道树的笔直马路，一直通向园区中央。<br>
<div forimg="1"><img border="0" class="blogimg" small="0" src="http://hiphotos.baidu.com/3tion/pic/item/177d68dbbb1ca37ad1164ed0.jpg"></div>
<br>
巨大的蜘蛛模型。<br>
<div forimg="1"><img border="0" class="blogimg" small="0" src="http://hiphotos.baidu.com/3tion/pic/item/6180fec352d0fb49b219a8d1.jpg"></div>
一块陨石，介绍说陨石上有一些石刻，可惜我未能找到。<br>
<br>
<div forimg="1"><img border="0" class="blogimg" small="0" src="http://hiphotos.baidu.com/3tion/pic/item/3fc1681288fa414df919b8d1.jpg"></div>
鸭脚半熟色犹青，纱囊驰寄江陵城。<br>
<div forimg="1"><img border="0" class="blogimg" small="0" src="http://hiphotos.baidu.com/3tion/pic/item/dc5b7f73c83542008601b0d1.jpg"></div>
银杏的叶子已经泛黄，掉落，让我想起了另外一个同学莉莉，她研究生的时候就是专门研究银杏的，现在毕业了，回到宜昌，跑到一个小县城当上了干部。<br>
于是大家聊了下其他同学，居然发现没几个真正在做园林设计了。而我们这几个在上海做事的，居然都进入了IT行业。<br>
于是又有了这个感悟：以前的事情并不重要，重要的是你现在想要什么，你希望以后得到什么。<br>
<br>
<div forimg="1"><img border="0" class="blogimg" small="0" src="http://hiphotos.baidu.com/3tion/pic/item/9ccd53082e15fbcd63d986d1.jpg"></div>
幽静的园区<br>
<br>
<div forimg="1"><img border="0" class="blogimg" small="0" src="http://hiphotos.baidu.com/3tion/pic/item/61b5c08fc10df9e6503d92d1.jpg"></div>
象征和平的鸽子永远是最受游人喜爱的生物<br>
<div forimg="1"><img border="0" class="blogimg" small="0" src="http://hiphotos.baidu.com/3tion/pic/item/d5a03c2224abd1b84723e8d1.jpg"></div>
蝙蝠形态的风筝，还能扇动它邪恶的翅膀<br>
<div forimg="1"><img border="0" class="blogimg" small="0" src="http://hiphotos.baidu.com/3tion/pic/item/417c2acb7fa70303bf09e6d1.jpg"></div>
只剩下枯枝的桃树，证明着现在已经是寒冬季节<br>
<div forimg="1"><img border="0" class="blogimg" small="0" src="http://hiphotos.baidu.com/3tion/pic/item/419c3159a6cc25362934f0d1.jpg"></div>
孩子们开心的游玩着<br>
<div forimg="1"><img border="0" class="blogimg" small="0" src="http://hiphotos.baidu.com/3tion/pic/item/20b66bf3b566184c342accd1.jpg"></div>
<div forimg="1"><img border="0" class="blogimg" small="0" src="http://hiphotos.baidu.com/3tion/pic/item/6d44e31104f24162cb80c4d1.jpg"></div>
硕果累累<br>
<br>
<div forimg="1"><img border="0" class="blogimg" small="0" src="http://hiphotos.baidu.com/3tion/pic/item/3b820882135621be0df4d2d1.jpg"></div>
我什么时候能拥有第三片叶子呢？<br>
<br>
<div forimg="1"><img border="0" class="blogimg" small="0" src="http://hiphotos.baidu.com/3tion/pic/item/b789e90eca0da5fb37d122d1.jpg"></div>
枝叶已经溃败，却掩盖不住花朵的娇嫩<br>
<div forimg="1"><img border="0" class="blogimg" small="0" src="http://hiphotos.baidu.com/3tion/pic/item/6ba9103470ebc152241f14d1.jpg"></div>
<br>
<br>
<div forimg="1"><img border="0" class="blogimg" small="0" src="http://hiphotos.baidu.com/3tion/pic/item/d97484623cd414c1e6113ad1.jpg"></div>
平静的湖面<br>
<div forimg="1"><img border="0" class="blogimg" small="0" src="http://hiphotos.baidu.com/3tion/pic/item/bb43b1fe52c44d2d5d6008d1.jpg"></div>
<br>
<br>
移植树木后留下的大坑<br>
<div forimg="1"><img border="0" class="blogimg" small="0" src="http://hiphotos.baidu.com/3tion/pic/item/5da51854dac22c48574e00d1.jpg"></div>
<br>
<div forimg="1"><img border="0" class="blogimg" small="0" src="http://hiphotos.baidu.com/3tion/pic/item/5ba7238bbef1480ec9fc7ad1.jpg"></div>
找了个草坪开始吃吃喝喝<br>
<div forimg="1"><img border="0" class="blogimg" small="0" src="http://hiphotos.baidu.com/3tion/pic/item/44ad5ff41c375c72dcc474d1.jpg"></div>
合影留恋<br>
<br>
下午4时，太阳快要落下，气温也开始变低，我们决定起身出园，我也把相机交给了小上海。下面是他拍摄的一组照片。<br>
<div forimg="1"><img border="0" class="blogimg" small="0" src="http://hiphotos.baidu.com/3tion/pic/item/3daec62bc7e5c4e6e7cd40d1.jpg"></div>
<div forimg="1"><img border="0" class="blogimg" small="0" src="http://hiphotos.baidu.com/3tion/pic/item/999213a7c2d13989d04358d1.jpg"></div>
<br>
<div forimg="1"><img border="0" class="blogimg" small="0" src="http://hiphotos.baidu.com/3tion/pic/item/14b40baf87edbae7faed50d1.jpg"></div>
<div forimg="1">这个建筑是温室<br>
<img border="0" class="blogimg" small="0" src="http://hiphotos.baidu.com/3tion/pic/item/21f312a9b3c43ee01f17a2d2.jpg"></div>
<div forimg="1"><img border="0" class="blogimg" small="0" src="http://hiphotos.baidu.com/3tion/pic/item/6eafd71809982ba84bedbcd2.jpg"><br>
我们离开了上海植物园<br>
<div forimg="1"><img border="0" class="blogimg" small="0" src="http://hiphotos.baidu.com/3tion/pic/item/3fb71d083fe4ec890b7b82d2.jpg"></div>
<br>
离开植物园后，我们来到了秀萍和Abla wolf他们合租的住所，由Abla wolf亲自下厨烧制了武汉风味的小菜。有种回到了家乡的感觉。与组织取得了联系，以后这样游玩的机会就更多了。</div>
</div>
</div> <a href="http://hi.baidu.com/3tion/blog/item/c4d08116b4b4ef1f962b432a.html">阅读全文</a>
		
		<br/><b>类别：</b><a href="http://hi.baidu.com/3tion/blog/category/%C4%AC%C8%CF%B7%D6%C0%E0">默认分类</a>&nbsp;<a href="http://hi.baidu.com/3tion/blog/item/c4d08116b4b4ef1f962b432a.html#comment">查看评论</a>]]></description>
        <pubDate>2008-11-30  11:46</pubDate>
        <category><![CDATA[默认分类]]></category>
        <author><![CDATA[3tion]]></author>
		<guid>http://hi.baidu.com/3tion/blog/item/c4d08116b4b4ef1f962b432a.html</guid>
</item>

<item>
        <title><![CDATA[冬天来了，春天还会远吗？]]></title>
        <link><![CDATA[http://hi.baidu.com/3tion/blog/item/9a85d644c7fe584b510ffea0.html]]></link>
        <description><![CDATA[
		
		今年年运不好，一年都是多灾多难。随着金融危机的爆发，不少公司都在缩减经费，尤其是许多需要依靠外资的IT企业。我们公司也跳不出这大环境，只得裁掉了一部分员工，并且退掉了C2这块办公场地。所有人都搬回了剩下的办公地点A7。<br>
<div forimg="1"><img border="0" class="blogimg" small="0" src="http://hiphotos.baidu.com/3tion/pic/item/ad71ce3dfa2f321cbba167a2.jpg"></div>
A7重新布局，搭建办公桌。<br>
<br>
由于公司有很多货物都放在C2，所有男同事发扬了当年《解放军占领巴黎》的精神<br>
<div forimg="1"><img border="0" class="blogimg" small="0" src="http://hiphotos.baidu.com/3tion/pic/item/0f93ed318664d0b45edf0ebc.jpg"></div>
<br>
协力合作，将活物搬到A7<br>
<div forimg="1"><img border="0" class="blogimg" small="0" src="http://hiphotos.baidu.com/3tion/pic/item/cc19f50f790618f1aa6457b4.jpg"></div>
<div forimg="1"><img border="0" class="blogimg" small="0" src="http://hiphotos.baidu.com/3tion/pic/item/f46fa3d3312af5c3a9ec9abe.jpg"></div>
<div forimg="1"><img border="0" class="blogimg" small="0" src="http://hiphotos.baidu.com/3tion/pic/item/f46fa3d3312bf5c3a9ec9abf.jpg"></div>
现在已经是21世纪，光靠人力是不行的，我们必须调用机械化部队。<br>
动车组：<br>
<div forimg="1"><img border="0" class="blogimg" small="0" src="http://hiphotos.baidu.com/3tion/pic/item/9a85d64461f4fe50510ffe84.jpg"></div>
老大的SUV也是体现它价值的时候了：<br>
<div forimg="1"><a target="_blank" href="http://hiphotos.baidu.com/3tion/pic/item/6b4cfe5123ce50938c543080.jpg">
<div forimg="1">
<div forimg="1">
<div forimg="1"><img border="0" class="blogimg" small="0" src="http://hiphotos.baidu.com/3tion/pic/item/6b4cfe5123ce50938c543080.jpg"></div>
</div>
<div forimg="1"><img border="0" class="blogimg" small="0" src="http://hiphotos.baidu.com/3tion/pic/item/c869dcb11506ad480923028d.jpg"></div>
</div>
<div forimg="1"><img border="0" class="blogimg" small="0" src="http://hiphotos.baidu.com/3tion/pic/item/3b8208821ca134be0cf4d28e.jpg"></div>
<br>
</a></div>
公司目前财政状况虽然没有以前好了，但是我相信通过公司全体员工的努力，公司一定会好起来的，也许以后公司能租下整个园区。<br>
<div forimg="1"><img border="0" class="blogimg" small="0" src="http://hiphotos.baidu.com/3tion/pic/item/5ba7238b410a5d0ec8fc7a89.jpg"></div>
C2，我们还会回来的。 <a href="http://hi.baidu.com/3tion/blog/item/9a85d644c7fe584b510ffea0.html">阅读全文</a>
		
		<br/><b>类别：</b><a href="http://hi.baidu.com/3tion/blog/category/%C4%AC%C8%CF%B7%D6%C0%E0">默认分类</a>&nbsp;<a href="http://hi.baidu.com/3tion/blog/item/9a85d644c7fe584b510ffea0.html#comment">查看评论</a>]]></description>
        <pubDate>2008-11-29  10:14</pubDate>
        <category><![CDATA[默认分类]]></category>
        <author><![CDATA[3tion]]></author>
		<guid>http://hi.baidu.com/3tion/blog/item/9a85d644c7fe584b510ffea0.html</guid>
</item>

<item>
        <title><![CDATA[flash在iframe之上的bug]]></title>
        <link><![CDATA[http://hi.baidu.com/3tion/blog/item/d09558f7b401a425730eec75.html]]></link>
        <description><![CDATA[
		
		最近的项目中，有个flash会在iframe上，在IE下会很正常的响应到注册的鼠标事件，但是在火狐中，如果flash漂浮在iframe框架页之上，就无法相应到任何鼠标事件。<br>
google之后，发现这个bug居然已经存在了1年多，firefox2，flash8的时候被人提出，到现在flash10出来了，firefox升级到3.1版本，依旧没有解决。<br>
相关bug描述：<br>
firefox网站的<br>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=448567">https://bugzilla.mozilla.org/show_bug.cgi?id=448567</a><br>
adobe网站的<br>
<a target="_blank" href="http://bugs.adobe.com/jira/browse/FP-289">http://bugs.adobe.com/jira/browse/FP-289</a><br>
<br>
一老外的所谓解决方案，当然没有什么实际价值，不过可以贴出来做个参考，也许别的地方能用到他这些思路。<br>
That's one of several limitation of Flash on Firefox which is<br>
acknowledged on various Adobe support pages. No doubt you're using Flash<br>
with wmode=transparent or even wmode=opaque. You might not have noticed<br>
yet, but things will be even worse in Safari. There are a few<br>
workarounds, none of them are nice, but it beats serving Firefox with a<br>
lesser experience.<br>
<br>
One is to switch to wmode=window for Firefox. I imagine that you need<br>
the transparency though, so we'll ignore that for now.<br>
<br>
Another is to actively hide the iframe as you move over it. Each time<br>
you move the DIV your Flash is on, look at all the iframe objects on the<br>
page and just do some intersection math to determine if you're over it.<br>
If you are, then you hide it. As you stop intersecting (or hide your<br>
DIV) then you make it visible again. This can also be necessary if your<br>
transparent flash finds itself over another flash object with<br>
wmode=window, or if you move over a HTML select dropdown menu. All of<br>
these things can bleed through your Flash, and they do it more on<br>
Firefox and even more on Safari.<br>
<br>
Another option is to create an iframe mask. You create an extra DIV<br>
layer with the same position as the one your Flash is on, except this<br>
has a z-index one lower than yours. On this new div you set the<br>
background color to white and put an iframe tag on it with src=&quot;&quot;. This<br>
iframe div will block the iframe that you're seeing bleed through your<br>
Flash. Simply move this div as you move your own Flash div. It will<br>
block out the nasty bleedthru objects that were bothering you. Of course<br>
this itself is a big white rectangle, so can spoil your transparency<br>
(although you never said you were running wmode=transparent, so it might<br>
still be an option). Even if you are running in transparent mode, you<br>
might be able to customize the size of this div (or have multiple divs)<br>
so that your links aren't affected. I've tried creating a transparent<br>
iframe mask but it doesn't work. The iframe masking only works when the<br>
DIV is white, and it has an iframe tag on it.<br>
<br>
A final option is to have an image object (using a fully transparent<br>
GIF) which is on an extra DIV with a higher z-index than your Flash. It<br>
can use the usemap tag of the IMG to catch clicks and do the appropriate<br>
action.<br>
<br>
Sorry if you want to follow up on any of these points, I'm just about to<br>
unsubscribe from this newsgroup.<br>
<br> <a href="http://hi.baidu.com/3tion/blog/item/d09558f7b401a425730eec75.html">阅读全文</a>
		
		<br/><b>类别：</b><a href="http://hi.baidu.com/3tion/blog/category/%BD%C5%B1%BE%BC%BC%CA%F5%26%2347%3Bjavascript%26%2347%3Bflash">脚本技术&#47;javascript&#47;flash</a>&nbsp;<a href="http://hi.baidu.com/3tion/blog/item/d09558f7b401a425730eec75.html#comment">查看评论</a>]]></description>
        <pubDate>2008-11-26  16:21</pubDate>
        <category><![CDATA[脚本技术&#47;javascript&#47;flash]]></category>
        <author><![CDATA[3tion]]></author>
		<guid>http://hi.baidu.com/3tion/blog/item/d09558f7b401a425730eec75.html</guid>
</item>

<item>
        <title><![CDATA[小野洋子个人展]]></title>
        <link><![CDATA[http://hi.baidu.com/3tion/blog/item/04ee800920ceaa85d1581baa.html]]></link>
        <description><![CDATA[
		
		话说公司变成公墓以后，小野洋子在个人展开幕前一天也亲自来到会场，指导会场的准备工作。<br>
而我的座位正对窗口，虽然她很低调的走近会场，不过还是被我狙到。<br>
<div forimg="1"><img border="0" class="blogimg" small="0" src="http://hiphotos.baidu.com/3tion/pic/item/c78b7797f588977154fb965e.jpg"></div>
走在最前面的便是74岁的小野洋子。<br>
<br>
到了周六也就是她个人展开幕的晚上，三辆mini cooper开进园区。<br>
<div forimg="1"><img border="0" class="blogimg" small="0" src="http://hiphotos.baidu.com/3tion/pic/item/a34cb7cd26ef344d0eb3455d.jpg"></div>
<div forimg="1"><img border="0" class="blogimg" small="0" src="http://hiphotos.baidu.com/3tion/pic/item/9a85d6442f9eb050500ffe5e.jpg"></div>
我最喜欢的车之一，再来张30秒曝光，不开闪光灯的。我们公司作为专业的动画制作公司，三脚架这样的行头，自然随便就能找的到，也不用花自己银子了。<br>
<div forimg="1"><img border="0" class="blogimg" small="0" src="http://hiphotos.baidu.com/3tion/pic/item/be82659bcd5df1a9c8eaf45e.jpg"></div>
<br>
不久之后，园区里面人山人海<br>
<div forimg="1"><img border="0" class="blogimg" small="0" src="http://hiphotos.baidu.com/3tion/pic/item/016bf0444b52f39eb3b7dc5e.jpg"></div>
虽然下着小雨，大家仍然十分激动，看来小野洋子的名气还是挺大的。<br>
接着，有工作人员将我们的请帖换成了一个精巧的手电，据说是等下需要大家配合小野一起表演。<br>
<div forimg="1"><img border="0" class="blogimg" small="0" src="http://hiphotos.baidu.com/3tion/pic/item/b86bf2cc8ebf270c00e9285e.jpg"></div>
小野洋子出场，大家掌声一片。<br>
手电筒派上作用了，小野奶奶告知大家跟着她的节奏闪烁手电筒<br>
i<br>
ii<br>
iii<br>
代表着i love you。<br>
<div forimg="1"><img border="0" class="blogimg" small="0" src="http://hiphotos.baidu.com/3tion/pic/item/a34cb7cd263a344d0eb345e2.jpg"></div>
大家也很配合的跟着一起打手电筒，最后将光线射向宇宙，表明对外星人也要充满爱！<br>
<br>
接着就是排队入场了。由于人很多，必须分批入场，由于天空下着雨，不少等得不耐烦的观众，离开了园区。我则继续跟着大部队，伺机拍摄。<br>
<div forimg="1"><img border="0" class="blogimg" small="0" src="http://hiphotos.baidu.com/3tion/pic/item/2f8eca50b1a47f7e8435245e.jpg"></div>
等待入场的混乱人群<br>
<br>
经过一个多小时的等待，终于入场<br>
<div forimg="1"><img border="0" class="blogimg" small="0" src="http://hiphotos.baidu.com/3tion/pic/item/3daec62b8e609fe6e7cd405e.jpg"></div>
<br>
一大群人围着几个作品看<br>
<div forimg="1"><img border="0" class="blogimg" small="0" src="http://hiphotos.baidu.com/3tion/pic/item/c0f8c358cf6e19c29d82045e.jpg"></div>
<br>
原来不是MY MIMI IS BEAUTIFUL<br>
<div forimg="1"><img border="0" class="blogimg" small="0" src="http://hiphotos.baidu.com/3tion/pic/item/32742c1e9e7ca4e81ad5765e.jpg"><br>
因为还有性器官的，不知道会不会因为这幅图被百度封号<img src="http://img.baidu.com/hi/jx/j_0016.gif"><br>
<div forimg="1"><img border="0" class="blogimg" small="0" src="http://hiphotos.baidu.com/3tion/pic/item/098ba9dced6710bdcc11665e.jpg"><br>
<br>
巨大的蚕茧，让我想到了西部瘟疫之地的臭蛆。<br>
<div forimg="1"><img border="0" class="blogimg" small="0" src="http://hiphotos.baidu.com/3tion/pic/item/a54cd38b8c7902cffc1f105e.jpg"></div>
</div>
<br>
由于公司只拿到一张VIP的票，我上不了3楼，随意的转了下，便回到了公司，另外一个拿到VIP票的同事，拍了一段小野的热舞，可惜居然转码以后图像就有严重问题了，我就只截几张图片上来吧。<br>
<div forimg="1"><img border="0" class="blogimg" small="0" src="http://hiphotos.baidu.com/3tion/pic/item/f6ef742d1fcc8228359bf7de.jpg"></div>
<div forimg="1"><img border="0" class="blogimg" small="0" src="http://hiphotos.baidu.com/3tion/pic/item/2fb71b9088ebd991a877a4d8.jpg"><br>
<br>
<div forimg="1"><img border="0" class="blogimg" small="0" src="http://hiphotos.baidu.com/3tion/pic/item/999213a7bbd96289d04358d9.jpg"></div>
小野奶奶和观众一起热舞<br>
<br>
最后show一把战利品：<br>
<div forimg="1"><img border="0" class="blogimg" small="0" src="http://hiphotos.baidu.com/3tion/pic/item/ef875b55c77e41d8b645ae5f.jpg"></div>
</div>
</div> <a href="http://hi.baidu.com/3tion/blog/item/04ee800920ceaa85d1581baa.html">阅读全文</a>
		
		<br/><b>类别：</b><a href="http://hi.baidu.com/3tion/blog/category/%C4%AC%C8%CF%B7%D6%C0%E0">默认分类</a>&nbsp;<a href="http://hi.baidu.com/3tion/blog/item/04ee800920ceaa85d1581baa.html#comment">查看评论</a>]]></description>
        <pubDate>2008-11-23  14:48</pubDate>
        <category><![CDATA[默认分类]]></category>
        <author><![CDATA[3tion]]></author>
		<guid>http://hi.baidu.com/3tion/blog/item/04ee800920ceaa85d1581baa.html</guid>
</item>


</channel>
</rss>