??xml version="1.0" encoding="utf-8" standalone="yes"?>亚洲综合网站色欲色欲,亚洲av永久无码精品网址,亚洲AV无码乱码在线观看性色扶http://www.tkk7.com/jjshcc/category/46368.html桑巴葡语译工作室是q州市最专业葡萄牙语译机构-www.puyufanyi.com-Ƣ迎LJava,As400,Mainframe的猎头eric_cc#qq.ccom(?换成@)zh-cnTue, 18 Mar 2014 21:31:26 GMTTue, 18 Mar 2014 21:31:26 GMT60[Red5]Red5之Flash媒体服务器的安装与使用教程完整?/title><link>http://www.tkk7.com/jjshcc/archive/2014/03/18/411173.html</link><dc:creator>Eric_jiang</dc:creator><author>Eric_jiang</author><pubDate>Tue, 18 Mar 2014 07:44:00 GMT</pubDate><guid>http://www.tkk7.com/jjshcc/archive/2014/03/18/411173.html</guid><wfw:comment>http://www.tkk7.com/jjshcc/comments/411173.html</wfw:comment><comments>http://www.tkk7.com/jjshcc/archive/2014/03/18/411173.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.tkk7.com/jjshcc/comments/commentRss/411173.html</wfw:commentRss><trackback:ping>http://www.tkk7.com/jjshcc/services/trackbacks/411173.html</trackback:ping><description><![CDATA[<div><span style="font-family: Verdana, Arial, Helvetica, sans-serif; line-height: normal; font-size: 12px; color: #9696ab; "><div class="icamaoe" id="mainContent" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 20px; padding-right: 20px; padding-bottom: 20px; padding-left: 20px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-size: 14px; line-height: 28px; color: #515050; "><p style="margin-top: 20px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; "><strong>Red5媒体服务器?/strong></p><p style="margin-top: 20px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; ">Red5是一个采用Java开发开源的Flash媒体服务器。它支持Q把音频QMP3Q和视频QFLVQ{换成播放; 录制客户端播放流Q只支持FLVQ;׃n对象Q现场直播流发布Q远E调用。Red5使用RSTP作ؓ媒体传输协议,在其自带的一些示例中演示了在U录Ӟflash媒体播放,在线聊天Q视频会议等一些基本功能?/p><p style="margin-top: 20px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; "><strong>软g环境</strong></p><p style="margin-top: 20px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; ">既然是Java开发的Q自然少不了要安装JDKQ这里用的是JDK6.x版本QRed5用的?.9.1版本QRed5内嵌了Tomcat6.x服务器。ؓ了测试和使用Red5Q需要另外搭建开发环境,开发部|相应的服务端应用,开发IDE为Eclipse3.3.x + MyEclipse6.xQ貌似版本有点低了,没办法,刚好电脑上安装程序,不想另外下蝲了,同时也够用了Q哈哈)QWeb服务器ؓTomcat6.xQ最后客L播放器用Flowplayer3.2.x。以下是Red5和Flowplayer3.2.x下蝲地址?/p><p style="margin-top: 20px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; ">Red5下蝲Qhttp://www.red5.org/downloads/<br />CuSunPlayer媒体播攑֙下蝲Qhttp://www.CuPlayer.com/CuSunPlayer/</p><p style="margin-top: 20px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; "><strong>安装软g与环境配|?/strong></p><p style="margin-top: 20px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; "><strong>1.安装JDK?/strong>q里使用的是jdk-6u21-windows-i586.exeQ双L提示安装卛_<br /> </p><p style="margin-top: 20px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; "><img alt="" src="http://www.cuplayer.com/player/uploads/allimg/130319/131G35195-0.png" data-pinit="registered" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; " /></p><p style="margin-top: 20px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; ">完毕后设|环境变量JAVA_HOME,PATH和CLASSPATHQ如何设|环境变量请h或百?/p><p style="margin-top: 20px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; "><img width="673" height="259" alt="" src="http://www.cuplayer.com/player/uploads/allimg/130319/131S51F4-0.png" data-pinit="registered" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; " /><br /><div><p style="margin-top: 20px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; "><strong>2.安装Red5</strong></p><p style="margin-top: 20px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; ">因ؓ是Windows环境Q这里下载的是setup-Red5-0.9.1.exe。直接双d装程序安装,安装q程中,需要填写服务器IP地址和端口,׃是本地测试,直接填写127.0.0.1Q端口随意,不冲H即可,>1024Q这里?050。安装完之后不要忘记讄RED5_HOME环境变量?/p><p style="margin-top: 20px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; "><img alt="" src="http://www.cuplayer.com/player/uploads/allimg/130319/131945N35-0.png" data-pinit="registered" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; " /></p><p style="margin-top: 20px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; ">Red5安装E序会默认把Red5注册为系l服务自动启动,打开pȝ服务Q查看是否服务是否已l存在:</p><p style="margin-top: 20px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; "><img data-pinit="registered" src="http://www.cuplayer.com/player/uploads/allimg/130319/1324131J6-0.png" alt="" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; " /></p><p style="margin-top: 20px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; ">我们看到服务已安装,但还没有启动Q需要我们手动启动一下,选择Red5服务Q鼠标右键,选择启动或者重新启动即可。系l界面操作,不赘q。如无意 外,应该可以正常启动。如果启动不了,h查前面的环境变量讄是否讄完毕q且正确Q最后检查Red5的启动日志文Ӟ看看是否有相应的提示信息Q日?文g在Red5ȝ录下的log目录下,日志文g有多个,查看red5_service.log卛_。启动后Q打开览器,敲入安装Red5时的IP地址 和端口,正常情况下,看到如下信息Q说明Red5已经正确安装了?/p><p style="margin-top: 20px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; "><img alt="" src="http://www.cuplayer.com/player/uploads/allimg/130319/13255V128-0.png" data-pinit="registered" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; " /></p><p style="margin-top: 20px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; ">q个时候可以点击Installq入下蝲其官Ҏ供的demoq行研究学习Q安装后的demo文g在Red5根目录下的webapps下,?D:\Red5\webapps。安装操作比较简单,q里不详l介l,不过要这里要提醒一下,安装完的demo后,需要重新启动一下Red5服务器,重启 操作参考上面的介绍?br /></p></div></p><p style="margin-top: 20px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; "></p></div><div style="margin-top: 5px; margin-right: auto; margin-bottom: 10px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; text-align: center; width: 500px; font-size: 14px; font-weight: bold; "><ul style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 12px; padding-right: 0px; padding-bottom: 12px; padding-left: 16px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; display: block; "><div><span style="color: #515050; font-weight: normal; line-height: 28px; "><p style="margin-top: 20px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; "><strong>3.安装配置开发环?/strong></p><p style="margin-top: 20px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; ">主要安装配置Eclipse3.3.x + MyEclipse6.x +Tomcat6.x?/p><p style="margin-top: 20px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; ">Eclipse下蝲的是eclipse3.3.1.zipQ直接解压到D:\Program Files目录下;Tomcat下蝲apache-tomcat-6.0.36-windows-x86.zip,直接解压到D:\ProgramFiles目录卛_Q然后安装MyEclipse6.xQ这里用的是MyEclipse_6.0.1GA_E3.3.1_Installer.exe,双击按提C安装完毕即可?/p><p style="margin-top: 20px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; "><img alt="" src="http://www.cuplayer.com/player/uploads/allimg/130319/13294TS2-0.png" data-pinit="registered" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; " /><br /><div><p style="margin-top: 20px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; ">配置Tomcat服务器和默认字符集ؓUTF-8</p><p style="margin-top: 20px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; "><img alt="" src="http://www.cuplayer.com/player/uploads/allimg/130319/13320L157-0.png" data-pinit="registered" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; " /></p><p style="margin-top: 20px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; ">xQY件的安装与环境配|完成,接下来就是开发和部v我们的流媒体服务器应用以及测试应用了?/p></div></p></span></div><li style="margin-top: 0px; margin-right: 6px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; float: left; font-family: Verdana, Arial, Helvetica, sans-serif, 宋体; line-height: 20px; "></li></ul></div></span></div><img src ="http://www.tkk7.com/jjshcc/aggbug/411173.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.tkk7.com/jjshcc/" target="_blank">Eric_jiang</a> 2014-03-18 15:44 <a href="http://www.tkk7.com/jjshcc/archive/2014/03/18/411173.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>用ActionScript开发高U可视化lg-lg的实?/title><link>http://www.tkk7.com/jjshcc/archive/2011/07/09/353998.html</link><dc:creator>Eric_jiang</dc:creator><author>Eric_jiang</author><pubDate>Sat, 09 Jul 2011 10:00:00 GMT</pubDate><guid>http://www.tkk7.com/jjshcc/archive/2011/07/09/353998.html</guid><wfw:comment>http://www.tkk7.com/jjshcc/comments/353998.html</wfw:comment><comments>http://www.tkk7.com/jjshcc/archive/2011/07/09/353998.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.tkk7.com/jjshcc/comments/commentRss/353998.html</wfw:commentRss><trackback:ping>http://www.tkk7.com/jjshcc/services/trackbacks/353998.html</trackback:ping><description><![CDATA[     摘要:     在用 ActionScript 创徏自定义组件时,必须重蝲 UIComponent cȝ一些方?实现基本的组件结?构造器,以及 createChildren(),commitProperties(), measure(), layoutChrome()?updateDisplayList()Ҏ. 基本lgl构下面例子展示了Flex lg的基?..  <a href='http://www.tkk7.com/jjshcc/archive/2011/07/09/353998.html'>阅读全文</a><img src ="http://www.tkk7.com/jjshcc/aggbug/353998.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.tkk7.com/jjshcc/" target="_blank">Eric_jiang</a> 2011-07-09 18:00 <a href="http://www.tkk7.com/jjshcc/archive/2011/07/09/353998.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>用ActionScript开发高U可视化lg-关于创徏高lghttp://www.tkk7.com/jjshcc/archive/2011/07/09/353991.htmlEric_jiangEric_jiangSat, 09 Jul 2011 09:37:00 GMThttp://www.tkk7.com/jjshcc/archive/2011/07/09/353991.htmlhttp://www.tkk7.com/jjshcc/comments/353991.htmlhttp://www.tkk7.com/jjshcc/archive/2011/07/09/353991.html#Feedback0http://www.tkk7.com/jjshcc/comments/commentRss/353991.htmlhttp://www.tkk7.com/jjshcc/services/trackbacks/353991.htmlDataGrid 控g~省?styles ?skins?br />在高U组件中Q通常会执行以下动作: 
1.  更改已有lg的可视化外观或者可视化Ҏ?
2. 创徏复合lgQ将两个或者多个组件包装在其中?nbsp;
3. 通过l承UIComponent cL创徏lg?
    我们通常用承现存类的方式来创徏lg。比如,要创建基?Button 的控Ӟ我们创建mx.controls.Button cȝ一个子cR要开发自qlgQ则需要创建mx.core.UIComponent cȝ子类?
关于重蝲 UIComponent cȝ protected Ҏ
    Flex 所有的可视化组仉是UIComponent cȝ子类?因此Q可视化lgl承?UIComponentcL定义?methodsQpropertiesQeventsQstyles ?effects?
     要创建高U的可视化组Ӟ必须实现一个构造器QconstructorQ。另外要有选择性地重蝲下表?UIComponent cȝ一个或者多?protected ҎQ?nbsp;
    commitProperties()  提交lg所有的属性变化。要么属性同时更改,要么保属性按照特定顺序设|?nbsp;
    createChildren()       创徏lg的子lg?br />    比如QComboBox 控g包含了一?TextInput 控g和一?Button 控g作ؓ它的子组件?br />    LayoutChrome()   定义 Container cȝ子类容器?border 区域?nbsp;
    measure()               讄lg的缺?size 和缺省的最?size?nbsp;
    updateDisplayList()   Ҏ以前所讄的属性和样式来确定组件的子组件在屏幕上的大小QsizeQ及位置QpositionQ?Qƈ且画出组件所使用的所有皮肤( skinsQ及囑Ş化元素。组件的父容器负责确定组件本w大(sizeQ?/strong> 
     lg的用者不会直接调用所有这些方法?/strong> 
关于失效(机制)的方?
     在组件的生命周期中,应用可能会改变组件的大小和位|,更改lg的属性来控制lg的显C,或者更改组件的样式QstylesQ和皮肤QskinQ属性。比如,可以更改lg中所昄?br />文本(Text )的字?Font)大小?作ؓ变更字体大小工作的一部分Q组件的大小也可能随之发生变化,q就需?Flex L新应用的布局。布局操作需要Flex 调用自定义组件的commitProperties(), measure(), layoutChrome(), 以及 updateDisplayList()Ҏ?
    应用通过E序来更改字体大的执行速度大大快于 Flex 更新应用的速度。因此,你应该在定最l要更改的字体之后再更新布局?nbsp;另外一个场景就是,当你讄了组件的多个属性后Q比?Button 控g?label ?icon 属性,你肯定会惌所有属性被讄后一ơ性执?commitProperties(), measure(), ?updateDisplayList()ҎQ而不是设|过 label 属性后执行一遍这些方法,然后在设|?icon属性后又执行一ơ这些方法?
    另外Q可能有几个lg同时改变了它们的字体大小。这时应该让 Flex d调布局操作Q以消除M冗余q程Q而不是在每个lg更新它的字体大小之后都执行一ơ布局操作?
     Flex 使用一U?#8220;失效机制Qinvalidation mechanismQ?#8221;来同步组件的更改?strong>Flex 用一pdҎ的调用来标记lg的某些东西已l发生变化,q?Flex 去调用组件的commitProperties(), measure(), layoutChrome(),或?updateDisplayList()Ҏ。通过q种办法QFlex 实现?#8220;失效机制” ?nbsp;
    下表描述了有?#8220;失效(invalidation)”ҎQ?nbsp;
     invalidateProperties()   通知lgQ以使下ơ屏q更新时Q它的commitProperties()Ҏ能被调用?nbsp;
     invalidateSize()            通知lgQ以使下ơ屏q更新时Q它?measure()Ҏ能被调用?nbsp;
     invalidateDisplayList()   通知lgQ以使下ơ屏q更新时它的 layoutChrome()Ҏ和updateDisplayList()Ҏ能被调用?
    当组件调用一?#8220;失效”ҎQ它通知 FlexQ该lg已经被更新。当多个lg调用失效ҎQFlex 会协调这些更斎ͼ以ɘq些更新操作下一ơ屏q更新时一h行?
    通常Q?strong>lg使用者不必直接调用这?#8220;失效”Ҏ。这?#8221;失效”Ҏ被组件的 setter Ҏ或者组件的其他Ҏ在需要的时候调?
 
 
关于lg实例化的生命周期 
    lg实例化生命周期描qC用组件类创徏lg对象时所发生的一pd步骤.作ؓ生命周期的一部分,Flex 自动调用lg的方?发出事g,qɾlg可见?nbsp;
    下面例子?ActionScript 创徏一?Button 控gQƈ其加入到容器之中: 
    //创徏一?Box 容器?nbsp;
    var boxContainer:Box = new Box(); 
    //讄 Box 容器 
    … 
    //创徏 Button 控g?nbsp;
    var b:Button = new Button() 
    //讄 button 控g?nbsp;
    b.label = "Submit"; 
    ... 
    // ?Button d?Box 容器中?nbsp;
    boxContainer.addChild(b); 下面的步骤显CZ用代码创Z?Button 控gQƈ这个控件添加到 Box 容器中时所发生的一切: 
    1.  调用了组件的构造函敎ͼ如下面代码所C? 
    // Create a Button control.  
    var b:Button = new Button() 
    2.  通过讄lg的属性对lgq行了设|?如下面代码所C? 
    // Configure the button control. 
    b.label = "Submit"; 
    lg?setter Ҏ会调用 invalidateProperties(), invalidateSize(), 或者invalidateDisplayList() Ҏ. 
    3.  调用 addChild()Ҏ该lgd到父lg?如下代码所C? 
    // Add the Button control to the Box container. 
    boxContainer.addChild(b); 
    Flex 执行以下动作: 
    4.   ?component ?parent 属性设|ؓ对父容器的引? 
    5.  计算lg的样?style) 讄.  
    6.  在组件上分发preinitialize 事g.  
    7.  调用lg的createChildren() Ҏ.  
    8.  调用invalidateProperties(), invalidateSize()?invalidateDisplayList()Ҏ以触发后l到来的,下一?#8220;渲染事g”(render?event)期间?commitProperties(), measure(),?updateDisplayList()Ҏ的调用?nbsp;
    q个规则唯一一个例外就是当用户讄lg?height ?width 属性时, Flex 不会调用measure() Ҏ.  
    9.  在组件上分发initialize 事g。此Ӟlg所有的子组仉被初始化Q但是组件没有改更size 和处理布局。可以利用这个事件在lg布局之前执行一些附加的处理?nbsp; 
    10. 在父容器上分?childAdd 事g.  
    11. 在父容器上分发initialize 事g.  12. 在下一?#8220;渲染事g”(render?event)? Flex 执行以下动作:  
    a.  调用lg?commitProperties()Ҏ.  
    b.  调用lg?measure()Ҏ.  
    c.  调用lg?layoutChrome()Ҏ.  
    d.  调用lg?updateDisplayList()Ҏ.  
    e.  在组件上分发 updateComplete 事g.  
    13. 如果commitProperties(), measure()或?updateDisplayList()Ҏ调用?invalidateProperties(), invalidateSize(),?invalidateDisplayList()Ҏ,?Flexh 会分发另外一?render 事g. 
    14. 在最后的render 事g发生? Flex 执行以下动作:  
    a.  通过讄lg?visible 属性ɾlg变ؓ可视. 
    b.  在组件上分发 creationComplete 事g.lg的大?size)和布局被确?q个事g只在lg创徏时分发一?  
    c.  在组件上分发 updateComplete 事g.无论什么时?只要lg的布局(layout),位置,大小或其它可视的属性发生变化就会分发这事g,然后lg被更斎ͼ以ɾlg能够被正地昄. 
    当?addChild()Ҏ组件添加到容器中时,大部分工作都是ؓ了设|这个组?q是因ؓ直到把组件添加到容器中时,Flex 才能定它的大小(size),讄它所l承样式(style)属?或者在屏幕上画出它. 也可以用 MXMLQ在应用中完成上面的lgd动作,如下面的例子所C?
<mx:Application xmlns:mx="    <mx:Box>
        <mx:Button label="Submit"/>
    </mx:Box>
</mx:Application> 
    ?MXML 中创建组件时QFlex 执行的步骤顺序同?ActionScript 的步骤顺序相? 使用 removeChild() Ҏ可将lg从容器中UdQ?如果对这个组件再没有其他的引?那就相当于?Adobe Flash  Player ?Adobe AIR 的垃圑֛收机制将lg从内存中删除. 关于创徏lg的步?nbsp;
    Z实现一个组?p重蝲lg的方?定义新的属?分发新的事g,或者执行其他Q何应用所需的自定义的逻辑.要想实现自己的组? 请遵循以下这些常规步? 
    1.  如果有必要,为组件创建所有的皮肤QskinsQ?Q?nbsp;
    2.  创徏 ActionScript cLӞ 
    a.  从一个基cL展,比如 UIComponent 或者其他的lgc. 
    b.  指定使用者能够通过 MXML 标记q行讄的属性. 
    c.  嵌入QEmbedQ所有的囄和皮肤文Ӟ 
    d.  实现构造器Q?nbsp;
    e.  实现 UIComponent.createChildren()Ҏ.  
    f.  实现 UIComponent.commitProperties() Ҏ.  
    g.  实现 UIComponent.measure() Ҏ.  
    h.  实现 UIComponent.layoutChrome() Ҏ.  
    i.   实现 UIComponent.updateDisplayList() Ҏ.  
    j.  增加属?properties),Ҏ(methods),样式(styles),事g QeventsQ以及元数据Q?nbsp;
    3.  ?ActionScript 文g或?SWC 文g的Ş式部|组Ӟ 
     定义新组件时不一定要重蝲所有的ҎQ只需要重载实现组件功能所需的方法.如果创徏现存lg的子c,比如 Button 控g或?VBox 容器Q那么必d现组件中所d的新功能所需
的方法. 
    例如Q实C个自定义?Button 控gQ该控g使用新的机制来定义缺省大(sizeQ?Q在q种情况下,只需要重?measure()ҎQ对于这个例子,参见实现 easure() ҎQ?
或者,要实?VBox 容器的一个新子类Q新子类利用 VBox cd有的所有有兌定大(sizingQ的逻辑Q但是变更了 VBox cȝ布局逻辑以实C底部到顶部的方式来布局容器中的
子控Ӟ而不是自向下的布局Q在q种情况下,只需要重载updateDisplayList()ҎQ关于这个例子,见实?updateDisplayList()ҎQ?br /> 
关于接口 

    Flex 用接口将lg的基本功能分为离散的单元Q?q得它们可以被 “一块一?#8221; 地实玎ͼ 例如Qɾlg可聚焦(有输入焦点) Q它必须实现 IFocusable 接口Q要使它能够参与布局q程Q它必须实现 ILayoutClient 接口Q?Z化接口的使用Q?UIComponent cdC下表中定义的所有接口,但是不包括IFocusManagerComponent 接口?IToolTipManagerClient 接口Q但 UIComponent 很多子类实现?IFocusManagerComponent ?IToolTipManagerClient 接口Q?nbsp;
    因此Q创?UIComponent 或其子类的子c,׃必实现这些接口.但是Q如果要创徏的组件不?UIComponent 的子c,q且q想?Flex 中用这个组Ӟ那么必dC个或者多个接口?nbsp;
    注意Q对?Flex, Adobe 所有的lg都应?UIComponent 及其子类l承. 
    下表列出?Flex components 所实现的主要接?  
    接口                                                           用?nbsp;
    IChildList                                                    表明容器中子控g的数? 
    IDeferredInstantiationUIComponent              表明lg或组件能实施延迟实例? 
    IFlexDisplayObject                                       指定皮肤元素的接? 
    IFocusManagerComponent                           表明lg或者对象是可聚焦的,q意味着lg可以?FocusManager 获取焦点. 
    UIComponent                                             lg没有实现 Ifocusable 接口,因ؓ有些lg不打接受焦? 
    IInvalidating                                               表明lg或者对象能够?#8221;失效机制”L行gq的,而不是立即的属性提? commitment), 度量(measurement), 以及d(drawing) 或布局( layout). 
    ILayoutManagerClient                                  表明lg或者对象能够参?LayoutManager 的提?commit) ,度量(measure)和更新次?update sequence)  
    IPropertyChangeNotifier                               表明lg支持特定形式的事件传? 
    IRepeaterClient                                           表明lg或者对象能够被用于 Repeater c? 
    IStyleClient                                                 表明lg能够从其他的对象l承样式,q且支持setStyle() ?getStyle() Ҏ. 
    IToolTipManagerClient                                  表明lg有一?toolTip 属?q且因此可以被ToolTipManager 所监控. 
    IUIComponent                                            定义lg能够成ؓ布局理器或列表的子lg所必须实现的基?APIs.
    IValidatorListener                                       表明lg能够监听校验(validation)事g,q且因此能够昄校验状?比如一个红色边框和昄
校验错误的提CZ?tooltips)

Eric_jiang 2011-07-09 17:37 发表评论
]]>
创徏 Flex lghttp://www.tkk7.com/jjshcc/archive/2011/07/03/353584.htmlEric_jiangEric_jiangSun, 03 Jul 2011 02:14:00 GMThttp://www.tkk7.com/jjshcc/archive/2011/07/03/353584.htmlhttp://www.tkk7.com/jjshcc/comments/353584.htmlhttp://www.tkk7.com/jjshcc/archive/2011/07/03/353584.html#Feedback0http://www.tkk7.com/jjshcc/comments/commentRss/353584.htmlhttp://www.tkk7.com/jjshcc/services/trackbacks/353584.html阅读全文

Eric_jiang 2011-07-03 10:14 发表评论
]]>
Flex 自定义组件外?/title><link>http://www.tkk7.com/jjshcc/archive/2011/07/02/353566.html</link><dc:creator>Eric_jiang</dc:creator><author>Eric_jiang</author><pubDate>Sat, 02 Jul 2011 14:55:00 GMT</pubDate><guid>http://www.tkk7.com/jjshcc/archive/2011/07/02/353566.html</guid><wfw:comment>http://www.tkk7.com/jjshcc/comments/353566.html</wfw:comment><comments>http://www.tkk7.com/jjshcc/archive/2011/07/02/353566.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.tkk7.com/jjshcc/comments/commentRss/353566.html</wfw:commentRss><trackback:ping>http://www.tkk7.com/jjshcc/services/trackbacks/353566.html</trackback:ping><description><![CDATA[<p sizset="90" sizcache="24"><a name="major4"><span id="gweqyks" class="atitle">动态按?/span></a></p> <p>动态按钮的的概念就是在鼠标悬停、鼠标点凅R鼠标离开控gӞlg呈现不同的外观,q三U不同的外观可以通过背景位图囄Q背?SWF 文g实现?/p> <p sizset="91" sizcache="24"><a name="minor4.1"><span id="uawkgqo" class="smalltitle">位图实现</span></a></p> <p>位图实现是将二进制图像文件作为控件背景,q里使用 Flex ?Button 控g作ؓ例子Q通过定义 Button ?upSkin、overSkin 以及 downSkin 样式分别讄鼠标d Button 时、鼠标悬?Button 上方时以及鼠标点?Button 时的皮肤Q皮肤制作则使用 Embed 标签加蝲囄Q之成?Class 对象Q通过 Button ?setStyle Ҏ?Class 对象作ؓ皮肤讄q去Q清?1 展示了其中设|?upSkin 的方?.downSkin ?overSkin 的设|方法相同?/p><br /><a name="listing1"><strong>清单 1. Button 控g讄 upSkin</strong></a><br /> <table cellspacing="0" cellpadding="0" width="100%" border="0" sizset="0" sizcache="2"> <tbody sizset="0" sizcache="1"> <tr> <td class="code-outline"><pre class="displaycode"> var btn:Button= … ; [Embed(source="images/up.jpg", scaleGridTop="26", scaleGridBottom="64", scaleGridLeft="30", scaleGridRight="106")] private var upSkin:Class; btn.setStyle("upSkin",upSkin); </pre></td></tr></tbody></table><br /> <p>清单 1 中,Embed 标签内的 scaleGridTop、scaleGridBottom、scaleGridLeft、scaleGridRight 属性涉及到一U?Web 技术,名ؓ九宫格的~放技术,Z解释该技术,请先看图 1.</p><br /><a name="fig1"><strong>?1. 九宫格原理图</strong></a><br /> <img height="144" alt="" src="http://www.tkk7.com/images/blogjava_net/jjshcc/www.puyufanyi.com/image002.gif" width="216" border="0" longdesc="" /><br /> <p><br /><strong>注:原图?/strong><img height="20" alt="" src="http://www.ibm.com/developerworks/cn/web/1008_weiqiang_flexui/image003.gif" width="20" /><strong>Q? * 5 Ҏ图,每个Ҏ 4 个像素,上图是被攑֤后的效果</strong></p> <p>?1 在四条红U的位置把图片块成了 9 块,四个角,四条边和中间一块,在羃攄时候,四个角始l不变,两条横向边只~放宽度Q高度不变,两条U向的边只羃N度,宽度不变Q中间一块宽和高同时~放Q这是九宫格羃攄原理。这U技术一般是在用图片做控g的皮肤时使用Q很多控件的皮肤样式Q在四个角的Z|是圆的或不规则的,所以用这U羃放技术可以保证控件与囄的大不一致的时候,囄看v来ƈ不变形?/p> <p>了解了九宫格技术再?scaleGridTop、scaleGridBottom、scaleGridLeft、scaleGridRight 四个属性,它们分别代表?1 中四条红色切割线的位|,scaleGridTop 代表横向剙的切割线距离囑փ剙的像素距;scaleGridBottom 代表横向底部的切割线距离囑փ剙的像素距;scaleGridLeft 代表U向左部的切割线距离囑փ左部的像素距;scaleGridRight 代表U向右部的切割线距离囑փ左部的像素距R?/p> <p>通过上述技术和Ҏ的用,具体实例效果展示如图 2. 从左臛_分别?upSkin、downSkin、overSkin 的效果?/p><br /><a name="fig2"><strong>?2. 位图实现效果展示?/strong></a><br /> <img height="109" alt="" src="http://www.tkk7.com/images/blogjava_net/jjshcc/www.puyufanyi.com/image005.jpg" width="172" border="0" longdesc="" /><img height="110" alt="" src="http://www.tkk7.com/images/blogjava_net/jjshcc/www.puyufanyi.com/image007.jpg" width="148" border="0" longdesc="" /><img height="111" alt="" src="http://www.tkk7.com/images/blogjava_net/jjshcc/www.puyufanyi.com/image009.jpg" width="162" border="0" longdesc="" /><br /> <p sizset="95" sizcache="24"><a name="minor4.2"><span id="uwqegoc" class="smalltitle">SWF 文g实现</span></a></p> <p sizset="96" sizcache="24">SWF 文g实现是?SWF 文g中具体的某一帧(MoiveClipQ作为控件皮肤,修改 <a href="http://www.ibm.com/developerworks/cn/web/1008_weiqiang_flexui/#_ 位图实现"><font color="#996699">位图实现</font></a>部分?Embed 标签Q构建的新的CZQ如清单 2.</p><br /><a name="listing2"><strong>清单 2. 使用 SWF 具体某作ؓ皮肤</strong></a><br /> <table cellspacing="0" cellpadding="0" width="100%" border="0" sizset="1" sizcache="2"> <tbody sizset="1" sizcache="1"> <tr> <td class="code-outline"><pre class="displaycode"> <mx:Style> Button{ up-skin:Embed(source="images/bg.swf",symbol="btnUP"); over-skin:Embed(source="images/bg.swf",symbol="btnOVER"); down-skin:Embed(source="images/bg.swf",symbol="btnDOWN"); } </mx:Style> <mx:Button id="btn" label="Hello World" width="100" height="60"/> </pre></td></tr></tbody></table><br /> <p>上面代码 Embed 中的 source 指向了一?SWF 文gQ没有与九宫格相关的布局属性,出现了新的属性:symbolQ它?SWF 文g中某一帧的标识W,意思是使用指定的作ؓ皮肤。清?2 的效果如?3. 从左臛_分别?upSkin、downSkin、overSkin 的效果?/p><br /><a name="fig3"><strong>?3. SWF 实现效果展示?/strong></a><br /> <img height="107" alt="" src="http://www.tkk7.com/images/blogjava_net/jjshcc/www.puyufanyi.com/image011.jpg" width="191" border="0" longdesc="" /><img height="108" alt="" src="http://www.tkk7.com/images/blogjava_net/jjshcc/www.puyufanyi.com/image013.jpg" width="190" border="0" longdesc="" /><img height="108" alt="" src="http://www.tkk7.com/images/blogjava_net/jjshcc/www.puyufanyi.com/image015.jpg" width="196" border="0" longdesc="" /><br /> <p>q种Ҏ?SWF 文g需要用?Flash 开发工P具体的开发方法读者可以查阅相关的 Flash 资料?/p> <div id="cqiqcki" class="ibm-alternate-rule"> <hr /> </div> <p sizset="100" sizcache="24"><a name="major5"><span id="qqcwayg" class="atitle">冒信息提示?/span></a></p> <p>冒信息提示框是自定义的 ToolTipQ传l的 Flex ToolTip 效果如图 4 所C?/p><br /><a name="fig4"><strong>?4. 传统 ToolTip</strong></a><br /> <img height="124" alt="" src="http://www.tkk7.com/images/blogjava_net/jjshcc/www.puyufanyi.com/image017.jpg" width="168" border="0" longdesc="" /><br /> <p>可以看到效果q是比较陋的Qؓ了增强用户体验,文章实现了新?ToolTip 让其拥有冒效果Q效果展C如?5.</p><br /><a name="fig5"><strong>?5. 冒 ToolTip</strong></a><br /><br /> <img height="103" alt="" src="http://www.tkk7.com/images/blogjava_net/jjshcc/www.puyufanyi.com/image019.jpg" width="243" border="0" longdesc="" /><br /> <p>冒 ToolTip 的思想是新建名?BubbleToolTip 的类Q承于 CanvasQ实?IToolTip 接口QIToolTip 是自定义 ToolTip 必须实现的接口。重?BubbleToolTip ?updateDisplayList ҎQ目的是重新l画 BubbleToolTip 的皮肤,皮肤的绘制依?BubbleToolTip 内部?Graphics 对象Q通过 this.graphics 语句可以获得?Graphics 对象的引用,调用 Graphics 对象?drawRoundRect Ҏl制冒的圆形,提示的具体内容则使用子对?Canvas 存放。清?3 ?BubbleToolTip ?updateDisplayList Ҏ代码?/p><br /><a name="listing3"><strong>清单 3. BubbleToolTip ?updateDisplayList Ҏ</strong></a><br /> <table cellspacing="0" cellpadding="0" width="100%" border="0" sizset="2" sizcache="2"> <tbody sizset="2" sizcache="1"> <tr> <td class="code-outline"><pre class="displaycode"> override protected function updateDisplayList( unscaledWidth:Number, unscaledHeight:Number ) : void { super.updateDisplayList( unscaledWidth, unscaledHeight ); this.graphics.clear(); this.graphics.beginFill( getStyle('backgroundColor'), 1 ); this.graphics.lineStyle(2, getStyle('borderColor'), 1); this.graphics.drawRoundRect(0, 35, 6, 6, 24, 24); this.graphics.endFill(); this.graphics.beginFill( getStyle('backgroundColor'), 1 ); this.graphics.lineStyle(2, getStyle('borderColor'), 1); this.graphics.drawRoundRect(10, 25, 15, 15, 24, 24); this.graphics.endFill(); } </pre></td></tr></tbody></table><br /> <p>清单 3 的作用是l画?5 中黑色的两个圆圈Q显C?Hello 信息的则是?Canvas lgQ该 Canvas 是在?MXML 文g中定义,代码如清?4 所C?/p><br /><a name="listing4"><strong>清单 4. 使用 BubbleToolTip ?MXML 文g</strong></a><br /> <table cellspacing="0" cellpadding="0" width="100%" border="0" sizset="3" sizcache="2"> <tbody sizset="3" sizcache="1"> <tr> <td class="code-outline"><pre class="displaycode"> <?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" xmlns:component="component.*" backgroundGradientAlphas="[1.0, 1.0]" backgroundGradientColors="[#FFFFFF, #FFFFFF]"> <mx:Script><![CDATA[ import mx.events.ToolTipEvent; import component.BubbleToolTip; private function createCustomTip(title:String,event:ToolTipEvent):void { var bt:BubbleToolTip = new BubbleToolTip(); bt.text=title; content.text = title; bt.addChild(ppp); ppp.visible=true; event.toolTip = bt; } private function positionTip(event:ToolTipEvent):void{ event.toolTip.x=event.currentTarget.x + event.currentTarget.width + 10; event.toolTip.y=event.currentTarget.y; } ]]></mx:Script> <mx:Button id="b1" label="Hello world" x="60" y="60" toolTip=" " toolTipCreate="createCustomTip('Hello World',event)" toolTipShow="positionTip(event)" /> <mx:Canvas id="ppp" visible="false" width="50" height="40" cornerRadius="15" borderColor="#000000" x="35" y="0" borderStyle="solid" borderThickness="2"> <mx:Text id= "content" text="xixi" x="4.5" y="5" width="40" height="23.5"> </mx:Text> </mx:Canvas> </mx:Application> </pre></td></tr></tbody></table><br /> <p>清单 4 中定义了存放信息?Canvas ,id ?pppQ首先设|?ppp ?visible ?falseQ不可见Q在昄 ToolTip 的时候将 ppp 加到 BubbleToolTip 中,q且讄 ppp 为可见。设|?event.tooltip 为指定的 BubbleToolTip 对象。在 createCutomTip Ҏ中设|新?ToolTipQ在 positionTip Ҏ中定?tooltip 的显CZ|?/p> <p sizset="105" sizcache="24">Z形象的表现出重写 updateDisplayList Ҏ前后?BubbleToolTip 的对比,<a href="http://www.ibm.com/developerworks/cn/web/1008_weiqiang_flexui/#_ ?_4._ 冒 ToolTip"><font color="#996699">?5</font></a>昄的是重写后弹出的信息提示框,?6 是不重写 updateDisplayList 的信息提C框Q从两张囄可以看出重写后发生的变化?/p><br /><a name="N101A8"><strong>?6. 不重?updateDisplayList Ҏ?BubbleToolTip</strong></a><br /><br /><img height="79" alt="" src="http://www.tkk7.com/images/blogjava_net/jjshcc/www.puyufanyi.com/image021.jpg" width="219" border="0" longdesc="" /><br /> <p>可以看到子对象的 Canvas 前后不变Q因为ƈ没有重写它的 updateDisplayListQ而重?BubbleToolTip ?updateDisplayList Ҏ后边框变成了两个冒。注?BubbleToolTip 对象实际上也是一?Canvas?/p> <div id="mqmycyw" class="ibm-alternate-rule"> <hr /> </div> <p sizset="108" sizcache="24"><a name="major6"><span id="cusgkqy" class="atitle">|格背景</span></a></p> <p>|格背景在一?Flex 程~辑器中可以看到Q画布的|格背景不仅可以增强用户体验Q对于流E编辑中的流E节点的寚w也有很大的帮助?/p> <p>|格背景的容器用画?Canvas 对象Q?CSS 重新定义容器的皮肤。定义新皮肤?CSS 代码如清?5.</p><br /><a name="listing5"><strong>清单 5. CSS 定义新皮?Canvas</strong></a><br /> <table cellspacing="0" cellpadding="0" width="100%" border="0" sizset="4" sizcache="2"> <tbody sizset="4" sizcache="1"> <tr> <td class="code-outline"><pre class="displaycode"> { borderSkin: ClassReference("skins.GridSkin"); } </pre></td></tr></tbody></table><br /> <p><code>skins</code>.GridSkin 是一?Flex c,l承?ProgrammaticSkinQProgrammaticSkin cM表编E式的皮肤定义,重写它的 updateDisplayList Ҏ可以讄新的皮肤Q这和直接重?Canvas ?updateDisplayList Ҏ效果上是一致的Q本文重在讲解新的定义方法,因此使用 CSS 定义。清?6 昄|格定义的代码?/p><br /><a name="listing6"><strong>清单 6. ProgrammaticSkin ?updateDisplayList 实现代码 </strong></a><br /> <table cellspacing="0" cellpadding="0" width="100%" border="0" sizset="5" sizcache="2"> <tbody sizset="5" sizcache="1"> <tr> <td class="code-outline"><pre class="displaycode"> override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void { var g:Graphics = this.graphics; g.clear(); g.beginFill(0x000000, 0); g.drawRect(0, 0, unscaledWidth, unscaledHeight); g.endFill(); g.lineStyle(1, 0x000000, 0.1); var squareSize:Number = 15; var numRows:Number = unscaledHeight / squareSize; var numCols:Number = unscaledWidth / squareSize; for(var row:Number = 0; row< numRows; row++) { g.moveTo(0, row * squareSize); g.lineTo(unscaledWidth, row * squareSize); } for(var col:Number = 0; col< numCols; col++) { g.moveTo(col * squareSize, 0); g.lineTo(col * squareSize, unscaledHeight); } } </pre></td></tr></tbody></table><br /> <p>清单 6 中的 unscaledWidth ?unscaledHeight 代表?Canvas d实际的宽和高Q画布内?Graphics 对象默认的绘dҎd左上角(0,0Q点。代?drawRect(0, 0, unscaledWidth, unscaledHeight) 用于l画整个d的边框,lineStyle(1, 0x000000, 0.1) 讄要ȝU的样式Q黑艌Ӏ透明?0.1、粗l?1QsquareSize 定义|格的大(|格为正方ŞQ。通过 unscaledHeight / squareSize ?unscaledWidth / squareSize 获得d允许的行数和列数QmoveTo Udl画原点QlineTo 表示从原点到目标点画UѝFor 循环代表每画一行(列)Q原点向下(叻IUd squareSize 的距,再从原点qȝU到d双~(底边~)。那么网格效果就出来?. 效果如图 7 所C?.</p><br /><a name="fig6"><strong>?7. |格背景效果</strong></a><br /> <img height="342" alt="" src="http://www.tkk7.com/images/blogjava_net/jjshcc/www.puyufanyi.com/image023.jpg" width="333" border="0" longdesc="" /><br /> <p sizset="113" sizcache="24"><a name="major7"><span id="moogcsq" class="atitle">囑փ圆角</span></a></p> <p>囑փ圆角?Web2.0 重要的标志,如果你用q?CSS q行圆角的开发,那么不管在开发过E中或者处理浏览器兼容问题时一定会大喊痛苦。然而在 Flex 中,囑փ圆角变的非常单,使用 Mask 技术就可以L得实现。这U技术的直观感觉是将某一控g A 覆盖在另一控g B 之上Q?B 昄的部分则是被 A 遮盖的部分。如?A h透明度,那么 B 也会有透明度。例子代码如清单 7. 所C?/p><br /><a name="N101F9"><strong>清单 7. 囑փ圆角lg</strong></a><br /> <table cellspacing="0" cellpadding="0" width="100%" border="0" sizset="6" sizcache="2"> <tbody sizset="6" sizcache="1"> <tr> <td class="code-outline"><pre class="displaycode"> <?xml version="1.0" encoding="utf-8"?> <mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:filters="flash.filters.*" width="100%" height="100%" > <mx:Image source="assets/ygy.jpg" x="10" y="10" mask="{maskCanvas}"> <mx:filters> <filters:DropShadowFilter /> </mx:filters> </mx:Image> <mx:Canvas x="81" y="62" width="344" height="274" backgroundColor="#ff0000" id="maskCanvas" cornerRadius="15" borderStyle="solid"/> </mx:Canvas> </pre></td></tr></tbody></table><br /> <p>清单 7 中图像圆角组件实际上是一?CanvasQ该lg内显C的是一?ImageQAQ,?Image 指定 mask ?maskCanvasQ也是一?id ?maskCanvas ?CanvasQBQ,代码的意思是使用 B 遮盖 AQ那?B 的样式决定了 A 昄的样式,B 的样式中重要的是 backgroundColor ?cornerRadiusQbackgroundColor 讄成红Ԍq不透明QcornerRadius 讄 B 的圆角(注意QImage 没有q个属性)Q那么用深色的 B 遮盖 AQA 显C B 遮盖的部分,也就是显CZ囑փ的圆角,效果如图 8?/p><br /><a name="N10204"><strong>?8. 囑փ圆角效果</strong></a><br /> <img height="259" alt="" src="http://www.tkk7.com/images/blogjava_net/jjshcc/www.puyufanyi.com/image025.jpg" width="245" border="0" longdesc="" /><br /> <p>该效果用的原图像如?9 所C。这是一张方形的囑փ?br /><a name="N10215"><strong>?9. 原图?/strong></a><br /> <img height="258" alt="" src="http://www.tkk7.com/images/blogjava_net/jjshcc/www.puyufanyi.com/image027.jpg" width="235" border="0" longdesc="" /></p> <p>从清?7 ?Design 视图可以看出 A ?B 的遮盖结果,效果如图 10?/p><br /><a name="N10226"><strong>?10. Design 视图</strong></a><br /> <img height="274" alt="" src="http://www.tkk7.com/images/blogjava_net/jjshcc/www.puyufanyi.com/image029.jpg" width="237" border="0" longdesc="" /><br /> <p>原图像主要内容被U色背景?Canvas 遮盖Q四个角没被遮盖因此q行时则不被昄。运行后效果׃如图 8 所CZ?/p><img src ="http://www.tkk7.com/jjshcc/aggbug/353566.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.tkk7.com/jjshcc/" target="_blank">Eric_jiang</a> 2011-07-02 22:55 <a href="http://www.tkk7.com/jjshcc/archive/2011/07/02/353566.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Using BlazeDS with Spring http://www.tkk7.com/jjshcc/archive/2011/07/02/353557.htmlEric_jiangEric_jiangSat, 02 Jul 2011 09:59:00 GMThttp://www.tkk7.com/jjshcc/archive/2011/07/02/353557.htmlhttp://www.tkk7.com/jjshcc/comments/353557.htmlhttp://www.tkk7.com/jjshcc/archive/2011/07/02/353557.html#Feedback0http://www.tkk7.com/jjshcc/comments/commentRss/353557.htmlhttp://www.tkk7.com/jjshcc/services/trackbacks/353557.html

Flex is rapidly becoming the preferred technology for building groundbreaking internet applications delivered in the browser and on the desktop (using the AIR runtime). For several years, Spring has been one of the most popular frameworks for building the Java back-end of internet applications. In this article, we describe how to use BlazeDS Remoting to seamlessly integrate the two technologies and build state-of-the-art internet applications made of a Flex front-end and a Spring back-end.

Getting started

Whether you are a Flex developer with limited knowledge of Spring, or a Spring developer with limited knowledge of Flex, you can benefit from the powerful integration of these products. This section describes how BlazeDS enables a tight integration between Flex and Spring, and provides background information on the technologies at play.

What is Spring?

Spring is one of the most popular Java frameworks. The foundation of the Spring framework is a lightweight component container that implements the Inversion of Control (IoC) pattern.

Using an IoC container, components don't instantiate or even look up their dependencies (the objects they work with). The container is responsible for injecting those dependencies when it creates the components (hence the term "Dependency Injection" also used to describe this pattern).

The result is looser coupling between components. The Spring IoC container has proven to be a solid foundation for building robust enterprise applications. The components managed by the Spring IoC container are called Spring beans.

The Spring framework includes several other modules in addition to its core IoC container. These modules are not covered in this document even though we will be using the Spring JDBC abstraction framework in the second sample application below. More information on the Spring framework can be found at http://www.springframework.org.

What is Flex?

Flex is an environment for building Rich Internet Applications. The Flex programming model is made of:

  • ActionScript, an ECMAScript compliant, object-oriented programming model. With some syntactical differences, ActionScript looks and feels similar to Java, and supports the same object-oriented constructs: packages, classes, inheritance, interfaces, strong (but also dynamic) typing etc.
  • MXML: an XML-based language that provides an abstraction on top of ActionScript, and allows parts of an application (typically the View) to be built declaratively.
  • An extensive set of class libraries. The documentation is available here in a Javadoc-like format.

The Flex source code (.mxml and .as files) is compiled into Flash bytecode (.swf) that is executed at the client-side by the Flash virtual machine using a Just-In-Time compiler.

The Flex SDK is an open source project. It includes the Flex component library, the compiler, the debugger, and the documentation. A complete discussion of Flex is beyond the scope of this document. You can find more information and download the Flex SDK at http://opensource.adobe.com.

What is BlazeDS?

BlazeDS is a set of data services that give your Flex applications additional options for data connectivity. Without BlazeDS (or, without deploying any Flex-specific component at the server-side), Flex applications can access back-end data using either the HTTPService or the WebService:

  • You use the HTTPService component to send HTTP requests to a server, and consume the response. Although the HTTPService is often used to consume XML, it can be used to consume other types of responses. The Flex HTTPService is similar to the XMLHttpRequest component available in Ajax.
  • You use the WebService component to invoke SOAP-based web services.

BlazeDS adds the following services:

  • The Remoting Service allows your Flex application to directly invoke methods of Java objects deployed in your application server.
  • The Message Service provides a publish/subscribe infrastructure that enables your Flex application to publish messages and subscribe to a messaging destination, enabling the development of real-time data push and collaborative applications.
  • The Proxy Service allows your Flex application to make cross-domain service requests in a secure and controlled manner. In other words, it allows your Flex application to access a service available on a different domain than the domain from where the application was downloaded (without having to deploy a crossdomain.xml policy file on the target domain).

BlazeDS is deployed as a set of JAR files as part of your web application. Like the Flex SDK, BlazeDS is an open-source project. More information is available at http://opensource.adobe.com.

In this document, we focus on the Remoting service. The Remoting Service provides a tight and natural integration with Spring. There is no need to transform data, or to expose services in a certain way: the Flex application can directly access the beans registered in the Spring IoC container.

How does Flex use BlazeDS to access Spring beans?

So, if Flex clients can remotely access Java objects, and if Spring beans are Java objects, aren't we all set and ready to start accessing Spring beans from Flex clients? Almost… There is one simple element to configure.

The whole idea behind Spring IoC is to let the container instantiate components (and inject their dependencies). By default, however, components accessed remotely by a Flex client are instantiated by BlazeDS on the server. The key to the Flex/Spring integration, therefore, is to configure BlazeDS to let the Spring container take care of instantiating Spring beans. BlazeDS supports the concept of a factory to enable this type of custom component instantiation. The role of a factory is simply to provide ready-to-use instances of components to BlazeDS (instead of letting BlazeDS instantiate these components).

The supporting files available with this article include a factory class (SpringFactory) that provides BlazeDS with fully initialized (dependency-injected) instances of Spring beans. Note: The SpringFactory was developed by Jeff Vroom (Flex Data Services architect) and is also available on Adobe Exchange.

The remainder of this article describes how to configure your web application to use BlazeDS and Spring, how to configure the Spring Factory, and how to put the pieces together and start invoking Spring beans from Flex applications.

Setting up your environment

Configuring your web application is simple and merely requires installing and registering the necessary components.

Step 1: Install the BlazeDS turnkey server

The BlazeDS turnkey server is a ready-to-use version of Apache Tomcat in which the Blaze data services have already been deployed along with sample applications. The goal of the turnkey server is to give developers an easy way to run samples and tutorials out of the box.

To install the BlazeDS turnkey server:
  1. Make sure that you have the JDK 1.5 or higher installed, and that you have a JAVA_HOME environment variable pointing to your Java Development Kit installation.
  2. Download blazeds-turnkey-<version>.zip.
  3. Unzip blazeds-turnkey-<version>.zip in /blazeds.

    Note.You can unzip blazeds-turnkey-<version>.zip anywhere else. Just make sure you adjust the path in the instructions provided in this document accordingly.

  4. Start the samples database.
    1. Open a command prompt.
    2. Navigate to /blazeds/sampledb.
    3. Execute startdb.bat (Windows) or startdb.sh (Unix-based systems)
  5. Start Tomcat.
    1. Open a command prompt.
    2. Navigate to /blazeds/tomcat/bin.
    3. Execute the following command:
catalina run
  1. Access http://localhost:8400/samples to make sure the installation is successful: you should see the BlazeDS samples home page.

As an alternative to using the turnkey server, you could use one of the following options:

  1. Download blazeds-<version>.war and deploy it in your own application server. Blazeds-<version>.war is a blank web application configured to use the BlazeDS data services.

    Note: samples-<version>.war includes everything included in blazeds.war, plus a series of samples.

  2. Download blazeds-<version>.war and merge its content in your own web application.

The instructions in this document assume that you use the BlazeDS turnkey server. If you are using one of the alternative options, you will have to adjust the instructions accordingly.

Step 2: Install the Flex SDK

You need the Flex compiler to compile the client-side (Flex-side) of the sample applications discussed in this document. The Flex compiler is part of the Flex SDK. As a convenience, the Flex SDK is available as part of the BlazeDS installation in blazeds/resources/flex_sdk/flex_sdk_3.zip.

Note: The Flex SDK can also be downloaded at http://opensource.adobe.com. It is also available as part of Flex Builder.

To install the Flex SDK:

You can skip this step if Flex Builder 3 is installed on your system.

Unzip /blazeds/resources/flex_sdk/flex_sdk_3.zip in /flex_sdk_3.

Note: You can unzip flex_sdk_3.zip anywhere else. Just make sure you adjust the path in the instructions provided in this document accordingly.

Step 3: Install Spring

Note: A complete discussion of the Spring installation process is beyond the scope of this article. Refer to http://www.springframework.org for more information. The steps below describe a basic configuration that is sufficient for the purpose of this article.

  1. Download the Spring framework at http://www.springframework.org/download (the version without dependencies is sufficient to complete the examples in this article).

    Note: The examples below have been developed and tested using Spring 2.x. However the integration approach described in this document (and the SpringFactory class) should work fine using Spring 1.2.8 (some of the examples might not work because they use Spring 2.x features).

  2. Unzip the downloaded file.
  3. Locate spring.jar in the dist directory and copy the file to /blazeds/tomcat/webapps/blazeds/WEB-INF/lib
  4. Open /blazeds/tomcat/webapps/blazeds/WEB-INF/web.xml and add the context-param and listener definitions as follows:
<context-param> <param-name>contextConfigLocation</param-name> <param-value>/WEB-INF/applicationContext.xml</param-value> </context-param> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener </listener-class> </listener>

Step 4: Install the supporting files

  1. Download flex-spring.zip here
  2. Unzip flex-spring.zip in /flex-spring

Flex-spring.zip includes the Spring factory as well as the supporting files for the examples below.

Step 5: Register the Spring factory

  1. Copy SpringFactory.class and SpringFactory$SpringFactoryInstance.class from /flex-spring/factory/bin/flex/samples/factories to /blazeds/tomcat/webapps/blazeds/WEB-INF/classes/flex/samples/factories.
  2. Register the Spring factory in /blazeds/tomcat/webapps/blazeds/WEB-INF/flex/services-config.xml:
<factories> <factory id="spring" class="flex.samples.factories.SpringFactory"/> </factories>

Example 1: Mortgage calculator

This first application is intentionally simplistic to provide an uncluttered example of wiring Spring beans together and invoking them from a Flex application.

Step 1: Examine the application source code

  1. Examine the Flex source code:
    Open MortgageCalc.mxml located in /flex-spring/samples/mortgage/flex in a code editor to familiarize yourself with the application. The application enables the user to enter a mortgage amount. When the user clicks the "Calculate" button, the application obtains the value of the monthly payment for that mortgage by invoking the calculate() method of the remote object identified by a logical name: "mortgageService". "mortgageService" is mapped to a fully qualified Java class name in the remoting-config.xml file (see Step 3 below).
  2. Examine the Java source code:
    Open RateFinder.java, SimpleRateFinder.java and Mortgage.java located in /flex-spring/samples/mortgage/java in a code editor. Notice that Mortgage has a dependency to a RateFinder object. Mortgage doesn't instantiate a RateFinder object itself, doesn't lookup up for a RateFinder object, and doesn't even know the exact type of the object it will be dealing with (RateFinder is an inteface). An instance of a class implementing the RateFinder interface will be injected by the container (using the setRateFinder method) when it instantiates the component (see step 2 below).

Step 2: Register Spring beans

  1. If it doesn't already exist, create a file named applicationContext.xml in /blazeds/tomcat/webapps/blazeds/WEB-INF.
  2. Register the rateFinderBean and mortgageBean beans in applicationContext.xml as follows:
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd"> <beans> <bean id="rateFinderBean" class="flex.samples.spring.mortgage.SimpleRateFinder"/> <bean id="mortgageBean" class="flex.samples.spring.mortgage.Mortgage"> <property name="rateFinder" ref="rateFinderBean"/> </bean> </beans>

Notice that in the mortgageBean definition, we tell the container how to inject the rateFinder dependency: the rateFinder property is mapped to rateFinderBean, which defines an instance of the SimpleRateFinder class.

Step 3: Configure the Flex Remoting destination

  1. Open remoting-config.xml in /blazeds/tomcat/webapps/blazeds/WEB-INF/flex.
  2. Add a mortgageService destination as follows:
<destination id="mortgageService"> <properties> <factory>spring</factory> <source>mortgageBean</source> </properties> </destination>

Notice that we use the Spring factory defined above (see "Register the Spring Factory"), and we provide the name of the Spring bean as defined in applicationContext.xml as the source.

Step 4: Build the project

The Flex SDK includes ANT tasks that make it easy to compile Flex applications and create HTML pages to host them as part of a build process. The support files include build scripts to compile and deploy each sample application.

Note: You need the Apache Ant build tool to build and deploy your applications as described in this document. If Apache Ant is not installed on your system, visit http://ant.apache.org and follow the download and installation instructions.

To build the Mortgage Calculator project:
  1. Edit /flex-spring/samples/mortgage/build.xml:
    1. Make sure the FLEX_HOME property points to the location of the Flex SDK on your system.
    2. Make sure the CONTEXT_ROOT property matches the context root of your web application.
  2. Open a command prompt.
  3. Navigate to /flex-spring/samples/mortgage.
  4. Execute the following command to compile and deploy the client and server of the application:
    ant

    The build process deploys the client side of the application (the compiled flex application) in /blazeds/tomcat/webapps/blazeds/mortgage and the server side (the compiled Java classes) in /blazeds/tomcat/webapps/blazeds/WEB-INF/classes/flex/samples/spring/mortgage.

Step 5: Run the client application

  1. Restart Tomcat.
  2. Open a browser, access http://localhost:8400/blazeds/mortgage/index.html, and test the application: Enter a loan amount and click "Calculate" to get the monthly payment for a 30-year mortgage.

Example 2: Store/inventory management using Flex Remoting

This second example is more sophisticated and includes database connectivity. To keep the application simple and avoid dependencies on other products or frameworks, the Spring JDBC abstraction framework is used to access the database. You could use the Spring support for ORM data access (using Hibernate, JDO, Oracle TopLink, iBATIS, or JPA) as an alternative: the specific Spring data access strategy you choose has no impact on the Flex/Spring integration. This sample application has two modules: a database maintenance module (storeadmin) and a customer-facing product catalog with filtering capabilities (store).

Step 1: Examine the application source code

  1. Examine the Flex source code:

    Open store.mxml located in /flex-spring/samples/store/flex in a code editor to familiarize yourself with the store application. Notice the RemoteObject declaration pointing to the "productService" destination. "productService" is mapped to a Spring bean in Step 3 below. When the application starts, it invokes the findAll() method on the remote bean to retrieve the list of products (see the createComplete event on the Application tag).

    Open storeadmin.mxml and ProductForm.mxml located in /flex-spring/samples/store/flex in a code editor to familiarize yourself with the storeadmin application. Notice that the storeadmin application uses the same remote Spring bean (productService) as the store application to retrieve the list of products using the findAll() method, and update changes using the updateProduct() method.

  2. Examine the Java source code:

    Open ProductDAO.java, SimpleProductDAO.java and Product.java located in /flex-spring/samples/store/java in a code editor. Notice that SimpleProductDAO extends org.springframework.jdbc.core.support.JdbcDaoSupport. JdbcDaoSupport has a dependency to a javax.sql.DataSource object (javax.sql.DataSource is an interface).

Step 2: Register Spring beans

  1. Register the dataSource and productDAOBean beans in applicationContext.xml as follows:
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"> <property name="driverClassName" value="org.hsqldb.jdbcDriver"/> <property name="url" value=" jdbc:hsqldb:hsql://localhost:9002/flexdemodb"/> <property name="username" value="sa"/> <property name="password" value=""/> </bean> <bean id="productDAOBean" class="flex.samples.spring.store.SimpleProductDAO"> <property name="dataSource" ref="dataSource"/> </bean>
  1. Copy hsqldb.jar from blazeds/tomcat/webapps/samples/WEB-INF/lib to /blazeds/tomcat/webapps/blazeds/WEB-INF/lib.

Step 3: Configure the Flex Remoting destination

  1. Open remoting-config.xml in /blazeds/tomcat/webapps/blazeds/WEB-INF/flex.
  2. Add the productService destination as follows:
<destination id="productService"> <properties> <factory>spring</factory> <source>productDAOBean</source> </properties> </destination>

Step 4: Build the project

  1. Edit /flex-spring/samples/store/build.xml:
    1. Make sure the FLEX_HOME property points to the location of the Flex SDK on your system.
    2. Make sure the CONTEXT_ROOT property matches the context root of your web application.
  2. Open a command prompt.
  3. Navigate to /flex-spring/samples/store.
  4. Execute the following command to compile and deploy the client-side and the server side of the application: ant

    The build process deploys the client-side of the store and storeadmin applications in /blazeds/tomcat/webapps/blazeds/store and /blazeds/tomcat/webapps/blazeds/storeadmin respectively, and the server-side (the compiled Java classes) in /blazeds/tomcat/webapps/blazeds/WEB-INF/classes/flex/samples/spring/store.

Step 5: Run the client application

  1. Restart Tomcat
  2. Open a browser, access http://localhost:8400/blazeds/storeadmin/index.html, and test the storeadmin application.
  3. Open a browser, access http://localhost:8400/blazeds/store/index.html, and test the store application.


Eric_jiang 2011-07-02 17:59 发表评论
]]>
BlazeDS with Remote Objects examplehttp://www.tkk7.com/jjshcc/archive/2011/07/02/353551.htmlEric_jiangEric_jiangSat, 02 Jul 2011 08:59:00 GMThttp://www.tkk7.com/jjshcc/archive/2011/07/02/353551.htmlhttp://www.tkk7.com/jjshcc/comments/353551.htmlhttp://www.tkk7.com/jjshcc/archive/2011/07/02/353551.html#Feedback0http://www.tkk7.com/jjshcc/comments/commentRss/353551.htmlhttp://www.tkk7.com/jjshcc/services/trackbacks/353551.htmlIn my previous tutorial on BlazeDS, I went over an example over how to setup remote objects with data push. There are however, a lot of instances where someone just wanted to receive data and they aren’t concerned with it being updated., so it turns more into a ‘client requesting data whenever it wants it’ scenario. This article will not be nearly as indepth as the last blazeDS article, but if you have not setup your environment for BlazeDS before, it will probably be in your best interest to check it out.

Lets begin by making sure that we have our server and BlazeDs war file. Both of them can be found here:

Tomcat 6
BlazeDS

Once again, we are going to extract the contents into our BlazeDS server project. This time, we are only going to edit remoting-config.xml. Make sure that the following lines are in there.

<default-channels>
   <channel ref="my-amf"/>
</default-channels>
<destination id="BlazeDsService"> 
  <properties> 
     <source>com.codeofdoom.BlazeDsService</source> 
  </properties> 
</destination>

We tell the remoting-config to use the channel “my-amf”, which is already defined with the services-config.xml file. Next we are telling it to use the the destination “BlazeDsService”. This is what our remote object will be looking at. The properties also contains a source. This source is going to be a java class with the methods it needs in order to process the calls from the front end. You must make sure you include the fully qualified name, so we will call it com.codeofdoom.BlazeDsService. So what does this file look like?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
package com.codeofdoom;
 
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import flex.messaging.io.ArrayCollection;
 
public class BlazeDsService {
    private static final String[] MASTER_LIST = {"C", "FNM", "FRE", "F", "GOOG", "AIG", "CSCO", "MSFT", "AAPL", "YHOO", "BSX", "PORT","F", "TNT", "ESP", "RET", "VBN", "EES"};
    public BlazeDsService(){}
    public List<StockQuote> getQuotes(){
        List<StockQuote> list = new ArrayList<StockQuote>();
        Random r = new Random();
        for (String s:MASTER_LIST){
            StockQuote sq = new StockQuote();
            sq.setName(s);
            sq.setPrice(r.nextInt(50));
            list.add(sq);
        }
        return list;
    }
}

Yep. Thats it. It not implementing anything crazy, not extending any service adapters, anything like that. It’s just a java class with some functions on it. Next we are going to create the object that we will be sending back and forth. In this example, we are going to be simulating retrieving some stock data, so I called the class StockQuote.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
package com.codeofdoom;
 
public class StockQuote {
    private String name;
    private int price;
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public int getPrice() {
        return price;
    }
    public void setPrice(int price) {
        this.price = price;
    }
}

On the front end, we are going to need the matching object, and here that is.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
package com.codeofdoom.dto
{
    [Bindable]
    [RemoteClass(alias="com.codeofdoom.StockQuote")]
    public class StockQuote{
        private var _name:String
        private var _price:int;
 
        public function get name():String{
            return _name;
        }
        public function get price():int{
            return _price;
        }
        public function get name(name:String):void{
            _name = name;
        }
        public function get price(price:int):void{
            _price = price;
        }
    }
}

I mentioned this in the last article, but I am going to mention this again, just to stress the importance. When we are using Remote Object, we must make sure that

  • All the properties are the same.
  • We have getters and setters for all properties on back the java side and the AS side.
  • We must have our AS object set as Bindable and the RemoteClass set to the path of our remote object.
  • We must make sure that the constructors match. I have seen where flex will swallow the error message if they don’t match, making debugging a pain.

Now lets take a look at the mxml.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
    <mx:Script>
        <![CDATA[
            import mx.rpc.events.ResultEvent;
            import mx.collections.ArrayCollection;
            import mx.messaging.messages.IMessage;
            import mx.messaging.events.MessageAckEvent;
            import mx.messaging.messages.AsyncMessage;
            import mx.messaging.events.MessageEvent;
 
            public function retrieveStocks():void{
                ro.getQuotes();
            }
            private function result(e:ResultEvent):void{
                stockChart.dataProvider = e.result as ArrayCollection;
            }
        ]]>
    </mx:Script>
    <mx:RemoteObject id="ro" result="result(event)" destination="BlazeDsService"/>
    <mx:VBox width="100%">
        <mx:BarChart width="100%" id="stockChart">
            <mx:horizontalAxis>
                <mx:CategoryAxis categoryField="name"/>
            </mx:horizontalAxis>
            <mx:series>
                <mx:ColumnSeries xField="name" yField="price"/>
            </mx:series>
        </mx:BarChart>
        <mx:Button label="Retrieve Stocks" click="retrieveStocks()"/>
    </mx:VBox>   
</mx:Application>

Once again, not much to it. There are three areas of importance.

  • Our remote object is that is subscribed to our destination that we declared within our remoting-config.xml.
  • The retrieveQuotes function is what calls our backend. Note that it just calls ‘getQuotes’ directly from the remote object.
  • The result function that is set on the RemoteObject is what comes back from the back end. Now a lot of examples will do something to the grid such as dataprovider = {ro.getQuotes.lastResult}. We could do the same here, but i wanted to give you a chance to inspect the object to see what exactly is coming back.

Once you click the Retrieve Stocks button, it then calls the getQuotes() function on the remote object. That then builds our List of objects and passes them to the front end. When it comes back, we then just apply it to the dataprovider of our chart.

I really wanted to take the time out to show you some other ways of handling your data within BlazeDS. It is an extremely powerful tool that every Flex developer should have under their belt. Its a lot less cumbersome than standard calls to the back end and the amount of data that is sent back and forth is a lot smaller than sending plane XML over the wire. Good luck!

Here is the source



Eric_jiang 2011-07-02 16:59 发表评论
]]>
BlazeDS Usage -Messagehttp://www.tkk7.com/jjshcc/archive/2011/06/29/353365.htmlEric_jiangEric_jiangWed, 29 Jun 2011 07:40:00 GMThttp://www.tkk7.com/jjshcc/archive/2011/06/29/353365.htmlhttp://www.tkk7.com/jjshcc/comments/353365.htmlhttp://www.tkk7.com/jjshcc/archive/2011/06/29/353365.html#Feedback0http://www.tkk7.com/jjshcc/comments/commentRss/353365.htmlhttp://www.tkk7.com/jjshcc/services/trackbacks/353365.htmlMessages

All communication between Flex client components and BlazeDS is performed with messages. Flex components use several message types to communicate with their corresponding services in BlazeDS. All messages have client-side (ActionScript) implementations and server-side (Java) implementations because the messages are serialized and deserialized on both the client and the server. You can also create messages directly in Java and have those messages delivered to clients using the server push API.

Some message types, such as AcknowledgeMessage and CommandMessage, are used across different Flex components and BlazeDS services. Other message types are used by specific Flex components and BlazeDSservices. Forexample, to have a Producer component send a message to subscribed Consumer components, you create a message of type AsyncMessage and pass it to the send() method of the Producer component.

In other situations, you do not write code for constructing and sending messages. For example, you simply use a RemoteObject component to call the remote method from the Flex application. The RemoteObject component creates a RemotingMessage to encapsulate the RemoteObject call. In response it receives an AcknowledgeMessage from the server. The AcknowledgeMessage is encapsulated in a ResultEvent in the Flex application.

Sometimes you must create a message to send to the server. For example, you could send a message by creating an AsyncMessage and passing it to a Producer.

Services and destinations
Services and destinations are the next links in the message processing chain in the BlazeDS server. The system includes four services and their corresponding destinationsBlazeDS:
     RemotingService and RemotingDestination
     HTPProxyService and HTTPProxyDestination
     MessageService and MessageDestination
Services are the targets of messages from client-side Flex components. Think of destinations as instances of a service configured in a certain way. For example, a RemoteObject component is used on the Flex client to communicate with
the RemotingService. In the RemoteObject component, you must specify a destination id property that refers to a remoting destination with certain properties, such as the class you want to invoke methods on. The mapping
between client-side Flex components and BlazeDS services is as follows:
     HTTPService and WebService communicate with HTTPProxyService/HTTPProxyDestination
     RemoteObject communicates with RemotingService/RemotingDestination
     Producer and Consumer communicate with MessageService/MessageDestination
You can configure services and their destinations in the services-config.xml file, but it is best practice to put them in separate files as follows:
     RemotingService configured in the remoting-config.xml file
     HTTPProxyService configured in the proxy-config.xml file
     MessageService configured in the messaging-config.xml file

The following table describes the typical setup of the configuration files. Commented versions of these files are available in the resources/config directory of the BlazeDS installation.

Filename Description
services-config.xml  The top-level BlazeDS configuration file. This file usually contains security constraint definitions,channel definitions, and logging settings that each of the services can use. It can contain service definitions inline or include them by reference. Generally, the services are defined in the remoting-config.xml, proxy-config.xml, and messaging-config.xml.
remoting-config.xml The Remoting Service configuration file, which defines Remoting Service destinations for working with remote objects.
proxy-config.xml The Proxy Service configuration file, which defines Proxy Service destinations for working with web services and HTTP services (REST services).
messaging-config.xml The Messaging Service configuration file, which defines Messaging Service destinations for performing publish subscribe messaging.

The file-path value is relative to the location of the services-config.xml file. The following example shows service definitions included by reference:
<services>
<!-- REMOTING SERVICE -->
<service-include file-path="remoting-config.xml"/>
<!-- PROXY SERVICE -->
<service-include file-path="proxy-config.xml"/>
<!-- MESSAGE SERVICE -->
<service-include file-path="messaging-config.xml"/>
</services>



Eric_jiang 2011-06-29 15:40 发表评论
]]>
BlazeDS Uage---Building your client-side applicationhttp://www.tkk7.com/jjshcc/archive/2011/06/29/353344.htmlEric_jiangEric_jiangWed, 29 Jun 2011 04:24:00 GMThttp://www.tkk7.com/jjshcc/archive/2011/06/29/353344.htmlhttp://www.tkk7.com/jjshcc/comments/353344.htmlhttp://www.tkk7.com/jjshcc/archive/2011/06/29/353344.html#Feedback0http://www.tkk7.com/jjshcc/comments/commentRss/353344.htmlhttp://www.tkk7.com/jjshcc/services/trackbacks/353344.htmlby default the compiler references the flex-config.xml configuration file, which specifies to include the libs/player directory in the library path for Flash Player. When you compile an application for AIR, use the load-config option to the mxmlc compiler to specify the air-config.xml file, which specifies to include the libs/air directory in the library path.

Specifying the services-config.xml file in a compilation
When you compile your Flex application, you typically specify the services-config.xml configuration file to the compiler. This file defines the channel URLs that the client-side Flex application uses to communicate with the BlazeDS server. Then the channel URLs are compiled into the resultant SWF file.
Both client-side and server-side code use the services-config.xml configuration file. If you change anything in services-config.xml, you usually have to recompile your client-side applications and restart your server-side application for the changes to take effect.
In Flex Builder, the appropriate services-config.xml file is included automatically based on the BlazeDS web application that you specified in the configuration of your Flex Builder project. When you use the mxmlc compiler, use the services option to specify the location of the file.
Note: You can also create channel definitions at run time in ActionScript. In that case, you might be able to omit the reference to the services-config.xml configuration file from the compiler.

Eric_jiang 2011-06-29 12:24 发表评论
]]>
BlazeDS Uage---Messaging Service examplehttp://www.tkk7.com/jjshcc/archive/2011/06/29/353343.htmlEric_jiangEric_jiangWed, 29 Jun 2011 03:58:00 GMThttp://www.tkk7.com/jjshcc/archive/2011/06/29/353343.htmlhttp://www.tkk7.com/jjshcc/comments/353343.htmlhttp://www.tkk7.com/jjshcc/archive/2011/06/29/353343.html#Feedback0http://www.tkk7.com/jjshcc/comments/commentRss/353343.htmlhttp://www.tkk7.com/jjshcc/services/trackbacks/353343.htmlDefine the messaging destination in WEB-INF/flex/messaging-config.xml, as the following example shows:
<destination id="MessagingDestination" channels="my-amf-poll"/>

Define the my-amf-poll channel in WEB-INF/flex/services-config.xml, as the following example shows:
<channel-definition id="my-amf-poll" class="mx.messaging.channels.AMFChannel">
<endpoint url="http://{server.name}:{server.port}/{context.root}/messagebroker/amfpoll" class="flex.messaging.endpoints.AMFEndpoint"/>
    
<properties>
     
<polling-enabled>true</polling-enabled>
     
<polling-interval-seconds>1</polling-interval-seconds>
    
</properties>
</channel-definition>

This channel definition creates a polling channel with a polling interval of 1 second. Therefore, the client sends a poll message to the server every second to request new messages. Use a polling channel because it is the easiest way for the client to receive updates. Other options include polling with piggybacking, long-polling, and streaming.The following Flex client application uses the Producer component to send a message to the destination, and the Consumer component to receive messages sent to the destination. To send the message, the Producer first creates an instance of the AsyncMessage class and then sets its body property to the message. Then, it calls the Producer.send() method to send it. To receive messages, the Consumer first calls the Consumer.subscribe() method to subscribe to messages sent to a specific destination.
<?xml version="1.0"?>
<!-- intro\intro_messaging.mxml -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
width
="100%" height="100%"
creationComplete
="consumer.subscribe();">
<mx:Script>
<![CDATA[
import mx.messaging.events.MessageFaultEvent;
import mx.messaging.events.MessageEvent;
import mx.messaging.messages.AsyncMessage;
import mx.messaging.Producer;
import mx.messaging.Consumer;
// Send the message in response to a Button click.
private function sendMessage():void {
var msg:AsyncMessage = new AsyncMessage();
msg.body = "Foo";
producer.send(msg);
}
// Handle the received message.
private function messageHandler(event:MessageEvent):void {
ta.text += "Consumer received message: "+ event.message.body + "\n";
}
// Handle a message fault.
private function faultHandler(event:MessageFaultEvent):void {
ta.text += "Received fault: " + event.faultString + "\n";
}
]]>
</mx:Script>
<mx:Producer id="producer" destination="MessagingDestination" fault="faultHandler(event);"/>
<mx:Consumer id="consumer" destination="MessagingDestination" fault="faultHandler(event);" message="messageHandler(event);"/>
<mx:Button label="Send" click="sendMessage();"/>
<mx:TextArea id="ta" width="100%" height="100%"/>
</mx:Application>
Compile the client application into a SWF file by using Flex Builder or the mxmlc compiler, and then deploy it to
your web application.


Eric_jiang 2011-06-29 11:58 发表评论
]]>
BlazeDS Uage---RPC service examplehttp://www.tkk7.com/jjshcc/archive/2011/06/29/353335.htmlEric_jiangEric_jiangWed, 29 Jun 2011 03:09:00 GMThttp://www.tkk7.com/jjshcc/archive/2011/06/29/353335.htmlhttp://www.tkk7.com/jjshcc/comments/353335.htmlhttp://www.tkk7.com/jjshcc/archive/2011/06/29/353335.html#Feedback0http://www.tkk7.com/jjshcc/comments/commentRss/353335.htmlhttp://www.tkk7.com/jjshcc/services/trackbacks/353335.htmlConfigure an existing J2EE web application to support BlazeDS by performing the following steps:
1 Add the BlazeDS JAR files and dependent JAR files to the WEB-INF/lib directory.
2 Edit the BlazeDS configuration files in the WEB-INF/flex directory.
3 Define MessageBrokerServlet and a session listener in WEB-INF/web.xml.

RPC service example
The Remoting Service is one of the RPC services included with BlazeDS. The Remoting Service lets clients access methods of Plain Old Java Objects (POJOs) on the server.In this example, you deploy a Java class, EchoService.java, on the server that echoes back a String passed to it from the client. The following code shows the definition of EchoService.java:

1 package remoting;
2 public class EchoService
3 {
4     public String echo(String text) {
5         return "Server says: I received '" + text + "' from you";
6     }
7 }
8 


The echo() method takes a String argument and returns it with additional text. After compiling EchoService.java,place EchoService.class in the WEB-INF/classes/remoting directory. Notice that the Java class does not have to import or reference any BlazeDS resources.
Define a destination, and reference one or more channels that transport the data. Configure EchoService.class as a remoting destination by editing the WEB-INF/flex/remoting-config.xml file and adding the following code:

<destination id="echoServiceDestination" channels="my-amf">
 
<properties>
  
<source>remoting.EchoService</source>
 
</properties>
</destination>

The source element references the Java class, and the channels attribute references a channel called my-amf.Define the my-amf channel in WEB-INF/flex/services-config.xml, as the following example shows:

<channel-definition id="my-amf" class="mx.messaging.channels.AMFChannel">
    
<endpoint url="http://{server.name}:{server.port}/{context.root}/messagebroker/amf" class="flex.messaging.endpoints.AMFEndpoint"/>
    
<properties>
        
<polling-enabled>false</polling-enabled>
    
</properties>
</channel-definition>

The channel definition specifies that the Flex client uses a non-polling AMFChannel to communicate with the AMFEndpoint on the server.
Note: If you deploy this application on the samples web application installed with BlazeDS, services-config.xml already contains a definition for the my-amf channel.The Flex client application uses the RemoteObject component to access EchoService. The RemoteObject component uses the destination property to specify the destination. The user clicks the Button control to invoke the remote
echo() method:

<?xml version="1.0"?>
<!-- intro\intro_remoting.mxml -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" width="100%" height="100%">
<mx:Script>
<![CDATA[
 import mx.rpc.events.FaultEvent;
 import mx.rpc.events.ResultEvent;
 // Send the message in response to a Button click.
 private function echo():void {
    var text:String = ti.text;
    remoteObject.echo(text);
 }
 // Handle the recevied message.
 private function resultHandler(event:ResultEvent):void {
     ta.text += "Server responded: "+ event.result + "\n";
 }
 // Handle a message fault.
 private function faultHandler(event:FaultEvent):void {
     ta.text += "Received fault: " + event.fault + "\n";
 }
 
]]>
</mx:Script>
<mx:RemoteObject id="remoteObject" destination="echoServiceDestination" result="resultHandler(event);" fault="faultHandler(event);"/>
<mx:Label text="Enter a text for the server to echo"/>
<mx:TextInput id="ti" text="Hello World!"/>
<mx:Button label="Send" click="echo();"/>
<mx:TextArea id="ta" width="100%" height="100%"/>
</mx:Application>

Compile the client application into a SWF file by using Flex Builder or the mxmlc compiler, and then deploy it to
your web application.
 



Eric_jiang 2011-06-29 11:09 发表评论
]]>
Flash、Flex资源攉之十全大?http://www.tkk7.com/jjshcc/archive/2011/06/29/353321.htmlEric_jiangEric_jiangWed, 29 Jun 2011 01:27:00 GMThttp://www.tkk7.com/jjshcc/archive/2011/06/29/353321.htmlhttp://www.tkk7.com/jjshcc/comments/353321.htmlhttp://www.tkk7.com/jjshcc/archive/2011/06/29/353321.html#Feedback0http://www.tkk7.com/jjshcc/comments/commentRss/353321.htmlhttp://www.tkk7.com/jjshcc/services/trackbacks/353321.htmlAPIs、Libs、Components

1、as3ebaylib

http://code.google.com/p/as3ebaylib/

2、as3youtubelib

http://code.google.com/p/as3youtubelib/

3、as3flickrlib

http://code.google.com/p/as3flickrlib/

4、Yahoo ASTRA Flash Components

http://developer.yahoo.com/flash/astra-flash/

5、facebook-as3

http://code.google.com/p/facebook-as3/

6、as3awss3lib

http://code.google.com/p/as3awss3lib/

7、Adobe ActionScript 3:resources:apis:libraries Q官方,包括corelib、FlexUnit、Flickr、Mappr、RSS and Atom libraries、Odeo、YouTubeQ?/p>

http://labs.adobe.com/wiki/index.php/ActionScript_3:resources:apis:libraries

8、Tweener    用于q渡与切换的一l动d

http://code.google.com/p/tweener/

9、uicomponents-as3     一l轻量的AS3 UIlg?/p>

http://code.google.com/p/uicomponents-as3/

10、as3ds     AS3的数据结构实?/p>

http://code.google.com/p/as3ds/

 

11、mecheye-as3-libraries     一l主要用于Flash 游戏开发的AS3?/p>

http://code.google.com/p/mecheye-as3-libraries/

12、XIFF    一套XMPP协议的AS3实现

http://svn.igniterealtime.org/svn/repos/xiff/branches/xiff_as3_flexlib_beta1/

13、FZip    一套AS3库,可用作对ZIP压羃文g的蝲入、修改与创徏

http://codeazur.com.br/lab/fzip/

14、FlexLib    一套开源的Flex界面lg?/p>

http://code.google.com/p/flexlib/

15、AnimatedGIfLoader Flex Component      可蝲入GIF的Flexlg

http://dougmccune.com/blog/animatedgifloader-flex-component/

16、goplayground     一套轻量的,可用创徏属于你自qAS3 动画工具的库

http://code.google.com/p/goplayground/

17、AlivePDF    开源的用于PDF创徏的AS3?/p>

http://www.alivepdf.org/

18、jwopitz-lib    一l开源的Flex用户界面lg

http://code.google.com/p/jwopitz-lib/

19、as3crypto    AS3实现的一套加密库Q包括多U加密算?/p>

http://code.google.com/p/as3crypto/

20、flare     一套强大的可视化交互的AS3cd

http://flare.prefuse.org/

21、SWFAddress     一而强大的库,可以为Flash和Ajax提供深链接的功能

http://www.asual.com/swfaddress/

22、SWFObject     用于嵌入FlashQAdobe官方也认可了

http://code.google.com/p/swfobject/

23、ulse Particle System 一套开源的强大的AS3动态粒子系l?/p>

http://code.google.com/p/pulse-particle/

http://www.rogue-development.com/pulseParticles.html

24、SpringGraph Flex Component

http://mark-shepherd.com/blog/springgraph-flex-component/

25、GoASAP     AS3动画?/p>

http://code.google.com/p/goasap/

http://www.goasap.org/index.html

26、asaplibrary    一套开源的Flash Actionscript3.0 RIA?/p>

http://code.google.com/p/asaplibrary/

http://asaplibrary.org/

http://asapframework.org

27、as3mathlib 开源Flex/Actionscript数学?/p>

http://code.google.com/p/as3mathlib/

28、as3corelib 包含一些基功能AS3?/p>

http://code.google.com/p/as3corelib/

29、minimalcomps 一lAS3 UIlg

http://www.bit-101.com/minimalcomps/

30、as3gif

http://code.google.com/p/as3gif/

31、queueloader-as3      一lAS3库,用来q行资源序列载入及监?/p>

http://code.google.com/p/queueloader-as3/

32、TweenMax (AS3)

http://blog.greensock.com/tweenmaxas3/

33、Atellis Reflection Component              一ƾFlex反射效果lg

http://labs.atellis.com/2007/07/11/atellis-reflection-component/

34、AS3Eval     单来_是用AS3实现的AS3~译?/p>

http://eval.hurlant.com/

35、ByteArray 的组件、库合集Q包括liquid components、mousegesture、ASZip、GIF Player、GIF Animation Encoder、AlivePDF、Live JPEG Encoder、ScaleBitmap{?/p>

http://www.bytearray.org/?page_id=82

36、AS3C     针对AVM2虚拟机,用C#写的字节码编译器

http://code.google.com/p/as3c/

37、as3httpclientlib    as3实现的http客户?/p>

http://code.google.com/p/as3httpclientlib/

38、as3ui   一l常规的as3 ui界面?/p>

http://code.google.com/p/as3ui/

39、as3xls 让你在flex中可以读写Excel文g

http://code.google.com/p/as3xls/

40、as3flexdb 让你的flexE序可以q接到MySQL服务器,主要是用AMFPHP来访问PHP服务?/p>

http://code.google.com/p/as3flexdb/

q一是一详l用介l的教程

http://itutorials.ro/viewtopic.php?f=9&t=7

41、vivisectingmedia-as3 一lAS3/Flex实用库,是作者在实践中ȝ出来?/p>

http://code.google.com/p/vivisectingmedia-as3/

42、assql   通过ActionScript 3.0 直接q接MySQL 数据?/p>

http://code.google.com/p/assql/

43、FlexserverLib   Flex & BlazeDS服务端扩?/p>

http://code.google.com/p/flexserverlib/

http://www.infoaccelerator.net/blog/post.cfm/announcing-flexserverlib-the-blazeds-extension-project

44、dphibernate Flex/BlazeDS Hibernate Adapter Q支持gq加?/p>

http://code.google.com/p/dphibernate/

45、as3syntaxhighlight   as3及mxml代码高亮?/p>

http://code.google.com/p/as3syntaxhighlight/

46、Tweensy   一ƾ新的缓动及q动效果?/p>

http://code.google.com/p/tweensy/

47、JSwoof the fastest JSON parser for Flex

http://www.waynemike.co.uk/jswoof

48、casa lib   it provides a core set of classes,interfaces,and utilities

http://casalib.org/

49、FlipCard    3D Flip Card for Flex

http://code.google.com/p/flipcard/

50、Efflex 一l特效库

http://code.google.com/p/efflex/

http://www.efflex.org/

51、ObjectHandles   一l能用UIlgQ允怽对组件进行熾放与Ud

http://www.rogue-development.com/objectHandles.html

http://code.google.com/p/flex-object-handles/wiki/ObjectHandlesUsage

52、as3commons 一las3通用?/p>

http://code.google.com/p/as3-commons/

http://www.as3commons.org/

53、urlkit 为Flex应用E序提供URL deep linking深度链接的库

http://code.google.com/p/urlkit/

54、standingwave 音频合成的Flash/Flex?/p>

http://code.google.com/p/standingwave/

 

 

Actionscript 3.0 Class

1、fZip    此类可允怽载入标准的zip文gq提取里面包含的文g

http://wahlers.com.br/claus/blog/zip-it-up/

2、AS3: Layout class for Flash CS3     一l用作布局的类

http://www.senocular.com/?id=2.8

3、CSSLoader     该类允许Flex应用E序在运行时载入CSS

http://www.rubenswieringa.com/blog/cssloader

4、AS3: QueryString      一个单例类Q用来获取URL地址后所带参数值对

http://evolve.reintroducing.com/2008/07/03/as3/as3-querystring/#more-141

5、ActionScript 3 Contextual Menu Manager Class         AS3兌菜单理c?/p>

http://www.blog.noponies.com/archives/103

6、Spark project 一pd丰富的AS3库,日本开?/p>

http://www.libspark.org/wiki/WikiStart/en

2D & 3D Engine

1、APE (Actionscript Physics Engine)  物理引擎

http://www.cove.org/ape/

2、Away3D

http://code.google.com/p/away3d/

3、Papervision3D

http://code.google.com/p/papervision3d/

4、Sandy     开?D?/p>

http://www.flashsandy.org/versions/3.0

5、FORM   一套AS3完成的用?D刚性物体的物理引擎

http://code.google.com/p/foam-as3/

6、Five3D    Z矢量的Flash 3D 交互动画创徏

http://five3d.mathieu-badimon.com/

7、Flade (Flash Dynamics Engine)   一套开源的2D物理引擎QAS2实现

http://www.cove.org/flade/

8、Box2DFlashAS3      2D物理引擎QAS3实现Q基于强大的Box2D C++物理?/p>

http://box2dflash.sourceforge.net/

http://sourceforge.net/projects/box2dflash/

9、Paradox    ZFlash的第一U?D引擎

http://animasinteractive.com/propaganda/

10、ND3D AS3 3D Engine 一Ƅ单的AS3开?D引擎Q编译后的引擎大仅U?0K

http://code.google.com/p/nd3d/

http://www.nulldesign.de/nd3d-as3-3d-engine/

11、Pulse Particles   能用的AS3_子创徏pȝ

http://www.rogue-development.com/pulseParticles.html

http://code.google.com/p/pulse-particle/

12、jiglibflash Flash 3D物理引擎

http://code.google.com/p/jiglibflash/

http://www.jiglibflash.com/blog/

13、motor2 同样是基于Box2DQActionScript3.0实现的一?D引擎

http://code.google.com/p/motor2/

http://lab.polygonal.de/motor_physics/

14、WOW-Engine as3实现的物理引擎,源于Sandy

http://seraf.mediabox.fr/wow-engine/as3-3d-physics-engine-wow-engine/

FrameWorks

1、Cairngorm    Adobe官方出的Flex框架

http://labs.adobe.com/wiki/index.php/Cairngorm

     flexcairngorm:Extensions for the Adobe Cairngorm MVC

http://code.google.com/p/flexcairngorm/

2、PureMVC    UAS3框架Q也有其它语a的实?/p>

http://www.puremvc.org/

3、ASWing AS3   一套开源的AS3 GUI框架

http://www.aswing.org/

4、EasyMVC   ׃仉动的MVC框架

http://projects.simb.net/easyMVC/

5、Mate ZTag及事仉动的Flex框架

http://mate.asfusion.com/

6、ARP     Z模式QPatternQ的RIA框架QFlashq_Q支持AS2和AS3

http://osflash.org/projects/arp

7、Gaia   开源的Flash前端框架Q支持AS2和AS3Q用于快速开?/p>

http://www.gaiaflashframework.com/

8、flest   Actionscript3.0/Flex应用E序框架Q用来开发企业的RIA

http://code.google.com/p/flest/

9、Gugga      Flash Framework    更新至AS3

http://www.gugga.com/flashblog/

10、Spring ActionScript(以前名ؓPranaQ?另一个提供了IOC反{控制的框ӞcM著名的Spring框架

http://www.pranaframework.org/

http://www.herrodius.com/blog/projects

11、OpenFlux    开源的Flexlg框架Q让开发Flexlg更加快速容?/p>

http://code.google.com/p/openflux/

12、Degrafa       声明式的Flex囑Ş框架Q允总MXML标签的方式绘制图形、创建皮肤,q包括对CSS的支?/p>

http://code.google.com/p/degrafa/

13、FlexMVCs    针对AS3和Flex的应用程序框ӞZPureMVCQ作了些修正和精

http://code.google.com/p/flexmvcs/

14、Ruboss   l合Flex与ROR的快速开发的框架

http://ruboss.com/

15、dpHibernate   Flex3/BlazeDS Hibernate适配器,支持延迟加蝲

http://code.google.com/p/dphibernate/

16、dpUnit 一套新的Flex试框架

http://code.google.com/p/dpuint/

17、flight framework 一套新的MVC框架Q可应用于Flash及Flex当中

http://code.google.com/p/flight-framework/

http://www.flightxd.com/flightframework/

18、Moccasin 一Ƒ֏用于囑Ş~辑应用E序的Flex框架

http://joeberkovitz.com/blog/2008/09/30/moccasin-intro/

19、RestfulX   一ƑְRails的设计理念带入Flex与AIR的框Ӟthe RESTful way to develop Adobe Flex and AIR applications

http://restfulx.github.com/

20、smartypants-ico Dependency Injection framework for Flex 提供了IOC控制反{性的Flex框架

http://code.google.com/p/smartypants-ioc/

http://flex.joshmcdonald.info/

21、glue    Beautiful Gooey MVC Framework for Flex

http://wiki.github.com/seanhess/glue/

22、coordy 一ƾ轻量的ActionScript3 布局框架

http://code.google.com/p/coordy/

http://somerandomdude.com/articles/technology/coordy/

23、Parsley 另一ƾAS3 ioc框架Q强烈推?★★★

http://www.spicefactory.org/

http://coenraets.org/blog/2009/07/building-a-flex-application-with-the-parsley-framework/

24、Flex IOC 框架

http://code.google.com/p/legato/

25、另一ƾFlex IOC 框架

http://sourceforge.net/projects/flicc/

26、一ƾ轻量的纯AS3的,部分思想来源于PureMVC

http://www.robotlegs.org/

http://github.com/robotlegs/robotlegs-demos-Bundle

Flash & Flex Tools、Servers

1、FlexUnit      Flex/Actionscript3.0单元试框架

http://code.google.com/p/as3flexunitlib/

2、Visual FlexUnit 增强的FlexUnitQ支?#8220;可视化断a”

http://code.google.com/p/visualflexunit/

3、RED bug       debug调试控制器,让Flash、Flex、AIR应用E序更加Ҏ

http://www.realeyesmedia.com/redbug/

4、reflexutil 可在q行时对Flexlgq行调试

http://code.google.com/p/reflexutil/

5、FxSpy    当Flex应用E序q行时可以检和动态的改变可视化组件属性?a >http://code.google.com/p/fxspy/

6、ThunderBolt ZFirefox的Firebug插g的日志扩展,支持AS2及AS3

http://code.google.com/p/flash-thunderbolt/

7、FlashTracer Firefox扩展Q可以以侧栏的方式将Flash中trace()的结果显C?/p>

8、RIALogger 另一ƾFlex/AIR的Debug工具

http://renaun.com/blog/flex-components/rialogger/

9、Alcon 一ƾ轻量的AS2及AS3的Debug工具QAIR方式Debug信息展示出来

http://blog.hexagonstar.com/alcon/

10、GDS (Granite Data Services) 开源,提供了Adobe LiveCycle Data ServicescM功能的服务器

http://www.graniteds.org/

11、FlexMonkey 针对Flex的单元测试框Ӟ为Flex应用E序Q提供了Flex UI功能的自动测?/p>

http://code.google.com/p/flexmonkey/

12、FlexCover 代码覆盖率检?/p>

http://code.google.com/p/flexcover/

13、Fluint 单元试与集成测试框Ӟ改进了些FlexUnit功能

http://code.google.com/p/fluint/

14、SWFScan Flash security tools

https://h30406.www3.hp.com/campaigns/2009/wwcampaign/1-5TUVE/index.php?key=swf&jumpid=go/swfscan

15、De MonsterDebugger Open source debugger for Adobe Flash,Flex and AIR

http://demonsterdebugger.com/

16、Antennae 使用Ant建立复杂Flex目的模?/p>

http://code.google.com/p/antennae/

 

 

Flex Explorers  Q大部分为Flex2版本Q但同样适用于Flex3Q?/p>

1、Flex3 Component Explorer    Flex各类lgCZ

http://examples.adobe.com/flex3/componentexplorer/explorer.html

2、Resize ManagerFX Explorer Q此为商业作品,要收费的Q?/p>

http://www.teotigraphix.com/explorers/ResizeManagerFX/ResizeManagerFXExplorer.html

3、Flex3 Style Explorer

http://examples.adobe.com/flex3/consulting/styleexplorer/Flex3StyleExplorer.html

4、Flex2 Style Explorer Q添加了Kuler功能QFlex UIlg风格定制q可输出为CSS

http://www.maclema.com/content/sek/

5、Flex2 Style Explorer QAdobe 原始的版本)

http://examples.adobe.com/flex2/consulting/styleexplorer/Flex2StyleExplorer.html

6、Flex2 Filter Explorer    查看各类滤镜效果q可q行讄

http://merhl.com/flex2_samples/filterExplorer/

http://merhl.com/?p=40                   (AIR版本)

7、Flex2 Primitive Explorer    在Flex中创建各U简单Ş?/p>

http://www.flexibleexperiments.com/Flex/PrimitiveExplorer/Flex2PrimitiveExplorer.html

8、Custom Easing Function Explore V1.0.0    自定义创建缓动效果函?/p>

http://www.madeinflex.com/img/entries/2007/05/customeasingexplorer.html

9、Tour De Flex   lg资源集合Q包括Flex核心lgQ第三方lg{,必备

http://flex.org/tour

10、Regular Expression Explorer    正则表达式浏览器

http://ryanswanson.com/regexp/

11、AS3 Performance Tester

http://businessintelligence.me/projects/performance_tester/performanceTester.html

转蝲的话h明出处:http://www.jexchen.com



Eric_jiang 2011-06-29 09:27 发表评论
]]>
Flex中XMLSocket与Java中Socket通信http://www.tkk7.com/jjshcc/archive/2011/06/28/353298.htmlEric_jiangEric_jiangTue, 28 Jun 2011 13:05:00 GMThttp://www.tkk7.com/jjshcc/archive/2011/06/28/353298.htmlhttp://www.tkk7.com/jjshcc/comments/353298.htmlhttp://www.tkk7.com/jjshcc/archive/2011/06/28/353298.html#Feedback0http://www.tkk7.com/jjshcc/comments/commentRss/353298.htmlhttp://www.tkk7.com/jjshcc/services/trackbacks/353298.htmlFlex中XMLSocket与Java中Socket通信Q遇到的问题是,Java中的socket能够接受到XMLSocket传输的数据,但是Flexq不能接受到从Java服务器传输的数据Q从|上搜了好多资料Q终于找C原因Q原来XMLSocket 接收到服务端下发的数据时Q将q箋放于接收~冲区,直到接收?"\0" 字节Q字节内容ؓ ASCII ?0Q,才认为接收完成,q调用相应的 onData ?onXML 事gQ因此,服务端若?Java ~写Qƈ使用标准?String cLQ则在发送数据结ֺ手动加上 "\0"Q同P当XMLSocket发送数据时Q也会在数据的结自动加?\0"?/p>

我现在将我做的一个简单的XMLSocket通信的例子脓出来跟大家共享一下,如果有什么不的地方Q还望大家批评指出,毕竟我也是flex初学者,呵呵Q?/p>

Java应用E序代码Q?br /> view plaincopy to clipboardprint?
public class XMLServerSocket {  
 
 
    private ServerSocket serverSocket;  
 
    private Socket socketin;  
 
    private BufferedReader br;  
 
    private PrintStream ps;  
 
    public static void main(String[] args) {  
        new XMLServerSocket();  
    }  
 
    private XMLServerSocket() {  
        try {  
            serverSocket = new ServerSocket(8800);  
            socketin = serverSocket.accept();  
            br = new BufferedReader(new InputStreamReader(socketin  
                    .getInputStream()));  
            ps = new PrintStream(socketin.getOutputStream());  
            ps.println("Input EXIT for end\0");  
            ps.flush();  
            out("Input EXIT for end");  
            boolean done = false;  
            while (!done) {  
                String str = br.readLine();  
                if (str == null || (str.length() == 1 && str.charAt(0) == '\0')) {  
                    done = true;  
                } else {  
                    char first = str.charAt(0);  
                    char tail = str.charAt(str.length() - 1);  
                    if (first == '\0') {  
                        str = str.substring(1);  
                    }  
                    if (tail == '\0') {  
                        str = str.substring(0, str.length() - 2);  
                    }  
                    out(str);  
                    ps.println(str + "\0");  
                    if (str.trim().equals("EXIT")) {  
                        done = true;  
                        br.close();  
                    }  
                }  
            }  
        } catch (Exception e) {  
            System.out.println(e.getMessage());  
        }  
    }  
 
    private void out(String str) {  
        System.out.println(str);  
    }  
 

public class XMLServerSocket {


 private ServerSocket serverSocket;

 private Socket socketin;

 private BufferedReader br;

 private PrintStream ps;

 public static void main(String[] args) {
  new XMLServerSocket();
 }

 private XMLServerSocket() {
  try {
   serverSocket = new ServerSocket(8800);
   socketin = serverSocket.accept();
   br = new BufferedReader(new InputStreamReader(socketin
     .getInputStream()));
   ps = new PrintStream(socketin.getOutputStream());
   ps.println("Input EXIT for end\0");
   ps.flush();
   out("Input EXIT for end");
   boolean done = false;
   while (!done) {
    String str = br.readLine();
    if (str == null || (str.length() == 1 && str.charAt(0) == '\0')) {
     done = true;
    } else {
     char first = str.charAt(0);
     char tail = str.charAt(str.length() - 1);
     if (first == '\0') {
      str = str.substring(1);
     }
     if (tail == '\0') {
      str = str.substring(0, str.length() - 2);
     }
     out(str);
     ps.println(str + "\0");
     if (str.trim().equals("EXIT")) {
      done = true;
      br.close();
     }
    }
   }
  } catch (Exception e) {
   System.out.println(e.getMessage());
  }
 }

 private void out(String str) {
  System.out.println(str);
 }

}

FlexE序代码Q?/p>

view plaincopy to clipboardprint?
<?xml version="1.0" encoding="utf-8"?> 
<mx:Application xmlns:mx="    <mx:Script> 
        <!--[CDATA[  
            private var xmlconnect:XMLSocket;  
            private function connectServer():void  
            {  
                try{  
                    xmlconnect = new XMLSocket();  
                    xmlconnect.connect("localhost",8800);  
                    xmlconnect.addEventListener(DataEvent.DATA,onData);  
                }  
                catch(e:Error)  
                {  
                    trace(e.message);  
                }  
            }  
            private function onData(event:DataEvent):void  
            {  
                content.text = event.text;  
            }  
            private function sendData():void  
            {  
                xmlconnect.send(datasend.text + "\n");//必须加上"\n"Q否则数据不能成功发?nbsp; 
            }  
        ]]--> 
    </mx:Script> 
    <mx:Text id="content" width="271" height="116" horizontalCenter="0" verticalCenter="0" /> 
    <mx:TextInput id="datasend" horizontalCenter="0" verticalCenter="95"/> 
    <mx:Button label="发? horizontalCenter="0" verticalCenter="121" click="sendData()"/> 
    <mx:Button label="q接" horizontalCenter="0" verticalCenter="-103" click="connectServer()"/> 
</mx:Application> 

 



Eric_jiang 2011-06-28 21:05 发表评论
]]>
搭徏全功能绿色版本的Flex Builder 3.0.1http://www.tkk7.com/jjshcc/archive/2011/06/27/353102.htmlEric_jiangEric_jiangMon, 27 Jun 2011 14:09:00 GMThttp://www.tkk7.com/jjshcc/archive/2011/06/27/353102.htmlhttp://www.tkk7.com/jjshcc/comments/353102.htmlhttp://www.tkk7.com/jjshcc/archive/2011/06/27/353102.html#Feedback0http://www.tkk7.com/jjshcc/comments/commentRss/353102.htmlhttp://www.tkk7.com/jjshcc/services/trackbacks/353102.html准备工作Q?/p>

JDK 6 安装E序
Eclipse IDE for Java EE Developers
Adobe Flex Builder 3.0.1 Professional Eclipse Plug-in
7-Zip Command Line Version

开始工作:
创徏两个目录Q分别用来存储Flex Builder文g和时文Ӟ如D:\Flex和D:\Temp?
下载得到的四个文g攑ֈD:\Temp内?
解压~下载到?-Zip文gQ获取到7za.exeE序Q也其攑ֈD:\Temp内?
安装JDK 6到D:\Flex\jdk1.6.0_07Q中途无需安装JRE?
提示Q如果已l安装了JDK的话Q直接将其复制过来即可?
q入命o行模式,依次执行以下命oQ?
D:
cd \Temp
切换到D:\Temp目录?
7za x eclipse-jee-ganymede-win32.zip -oD:\Flex
move D:\Flex\eclipse D:\Flex\eclipse3.4jee
解压eclipseq将目录名改成eclipse3.4jee?
7za x FB3_WWEJ_Plugin.exe -oFB3
7za x FB3\InstallerData\Disk1\InstData\Resource1.zip -oFB3
从Flex Builder安装E序提取出我们所需要的文g备用?
创徏一个启动文件startup.batQ内容如下:
@echo off
set JAVA_HOME=%CD%\jdk1.6.0_07
set JRE_HOME=%JAVA_HOME%\jre
set CLASSPATH=.;%JAVA_HOME%\lib\dt.jar;%JAVA_HOME%\lib\tools.jar
set PATH=%JRE_HOME%\bin;%JAVA_HOME%\bin;%PATH%
start eclipse3.4jee\eclipse.exe
启动eclipseQ进行如下操作:
讄工作区:D:\Temp?
Help -> Software Updates...Q弹出如下图所C窗口,我们点击Update...Q经q一pd的Next -> FinishQ开始了eclipse3.4jee版本的自更新,更新完成后,点击Yes重启eclipse?nbsp;重启完成后,再次Help -> Software Update...Q这ơ,我们使用Available Software选项卡?nbsp;点Add Site... -> Archive...后选择“D:\Temp\FB3\$BUILDSTAGE$\com.adobe.flexbuilder.update.site_ad0c1b9596a1_zg_ia_sf.jar”或直接输?#8220;jar:file:D:\Temp\FB\$BUILDSTAGE$\com.adobe.flexbuilder.update.site_ad0c1b9596a1_zg_ia_sf.jar!/”QOK?nbsp;
 选择新加入的Flex BuilderQƈ点击右上角的Install...Q经q一pd的Next -> FinishQ开始了Flex Builder插g的安装?nbsp;
 再次重启Q完成了Eclipse集成Flex Builder插g的操作?
我们的工作还没完Ql在命o行中执行以下命o来提取Flex SDKQ?
7za x FB3\$DEFAULT_SDK$_ad0c1ba696ac_zg_ia_sf.jar -oD:\Flex\eclipse3.4jee\plugins\com.adobe.flexbuilder.flex_3.0.205647\devsdks\3.1.0
7za x FB3\$NDEPOT_IDE_ROOT$\zorn.flex\devsdks\2.0.1_zg_ia_sf.jar -oD:\Flex\eclipse3.4jee\plugins\com.adobe.flexbuilder.flex_3.0.205647\devsdks\2.0.1
清理掉D:\TempQOKQ大功告成!
最后,我们其压羃hQ以便日后的使用Q命令行命o如下Q?
D:
cd \Flex
del eclipse3.4jee\configuration\.settings\org.eclipse.ui.ide.prefs
7za a FlexBuilder.zip或FlexBuilder.7z
把FlexBuilder.zipQ?37MBQ或FlexBuilder.7zQ?77MBQ保留v来吧Q以后只需要简单的解压q执行其中的startup.bat可以立卌入到Flex Builder开发环境啦Q?

 



Eric_jiang 2011-06-27 22:09 发表评论
]]>
վ֩ģ壺 ŷŮƵ | ھƷѾþӰԺ| avһ߲| ޳߹ۿ| ޳վ| ҹƷ| ҹav2019| ɫ͵͵Ů˵ | һػƬ| ӰԺ޹һҳ| պһ| ۺҹ | þþƷav| ޹Ʒһ| ŮƵ| ޸Ƶ| һ͵| ͬgayƬ| ɫƬվѹۿ| žžþþƷѿС˵| 㽶Ƶѿ| Ʒ׽߹ۿ | ձĻѿ| aëƬȫƵ18| ѾƷ99þùۺϾƷ| 88xxѹۿ| ŮߵƵѹۿڵ| þֻоƷ10| þþѹۿ| AV˳ۺ| ŮͬavƬ߹ۿ| Ļ| һͼƬ| һëƬѿ| ѻվ߹ۿ| ȫӰѹۿȫ| ޾ƷɫƵ߹ۿԴ| ޾ƷƬ߹ۿ| ޻ɫվ| ޸ľƷŮ| Ƶ|