<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title><![CDATA[阿权的书房]]></title> 
<link>http://www.aslibra.com/blog/index.php</link> 
<description><![CDATA[技术经验分享，资料收集，偶尔晾几张相片，感言生活]]></description> 
<language>zh-cn</language> 
<copyright><![CDATA[阿权的书房]]></copyright>
<item>
<link>http://www.aslibra.com/blog/read.php/878.htm</link>
<title><![CDATA[Flash如何全屏显示]]></title> 
<author>hqlulu &lt;hqlulu@163.com&gt;</author>
<category><![CDATA[Flash]]></category>
<pubDate>Sat, 08 Sep 2007 17:28:55 +0000</pubDate> 
<guid>http://www.aslibra.com/blog/read.php/878.htm</guid> 
<description>
<![CDATA[ 
	现在很多视频网站都有全屏观看，效果非常不错，一直纳闷怎么弄的。<br/><br/>首先看到这个全屏是在youtube上，保存了网页察看，实在是没法知道如何实现的，隐约看到有控制flash的层，但是这个绝对不可能会出现在屏幕的全部，最多也只能出现在网页界面的部分全部占据了。<br/><br/>JS控制DIV的位置浮动，并且控制占满网页，这个是可能的，代码也应该不算难，可要实现全屏是不行的。昨天看到了一个blog介绍了全屏的代码，原来是Flash9的特性，怪不得我没听说过呢，原来是新鲜的Flash9，自己一直都在使用Flash8而已。<br/><br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content">这里不说用JS改变document内容实现的全屏方法,而是FLASH 9以后一种新的实现方法.<br/><br/>首先HTML的&lt;object&gt;&lt;embed&gt;标记要添加一个allowfullscreen,值为true.<br/><br/>也就是加上&lt;param name=&quot;allowFullScreen&quot; value=&quot;true&quot; /&gt;<br/><br/>AS2里是没有这个代码的,所以我们要手动添加.<br/><br/>打开你的Flash 8/(zh_cn)/First Run/Classes/FP8/Stage.as<br/><br/>在那一排申明的变量里加上下一句<br/><br/>static var displayState:String;<br/><br/>那么你的flash里,就可以使用<br/><br/>Stage[&quot;displayState&quot;] = &quot;fullScreen&quot;;<br/><br/>或者<br/><br/>Stage.displayState = &quot;fullScreen&quot;;<br/><br/>来启动全屏了.<br/><br/>退出全屏<br/><br/>Stage.displayState = &quot;Normal&quot;;<br/><br/>对全屏有影响的除了开始提到的allowfullscreen,还有scaleMode,默认设置是showAll,这以为全屏伸延了整个窗口后,比例保持不变.如果你需要控制尺寸,这个值就应该是noScale<br/><br/>差不多就这样了,实现全屏,只用你把按钮的功能做成改变 Stage的displayState是fullscreen或者Normal.当然,客户端的flash版本必须是9以上.<br/>也可以和JS实现的全屏一起使用,让JS对应FLASH8以前的版本,此方法用于FLASH9以后的版本</div></div><br/><br/>摘自：<a href="http://blog.sina.com.cn/s/blog_54dae52e010009s6.html" target="_blank">http://blog.sina.com.cn/s/blog_54dae52e010009s6.html</a><br/><br/>mousebomb的仁兄做了一个flash9的例子：<br/><a href="http://www.mousebomb.org/blog/article.asp?id=165" target="_blank">http://www.mousebomb.org/blog/article.asp?id=165</a><br/><br/><br/><div class="code">Stage.scaleMode = &quot;noscale&quot;;<br/><br/>function fullS() &#123;<br/> &nbsp; &nbsp;switch (Stage.displayState) &#123;<br/> &nbsp; &nbsp; &nbsp; &nbsp;case &quot;fullScreen&quot; :<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Stage.displayState = &quot;normal&quot;;<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;break;<br/> &nbsp; &nbsp; &nbsp; &nbsp;case &quot;normal&quot; :<br/> &nbsp; &nbsp; &nbsp; &nbsp;default :<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Stage.displayState = &quot;fullScreen&quot;;<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;break;<br/> &nbsp; &nbsp;&#125;<br/>&#125;<br/><br/>var expandmenu = new ContextMenu();<br/>expandmenu.hideBuiltInItems();<br/>//new ContextMenuItem(caption, callbackFunction, &#91; separatorBefore, &#91; enabled, &#91; visible &#93; &#93; &#93; )<br/>var btn1 = new ContextMenuItem(&quot;进入全屏&quot;, fullS);<br/>expandmenu.customItems.push(btn1);<br/>_root.menu = expandmenu;<br/><br/>StageLS = new Object();<br/>StageLS.onResize = function() &#123;<br/> &nbsp; &nbsp;switch (Stage.displayState) &#123;<br/> &nbsp; &nbsp; &nbsp; &nbsp;case &quot;fullScreen&quot; :<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;btn1.caption = &quot;退出全屏&quot;;<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;break;<br/> &nbsp; &nbsp; &nbsp; &nbsp;case &quot;normal&quot; :<br/> &nbsp; &nbsp; &nbsp; &nbsp;default :<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;btn1.caption = &quot;进入全屏&quot;;<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;break;<br/> &nbsp; &nbsp;&#125;<br/>&#125;;<br/>Stage.addListener(StageLS);</div><br/><br/>如果客户端flash播放器的版本在9以前的话是无法正常全屏的<br/>源文件在原帖子有提供：<br/><a href="http://www.mousebomb.org/blog/attachments/month_0707/t2007730132141.rar" target="_blank">http://www.mousebomb.org/blog/attachments/month_0707/t2007730132141.rar</a><br/><br/>感谢mousebomb的例子，看来我也得研究一下Flash CS3了....<br/>Tags - <a href="http://www.aslibra.com/blog/go.php/tags/flash/" rel="tag">flash</a>
]]>
</description>
</item><item>
<link>http://www.aslibra.com/blog/read.php/853.htm</link>
<title><![CDATA[昨晚的flash错误]]></title> 
<author>hqlulu &lt;hqlulu@163.com&gt;</author>
<category><![CDATA[Flash]]></category>
<pubDate>Wed, 15 Aug 2007 15:56:19 +0000</pubDate> 
<guid>http://www.aslibra.com/blog/read.php/853.htm</guid> 
<description>
<![CDATA[ 
	昨晚修改一个flash游戏碰到的错误，忙乎了两个小时才查到问题，加了如下语句：<br/><br/><div class="code"> &nbsp;var carx = _car._x;<br/> &nbsp;var cary = _car._y;<br/> &nbsp;point = new Object();<br/> &nbsp;point.x = gamexy_mc._x;<br/> &nbsp;point.y = gamexy_mc._y;<br/> &nbsp;localToGlobal(point);<br/> &nbsp;carx += point.x;<br/> &nbsp;cary += point.y;</div><br/><br/>其实游戏在单独查看就没有问题，只是在合成到杂志就出问题了。12点的时候被叫着帮忙看看，刚刚开始的直觉就是游戏的地图偏移了，还打算手工修正，后来觉得应该是合成杂志的时候与0坐标的偏移的问题，正解，把偏移加上就好了，上面的是自动修正偏移的问题。如果有朋友碰到脚本坐标的问题，可以看看是否可以用 “localToGlobal”来解决。<br/><br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content"><strong>MovieClip.localToGlobal</strong><br/><br/>用法<br/><br/>myMovieClip.localToGlobal(point)<br/><br/>参数<br/><br/>point 用 Object 对象创建的对象的名称或标识符，并指定 x 和 y 坐标作为其属性。 <br/><br/>说明<br/><br/>方法；将 point 对象从影片剪辑（本地）坐标转换为舞台（全局）坐标。 <br/><br/>示例<br/><br/>下面的示例将 point 对象的 x 和 y 坐标从影片剪辑坐标（本地）转换为舞台坐标（全局）。本地 x 和 y 坐标是用 _xmouse 和 _ymouse 属性指定的，以获取鼠标位置的 x 和 y 坐标。 <br/><br/>onClipEvent(mouseMove) &#123;<br/>&nbsp;&nbsp;point = new object();<br/>&nbsp;&nbsp;point.x = _xmouse;<br/>&nbsp;&nbsp;point.y = _ymouse;<br/>&nbsp;&nbsp;_root.out3 = point.x + " === " + point.y;<br/>&nbsp;&nbsp;_root.out = _root._xmouse + " === " + _root._ymouse;<br/>&nbsp;&nbsp;localToGlobal(point);<br/>&nbsp;&nbsp;_root.out2 = point.x + " === " + point.y;<br/>&nbsp;&nbsp;updateAfterEvent();<br/>&#125;</div></div><br/>Tags - <a href="http://www.aslibra.com/blog/go.php/tags/flash/" rel="tag">flash</a>
]]>
</description>
</item><item>
<link>http://www.aslibra.com/blog/read.php/814.htm</link>
<title><![CDATA[C++中使用flash]]></title> 
<author>hqlulu &lt;hqlulu@163.com&gt;</author>
<category><![CDATA[Flash]]></category>
<pubDate>Fri, 20 Jul 2007 16:57:30 +0000</pubDate> 
<guid>http://www.aslibra.com/blog/read.php/814.htm</guid> 
<description>
<![CDATA[ 
	今天弄了一下VC++，尝试使用flash，不错，至少可以两个家伙进行通信。<br/><br/>VC的做法：<br/>1 添加一个控件 shockwave flash<br/>2 添加fscommand指令接收<br/>3 添加调用flash内部函数的方法<br/><br/>Flash的做法：<br/>1 添加脚本显示效果<br/>2 添加fscommand测试<br/>3 添加可以提供外部调用的函数<br/><br/>代码如下，可以提供参考：<br/><br/>Flash代码：<br/><br/><div class="code">import flash.external.*;<br/>ExternalInterface.addCallback(&quot;CallMeFromApplication&quot;, this, InternalFunction);<br/>function InternalFunction(str:String):String &#123;<br/>	a_txt.text = str;<br/>	return Array(&quot;test&quot;, &quot;testsdf&quot;);<br/>	return &quot;The function was called successfully&quot;;<br/>&#125;<br/>//<br/>var a_str:String = &quot;test&quot;;<br/>a_txt.text = gggg;<br/>fscommand(&quot;ffff&quot;, &quot;sdfsdf&quot;);<br/>//FlashCall(&quot;test&quot;);<br/>a_btn.onRelease = function() &#123;<br/>	a_txt.text = gggg;<br/>&#125;;</div><br/><br/>VC++代码：<br/><br/><div class="code">void CflashDlg::FSCommandShockwaveflash2(LPCTSTR command, LPCTSTR args)<br/>&#123;<br/>	// TODO: 在此处添加消息处理程序代码<br/>	MessageBox(command);<br/>	flash_movie.SetVariable(&quot;gggg&quot;,&quot;test&quot;);<br/>	//((CShockwaveflash2*)GetDlgItem(IDC_SHOCKWAVEFLASH2))-&gt;SetVariable(&quot;gggg&quot;,&quot;test&quot;);<br/>	CString test;<br/>	test=flash_movie.CallFunction(&quot;&lt;invoke name=&quot;CallMeFromApplication&quot;&gt;&lt;arguments&gt;&lt;string&gt;Some text for TFlashPlayerControl&lt;/string&gt;&lt;/arguments&gt;&lt;/invoke&gt;&quot;);<br/>	MessageBox(test);<br/>&#125;</div><br/><br/>大家试试啊~~<br/>可以通信后那就啥事都可以做了。
]]>
</description>
</item><item>
<link>http://www.aslibra.com/blog/read.php/716.htm</link>
<title><![CDATA[Flash接受参数添加链接]]></title> 
<author>hqlulu &lt;hqlulu@163.com&gt;</author>
<category><![CDATA[Flash]]></category>
<pubDate>Thu, 05 Apr 2007 11:36:11 +0000</pubDate> 
<guid>http://www.aslibra.com/blog/read.php/716.htm</guid> 
<description>
<![CDATA[ 
	<div class="code">//var addlink = &quot;http://www.aslibra.com&quot;; //test<br/>if (addlink) &#123;<br/>	//program by hqlulu 20070406<br/>	//add link bottom in movie clip<br/>	this.createEmptyMovieClip(&quot;link_mc&quot;, this.getNextHighestDepth());<br/>	link_mc.beginFill(0xFF0000, 0);<br/>	var __w:Number = Stage.width;<br/>	var __h:Number = Stage.height;<br/>	link_mc.moveTo(0, 0);<br/>	link_mc.lineTo(__w, 0);<br/>	link_mc.lineTo(__w, __h);<br/>	link_mc.lineTo(0, __h);<br/>	link_mc.lineTo(0, 0);<br/>	link_mc.endFill();<br/>	link_mc.onRelease = function() &#123;<br/>		getURL(addlink, &quot;_blank&quot;);<br/>	&#125;;<br/>&#125;</div><br/><br/><a href="/down/addlink/" target="_blank">效果预览：点击这里</a><br/><br/><strong>原理：</strong><br/><br/>1 判断是否有外部通过url传送过来的参数<br/>2 如果有，则建立与舞台一样长宽的影片剪辑，为透明状态<br/>3 给影片剪辑加上链接<br/><br/><br/><strong>boject代码的例子：</strong><br/><br/><div class="code">&lt;object classid=&quot;clsid:d27cdb6e-ae6d-11cf-96b8-444553540000&quot; codebase=&quot;http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0&quot; width=&quot;550&quot; height=&quot;400&quot; id=&quot;addlink&quot; align=&quot;middle&quot;&gt;<br/>&lt;param name=&quot;allowScriptAccess&quot; value=&quot;sameDomain&quot; /&gt;<br/>&lt;param name=&quot;movie&quot; value=&quot;1.swf?addlink=http://www.aslibra.com&quot; /&gt;&lt;param name=&quot;quality&quot; value=&quot;high&quot; /&gt;&lt;param name=&quot;bgcolor&quot; value=&quot;#ffffff&quot; /&gt;&lt;embed src=&quot;1.swf?addlink=http://www.aslibra.com&quot; quality=&quot;high&quot; bgcolor=&quot;#ffffff&quot; width=&quot;550&quot; height=&quot;400&quot; name=&quot;addlink&quot; align=&quot;middle&quot; allowScriptAccess=&quot;sameDomain&quot; type=&quot;application/x-shockwave-flash&quot; pluginspage=&quot;http://www.macromedia.com/go/getflashplayer&quot; /&gt;<br/>&lt;/object&gt;</div><br/><br/>
]]>
</description>
</item><item>
<link>http://www.aslibra.com/blog/read.php/659.htm</link>
<title><![CDATA[Flash内部设置样式表例子]]></title> 
<author>hqlulu &lt;hqlulu@163.com&gt;</author>
<category><![CDATA[Flash]]></category>
<pubDate>Tue, 06 Mar 2007 09:44:31 +0000</pubDate> 
<guid>http://www.aslibra.com/blog/read.php/659.htm</guid> 
<description>
<![CDATA[ 
	[swf width=400 height=150]http://www.aslibra.com/down/txt_style.swf[/swf]<br/><br/>代码如下：<br/><br/>Stage.scaleMode = &quot;noscale&quot;;<br/>//<br/>import TextField.StyleSheet;<br/>//new style<br/>var my_styleSheet:StyleSheet = new StyleSheet();<br/>//方式1,每个属性分别赋值<br/>var styleObj:Object = new Object();<br/>styleObj.color = &quot;#0000ff&quot;;<br/>styleObj.fontWeight = &quot;bold&quot;;<br/>my_styleSheet.setStyle(&quot;.bold&quot;, styleObj);<br/>delete styleObj;<br/>//方式2,直接写成一个对象<br/>my_styleSheet.setStyle(&quot;.fade&quot;, &#123;color:&quot;#999999&quot;, fontWeight:&quot;bold&quot;&#125;);<br/>my_styleSheet.setStyle(&quot;p&quot;, &#123;color:&quot;#ff0000&quot;, fontSize:&quot;14px&quot;, fontWeight:&quot;bold&quot;&#125;);<br/>//还可以设置伪类<br/>my_styleSheet.setStyle(&quot;a&quot;, &#123;color:&quot;#ff0000&quot;&#125;);<br/>my_styleSheet.setStyle(&quot;a:hover&quot;, &#123;color:&quot;#000000&quot;, fontStyle:&quot;italic&quot;&#125;);<br/>//<br/>//txt<br/>var newsText:String = &quot;&lt;p&gt;李白简介&lt;/p&gt;&quot;;<br/>newsText += &quot;&lt;br&gt;李白（&lt;span class='fade'&gt;公元701年—公元762年&lt;/span&gt;），&quot;;<br/>newsText += &quot;字太白，号青莲居士。&quot;;<br/>newsText += &quot;李白是唐朝著名诗人，也是中国最著名的诗人之一，&lt;span class='bold'&gt;&lt;/span&gt; &quot;;<br/>newsText += &quot;是我国文学史上继屈原之后又一伟大的浪漫主义诗人&quot;;<br/>newsText += &quot;,有“诗仙”之称。&lt;br&gt;李白和杜甫合称“&lt;span class='bold'&gt;李杜&lt;/span&gt;”。 &quot;;<br/>newsText += &quot;&lt;br&gt;link style: &lt;a href='http://www.aslibra.com' target='_blank'&gt;&quot;;<br/>newsText += &quot;&lt;u&gt; http://www.aslibra.com &lt;/u&gt;&lt;/a&gt;&quot;;<br/>//<br/>//set<br/>news_txt.styleSheet = my_styleSheet;<br/>news_txt.wordWrap = true;<br/>news_txt.multiline = true;<br/>news_txt.html = true;<br/>news_txt.htmlText = newsText;<br/><br/><a href="http://www.aslibra.com/down/txt_style.rar" target="_blank">点击这里下载fla文件</a>
]]>
</description>
</item><item>
<link>http://www.aslibra.com/blog/read.php/523.htm</link>
<title><![CDATA[Flash的MD5类(class)和MD5的函数]]></title> 
<author>hqlulu &lt;hqlulu@163.com&gt;</author>
<category><![CDATA[Flash]]></category>
<pubDate>Thu, 21 Dec 2006 10:31:16 +0000</pubDate> 
<guid>http://www.aslibra.com/blog/read.php/523.htm</guid> 
<description>
<![CDATA[ 
	MD5的加密有广泛的应用，flash里面有两个写法：<br/>1 写成 md5 的类文件<br/>2 写成 md5 的函数<br/><br/>看怎么方便了，这里列举两个方法的范例可以给大家下载：<br/><br/>1 类文件和实例：<a href="up/1166696921.rar" target="_blank">up/1166696921.rar</a><br/><br/>2 函数的写法和实例：<a href="up/1166697053.rar" target="_blank">up/1166697053.rar</a><br/><br/>大家使用愉快～
]]>
</description>
</item><item>
<link>http://www.aslibra.com/blog/read.php/503.htm</link>
<title><![CDATA[Flash Class 类文件的函数方法]]></title> 
<author>hqlulu &lt;hqlulu@163.com&gt;</author>
<category><![CDATA[Flash]]></category>
<pubDate>Wed, 13 Dec 2006 07:03:14 +0000</pubDate> 
<guid>http://www.aslibra.com/blog/read.php/503.htm</guid> 
<description>
<![CDATA[ 
	以前不太清楚函数怎么设定，发觉比较简单：<br/><br/>设定一个函数就可以直接调用了，如果需要再次调用，比如里面还有另外一个对象，那把它的函数再次分配给本对象就可以了，很简单。<br/><br/>见下面的例子：<br/><br/>MagKeywordSearch.as<br/><br/><div class="code">class MagKeywordSearch &#123;<br/>	//定义变量<br/>	var sth:String;<br/>	//定义函数<br/>	var onLoad:Function;<br/>	var when_init:Function;<br/>	//同名函数做初始化<br/>	function MagKeywordSearch() &#123;<br/>		this.sth = &quot;init ok!&quot;;<br/>	&#125;<br/>	function get_info_by_key(keyword:String) &#123;<br/>		trace(&quot;get_info&quot;);<br/>		//直接调用的函数<br/>		this.when_init(this.sth);<br/>		var a_lv:LoadVars = new LoadVars();<br/>		a_lv.sendAndLoad(&quot;http://localhost&quot;, a_lv);<br/>		//需要等待的<br/>		a_lv.onLoad = this.onLoad;<br/>	&#125;<br/>&#125;</div><br/><br/>flash里面的代码：<br/><br/><div class="code">var a = new MagKeywordSearch();<br/>a.when_init = function(sth) &#123;<br/>	trace(&quot;out:&quot;+sth);<br/>&#125;;<br/>a.onLoad = function(s) &#123;<br/>	trace(s);<br/>&#125;;<br/>a.get_info_by_key(&quot;a&quot;);</div>
]]>
</description>
</item><item>
<link>http://www.aslibra.com/blog/read.php/487.htm</link>
<title><![CDATA[flash与网页的简单通信过程]]></title> 
<author>hqlulu &lt;hqlulu@163.com&gt;</author>
<category><![CDATA[Flash]]></category>
<pubDate>Wed, 06 Dec 2006 08:13:16 +0000</pubDate> 
<guid>http://www.aslibra.com/blog/read.php/487.htm</guid> 
<description>
<![CDATA[ 
	<strong>1 设定一个针对flash的id的函数，这里的id是main</strong><br/><br/>&lt;SCRIPT event=&quot;FSCommand(command,arg)&quot; for=&quot;main&quot; language=JavaScript&gt; &nbsp; <br/>	alert(command+arg);<br/>	window.document.main.SetVariable(&quot;info&quot;,&quot;test&quot;);<br/>&lt;/SCRIPT&gt;<br/><br/>第一行是设定命令(event)以及针对的id(for)<br/>第二行是使用传递过来的两个变量<br/>第三行是设定flash里面的变量的值，暂时找到就这样做反馈了<br/><br/><strong>2 对于flash，embed里面要有一个 id=&quot;main&quot;</strong><br/><br/>&lt;embed src=&quot;index.swf&quot; quality=&quot;high&quot; bgcolor=&quot;#ffffff&quot; width=&quot;550&quot; height=&quot;400&quot; name=&quot;main&quot; align=&quot;middle&quot; id=&quot;main&quot; allowScriptAccess=&quot;sameDomain&quot; type=&quot;application/x-shockwave-flash&quot; pluginspage=&quot;http://www.macromedia.com/go/getflashplayer&quot; /&gt;<br/><br/>唉，又搞这类的互动了……<br/>以前做盛大的时候就烦了一次。<br/>
]]>
</description>
</item><item>
<link>http://www.aslibra.com/blog/read.php/486.htm</link>
<title><![CDATA[也谈Flash AS2 中的拍照图片无损压缩]]></title> 
<author>hqlulu &lt;hqlulu@163.com&gt;</author>
<category><![CDATA[Flash]]></category>
<pubDate>Mon, 04 Dec 2006 15:48:39 +0000</pubDate> 
<guid>http://www.aslibra.com/blog/read.php/486.htm</guid> 
<description>
<![CDATA[ 
	看过FlashK写的《<a href="http://bbs.blueidea.com/thread-2697271-1-1.html" target="_blank">关于Flash AS2 中的拍照图片传输量太大的解决思路</a>》，也想加一个算法。<br/>我们都说无损压缩吧，保留点阵数据。<br/>此法压缩的数据已经接近BMP格式的图片大小，我的机器花费大约1秒处理200*200的图片，比未压缩的字符的压缩比率为50%。具体图片比较黑暗则压缩更好。<br/><br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content">未压缩文本：295k<br/>压缩文本：143k<br/>BMP图片(200*200一样的图片)：117k</div></div><br/><br/><strong>压缩结果类似：</strong><br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content">200,200='c,'c,'c,'c,'c,Eg,'c,'c,'c,'c,'c,'c,'c,'c,'c,'c,'c,'c,'c,'c,'c,'c,Eg,Eg,Eg,'c,'c,'c,'c,'c,'c,'c,'c,'c,'c,'c,'c,'c,'c,'c,'c,R9,R9,R9,R9,0i,0i,0i,0i,0i,0i,0i,0i,0i,0i,0i,0i,Eg,Q9,)&#123;,)c,0i,Eg,Eg,0i,0i,0i,R9,R9,R9,R9,)c,/E,'c,0i,R9,0i,R9,R9,R9,R9,R9,R9,0i,)c,)c,R9,R9,R9,R9,R9,R9,R9,R9,R9,R9,EE,)</div></div><br/><br/>我这里的思维是用自定义的进制来处理数字压缩的问题。<br/><br/><strong>原理：</strong>按字符来算，一个数字用2进制是最长的，用十进制则更短，用16进制更短，那用尽量大的进制则字符越少。<br/><br/><strong>进阶压缩算法：</strong>选择起始点算法，分段压缩，邻近同样字符用范围数表示。<br/><br/>先说一下本次的算法：<br/><br/><div class="code"><br/>//program by hqlulu<br/>//www.aslibra.com<br/><br/>import flash.display.BitmapData;<br/>//自定义宽和高<br/>var max_w:Number = 200;<br/>var max_h:Number = 200;<br/>var myBitmap:BitmapData = new BitmapData(max_w, max_h, true, 0x000000);<br/>myBitmap.draw(_root);<br/>view_mc.attachBitmap(myBitmap, 10);<br/>//是否压缩<br/>//我的测试数据：<br/>//true:1382 ms<br/>//false:364 ms<br/>var is_compress:Boolean = true;<br/>//<br/>//定义进制字符,在这里差不多把所有的字符用上了，用的越多压缩越好，不过选择ffffff所达到的字符数最好<br/>var code:String = &quot;0123456789qwertyuiop[]asdfghjkl;zxcvbnm./QWERTYUIOP&#123;&#125;|ASDFGHJKL:ZXCVBNM&lt;&gt;?~!@#$%^&amp;*()_+'&quot;;<br/>var code_array:Array = code.split(&quot;&quot;);<br/>//多少个字符就是多少进制了<br/>var byte:Number = code.length;<br/>function getcode(i:Number):String &#123;<br/>	//取整求余法<br/>	var return_code:String = &quot;&quot;;<br/>	while ((i=Math.ceil(i/byte))&gt;byte) &#123;<br/>		return_code += code_array[i%byte];<br/>	&#125;<br/>	return_code += code_array[i];<br/>	return return_code;<br/>&#125;<br/>//<br/>//记录的数组<br/>var p_array:Array = new Array();<br/>var timer:Number = getTimer();<br/>function save2array():Void &#123;<br/>	for (var i:Number = 0; i&lt;max_w; i++) &#123;<br/>		p_array[i] = new Array();<br/>		for (var j:Number = 0; j&lt;max_h; j++) &#123;<br/>			//这里不加判断的话，速度可以提高些<br/>			if (is_compress) &#123;<br/>				p_array[i].push(getcode(myBitmap.getPixel(i+1, j+1)));<br/>			&#125; else &#123;<br/>				p_array[i].push(myBitmap.getPixel(i+1, j+1));<br/>			&#125;<br/>		&#125;<br/>	&#125;<br/>&#125;<br/>save2array();<br/>trace(&quot;转换时间: &quot;+(getTimer()-timer)+&quot; ms&quot;);<br/>//分隔符要用那些没有做在进制字符的<br/>var my_data:String = max_w+&quot;,&quot;+max_h+&quot;=&quot;;<br/>//trace(my_data);<br/>my_data += p_array.join(&quot;,&quot;);<br/>trace(&quot;字符长度：&quot;+my_data.length);<br/>//字符长度<br/>//我的测试数据：<br/>//false:302419<br/>//true:147174<br/>//trace(my_data);<br/></div><br/><br/>执行时间不多，对于程序的有效行比较好。<br/>大家可以看一下代码的执行效果<br/><br/><strong>进阶压缩的原理：</strong><br/><br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content">'c,'c,'c,'c,'c,Eg,'c,'c,'c,'c,'c,'c,'c,'c,'c,'c,'c,'c,'c,'c,'c,'c,Eg,Eg,Eg,'c,'c,'c,'c,'c,'c,'c,'c,'c,'c,'c,'c,'c,'c,'c,'c,</div></div><br/><br/>看到上面的数据了，对于重复的点，可以考虑这样处理：<br/><br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content">'c(5),Eg,'c(10),Eg,Eg,Eg,'c(15),</div></div><br/><br/>这个算法需要再对数组处理，本人未写出，提高的压缩比率是客观的。<br/>当然&quot;()&quot;需要在后期先处理，把&quot;()&quot;的多个字符先行恢复。<br/><br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content">0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,</div></div><br/><br/>对于上面字符，可以看出来，如果相片偏暗，以黑色为基点运算就好，相片偏亮，则适宜以白色为基点运算。<br/><br/>分段压缩的算法效率不大，毕竟现在已经是三个字符表示了，如果分区间，可以用两个字符表示颜色，但是还要用一个字符表示区间。<br/><br/><br/><strong>图片压缩方法</strong><br/><br/>相邻的点的颜色一样，采用&quot;(个数)&quot;表示<br/>如果颜色相差不大，差值为n，则在二维数组中进行比较，把某些点近似为该点，这样就有更多的个数了，字符数量就更加少。
]]>
</description>
</item><item>
<link>http://www.aslibra.com/blog/read.php/388.htm</link>
<title><![CDATA[滚动区域代码分享（电子杂志常用！）]]></title> 
<author>hqlulu &lt;hqlulu@163.com&gt;</author>
<category><![CDATA[Flash]]></category>
<pubDate>Wed, 01 Nov 2006 01:58:39 +0000</pubDate> 
<guid>http://www.aslibra.com/blog/read.php/388.htm</guid> 
<description>
<![CDATA[ 
	做电子杂志经常需要做文字滚动和图片滚动，于是我编写了这个代码<br/>可以方便快捷的使用，提高工作效率<br/>我一直都在使用这个代码，比较实用，希望大家也喜欢<br/><br/>使用方法：<br/><br/>做两个按钮做滚动：up_btn,down_btn<br/>做遮罩定下显示的范围：mask_mc<br/>移动的mc：move_mc<br/>把代码贴上去就OK！！<br/><br/>我整理了一下，与大家分享<br/>会上传该fla文件，同时贴上脚本：<br/><br/>设置代码<br/><br/><div class="code">/*<br/>program &nbsp; &nbsp;: hqlulu<br/>mail &nbsp; &nbsp;: hqlulu@163.com<br/>website &nbsp; &nbsp;: http://www.aslibra.com<br/>publish &nbsp; &nbsp;: 2006-10-31<br/>*/<br/>//判断是否移动<br/>var move_it:Boolean = false;<br/>//移动方向<br/>var dir:Number = 1;<br/>//移动速度<br/>var speed:Number = 5;<br/>//按下的移动速度加倍<br/>var scale:Number = 3;<br/>//滚轮的移动速度加倍<br/>var scale_mouse:Number = 2;<br/>//设置上下的边距<br/>var margin:Number = 2;<br/>//计算移动的范围<br/>var max1:Number = mask_mc._y+margin;<br/>var min1:Number = mask_mc._y-move_mc._height+mask_mc._height-margin;<br/>//是否自动设置遮罩<br/>var is_set_mask:Boolean = false;<br/>//是否支持鼠标<br/>var is_mouse_enable:Boolean = true;<br/>//设置按钮、遮罩和移动的对象<br/>var my_move_mc:MovieClip = move_mc;<br/>var my_up_btn:Button = up_btn;<br/>var my_down_btn:Button = down_btn;<br/>var my_mask_mc:MovieClip = mask_mc;</div><br/><br/><strong>脚本代码：</strong><br/><br/><div class="code">//自动调整遮罩的xy和宽<br/>if (is_set_mask) &#123;<br/> &nbsp; &nbsp;my_mask_mc._x = my_move_mc._x;<br/> &nbsp; &nbsp;my_mask_mc._y = my_move_mc._y;<br/> &nbsp; &nbsp;my_mask_mc._width = my_move_mc._width;<br/> &nbsp; &nbsp;my_move_mc.setMask(my_mask_mc);<br/>&#125;<br/>//支持滚轮移动 &nbsp; <br/>if (is_mouse_enable) &#123;<br/> &nbsp; &nbsp;var mouseListener:Object = new Object();<br/> &nbsp; &nbsp;mouseListener.onMouseWheel = function(delta) &#123;<br/> &nbsp; &nbsp; &nbsp; &nbsp;if (delta&gt;0) &#123;<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;my_dir = 1;<br/> &nbsp; &nbsp; &nbsp; &nbsp;&#125; else &#123;<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;my_dir = -1;<br/> &nbsp; &nbsp; &nbsp; &nbsp;&#125;<br/> &nbsp; &nbsp; &nbsp; &nbsp;speed *= scale_mouse*scale;<br/> &nbsp; &nbsp; &nbsp; &nbsp;move_me();<br/> &nbsp; &nbsp; &nbsp; &nbsp;speed /= scale_mouse*scale;<br/> &nbsp; &nbsp;&#125;;<br/> &nbsp; &nbsp;Mouse.addListener(mouseListener);<br/>&#125;<br/>//给向上的按钮赋予事件 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br/>my_up_btn.onRollOver = function() &#123;<br/> &nbsp; &nbsp;move_it = true;<br/> &nbsp; &nbsp;my_dir = 1;<br/>&#125;;<br/>my_up_btn.onRollOut = function() &#123;<br/> &nbsp; &nbsp;move_it = false;<br/>&#125;;<br/>my_up_btn.onPress = function() &#123;<br/> &nbsp; &nbsp;speed *= scale;<br/>&#125;;<br/>my_up_btn.onRelease = function() &#123;<br/> &nbsp; &nbsp;speed /= scale;<br/>&#125;;<br/>my_up_btn.onReleaseOutside = function() &#123;<br/> &nbsp; &nbsp;speed /= scale;<br/> &nbsp; &nbsp;move_it = false;<br/>&#125;;<br/>//给向下的按钮赋予事件 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br/>my_down_btn.onRollOver = function() &#123;<br/> &nbsp; &nbsp;move_it = true;<br/> &nbsp; &nbsp;my_dir = -1;<br/>&#125;;<br/>my_down_btn.onRollOut = function() &#123;<br/> &nbsp; &nbsp;move_it = false;<br/>&#125;;<br/>my_down_btn.onPress = function() &#123;<br/> &nbsp; &nbsp;speed *= scale;<br/>&#125;;<br/>my_down_btn.onRelease = function() &#123;<br/> &nbsp; &nbsp;speed /= scale;<br/>&#125;;<br/>my_down_btn.onReleaseOutside = function() &#123;<br/> &nbsp; &nbsp;speed /= scale;<br/> &nbsp; &nbsp;move_it = false;<br/>&#125;;<br/>//判断是否该移动 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br/>my_move_mc.onEnterFrame = function() &#123;<br/> &nbsp; &nbsp;if (move_it) &#123;<br/> &nbsp; &nbsp; &nbsp; &nbsp;move_me();<br/> &nbsp; &nbsp;&#125;<br/>&#125;;<br/>//移动mc &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br/>function move_me() &#123;<br/> &nbsp; &nbsp;if ((my_move_mc._y+my_dir*speed)&gt;max1) &#123;<br/> &nbsp; &nbsp; &nbsp; &nbsp;my_move_mc._y = max1;<br/> &nbsp; &nbsp;&#125; else &#123;<br/> &nbsp; &nbsp; &nbsp; &nbsp;if ((my_move_mc._y+my_dir*speed)&lt;min1) &#123;<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;my_move_mc._y = min1;<br/> &nbsp; &nbsp; &nbsp; &nbsp;&#125; else &#123;<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;my_move_mc._y += my_dir*speed;<br/> &nbsp; &nbsp; &nbsp; &nbsp;&#125;<br/> &nbsp; &nbsp;&#125;<br/>&#125;</div><br/><br/>下载源文件：<a href="up/1162346304.rar" target="_blank">up/1162346304.rar</a>
]]>
</description>
</item>
</channel>
</rss>