<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title><![CDATA[动威9号-Flex、Flash技术探讨]]></title> 
<link>http://www.dv9.org/index.php</link> 
<description><![CDATA[动威9号是bearjia的私人领地，致力研究Flex、Flash、JS等技术]]></description> 
<language>zh-cn</language> 
<copyright><![CDATA[动威9号-Flex、Flash技术探讨]]></copyright>
<item>
<link>http://www.dv9.org/post/166/</link>
<title><![CDATA[flex4局域网(LAN)的P2P通讯]]></title> 
<author>bearjia &lt;admin@dv9.org&gt;</author>
<category><![CDATA[Flex相关]]></category>
<pubDate>Sun, 29 Aug 2010 02:35:15 +0000</pubDate> 
<guid>http://www.dv9.org/post/166/</guid> 
<description>
<![CDATA[ 
	flash在局域网（LAN）建立P2P连接?<br/>其实flash原生就有个IP-only多播！<br/>多播其实是个简单的步骤。<br/><br/>建立一个IP多播连接。指定连接字符串“rtmfp”. 注意，这种方式不能用于一对一通讯。所以不需要设置NetStream为DIRECT_CONNECTIONS，但可以进行RTMFP Group的所有操作。 也就是说，只能群发信息。<br/><br/>没错，就是这个了<div class="code">netConnection.connect(&quot;rtmpf:&quot;);</div><br/><br/>一旦连接成功（返回NetConnection.Connect.Success）就可以通过GroupSpecifier建立NetGroup或NetStream.<br/>再设置ipMulticastMemberUpdatesEnabled为true，负责点与点间建立本地的连接，各点使用多播地址和相应端口调用addIPMulticastAddress方法。<br/><br/>多播地址至少以224为起始值，而端口要大于1024 - 即：224.0.0.0:1024<br/>端口越高越好 —— 唯一性。<br/><br/>废话不多说，下面就是完整的代码。<br/><br/><div class="code">&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;<br/>&lt;s:Application xmlns:fx=&quot;http://ns.adobe.com/mxml/2009&quot; <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; xmlns:s=&quot;library://ns.adobe.com/flex/spark&quot; <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; xmlns:mx=&quot;library://ns.adobe.com/flex/mx&quot; applicationComplete=&quot;connect()&quot;&gt;<br/>&nbsp;&nbsp;&lt;fx:Declarations&gt;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&lt;!-- Place non-visual elements (e.g., services, value objects) here --&gt;<br/>&nbsp;&nbsp;&lt;/fx:Declarations&gt;<br/>&nbsp;&nbsp;<br/>&nbsp;&nbsp;&lt;fx:Script&gt;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&lt;!&#91;CDATA&#91;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;private var nc:NetConnection;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;private var group:NetGroup;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#91;Bindable&#93;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;private var userName:String;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#91;Bindable&#93;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;private var connected:Boolean = false;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;private function connect():void&#123;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;nc = new NetConnection();<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;nc.addEventListener(NetStatusEvent.NET_STATUS, netStatus);<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;nc.connect(&quot;rtmfp:&quot;);<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;userName = &quot;user&quot;+Math.round(Math.random()*1000);<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#125;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;private function netStatus(event:NetStatusEvent):void&#123;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;writeText(event.info.code);<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;switch(event.info.code)&#123;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;case &quot;NetConnection.Connect.Success&quot;:<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;setupGroup();<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;break;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;case &quot;NetGroup.Connect.Success&quot;:<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;connected = true;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;break;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;case &quot;NetGroup.Posting.Notify&quot;:<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;receiveMessage(event.info.message)<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;break;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#125;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#125;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;private function setupGroup():void&#123;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var groupspec:GroupSpecifier = new GroupSpecifier(&quot;myGroup/groupOne&quot;);<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;groupspec.postingEnabled = true;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;groupspec.ipMulticastMemberUpdatesEnabled = true;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;groupspec.addIPMulticastAddress(&quot;225.225.0.1:30303&quot;);<br/><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;group = new NetGroup(nc,groupspec.groupspecWithAuthorizations());<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;group.addEventListener(NetStatusEvent.NET_STATUS,netStatus);<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#125;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;private function sendMessage(txt:String):void&#123;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var message:Object = new Object();<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;message.text = txt;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;message.sender = group.convertPeerIDToGroupAddress(nc.nearID);<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;message.userName = txtUser.text;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;group.post(message);<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;receiveMessage(message);<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#125;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;public function receiveMessage(message:Object):void&#123;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;writeText(message.userName+&quot;: &quot;+message.text);<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#125;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;private function writeText(txt:String):void&#123;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;txtHistory.text += txt+&quot;&#92;n&quot;;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#125;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;protected function btnSend_clickHandler(event:MouseEvent):void<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#123;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sendMessage( txtMessage.text );<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#125;<br/><br/>&nbsp;&nbsp;&nbsp;&nbsp;&#93;&#93;&gt;<br/>&nbsp;&nbsp;&lt;/fx:Script&gt;<br/>&nbsp;&nbsp;&lt;s:TextInput text=&quot;&#123;userName&#125;&quot; x=&quot;10&quot; bottom=&quot;10&quot; id=&quot;txtUser&quot;/&gt;<br/>&nbsp;&nbsp;&lt;s:TextInput left=&quot;146&quot; right=&quot;88&quot; bottom=&quot;10&quot; id=&quot;txtMessage&quot; enter=&quot;btnSend_clickHandler(null)&quot;/&gt;<br/>&nbsp;&nbsp;&lt;s:TextArea left=&quot;10&quot; right=&quot;10&quot; top=&quot;75&quot; bottom=&quot;40&quot; id=&quot;txtHistory&quot;/&gt;<br/>&nbsp;&nbsp;&lt;s:Button enabled=&quot;&#123;connected&#125;&quot; label=&quot;Send&quot; bottom=&quot;10&quot; right=&quot;10&quot; click=&quot;btnSend_clickHandler(event)&quot; id=&quot;btnSend&quot;/&gt;<br/><br/><br/>&lt;/s:Application&gt;<br/></div><br/>Tags - <a href="http://www.dv9.org/tags/flex4/" rel="tag">flex4</a> , <a href="http://www.dv9.org/tags/p2p%25E9%2580%259A%25E8%25AE%25AF/" rel="tag">p2p通讯</a>
]]>
</description>
</item><item>
<link>http://www.dv9.org/post/163/</link>
<title><![CDATA[今天拿flex4做了2个表单系统]]></title> 
<author>bearjia &lt;admin@dv9.org&gt;</author>
<category><![CDATA[Flex相关]]></category>
<pubDate>Wed, 25 Aug 2010 13:49:55 +0000</pubDate> 
<guid>http://www.dv9.org/post/163/</guid> 
<description>
<![CDATA[ 
	一直就出处于忙碌的状态<br/>用flex4做了个留言和报名的小东西<br/><a href="http://www.dv9.org/attachment.php?fid=146" target="_blank"><img src="http://www.dv9.org/attachment.php?fid=146" class="insertimage" alt="点击在新窗口中浏览此图片" title="点击在新窗口中浏览此图片" border="0"/></a><br/>简单的3个字段，蕴含着无穷的魅力。<br/><a href="http://www.dv9.org/attachment.php?fid=147" target="_blank"><img src="http://www.dv9.org/attachment.php?fid=147" class="insertimage" alt="点击在新窗口中浏览此图片" title="点击在新窗口中浏览此图片" border="0"/></a><br/><a href="http://www.dv9.org/attachment.php?fid=148" target="_blank"><img src="http://www.dv9.org/attachment.php?fid=148" class="insertimage" alt="点击在新窗口中浏览此图片" title="点击在新窗口中浏览此图片" border="0"/></a><br/>用了个传说中的TabNavigator弄了个选项卡，然后打包成了EXE文件，在桌面上直接看情况。<br/><a href="http://www.dv9.org/attachment.php?fid=149" target="_blank"><img src="http://www.dv9.org/attachment.php?fid=149" class="insertimage" alt="点击在新窗口中浏览此图片" title="点击在新窗口中浏览此图片" border="0"/></a><br/>报名依旧银弹～<br/>Tags - <a href="http://www.dv9.org/tags/flex4/" rel="tag">flex4</a> , <a href="http://www.dv9.org/tags/%25E6%258A%25A5%25E5%2590%258D%25E7%25B3%25BB%25E7%25BB%259F/" rel="tag">报名系统</a> , <a href="http://www.dv9.org/tags/%25E7%2595%2599%25E8%25A8%2580%25E6%259D%25BF/" rel="tag">留言板</a>
]]>
</description>
</item><item>
<link>http://www.dv9.org/post/69/</link>
<title><![CDATA[flex来加载XML播放FLV视频]]></title> 
<author>bearjia &lt;admin@dv9.org&gt;</author>
<category><![CDATA[Flex相关]]></category>
<pubDate>Fri, 21 May 2010 15:50:12 +0000</pubDate> 
<guid>http://www.dv9.org/post/69/</guid> 
<description>
<![CDATA[ 
	用flash来做flv播放器那可是相当的简单，无赖近日自己的一个项目需要在flex框架里面嵌入视频播放，没办法，也做一个来耍耍<br/>下面为主程序：<br/><div class="code">&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;<br/>&lt;mx:Application xmlns:mx=&quot;http://www.adobe.com/2006/mxml&quot; layout=&quot;vertical&quot;<br/>&nbsp;&nbsp; backgroundGradientAlphas=&quot;&#91;1.0, 1.0&#93;&quot; backgroundGradientColors=&quot;&#91;#FFFFFF, #000000&#93;&quot;<br/>&nbsp;&nbsp; creationComplete=&quot;service.send()&quot;&gt;<br/><br/>&lt;mx:Style&gt;<br/>&nbsp;&nbsp;ComboBox &#123;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; color: #000000;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; selectionColor: #ffffff;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; rollOverColor: #cccccc;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; textRollOverColor: #000000;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; themeColor: #000000;<br/>&nbsp;&nbsp;&#125;<br/>&lt;/mx:Style&gt;<br/><br/>&lt;mx:Script&gt;<br/>&nbsp;&nbsp;&lt;!&#91;CDATA&#91;<br/>&nbsp;&nbsp;&nbsp;&nbsp;import mx.collections.ArrayCollection;<br/>&nbsp;&nbsp;&nbsp;&nbsp;import mx.rpc.events.ResultEvent;<br/><br/>&nbsp;&nbsp;&nbsp;&nbsp;&#91;Bindable&#93;<br/>&nbsp;&nbsp;&nbsp;&nbsp;private var videos : ArrayCollection;<br/><br/>&nbsp;&nbsp;&nbsp;&nbsp;private function resultHandler(event:ResultEvent):void&#123;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;videos = event.result.videolist.video;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&#125;<br/><br/>&nbsp;&nbsp;&nbsp;&nbsp;private function playVideo(event:Event):void&#123;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;videoDisplay.source = &quot;assets/&quot; + event.currentTarget.selectedItem.src;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&#125;<br/><br/>&nbsp;&nbsp;&#93;&#93;&gt;<br/>&lt;/mx:Script&gt;<br/><br/>&nbsp;&nbsp;&lt;mx:HTTPService id=&quot;service&quot; url=&quot;data.xml&quot; result=&quot;resultHandler(event)&quot;/&gt;<br/><br/>&nbsp;&nbsp;&lt;mx:VideoDisplay id=&quot;videoDisplay&quot; width=&quot;320&quot; height=&quot;240&quot;/&gt;<br/>&nbsp;&nbsp;&lt;mx:ComboBox prompt=&quot;Select a video ...&quot; dataProvider=&quot;&#123;videos&#125;&quot;<br/>&nbsp;&nbsp;&nbsp;&nbsp;labelField=&quot;title&quot; change=&quot;playVideo(event)&quot; width=&quot;165&quot;/&gt;<br/><br/>&lt;/mx:Application&gt;</div><br/><br/>外部XML文件：<br/><div class="code">&lt;?xml version=&quot;1.0&quot;?&gt;<br/>&lt;videolist&gt;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&lt;video&gt;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;src&gt;1.flv&lt;/src&gt;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;title&gt;这个是什么呢&lt;/title&gt;<br/>&nbsp;&nbsp;&lt;/video&gt;<br/>&nbsp;&nbsp;&lt;video&gt;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;src&gt;2.flv&lt;/src&gt;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;title&gt;这个是什么呢&lt;/title&gt;<br/>&nbsp;&nbsp;&lt;/video&gt;<br/>&nbsp;&nbsp;&lt;video&gt;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;src&gt;3.flv&lt;/src&gt;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;title&gt;这个是什么呢&lt;/title&gt;<br/>&nbsp;&nbsp;&lt;/video&gt;<br/>&lt;/videolist&gt;</div><br/>Tags - <a href="http://www.dv9.org/tags/flex/" rel="tag">flex</a> , <a href="http://www.dv9.org/tags/flv/" rel="tag">flv</a> , <a href="http://www.dv9.org/tags/xml/" rel="tag">xml</a>
]]>
</description>
</item><item>
<link>http://www.dv9.org/post/51/</link>
<title><![CDATA[学习LCCS 第三步]]></title> 
<author>bearjia &lt;admin@dv9.org&gt;</author>
<category><![CDATA[Flex相关]]></category>
<pubDate>Sat, 08 May 2010 02:28:30 +0000</pubDate> 
<guid>http://www.dv9.org/post/51/</guid> 
<description>
<![CDATA[ 
	好吧 前面也了解了LCCS的管理<br/>现在弄个LCCS聊天室、文档协作的实例来耍耍<br/>在flex中新建个项目 并引用LCCS SDK中的SWC 在SDK中的lib文件夹中 有flash9、flash10、flash10.1等各个版本<br/><div class="code">&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;<br/>&lt;mx:Application xmlns:mx=&quot;http://www.adobe.com/2006/mxml&quot; layout=&quot;absolute&quot; minWidth=&quot;955&quot; minHeight=&quot;600&quot; xmlns:rtc=&quot;AfcsNameSpace&quot;&gt;<br/>&nbsp;&nbsp;&lt;mx:Script&gt;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&lt;!&#91;CDATA&#91;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;import mx.controls.Alert;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;public function onClick(event:Event) : void<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#123;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;auth.userName = username.text;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cSession.login();<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#125;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;public function onAuthFailure(event:Event) : void<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#123;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Alert.show(&#039;………………&#039;);<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#125;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;public function onAuthSuccess(event:Event) : void<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#123;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;vs.selectedIndex = 1;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#125;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&#93;&#93;&gt;<br/>&nbsp;&nbsp;&lt;/mx:Script&gt;<br/>&nbsp;&nbsp;&lt;rtc:AdobeHSAuthenticator id=&quot;auth&quot; authenticationSuccess=&quot;onAuthSuccess(event);&quot; authenticationFailure=&quot;onAuthFailure(event);&quot; /&gt;<br/>&nbsp;&nbsp;&lt;mx:ViewStack id=&quot;vs&quot; width=&quot;100%&quot; height=&quot;100%&quot;&gt;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&lt;mx:VBox width=&quot;100%&quot; height=&quot;100%&quot; verticalAlign=&quot;middle&quot; horizontalAlign=&quot;center&quot;&gt;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;mx:TextInput id=&quot;username&quot; text=&quot;Username&quot; click=&quot;username.text = &#039;&#039;&quot; /&gt;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;mx:Button id=&quot;btn&quot; label=&quot;Login&quot; click=&quot;onClick(event);&quot; /&gt;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&lt;/mx:VBox&gt;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&lt;rtc:ConnectSessionContainer id=&quot;cSession&quot; authenticator=&quot;&#123;auth&#125;&quot; roomURL=&quot;http://connectnow.acrobat.com/gggg/mybox/&quot; autoLogin=&quot;false&quot;&gt;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;rtc:Roster id=&quot;roster&quot; width=&quot;200&quot; height=&quot;200&quot; /&gt;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;rtc:SharedWhiteBoard id=&quot;wb&quot; width=&quot;400&quot; height=&quot;400&quot; x=&quot;205&quot; /&gt;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;rtc:SimpleChat id=&quot;chat&quot; width=&quot;200&quot; height=&quot;200&quot; y=&quot;205&quot; /&gt;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&lt;/rtc:ConnectSessionContainer&gt;<br/>&nbsp;&nbsp;&lt;/mx:ViewStack&gt;<br/>&lt;/mx:Application&gt;</div><br/>其中roomURL就是你在afcs申请的帐号中的房间地址了<br/>Roster会返回在房间中的用户列表<br/>SharedWhiteBoard是一个类似涂鸦板的玩意<br/>SimpleChat是一个简单的聊天控件<br/>每个控件后的id都很重要 在本地的lccs管理中都可以看到<br/><br/>恩 这个例子后就基本了解了LCCS的用法<br/>Tags - <a href="http://www.dv9.org/tags/lccs/" rel="tag">lccs</a> , <a href="http://www.dv9.org/tags/roomurl/" rel="tag">roomurl</a> , <a href="http://www.dv9.org/tags/roster/" rel="tag">roster</a> , <a href="http://www.dv9.org/tags/sharedwhiteboard/" rel="tag">sharedwhiteboard</a> , <a href="http://www.dv9.org/tags/simplechat/" rel="tag">simplechat</a>
]]>
</description>
</item><item>
<link>http://www.dv9.org/post/50/</link>
<title><![CDATA[学习LCCS 第二步]]></title> 
<author>bearjia &lt;admin@dv9.org&gt;</author>
<category><![CDATA[Flex相关]]></category>
<pubDate>Fri, 07 May 2010 01:53:26 +0000</pubDate> 
<guid>http://www.dv9.org/post/50/</guid> 
<description>
<![CDATA[ 
	继续LCCS的学习<br/>如下图：<br/><a href="http://www.dv9.org/attachment.php?fid=21" target="_blank"><img src="http://www.dv9.org/attachment.php?fid=21" class="insertimage" alt="点击在新窗口中浏览此图片" title="点击在新窗口中浏览此图片" border="0"/></a><br/>选择第一项：Room Console<br/>点击ADD按钮 添加如下信息<br/><a href="http://www.dv9.org/attachment.php?fid=22" target="_blank"><img src="http://www.dv9.org/attachment.php?fid=22" class="insertimage" alt="点击在新窗口中浏览此图片" title="点击在新窗口中浏览此图片" border="0"/></a><br/>完成后点击<br/><a href="http://www.dv9.org/attachment.php?fid=23" target="_blank"><img src="http://www.dv9.org/attachment.php?fid=23" class="insertimage" alt="点击在新窗口中浏览此图片" title="点击在新窗口中浏览此图片" border="0"/></a><br/><br/>就可以进入协作管理界面了<br/>在里面就可以管理用户的权限 以及分配文件 查看流量 访问日志等信息<br/>如图所示：<br/><a href="http://www.dv9.org/attachment.php?fid=24" target="_blank"><img src="http://www.dv9.org/attachment.php?fid=24" class="insertimage" alt="点击在新窗口中浏览此图片" title="点击在新窗口中浏览此图片" border="0"/></a><br/>Tags - <a href="http://www.dv9.org/tags/lccs/" rel="tag">lccs</a>
]]>
</description>
</item><item>
<link>http://www.dv9.org/post/49/</link>
<title><![CDATA[学习LCCS 第一步]]></title> 
<author>bearjia &lt;admin@dv9.org&gt;</author>
<category><![CDATA[Flex相关]]></category>
<pubDate>Thu, 06 May 2010 16:10:15 +0000</pubDate> 
<guid>http://www.dv9.org/post/49/</guid> 
<description>
<![CDATA[ 
	LCCS全称Adobe LiveCycle Collaboration Service译过来就是Adobe LiveCycle协作服务<br/>LCCS能干什么？<br/><br/>我不介绍些官方说的那些功能了，反正我现在只想把LCCS拿来做个小型聊天室。像某某博客上的那种，但是被加密了，所以自己零开始。<br/><br/>首先得去https://afcs.acrobat.com上注册个帐号<br/>登录后在里面点击下载SDK即可 我装了AIR所以直接被安装了<br/><br/>对 就是LCCS SDK Navigator<br/><br/>LCCS SDK Navigator这玩意很牛逼 几乎把LCCS的所有都做在了里面 但是俺鸟语很烂<br/><br/>直接来连接下刚刚注册的那帐号<br/>LCCS SDK Navigator打开后 点击左侧的选项卡“开发工具”选择3个按钮中的“ROOM Console”<br/><br/>待续……<br/>Tags - <a href="http://www.dv9.org/tags/lccs/" rel="tag">lccs</a> , <a href="http://www.dv9.org/tags/adobe/" rel="tag">adobe</a> , <a href="http://www.dv9.org/tags/livecycle/" rel="tag">livecycle</a> , <a href="http://www.dv9.org/tags/collaboration/" rel="tag">collaboration</a> , <a href="http://www.dv9.org/tags/service/" rel="tag">service</a>
]]>
</description>
</item><item>
<link>http://www.dv9.org/post/38/</link>
<title><![CDATA[flex通过amfphp连接sqlite(一)]]></title> 
<author>bearjia &lt;admin@dv9.org&gt;</author>
<category><![CDATA[Flex相关]]></category>
<pubDate>Tue, 12 Jan 2010 09:18:18 +0000</pubDate> 
<guid>http://www.dv9.org/post/38/</guid> 
<description>
<![CDATA[ 
	早就想写篇flex与flash怎样读取sqlite数据库的文章了<br/>网上大多都是flex的AIR中直接使用SQL类去连接的例子<br/>咱做的是RIA<br/>所以我就上这方面的东西<br/><br/>Flex 3.4(4.0其实也差不多)，amfphp 1.9(唉，竟然是绝唱了),as3,sqlite 3.0,PHP 5.26<br/><br/>FLEX------------------------------------------------------------------------------------------<br/><div class="code">&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;<br/>&lt;mx:Application xmlns:mx=&quot;http://www.adobe.com/2006/mxml&quot; layout=&quot;absolute&quot; horizontalAlign=&quot;center&quot; initialize=&quot;init();&quot; &gt;<br/>&lt;mx:Script&gt;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&lt;!&#91;CDATA&#91;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;import mx.utils.ArrayUtil; <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;import mx.collections.ArrayCollection;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;import mx.controls.Alert;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;import flash.events.Event;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;import flash.events.MouseEvent;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;import mx.events.CloseEvent;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;import mx.rpc.events.ResultEvent; <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;import mx.rpc.events.FaultEvent;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;import mx.managers.PopUpManager;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#91;Bindable&#93; <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;private var sqlitedata:ArrayCollection;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#91;Bindable&#93;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;public var news:News;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;private function init():void<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#123;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;myamf.getNews.send();<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#125;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;private function getData(evt:ResultEvent):void<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#123;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sqlitedata = new ArrayCollection(ArrayUtil.toArray(evt.result));<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#125;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;private function onFault(evt:FaultEvent):void<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#123;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Alert.show(evt.fault.faultString, evt.fault.faultCode.toString());<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#125;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;private function onSelected(evt:Event):void<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#123;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;news= News(DataGrid(evt.target).selectedItem);<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#125;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&#93;&#93;&gt;<br/>&nbsp;&nbsp;&lt;/mx:Script&gt;<br/>&nbsp;&nbsp;<br/>&nbsp;&nbsp;&lt;mx:RemoteObject id=&quot;getNews&quot; source=&quot;NewsClass&quot;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; destination=&quot;AMFPHP&quot; fault=&quot;onFault(event)&quot; showBusyCursor=&quot;false&quot;&gt;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&lt;mx:method name=&quot;getNews&quot; result=&quot;getData(event)&quot; fault=&quot;onFault(event)&quot; /&gt; <br/>&nbsp;&nbsp;&lt;/mx:RemoteObject&gt; <br/>&nbsp;&nbsp;<br/>&nbsp;&nbsp;&lt;mx:DataGrid id=&quot;dg&quot;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; dataProvider=&quot;&#123;sqlitedata&#125;&quot; width=&quot;600&quot; height=&quot;300&quot; horizontalCenter=&quot;0&quot; y=&quot;0&quot; editable=&quot;false&quot; enabled=&quot;true&quot; variableRowHeight=&quot;true&quot;&gt;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&lt;mx:columns&gt;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;mx:DataGridColumn dataField=&quot;id&quot; headerText=&quot;编号&quot; resizable=&quot;false&quot; width=&quot;40&quot; textAlign=&quot;center&quot;/&gt;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;mx:DataGridColumn dataField=&quot;name&quot; headerText=&quot;标题&quot; resizable=&quot;false&quot; sortable=&quot;false&quot; width=&quot;560&quot;/&gt;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&lt;/mx:columns&gt;<br/>&nbsp;&nbsp;&lt;/mx:DataGrid&gt;<br/>&nbsp;&nbsp; <br/>&lt;/mx:Application&gt;<br/></div><br/><br/>再来创建个类<br/><br/><div class="code">package<br/>&#123;<br/>&nbsp;&nbsp;&#91;RemoteClass(alias = &quot;NewsClass&quot;)&#93;<br/>&nbsp;&nbsp;&#91;Bindable&#93;<br/>&nbsp;&nbsp;public class News<br/>&nbsp;&nbsp;&#123;<br/>&nbsp;&nbsp;&nbsp;&nbsp;public var id:String;<br/>&nbsp;&nbsp;&nbsp;&nbsp;public var name:String;<br/>&nbsp;&nbsp;&nbsp;&nbsp;<br/>&nbsp;&nbsp;&nbsp;&nbsp;public function News()<br/>&nbsp;&nbsp;&nbsp;&nbsp;&#123;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&#125;<br/>&nbsp;&nbsp;&#125;<br/>&#125;</div><br/><br/>基本上完成？no，还要给flex配置个参数，就像c#的config文件一样，这个很重要，不能忘（不过似乎可以用的别的方法）<br/><br/><div class="code"><br/>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;<br/>&lt;services-config&gt;<br/>&nbsp;&nbsp;&lt;services&gt;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&lt;service id=&quot;amfphp-flashremoting-service&quot; class=&quot;flex.messaging.services.RemotingService&quot; messageTypes=&quot;flex.messaging.messages.RemotingMessage&quot;&gt;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;destination id=&quot;AMFPHP&quot;&gt;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;channels&gt;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;channel ref=&quot;my-amfphp&quot;/&gt;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/channels&gt;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;properties&gt;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;source&gt;*&lt;/source&gt;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/properties&gt;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/destination&gt;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&lt;/service&gt;<br/>&nbsp;&nbsp;&lt;/services&gt;<br/>&nbsp;&nbsp;&lt;channels&gt;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&lt;channel-definition id=&quot;my-amfphp&quot; class=&quot;mx.messaging.channels.AMFChannel&quot;&gt;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;endpoint uri=&quot;http://localhost/gateway.php&quot; class=&quot;flex.messaging.endpoints.AMFEndpoint&quot;/&gt;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&lt;/channel-definition&gt;<br/>&nbsp;&nbsp;&lt;/channels&gt;<br/>&lt;/services-config&gt;<br/></div><br/><br/>http://localhost/gateway.php的路径必须正确<br/><br/>下面就来弄amfphp那边的东西<br/>NewsClass.php<br/><div class="code">&lt;?php<br/>include_once (&quot;X.php&quot;);<br/>class NewsClass&#123;<br/>public function getNews ()<br/>&nbsp;&nbsp;&nbsp;&nbsp;&#123;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$db = new PDO(&quot;sqlite:news.db&quot;);<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$conn = $db-&gt;prepare(&#039;select * from news&#039;);<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$conn-&gt;execute();<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$result = $conn-&gt;fetchAll();<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$arr = array();<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for ($i = 0; $i &lt; count($result); $i++)<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#123;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$news= new X();<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$news-&gt;id = $result&#91;$i&#93;&#91;0&#93;;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$news-&gt;name = $result&#91;$i&#93;&#91;1&#93;;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$arr&#91;&#93; = $tongji;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#125;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$conn = null;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$db = null;<br/> <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return $arr;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&#125;<br/>&#125;&gt;<br/></div><br/><br/>X.php<br/><div class="code">&lt;?php<br/>class X <br/>&#123;<br/>&nbsp;&nbsp;&nbsp;&nbsp;public $id;<br/>&nbsp;&nbsp;&nbsp;&nbsp;public $name;<br/>&nbsp;&nbsp;&nbsp;&nbsp;public $_explicitType = &quot;News&quot;;//对应AS中的类名<br/>&#125;</div><br/><br/><br/>接下来还得创建个SQLITE的数据库才行<br/>不会用命令创建数据库的话可以去下个SQLiteManager，而且支持中文<br/><br/>数据库名:news.db<br/>表名:news<br/>字段:id&nbsp;&nbsp;name<br/><br/>然后把数据放到和php类相同的目录下就可以了<br/><br/>编译 运行 看到了什么？<br/>对 什么都没有<br/>因为没添加数据的原因……期待下篇的sqlite的写入<br/>Tags - <a href="http://www.dv9.org/tags/flex3/" rel="tag">flex3</a> , <a href="http://www.dv9.org/tags/amfphp/" rel="tag">amfphp</a> , <a href="http://www.dv9.org/tags/sqlite/" rel="tag">sqlite</a> , <a href="http://www.dv9.org/tags/pdo/" rel="tag">pdo</a> , <a href="http://www.dv9.org/tags/php/" rel="tag">php</a>
]]>
</description>
</item><item>
<link>http://www.dv9.org/post/34/</link>
<title><![CDATA[flex4 Flash Builder4 放大缩小裁剪图片]]></title> 
<author>bearjia &lt;admin@dv9.org&gt;</author>
<category><![CDATA[Flex相关]]></category>
<pubDate>Fri, 23 Oct 2009 15:31:32 +0000</pubDate> 
<guid>http://www.dv9.org/post/34/</guid> 
<description>
<![CDATA[ 
	拿着网上一位仁兄的flex3代 改了下<br/><br/><div class="code">&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;<br/>&lt;s:Application contentCreationComplete=&quot;initApp()&quot; xmlns:fx=&quot;http://ns.adobe.com/mxml/2009&quot; <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; xmlns:s=&quot;library://ns.adobe.com/flex/spark&quot; <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; xmlns:mx=&quot;library://ns.adobe.com/flex/halo&quot; minWidth=&quot;1024&quot; minHeight=&quot;768&quot;&gt;<br/>&nbsp;&nbsp;&lt;fx:Script&gt;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&lt;!&#91;CDATA&#91;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;import mx.controls.Alert;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;import flash.events.ProgressEvent;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;import flash.events.MouseEvent;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;import flash.geom.Point;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;import mx.controls.Image;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;import mx.graphics.codec.JPEGEncoder;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;import flash.display.BitmapData;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;import flash.display.Bitmap;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;private var oldY:Number;//记录  上一次停留的y坐 值<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;private var oldX:Number;//记录  上一次停留的x坐 值<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;public var ratio:Number;//记录图片的宽高比<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;public var oldWidth:Number;//记录放缩前的图片宽<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/*要保证图片在放缩过程之中不会乱跑，就必须锁定图片的中心点*/<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;private var newCY:Number;//当对图片进行放大缩小时，记录图片中心点的x坐 值。<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;private var newCX:Number;//当对图片进行放大缩小时，记录图片中心点的y坐 值。<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;private var cover_X:Number;//当创建一个矩形来截取图片时，此变量表示矩形位置的x坐 值。<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;private var cover_Y:Number;//当创建一个矩形来截取图片时，此变量表示矩形位置的y坐 值。<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/*创建完程序之后执行的初始化*/<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;internal function initApp():void&#123; <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;img.source=&quot;xxx.jpg&quot;; <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#125; <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/*当图片正在 载的时候执行此方法*/<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;internal function showProcess(event:ProgressEvent):void&#123; <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var loaded:Number=event.bytesLoaded; <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var total:Number=event.bytesTotal; <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var p:Number=Math.floor(loaded/total*100); <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;tip_txt.text=&quot;正在 载图片:&quot;+p; <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#125;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/*当图片 载完成之后执行此方法*/&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;internal function initImg():void&#123; <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;tip_txt.text=&quot;图片 载完毕！&quot;;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ratio=img.contentHeight/img.contentWidth;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;oldWidth=img.contentWidth;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cover_X=cover.x;//把截图的矩形定位到中间，即现在与cover重合<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cover_Y=cover.y;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;newCY=img.contentHeight/2;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;newCX=img.contentWidth/2;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//drawCover();<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#125;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/**/<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;private function onMouseMove(event:MouseEvent):void&#123;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(event.buttonDown)&#123;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var x:Number = event.stageX - oldX;//  x轴的偏移量<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var y:Number = event.stageY - oldY;//  y轴的偏移量<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;oldX = event.stageX;//  现在的x坐 值<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;oldY = event.stageY;//  现在的y坐 值&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;img.move(img.x + x,img.y + y);//改变图片的x和y值，实现图片移动<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//由于图片 载进来的时候注册点都是在父层的左上角，这是不会改变的。我们所看到的图片移动只是图片坐 在平移。<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//但是我们创建的矩形框与我们对图片位置的看法是不一 的，在它的眼中看到并不是我们移动后的图片，不管我们怎么移动，它看到的都是在左上角没有动的图片。<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//虽然这 图片在我们看来不存在，但是矩形框会记得这 图片在左上角的 子（如果这 图片被放缩，它也会 据实际比例对它眼中的左上角的图片进行相应的放缩）。<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//当我们移动图片到中间的cover时，矩形框此时的坐 并没有改变，除非我们 据移动的情况，来给矩形框设定相应的值。<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cover_X -= x;//为什么用减号呢，这是 为如果我们把图片从左向右移动到cover中，那么对应的矩形如果想找到和cover中一 的像 集合，就必须向左移动， 为矩形<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//眼中的图片不会跟着我们也向右平移，所以只有矩形向左平移才能找到相应的像 集合。所以x坐 值就得减，而不是 。<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cover_Y -= y;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;newCX=img.x+img.width/2;//当滑动图片到一个位置，计算出此时图片的中心点的x坐 值，如果放缩图片，则让此坐 不变。<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;newCY=img.y+img.height/2;//当滑动图片到一个位置，计算出此时图片的中心点的y坐 值，如果放缩图片，则让此坐 不变。<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//drawCover();<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#125;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#125;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;private function onMouseDown(event:MouseEvent):void&#123;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;oldX = event.stageX;//在  按下，但未滑动之前记录  的位置坐 <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;oldY = event.stageY;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#125;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;internal function hsChange(target:DisplayObject):void&#123;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var xx:Number=img.x;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var yy:Number=img.y;//这里的xx和yy相当与图片为移动之前的坐 <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;img.x=newCX-(hsval.value*oldWidth)/2;//图片放缩时，图片的中心点不变，变的是图片的左顶点的坐 <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;img.y=newCY-(hsval.value*oldWidth*ratio)/2;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;img.width=hsval.value*oldWidth;//图片放缩时改变图片的宽<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;img.height=img.width*ratio;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cover_X = cover_X-(img.x-xx);<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cover_Y = cover_Y-(img.y-yy);//这两句的意思与图片移动一 。&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;//drawCover();<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#125;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;private function drawCover():void<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#123;&nbsp;&nbsp;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//创建一个矩形区域，来截取相片，在此之前我们已经虚构了一个矩形，现在就相当于把这个虚构的矩形弄成真的。<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var rect:Rectangle = new Rectangle(cover_X,cover_Y,cover.width,cover.height);<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//var bmd:BitmapData = (img.content as Bitmap).bitmapData;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//创建了一个位图<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var bmd:BitmapData = new BitmapData(img.width,img.height,false,0);<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//把图片在父层的左上角画出来（如果图片已经被放缩，就画放缩之后的,这也就是虚构矩形眼中的那 我们看不见的图片）。<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;bmd.draw(img,null,null,null,null,false); <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//创建一个与矩形一 大小的位图&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var bmd2:BitmapData = new BitmapData(rect.width,rect.height);<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var point:Point = new Point(0,0); <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//从bmd的位图中复制rect位置，rect大小的矩形区域，赋给bmd2,在bmd2中的起始点是point&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;bmd2.copyPixels(bmd,rect,point,null,null,false);<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/*cover.graphics.beginBitmapFill(bmd2);<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cover.graphics.drawRect(0,0,rect.width,rect.height);<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cover.graphics.endFill();*/<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//将bmd2的像 数据填充到画布can3中。<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;can3.graphics.beginBitmapFill(bmd2);<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;can3.graphics.drawRect(0,0,rect.width,rect.height);<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;can3.graphics.endFill();<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#125;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/* <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;public function takeSnapshot(b:BitmapData) :void<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#123;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var jpegenc:JPEGEncoder=new JPEGEncoder(80);<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var imgByteArray:ByteArray=jpegenc.encode(b);<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#125;*/<br/>&nbsp;&nbsp;&nbsp;&nbsp;&#93;&#93;&gt;<br/>&nbsp;&nbsp;&lt;/fx:Script&gt;<br/>&nbsp;&nbsp;&lt;fx:Declarations&gt;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&lt;!-- Place non-visual elements (e.g., services, value objects) here --&gt;<br/>&nbsp;&nbsp;&lt;/fx:Declarations&gt;<br/>&nbsp;&nbsp;&lt;s:Label x=&quot;10&quot; y=&quot;29&quot; text=&quot; 签&quot; width=&quot;291&quot; id=&quot;tip_txt&quot; height=&quot;17&quot;/&gt;<br/>&nbsp;&nbsp;&lt;s:HSlider id=&quot;hsval&quot; x=&quot;21&quot; y=&quot;10&quot; minimum=&quot;0.1&quot; maximum=&quot;2&quot; value=&quot;1&quot; liveDragging=&quot;true&quot; change=&quot;hsChange(img)&quot; snapInterval=&quot;0.1&quot;/&gt;<br/>&nbsp;&nbsp;&lt;s:Group x=&quot;260&quot; y=&quot;10&quot; width=&quot;500&quot; height=&quot;500&quot; id=&quot;can&quot; mouseMove=&quot;onMouseMove(event)&quot; mouseDown=&quot;onMouseDown(event)&quot; buttonMode=&quot;true&quot; contentBackgroundColor=&quot;#000000&quot;&gt;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&lt;s:Rect width=&quot;100%&quot; height=&quot;100%&quot;&gt;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;s:fill&gt; <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;s:SolidColor color=&quot;#000000&quot;/&gt; <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/s:fill&gt; <br/>&nbsp;&nbsp;&nbsp;&nbsp;&lt;/s:Rect&gt;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&lt;mx:Image x=&quot;10&quot; y=&quot;10&quot; width=&quot;153&quot; height=&quot;113&quot; id=&quot;img&quot; progress=&quot;showProcess(event)&quot; complete=&quot;initImg()&quot; alpha=&quot;1.0&quot;/&gt;&nbsp;&nbsp;&nbsp;&nbsp;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&lt;s:Group x=&quot;0&quot; y=&quot;0&quot; width=&quot;500&quot; height=&quot;176&quot; alpha=&quot;0.4&quot; contentBackgroundColor=&quot;#FFFFFF&quot;&gt;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&lt;/s:Group&gt;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&lt;s:Group x=&quot;0&quot; y=&quot;176&quot; width=&quot;176&quot; height=&quot;149&quot; alpha=&quot;0.4&quot; contentBackgroundColor=&quot;#FFFFFF&quot;&gt;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&lt;/s:Group&gt;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&lt;s:Group x=&quot;0&quot; y=&quot;325&quot; width=&quot;500&quot; height=&quot;200&quot; alpha=&quot;0.4&quot; contentBackgroundColor=&quot;#FFFFFF&quot;&gt;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&lt;/s:Group&gt;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&lt;s:Group x=&quot;324&quot; y=&quot;176&quot; width=&quot;177&quot; height=&quot;149&quot; alpha=&quot;0.4&quot; contentBackgroundColor=&quot;#FFFFFF&quot;&gt;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&lt;/s:Group&gt;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&lt;s:Group width=&quot;150&quot; height=&quot;150&quot; id=&quot;cover&quot; x=&quot;175&quot; y=&quot;175&quot;&gt;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;s:Rect width=&quot;100%&quot; height=&quot;100%&quot;&gt;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;s:fill&gt; <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;s:SolidColor color=&quot;#ffffff&quot; alpha=&quot;0.4&quot;/&gt; <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/s:fill&gt; <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/s:Rect&gt;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&lt;/s:Group&gt;<br/>&nbsp;&nbsp;&lt;/s:Group&gt;<br/>&nbsp;&nbsp;&lt;s:Button x=&quot;10&quot; y=&quot;364&quot; label=&quot;按钮&quot; id=&quot;result&quot; click=&quot;drawCover()&quot;/&gt;<br/>&nbsp;&nbsp;&lt;s:Group x=&quot;21&quot; y=&quot;174&quot; width=&quot;150&quot; height=&quot;150&quot; id=&quot;can3&quot;&gt;<br/>&nbsp;&nbsp;&lt;/s:Group&gt;<br/>&lt;/s:Application&gt;<br/></div><br/><br/>下篇文  flex4与sqlite的交互<br/>Tags - <a href="http://www.dv9.org/tags/flex4/" rel="tag">flex4</a> , <a href="http://www.dv9.org/tags/flash/" rel="tag">flash</a> , <a href="http://www.dv9.org/tags/builder4/" rel="tag">builder4</a> , <a href="http://www.dv9.org/tags/%25E6%2594%25BE%25E5%25A4%25A7%25E7%25BC%25A9%25E5%25B0%258F%25E8%25A3%2581%25E5%2589%25AA%25E5%259B%25BE%25E7%2589%2587/" rel="tag">放大缩小裁剪图片</a>
]]>
</description>
</item><item>
<link>http://www.dv9.org/post/32/</link>
<title><![CDATA[flex与flash的交互]]></title> 
<author>bearjia &lt;admin@dv9.org&gt;</author>
<category><![CDATA[Flex相关]]></category>
<pubDate>Sun, 20 Sep 2009 15:55:54 +0000</pubDate> 
<guid>http://www.dv9.org/post/32/</guid> 
<description>
<![CDATA[ 
	我的一个小CASE主要是以flash来做表现 flex做逻辑<br/>所以在flash中画些按钮啊 之类的<br/>但是遇到了一点小问题<br/>就是远程打开该CASE的第一次 flex会接受不到flash 过来的值<br/>flash代 如下：<br/><div class="code">v1.addEventListener(MouseEvent.CLICK,b1);<br/>v2.addEventListener(MouseEvent.CLICK,b2);<br/>v3.addEventListener(MouseEvent.CLICK,b3);<br/><br/>function b1(event:MouseEvent):void&#123;<br/>&nbsp;&nbsp;trace(&quot;clickAdmin&quot;);<br/>&nbsp;&nbsp;&#125;<br/>function b2(event:MouseEvent):void&#123;<br/>&nbsp;&nbsp;trace(&quot;clickGbook&quot;);<br/>&nbsp;&nbsp;&#125;<br/>function b3(event:MouseEvent):void&#123;<br/>&nbsp;&nbsp;trace(&quot;clickAbout&quot;);<br/>&nbsp;&nbsp;&#125;</div><br/>flex代 如下：<br/><div class="code">&lt;mx:SWFLoader source=&quot;swf/nav.swf&quot; height=&quot;245.1&quot; width=&quot;254.1&quot; id=&quot;bearflash&quot; y=&quot;0&quot;/&gt;<br/><br/>&lt;mx:Script&gt;<br/>&lt;!&#91;CDATA&#91;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; import mx.managers.PopUpManager;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; import mx.controls.Alert;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; import com.bear.jia.caringorm.view.login;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;internal function init():void&#123;<br/>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;var obj:Object=bearflash.content;<br/>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;obj.v3.addEventListener(MouseEvent.CLICK,clickAbout);<br/>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;obj.v2.addEventListener(MouseEvent.CLICK,clickGbook);<br/>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;obj.v1.addEventListener(MouseEvent.CLICK,clickAdmin);&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;<br/>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&#125;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;public function clickAbout(event:MouseEvent):void&#123;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var _about:about = new about()<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;_about.x = 250;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;_about.y = 120;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;PopUpManager.addPopUp(_about, this, true);<br/>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&#125;<br/>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;public function clickGbook(event:MouseEvent):void&#123;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var gbook:guestBook = new guestBook();<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;gbook.x = 250;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;gbook.y = 120;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;PopUpManager.addPopUp(gbook, this, true);<br/><br/>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&#125;<br/>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;public function clickAdmin(event:MouseEvent):void&#123;<br/>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;var adminLogin:login = new login();&nbsp;&nbsp;<br/>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;adminLogin.x = 350;<br/>&nbsp;&nbsp;&nbsp;&nbsp;adminLogin.y = 250;<br/>&nbsp;&nbsp;&nbsp;&nbsp;PopUpManager.addPopUp(adminLogin, this, true);<br/>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&#125;<br/>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&#93;&#93;&gt;<br/>&lt;/mx:Script&gt;</div><br/><br/>改动后如下<br/>flash代 ：<br/><div class="code">v1.addEventListener(MouseEvent.CLICK,b1);<br/>v2.addEventListener(MouseEvent.CLICK,b2);<br/>v3.addEventListener(MouseEvent.CLICK,b3);<br/><br/>function b1(event:MouseEvent):void&#123;<br/>&nbsp;&nbsp;dispatchEvent(new Event(&quot;clickAdmin&quot;));<br/>&nbsp;&nbsp;&#125;<br/>function b2(event:MouseEvent):void&#123;<br/>&nbsp;&nbsp;dispatchEvent(new Event(&quot;clickGbook&quot;));<br/>&nbsp;&nbsp;&#125;<br/>function b3(event:MouseEvent):void&#123;<br/>&nbsp;&nbsp;dispatchEvent(new Event(&quot;clickAbout&quot;));<br/>&nbsp;&nbsp;&#125;</div><br/><br/>flex代 ：<br/><div class="code">&lt;mx:SWFLoader source=&quot;swf/nav.swf&quot; height=&quot;245.1&quot; width=&quot;254.1&quot; y=&quot;0&quot; complete=&quot;Flash(event)&quot; id=&quot;flashContent&quot;/&gt;<br/><br/>&lt;mx:Script&gt;<br/>&lt;!&#91;CDATA&#91;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; import mx.managers.PopUpManager;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; import mx.controls.Alert;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; import com.bear.jia.caringorm.view.login;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var flashMc:MovieClip;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;internal function Flash(event):void&#123;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;flashMc=flashContent.content as MovieClip; <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;flashMc.addEventListener(&quot;clickAbout&quot;,clickAbout);<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;flashMc.addEventListener(&quot;clickGbook&quot;,clickGbook); <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;flashMc.addEventListener(&quot;clickAdmin&quot;,clickAdmin); <br/>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&#125;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;public function clickAbout(event:Event):void&#123;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var _about:about = new about()<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;_about.x = 250;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;_about.y = 120;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;PopUpManager.addPopUp(_about, this, true);<br/>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&#125;<br/>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;public function clickGbook(event:Event):void&#123;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var gbook:guestBook = new guestBook();<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;gbook.x = 250;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;gbook.y = 120;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;PopUpManager.addPopUp(gbook, this, true);<br/><br/>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&#125;<br/>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;public function clickAdmin(event:Event):void&#123;<br/>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;var adminLogin:login = new login();&nbsp;&nbsp;<br/>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;adminLogin.x = 350;<br/>&nbsp;&nbsp;&nbsp;&nbsp;adminLogin.y = 250;<br/>&nbsp;&nbsp;&nbsp;&nbsp;PopUpManager.addPopUp(adminLogin, this, true);<br/>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&#125;<br/>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&#93;&#93;&gt;<br/>&lt;/mx:Script&gt;</div><br/><br/>总结了一下<br/>自己想得过于简单了，原本以为把flash产生的数据转换一下数据类型就可以万事大吉。唉，还是时间广播比较好啊，不再取巧了。<br/>Tags - <a href="http://www.dv9.org/tags/flex%25E4%25B8%258Eflash%25E7%259A%2584%25E4%25BA%25A4%25E4%25BA%2592/" rel="tag">flex与flash的交互</a> , <a href="http://www.dv9.org/tags/dispatchevent/" rel="tag">dispatchevent</a>
]]>
</description>
</item><item>
<link>http://www.dv9.org/post/20/</link>
<title><![CDATA[Flex自定义加载loading]]></title> 
<author>bearjia &lt;admin@dv9.org&gt;</author>
<category><![CDATA[Flex相关]]></category>
<pubDate>Sat, 25 Jul 2009 14:14:09 +0000</pubDate> 
<guid>http://www.dv9.org/post/20/</guid> 
<description>
<![CDATA[ 
	<div class="code">package Bearbox.Loading<br/>&#123; <br/>&nbsp;&nbsp;import flash.display.Loader;<br/>&nbsp;&nbsp;import flash.display.Shape;<br/>&nbsp;&nbsp;import flash.display.Sprite;<br/>&nbsp;&nbsp;import flash.events.Event;<br/>&nbsp;&nbsp;import flash.events.ProgressEvent;<br/>&nbsp;&nbsp;import flash.net.URLRequest;<br/>&nbsp;&nbsp;import flash.text.TextField;<br/>&nbsp;&nbsp;import flash.text.TextFormat;<br/> <br/>&nbsp;&nbsp;import mx.events.FlexEvent;<br/>&nbsp;&nbsp;import mx.preloaders.DownloadProgressBar;<br/> <br/>&nbsp;&nbsp;public class MyLoading extends DownloadProgressBar<br/>&nbsp;&nbsp;&#123;<br/> <br/>&nbsp;&nbsp;&nbsp;&nbsp;private var _preloader:Sprite;<br/> <br/>&nbsp;&nbsp;&nbsp;&nbsp;private var logo:Loader = new Loader();<br/>&nbsp;&nbsp;&nbsp;&nbsp;private var loadingBar:Shape = new Shape();<br/>&nbsp;&nbsp;&nbsp;&nbsp;private var txt:TextField = new TextField();<br/> <br/>&nbsp;&nbsp;&nbsp;&nbsp;public function MyLoading()<br/>&nbsp;&nbsp;&nbsp;&nbsp;&#123;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// logo<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;logo.load(new URLRequest(&quot;http://www.dv9.org/images/logo.gif&quot;));<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;addChild(logo);<br/> <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// loading bar<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;addChild(loadingBar);<br/> <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// txt<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var style:TextFormat = new TextFormat(null, null, 0xFFFFFF, null, null, null, null, null, &quot;center&quot;);<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;txt.defaultTextFormat = style;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;txt.selectable = false;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;txt.width = 200;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;txt.height = 50;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;addChild(txt);<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;super();<br/>&nbsp;&nbsp;&nbsp;&nbsp;&#125;<br/> <br/>&nbsp;&nbsp;&nbsp;&nbsp;override public function set preloader(value:Sprite):void<br/>&nbsp;&nbsp;&nbsp;&nbsp;&#123;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;_preloader = value;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;_preloader.contextMenu = MyContextMenu.getMyContextNenu();<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//四个侦听~分别是加载进度 / 加载完毕 / 初始化进度 / 初始化完毕<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;_preloader.addEventListener(ProgressEvent.PROGRESS, loadProgressHandler);<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;_preloader.addEventListener(Event.COMPLETE, loadCompleteHandler);<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;_preloader.addEventListener(FlexEvent.INIT_PROGRESS, loadInitProgressHandler);<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;_preloader.addEventListener(FlexEvent.INIT_COMPLETE, loadInitCompleteHandler);<br/> <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;stage.addEventListener(Event.RESIZE, resizeHandler);<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;resizeHandler(null);<br/>&nbsp;&nbsp;&nbsp;&nbsp;&#125;<br/> <br/>&nbsp;&nbsp;&nbsp;&nbsp;private function loadProgressHandler(event:ProgressEvent):void<br/>&nbsp;&nbsp;&nbsp;&nbsp;&#123;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var ratio:Number = event.bytesLoaded/event.bytesTotal;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// loading bar<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;loadingBar.graphics.clear();<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;loadingBar.graphics.beginFill(Math.random() * 0xFFFFFF);<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;loadingBar.graphics.drawRect(0,0, ratio*128, 5);<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;loadingBar.graphics.endFill();<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// txt<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;txt.text = &quot;Dv9.Org� 载中 &quot; + ((ratio*100)&amp;gt;&amp;gt;0) + &quot;%&quot;;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&#125;<br/> <br/>&nbsp;&nbsp;&nbsp;&nbsp;private function loadCompleteHandler(event:Event):void<br/>&nbsp;&nbsp;&nbsp;&nbsp;&#123;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;txt.text = &quot;Dv9.Org加载成功!&quot;;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&#125;<br/> <br/>&nbsp;&nbsp;&nbsp;&nbsp;private function loadInitProgressHandler(event:FlexEvent):void<br/>&nbsp;&nbsp;&nbsp;&nbsp;&#123;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;txt.text = &quot;Dv9.Org加载中!&quot;;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&#125;<br/> <br/>&nbsp;&nbsp;&nbsp;&nbsp;private function loadInitCompleteHandler(event:FlexEvent):void<br/>&nbsp;&nbsp;&nbsp;&nbsp;&#123;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;txt.text = &quot;Dv9.Org加载中成功!&quot;;<br/> <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;_preloader.removeEventListener(ProgressEvent.PROGRESS, loadProgressHandler);<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;_preloader.removeEventListener(Event.COMPLETE, loadCompleteHandler);<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;_preloader.removeEventListener(FlexEvent.INIT_PROGRESS, loadInitProgressHandler);<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;_preloader.removeEventListener(FlexEvent.INIT_COMPLETE, loadInitCompleteHandler);<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;stage.removeEventListener(Event.RESIZE, resizeHandler);<br/> <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//最后这个地方需要dpepatch一个Event.COMPLETE事件..表示� 载完毕让swf继续操作~<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dispatchEvent(new Event(Event.COMPLETE));<br/>&nbsp;&nbsp;&nbsp;&nbsp;&#125;<br/> <br/>&nbsp;&nbsp;&nbsp;&nbsp;private function resizeHandler(event:Event):void<br/>&nbsp;&nbsp;&nbsp;&nbsp;&#123;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;logo.x = (stage.stageWidth-128) * .5;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;logo.y = (stage.stageHeight-185) *.5;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;loadingBar.x = (stage.stageWidth-128) * .5;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;loadingBar.y = (stage.stageHeight-185) *.5 + 128;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;txt.x = (stage.stageWidth-200) * .5;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;txt.y = (stage.stageHeight-185) *.5 + 135;<br/> <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;graphics.clear();<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;graphics.beginFill(0x333333);<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;graphics.drawRect(0,0,stage.stageWidth,stage.stageHeight);<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;graphics.endFill();<br/>&nbsp;&nbsp;&nbsp;&nbsp;&#125;<br/>&nbsp;&nbsp;&#125;<br/>&#125;</div><br/><br/><div class="code">&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;<br/>&lt;mx:Application xmlns:mx=&quot;http://www.adobe.com/2006/mxml&quot; layout=&quot;absolute&quot; <br/>&nbsp;&nbsp; preloader=&quot;Bearbox.Loading&quot; creationComplete=&quot;init()&quot;&gt;<br/> <br/>&nbsp;&nbsp;&lt;mx:Script&gt;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&lt;!&#91;CDATA&#91; <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;private function init():void<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#123;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;this.contextMenu = MyContextMenu.getMyContextNenu();<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#125;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&#93;&#93;&gt;<br/>&nbsp;&nbsp;&lt;/mx:Script&gt;<br/>&lt;/mx:Application&gt;</div><br/>Tags - <a href="http://www.dv9.org/tags/flex/" rel="tag">flex</a> , <a href="http://www.dv9.org/tags/%25E8%2587%25AA%25E5%25AE%259A%25E4%25B9%2589%25E5%258A%25A0%25E8%25BD%25BD/" rel="tag">自定义加载</a> , <a href="http://www.dv9.org/tags/loading/" rel="tag">loading</a>
]]>
</description>
</item>
</channel>
</rss>