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

<channel>
	<title>Li Guoliang &#187; ActionScript</title>
	<atom:link href="http://liguoliang.com/category/flex/actionscript-flex/feed/" rel="self" type="application/rss+xml" />
	<link>http://liguoliang.com</link>
	<description>ActionScript Flex Java JEE PHP...</description>
	<lastBuildDate>Mon, 21 May 2012 17:04:30 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Apache Flex: MXML or ActionScript ?</title>
		<link>http://liguoliang.com/2012/apache-flex-mxml-or-actionscript/</link>
		<comments>http://liguoliang.com/2012/apache-flex-mxml-or-actionscript/#comments</comments>
		<pubDate>Sun, 22 Apr 2012 13:59:08 +0000</pubDate>
		<dc:creator>Guoliang</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[ApacheFlex]]></category>

		<guid isPermaLink="false">http://liguoliang.com/?p=2246</guid>
		<description><![CDATA[Deciding to create components in MXML or ActionScript
&#160;
One of the first decisions that you must make when creating custom components is deciding<p class='read-more'><a href='http://liguoliang.com/2012/apache-flex-mxml-or-actionscript/'>More...</a></p><p><p>

----------Post from: <a href="http://liguoliang.com">@LiGuoliang.com, 欢迎回来~</a>----------</p></p>
]]></description>
			<content:encoded><![CDATA[<h2>Deciding to create components in MXML or ActionScript</h2>
<p>&nbsp;</p>
<blockquote><p>One of the first decisions that you must make when creating custom components is deciding whether to write<br />
them in MXML or in ActionScript. Ultimately, it is the requirements of your application that determine how you<br />
develop your custom component.<br />
Some basic guidelines include the following:</p>
<p><em><span style="font-size: x-small;">•MXML components and ActionScript components both define new ActionScript classes.<br />
•Almost anything that you can do in a custom ActionScript custom component, you can also do in a custom MXML component. However, for simple components, such as components that modify the behavior of an existing component or add a basic feature to an existing component, it is simpler and faster to create them in MXML.<br />
•When your new component is a composite component that contains other components, and you can express the positions and sizes of those other components using one of the Flex layout containers, you should use MXML to define your component.<br />
•To modify the behavior of the component, such as the way a container lays out its children, use ActionScript.<br />
•To create a visual component by creating a subclass from UIComponent, use ActionScript.<br />
•To create a nonvisual component, such as a formatter, validator, or effect, use ActionScript.<br />
•To add logging support to your control, use ActionScript. For more information, see “Logging” on page 227 in Building and Deploying Adobe Flex 3 Applications.</span></em></p></blockquote>
<p>Flex3 官方文档中如上释疑. 2010年我参加Flex Developer Day时, 有开发者提问国内是否有大型企业应用实例? 未得到正面回答. 倒是群硕的团队还上台张扬了一把, 他们的项目大约是奥运时CCTV直播网站.</p>
<p>其实即便国内有大型的企业应用, 也不一定能获得足够价值的经验.</p>
<p>07年底开始做的教育应用, 大致有120W行代码, 其中有60%+的为AS代码, 除了入口文件及部分复杂UI使用MXML之外, 清一色都是AS代码, 所有的UI都小心谨慎的创建, 销毁. 在10年的DevDay时, 坐在我旁边的某研发他们也是纯AS.</p>
<p>几年过去了, Flex贡献给了Apache, Flex也已经4.6了, 接触的代码多了, 习惯了清纯的AS代码, 当满篇都是MXML标签时, 我不淡定了.</p>
<p>思想斗争良久, 到底孰优孰劣? 在多数common的情况下, 几乎不分上下. 我觉得AS代码更优雅更易读, 可人家说了: 我们可以Design, 不用代码, 一眼就看出来了&#8230;:(</p>
<p><a href="http://liguoliang.com/wp-content/uploads/2012/02/201226212008.png"><img style="display: inline; border: 0px;" title="2012-2-6 21-20-08" src="http://liguoliang.com/wp-content/uploads/2012/02/201226212008_thumb.png" alt="2012-2-6 21-20-08" width="644" height="402" border="0" /></a></p>
<p>如上View, 假如我们只用MXML或只用AS来实现, 似乎看不出明显差异来, 其实相比选择编程方式, 可能对<strong>组件/Class的划分可能更加重要.</strong></p>
<p>不论用MXML还是AS, Class设计好更加关键:</p>
<p>1.1.1 可以设计成一个Common的组件;</p>
<p>1.1 可以作为一个组合的UserList</p>
<p>2.1/2.2  作为显示用户基本信息的组件;</p>
<p>这样划分, 不论MXML还是AS都可以很好的降低耦合, 更可重用, 但不论如何, 我还是喜欢干净的AS代码.</p>
<p><p>

----------Post from: <a href="http://liguoliang.com">@LiGuoliang.com, 欢迎回来~</a>----------</p></p>
]]></content:encoded>
			<wfw:commentRss>http://liguoliang.com/2012/apache-flex-mxml-or-actionscript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using XML filter in ActionScript &#8211; Flex中过滤XML</title>
		<link>http://liguoliang.com/2012/using-xml-filter-in-actionscript/</link>
		<comments>http://liguoliang.com/2012/using-xml-filter-in-actionscript/#comments</comments>
		<pubDate>Thu, 01 Mar 2012 14:44:57 +0000</pubDate>
		<dc:creator>Guoliang</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[ActionScirpt]]></category>
		<category><![CDATA[ApacheFlex]]></category>
		<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">http://liguoliang.com/?p=2293</guid>
		<description><![CDATA[我一直不喜欢在AS中频繁的操作XML, 但没办法, 最近所有的data都是来自于XML, 没有任何ValueObject, 清一色的XML.
把把都得翻书找手册 <img src='http://liguoliang.com/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' />   弱到爆
&#160;
<a href="http://liguoliang.com/wp-content/uploads/2012/03/image.png"><img style="display: inline; border-width: 0px;" title="image" src="http://liguoliang.com/wp-content/uploads/2012/03/image_thumb.png" alt="image" width="657" height="362" border="0" /></a>
Trace到的结果:
<a href="http://liguoliang.com/wp-content/uploads/2012/03/image1.png"><img style="display: inline; border: 0px;" title="image" src="http://liguoliang.com/wp-content/uploads/2012/03/image_thumb1.png" alt="image" width="209" height="266" border="0" /></a>


----------Post from: <a href="http://liguoliang.com">@LiGuoliang.com, </a><p class='read-more'><a href='http://liguoliang.com/2012/using-xml-filter-in-actionscript/'>More...</a></p><p><p>

----------Post from: <a href="http://liguoliang.com">@LiGuoliang.com, 欢迎回来~</a>----------</p></p>
]]></description>
			<content:encoded><![CDATA[<p>我一直不喜欢在AS中频繁的操作XML, 但没办法, 最近所有的data都是来自于XML, 没有任何ValueObject, 清一色的XML.</p>
<p>把把都得翻书找手册 <img src='http://liguoliang.com/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' />   弱到爆</p>
<p>&nbsp;</p>
<p><a href="http://liguoliang.com/wp-content/uploads/2012/03/image.png"><img style="display: inline; border-width: 0px;" title="image" src="http://liguoliang.com/wp-content/uploads/2012/03/image_thumb.png" alt="image" width="657" height="362" border="0" /></a></p>
<p>Trace到的结果:</p>
<p><a href="http://liguoliang.com/wp-content/uploads/2012/03/image1.png"><img style="display: inline; border: 0px;" title="image" src="http://liguoliang.com/wp-content/uploads/2012/03/image_thumb1.png" alt="image" width="209" height="266" border="0" /></a></p>
<p><p>

----------Post from: <a href="http://liguoliang.com">@LiGuoliang.com, 欢迎回来~</a>----------</p></p>
]]></content:encoded>
			<wfw:commentRss>http://liguoliang.com/2012/using-xml-filter-in-actionscript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ActionScript: conversion to Boolean</title>
		<link>http://liguoliang.com/2012/actionscript-conversion-to-boolean/</link>
		<comments>http://liguoliang.com/2012/actionscript-conversion-to-boolean/#comments</comments>
		<pubDate>Mon, 27 Feb 2012 11:46:54 +0000</pubDate>
		<dc:creator>Guoliang</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[ActionScirpt]]></category>
		<category><![CDATA[ApacheFlex]]></category>

		<guid isPermaLink="false">http://liguoliang.com/?p=2287</guid>
		<description><![CDATA[The following table summarizes the results of casting to the Boolean data type from other data types:



<strong>Data type or value</strong>
<strong>Result of conversion to Bo</strong><p class='read-more'><a href='http://liguoliang.com/2012/actionscript-conversion-to-boolean/'>More...</a></p><p><p>

----------Post from: <a href="http://liguoliang.com">@LiGuoliang.com, 欢迎回来~</a>----------</p></p>
]]></description>
			<content:encoded><![CDATA[<p>The following table summarizes the results of casting to the Boolean data type from other data types:</p>
<table border="0" cellspacing="0" cellpadding="2" width="679">
<tbody>
<tr>
<td valign="top" width="200"><strong>Data type or value</strong></td>
<td valign="top" width="477"><strong>Result of conversion to Boolean</strong></td>
</tr>
<tr>
<td valign="top" width="200">String</td>
<td valign="top" width="477"><samp>false </samp>if the value is <samp>null </samp>or the empty string (<samp> &#8220;&#8221; </samp>); <samp>true </samp>otherwise.</td>
</tr>
<tr>
<td valign="top" width="200">null</td>
<td valign="top" width="477">false</td>
</tr>
<tr>
<td valign="top" width="200">Number, int or uint</td>
<td valign="top" width="477"><samp>false </samp>if the value is <samp>NaN </samp>or 0; <samp>true </samp>otherwise.</td>
</tr>
<tr>
<td valign="top" width="200">Object</td>
<td valign="top" width="477"><samp>false </samp>if the instance is <samp>null </samp>; <samp>true </samp>otherwise.</td>
</tr>
</tbody>
</table>
<p>ref:<a href="http://help.adobe.com/en_US/ActionScript/3.0_ProgrammingAS3/WS5b3ccc516d4fbf351e63e3d118a9b90204-7f87.html">http://help.adobe.com/en_US/ActionScript/3.0_ProgrammingAS3/WS5b3ccc516d4fbf351e63e3d118a9b90204-7f87.html</a></p>
<p>Note: when you convert a string to boolean, remeber to trim the string first.</p>
<p>and this is a capture from &lt;&lt;Essential ActionScript 3.0&gt;&gt;:</p>
<p><a href="http://liguoliang.com/wp-content/uploads/2012/02/image3.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://liguoliang.com/wp-content/uploads/2012/02/image_thumb4.png" width="584" height="418"></a></p>
<p><p>

----------Post from: <a href="http://liguoliang.com">@LiGuoliang.com, 欢迎回来~</a>----------</p></p>
]]></content:encoded>
			<wfw:commentRss>http://liguoliang.com/2012/actionscript-conversion-to-boolean/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ActionScript: Check if a xml attribute/element exists 检查XML属性/元素是否存在</title>
		<link>http://liguoliang.com/2012/actionscript-check-if-a-xml-attributeelement-exists/</link>
		<comments>http://liguoliang.com/2012/actionscript-check-if-a-xml-attributeelement-exists/#comments</comments>
		<pubDate>Fri, 13 Jan 2012 16:21:03 +0000</pubDate>
		<dc:creator>Guoliang</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[ApacheFlex]]></category>
		<category><![CDATA[Flex]]></category>

		<guid isPermaLink="false">http://liguoliang.com/?p=2228</guid>
		<description><![CDATA[Here is the XML:
<code>&#60;XeSex sexIDElement='MID'&#62; &#60;SexID&#62; M &#60;/SexID&#62; &#60;Name&#62; Male &#60;/Name&#62; &#60;Active&#62; y &#60;/Active&#62; &#60;</code><p class='read-more'><a href='http://liguoliang.com/2012/actionscript-check-if-a-xml-attributeelement-exists/'>More...</a></p><p><p>

----------Post from: <a href="http://liguoliang.com">@LiGuoliang.com, 欢迎回来~</a>----------</p></p>
]]></description>
			<content:encoded><![CDATA[<p>Here is the XML:</p>
<p><code>&lt;XeSex sexIDElement='MID'&gt; &lt;SexID&gt; M &lt;/SexID&gt; &lt;Name&gt; Male &lt;/Name&gt; &lt;Active&gt; y &lt;/Active&gt; &lt;Code&gt; M &lt;/Code&gt; &lt;/XeSex&gt; </code>
<p>Attitude:&nbsp; sexIDElement = ‘MID’;<br />Element: Name = Male</p>
<p><code class="java" name="code">trace(xmlTest.hasOwnProperty('@sexIDElement')); // check if the attribute exists trace(xmlTest.hasOwnProperty('Name')); // check if the element exists</code></p>
<p>BTW, About: <a href="http://www.w3schools.com/dtd/dtd_el_vs_attr.asp">XML Elements vs. Attributes</a></p>
<p><p>

----------Post from: <a href="http://liguoliang.com">@LiGuoliang.com, 欢迎回来~</a>----------</p></p>
]]></content:encoded>
			<wfw:commentRss>http://liguoliang.com/2012/actionscript-check-if-a-xml-attributeelement-exists/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Flex Build: org.xml.sax.SAXParseException :The entity name must immediately follow the &#8216;&amp;&#8217; in the entity reference</title>
		<link>http://liguoliang.com/2012/org-xml-sax-saxparseexception-the-entity-name-must-immediately-follow/</link>
		<comments>http://liguoliang.com/2012/org-xml-sax-saxparseexception-the-entity-name-must-immediately-follow/#comments</comments>
		<pubDate>Fri, 13 Jan 2012 15:25:16 +0000</pubDate>
		<dc:creator>Guoliang</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[ApacheFlex]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[SAXParseException]]></category>

		<guid isPermaLink="false">http://liguoliang.com/?p=2226</guid>
		<description><![CDATA[在过去接近4年的时间里, 很少使用MXML, 几乎都是纯AS, 最近操作了一点点MXML, 譬如:
<code>&#60;s:Button enabled=”isDirty() &#38;&#38; canSaveNow()” /&#62;</code>
&#160;
在build的时候遇到错误: 
org.xml.sax.SA<p class='read-more'><a href='http://liguoliang.com/2012/org-xml-sax-saxparseexception-the-entity-name-must-immediately-follow/'>More...</a></p><p><p>

----------Post from: <a href="http://liguoliang.com">@LiGuoliang.com, 欢迎回来~</a>----------</p></p>
]]></description>
			<content:encoded><![CDATA[<p>在过去接近4年的时间里, 很少使用MXML, 几乎都是纯AS, 最近操作了一点点MXML, 譬如:</p>
<p><code>&lt;s:Button enabled=”isDirty() &amp;&amp; canSaveNow()” /&gt;</code>
<p>&nbsp;</p>
<p>在build的时候遇到错误: </p>
<blockquote><p>org.xml.sax.SAXParseException :The entity name must immediately follow the ‘&amp;’ in the entity reference</p>
</blockquote>
<p>Google了一下, XML解析的问题, 解决方法:</p>
<p>&amp;&amp; 替换为:&nbsp; [&amp;amp;&amp;amp;]</p>
<p><code>&lt;s:Button enabled=”isDirty() &amp;amp;&amp;amp; canSaveNow()” /&gt;</code></p>
<p><p>

----------Post from: <a href="http://liguoliang.com">@LiGuoliang.com, 欢迎回来~</a>----------</p></p>
]]></content:encoded>
			<wfw:commentRss>http://liguoliang.com/2012/org-xml-sax-saxparseexception-the-entity-name-must-immediately-follow/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Replace all by Split/RegEx in ActionScript</title>
		<link>http://liguoliang.com/2011/replace-all-in-actionscript/</link>
		<comments>http://liguoliang.com/2011/replace-all-in-actionscript/#comments</comments>
		<pubDate>Tue, 06 Dec 2011 12:53:55 +0000</pubDate>
		<dc:creator>Guoliang</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[ReplaceAll]]></category>

		<guid isPermaLink="false">http://liguoliang.com/2011/replace-all-in-actionscript/</guid>
		<description><![CDATA[Problem
We need replace all method.
Solution
use RegEx or split&#38;jion;
Detailed explanation
We can use the following two methods:
	private function<p class='read-more'><a href='http://liguoliang.com/2011/replace-all-in-actionscript/'>More...</a></p><p><p>

----------Post from: <a href="http://liguoliang.com">@LiGuoliang.com, 欢迎回来~</a>----------</p></p>
]]></description>
			<content:encoded><![CDATA[<h4>Problem</h4>
<p>We need replace all method.<br />
<h4>Solution</h4>
<p>use RegEx or split&amp;jion;<br />
<h4>Detailed explanation</h4>
<p>We can use the following two methods:</p>
<pre class="java" name="code">	private function testFlexStringReplaceAll():void {
		var strSource:String = "Li_guo_Liang.com";
		trace(strSource + " - " + replaceAllBySplit(strSource, "_", ""));
		trace(strSource + " - " + replaceAllByRegex(strSource, "_", ""));
	}

	/**
	 * Repalce all by split and join;
	 */
	public static function replaceAllBySplit(strSource:String, strReplaceFrom:String, strRepalceTo:String):String {
		return strSource == null ? null : strSource.split(strReplaceFrom).join(strRepalceTo);
	}

	/**
	 * Replace all by RegEx;
	 */
	public static function replaceAllByRegex(strSource:String, strReplaceFrom:String, strRepalceTo:String):String {
		return strSource == null ? null : strSource.replace(new RegExp(strReplaceFrom, 'g'), strRepalceTo);
	}
</pre>
<p>TraceLog:</p>
<p>Li_guo_Liang.com &#8211; LiguoLiang.com<br />Li_guo_Liang.com &#8211; LiguoLiang.com</p>
<p><p>

----------Post from: <a href="http://liguoliang.com">@LiGuoliang.com, 欢迎回来~</a>----------</p></p>
]]></content:encoded>
			<wfw:commentRss>http://liguoliang.com/2011/replace-all-in-actionscript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Flex: verticalScrollPolicy auto/on/off</title>
		<link>http://liguoliang.com/2011/flex-scroll-policy/</link>
		<comments>http://liguoliang.com/2011/flex-scroll-policy/#comments</comments>
		<pubDate>Mon, 05 Dec 2011 15:54:52 +0000</pubDate>
		<dc:creator>Guoliang</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[ScrollPolicy]]></category>

		<guid isPermaLink="false">http://liguoliang.com/2011/flex-scroll-policy/</guid>
		<description><![CDATA[最近碰到一个问题: 当Flex右侧垂直滚动条出现时, 下方水平滚动条必定随之出现, 详细的描述就是:
该UIComponent高度一定, 宽度设置为percent(也就是说宽度可以变化), 当Add一个内部组件到该UI上后, UI需要更多高度, 但高度一定, 只好出现右侧滚动条(默认的ScrollP<p class='read-more'><a href='http://liguoliang.com/2011/flex-scroll-policy/'>More...</a></p><p><p>

----------Post from: <a href="http://liguoliang.com">@LiGuoliang.com, 欢迎回来~</a>----------</p></p>
]]></description>
			<content:encoded><![CDATA[<p>最近碰到一个问题: 当Flex右侧垂直滚动条出现时, 下方水平滚动条必定随之出现, 详细的描述就是:</p>
<p>该UIComponent高度一定, 宽度设置为percent(也就是说宽度可以变化), 当Add一个内部组件到该UI上后, UI需要更多高度, 但高度一定, 只好出现右侧滚动条(默认的ScrollPolicy为auto), 假使被增加组件的宽度与外部组件宽度一致, 此时由于滚动条的出现, 外部UI不能直接完整显示该组件, 于是出现水平滚动条,.</p>
<p>Flex API中有关内容: Sizing components <a title="http://livedocs.adobe.com/flex/3/html/help.html?content=size_position_3.html" href="http://livedocs.adobe.com/flex/3/html/help.html?content=size_position_3.html">http://livedocs.adobe.com/flex/3/html/help.html?content=size_position_3.html</a></p>
<p>参考: <a name="244554"></a><strong>Using Scroll bars一章:</strong></p>
<blockquote><p>Notice that the addition of the scroll bar doesn&#8217;t increase the height of the container from its initial value. Flex considers scroll bars in its sizing calculations only if you explicitly set the scroll policy to</p>
<p><samp>ScrollPolicy.ON</samp>. So, if you use an auto scroll policy (the default), the scroll bar overlaps the buttons. To prevent this behavior, you can set the</p>
<p><samp>height</samp>property for the HBox container or allow the HBox container to resize by setting a percentage-based width. Remember that changing the height of the HBox container causes other components in your application to move and resize according to their own sizing rules.</p></blockquote>
<p>解决方案比较清晰, 要么设置ScrollPoliocy为No, 要么调整宽高设置. 为了清晰演示, 写了个小Application:</p>
<p><a href="http://liguoliang.com/wp-content/uploads/2011/12/Flex3TestWeb_ScrollPolicy.swf">Flex3TestWeb_ScrollPolicy</a></p>
<p><object width="500" height="500" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="play" value="true" /><param name="quality" value="high" /><param name="src" value="http://liguoliang.com/wp-content/uploads/2011/12/Flex3TestWeb_ScrollPolicy.swf" /><param name="pluginspage" value="http://www.macromedia.com/go/getflashplayer" /><embed width="600" height="500" type="application/x-shockwave-flash" src="http://liguoliang.com/wp-content/uploads/2011/12/Flex3TestWeb_ScrollPolicy.swf" play="true" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object></p>
<p><p>

----------Post from: <a href="http://liguoliang.com">@LiGuoliang.com, 欢迎回来~</a>----------</p></p>
]]></content:encoded>
			<wfw:commentRss>http://liguoliang.com/2011/flex-scroll-policy/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Flex: 检查/撤销Datagrid编辑数据 Validate/revert editable Datagrid input value</title>
		<link>http://liguoliang.com/2011/validaterevert-editable-datagrid-input-value/</link>
		<comments>http://liguoliang.com/2011/validaterevert-editable-datagrid-input-value/#comments</comments>
		<pubDate>Mon, 05 Dec 2011 13:42:11 +0000</pubDate>
		<dc:creator>Guoliang</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[DataGrid]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[itemEditor]]></category>
		<category><![CDATA[UI]]></category>

		<guid isPermaLink="false">http://liguoliang.com/2011/flex-%e6%a3%80%e6%9f%a5%e6%92%a4%e9%94%80datagrid%e7%bc%96%e8%be%91%e6%95%b0%e6%8d%ae-validaterevert-editable-datagrid-input-value/</guid>
		<description><![CDATA[Requirement: We want to validate user input in editable datagrid, and revert the original value(undo) if necessary.
Solution: Handle the ‘itemEditEnd’<p class='read-more'><a href='http://liguoliang.com/2011/validaterevert-editable-datagrid-input-value/'>More...</a></p><p><p>

----------Post from: <a href="http://liguoliang.com">@LiGuoliang.com, 欢迎回来~</a>----------</p></p>
]]></description>
			<content:encoded><![CDATA[<p>Requirement: We want to validate user input in editable datagrid, and revert the original value(undo) if necessary.</p>
<p>Solution: Handle the ‘itemEditEnd’ Event dispatched by the datagrid.</p>
<p>Codes:</p>
<pre class="java" name="code">	/**
	 * validate user input, revert the original value if necessary.
	 */
	protected function datagirdTest_itemEditEndHandler(event:DataGridEvent):void {
		if(event.dataField != "Name") { // chech the field;
			return;
		}
		var input:String = (datagirdTest.itemEditorInstance as TextInput).text; // get the user input data.
		if(input == null || input == "") {
			event.preventDefault(); // prevent default behavior
			// var filed:String = (datagirdTest.columns[event.columnIndex] as DataGridColumn).editorDataField;
			// trace(datagirdTest.itemEditorInstance[filed]);
			(datagirdTest.itemEditorInstance as TextInput).text = (event.itemRenderer.data as XML).Name;// Undo: revert the original data by the selected item.
			Alert.show(errorMesg);
			return;
		}
	}
</pre>
<p>Screen caputre: </p>
</p>
<p><a href="http://liguoliang.com/wp-content/uploads/2011/12/image.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://liguoliang.com/wp-content/uploads/2011/12/image_thumb.png" width="512" height="406"></a> </p>
<p>User input is empty, we got the Event, prevent the default behavior, and revert the value form the modeling.</p>
<p>Ref:</p>
<p>1. itemEditEnd called multiple times <a title="http://forums.adobe.com/message/2459209" href="http://forums.adobe.com/message/2459209">http://forums.adobe.com/message/2459209</a><br />2. Using cell editing events&nbsp; &#8211; <a title="http://livedocs.adobe.com/flex/3/html/help.html?content=celleditor_7.html" href="http://livedocs.adobe.com/flex/3/html/help.html?content=celleditor_7.html">http://livedocs.adobe.com/flex/3/html/help.html?content=celleditor_7.html</a></p>
<p><p>

----------Post from: <a href="http://liguoliang.com">@LiGuoliang.com, 欢迎回来~</a>----------</p></p>
]]></content:encoded>
			<wfw:commentRss>http://liguoliang.com/2011/validaterevert-editable-datagrid-input-value/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>推荐:Chrome下ActionScript API 搜索插件</title>
		<link>http://liguoliang.com/2011/%e6%8e%a8%e8%8d%90chrome%e4%b8%8bactionscript-api-%e6%90%9c%e7%b4%a2%e6%8f%92%e4%bb%b6/</link>
		<comments>http://liguoliang.com/2011/%e6%8e%a8%e8%8d%90chrome%e4%b8%8bactionscript-api-%e6%90%9c%e7%b4%a2%e6%8f%92%e4%bb%b6/#comments</comments>
		<pubDate>Wed, 26 Oct 2011 13:34:16 +0000</pubDate>
		<dc:creator>Guoliang</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[ActionScript API辅助工具]]></category>

		<guid isPermaLink="false">http://liguoliang.com/2011/%e6%8e%a8%e8%8d%90chrome%e4%b8%8bactionscript-api-%e6%90%9c%e7%b4%a2%e6%8f%92%e4%bb%b6/</guid>
		<description><![CDATA[A Chrome plugin for: ActionScript 3.0 Reference.Input &#8220;as3 + &#8216;space&#8217;&#8221; and keywords:
<a href="http://liguoliang.com/wp-content/uploads/2011/10/image3.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://liguoliang.com/wp-content/uploads/2011/10/image_thumb3.png" width="633" height="220"/></a>
<a href="http://blogs.adobe.com/flexdoc">Flex Doc Team</a> Blog 推荐: Chrome浏览器下AS文档的搜索插<p class='read-more'><a href='http://liguoliang.com/2011/%e6%8e%a8%e8%8d%90chrome%e4%b8%8bactionscript-api-%e6%90%9c%e7%b4%a2%e6%8f%92%e4%bb%b6/'>More...</a></p><p><p>

----------Post from: <a href="http://liguoliang.com">@LiGuoliang.com, 欢迎回来~</a>----------</p></p>
]]></description>
			<content:encoded><![CDATA[<p>A Chrome plugin for: ActionScript 3.0 Reference.<br />Input &#8220;as3 + &#8216;space&#8217;&#8221; and keywords:</p>
<p><a href="http://liguoliang.com/wp-content/uploads/2011/10/image3.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://liguoliang.com/wp-content/uploads/2011/10/image_thumb3.png" width="633" height="220"></a></p>
<p><a href="http://blogs.adobe.com/flexdoc">Flex Doc Team</a> Blog 推荐: Chrome浏览器下AS文档的搜索插件, &#8216;as3 + 空格键&#8217; 输入关键字后激发选项, 方便易用.</p>
<p>&gt;&gt;<a href="https://chrome.google.com/webstore/detail/agjdnfifalomicffgfocgdgpbnkkefle?hl=en-US">ActionScript 3.0 Search</a> plugin homepage&lt;&lt;</p>
<p>&nbsp;</p>
<blockquote><p>This extension integrates with the Chrome omnibox to bring ActionScript 3.0 standard library API autocompletion right to your fingertips. To use, type &#8220;as3&#8243;, followed by a space or tab, followed by your query. The first time you use the extension, there may be some delay, as the class index is retrieved and cached. On subsequent uses, however, you should see instantaneous autocompletions. Selecting a completion or fully typing a class name and then pressing enter will take you directly to the relevant documentation. If a completion cannot be found, several search suggestions will be provided, including using the Adobe Community Help search function, using Google Codesearch, and using the Development and Coding Search custom search engine. If you experience any issues with this extension, please use the bug tracker given below.
<p>== Chrome Omnibox Search Extensions for Developers==<br />If you like this extension, you might also like the other omnibox search extensions given at the following link:<br />http://code.google.com/p/developer-omniboxes-for-chrome/</p>
</blockquote>
<p><p>

----------Post from: <a href="http://liguoliang.com">@LiGuoliang.com, 欢迎回来~</a>----------</p></p>
]]></content:encoded>
			<wfw:commentRss>http://liguoliang.com/2011/%e6%8e%a8%e8%8d%90chrome%e4%b8%8bactionscript-api-%e6%90%9c%e7%b4%a2%e6%8f%92%e4%bb%b6/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>About the overloading in Flex</title>
		<link>http://liguoliang.com/2011/about-the-overloading-in-flex/</link>
		<comments>http://liguoliang.com/2011/about-the-overloading-in-flex/#comments</comments>
		<pubDate>Sat, 16 Jul 2011 05:05:17 +0000</pubDate>
		<dc:creator>Guoliang</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Flex]]></category>

		<guid isPermaLink="false">http://liguoliang.com/2011/about-the-overloading-in-flex/</guid>
		<description><![CDATA[Those days I’m looking a new job related to Java and Flex… Seems that this is a popular interview question, I event didn’t encounter it in the ACE. Bu<p class='read-more'><a href='http://liguoliang.com/2011/about-the-overloading-in-flex/'>More...</a></p><p><p>

----------Post from: <a href="http://liguoliang.com">@LiGuoliang.com, 欢迎回来~</a>----------</p></p>
]]></description>
			<content:encoded><![CDATA[<p>Those days I’m looking a new job related to Java and Flex… Seems that this is a popular interview question, I event didn’t encounter it in the ACE. But I was asked more than 3 times. </p>
<p><strong>Talk about overloading in OOPS:</strong></p>
<p>Overloading is between the methods with the same name, If two methods of a class (whether both declared in the same class, or both inherited by a class, or one declared and one inherited) have the same name but signatures that are not override-equivalent, then the method name is said to be overloaded.<strong></p>
<p></strong>
<p><strong>ActionScript 3 support overriding, But why it is not support overloading?</strong></p>
<p>It’s a good question, and can be the answer of what’s the difference between Java and Flex?<br />Based on the Standard <a href="http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-262.pdf">ECMA-262</a> (ECMAScript Language Specification), Action Script does not implement the overloading. and every method in the class is a Function object(property) </p>
<p><strong>Since AS doesn’t support overloading, what can you do to implement the overloading?</strong></p>
<p>As I known, Basically there are three way to handle the overload requirement:</p>
<p>1. <strong>Using optional parameters, such as:<br /></strong>getUser(userID:int = –1, userName: String = null):User {..}</p>
<p>2. <strong>Using rich parameters:<br /></strong>getUser(…args):User{<br />if(args.length == 0) {<br />return null; <br />}else if (args.length…)….<br />}</p>
<p>3. <strong>Using Object as the parameters, like:<br /></strong>getUser(arg: Object):User {<br />if(arg is String) {<br />return …. get user by the userName;<br />} else {<br />if (arg is int) {<br />return …get user by the userID;<br />}//end of if.<br />}</p>
<p>According those codes, you can see those methods all need very clear comments, and not easy for other to use them. in the comment we need to tell others the parameters type or sequence.</p>
<p>In fact, Since the AS does not support the overloading, and the comments need be very very clear, and usually, there will be two public methods: getUserByID(), getUserByName(), maybe a private or protected method using the above 3 ways to do the get user job.</p>
<p><p>

----------Post from: <a href="http://liguoliang.com">@LiGuoliang.com, 欢迎回来~</a>----------</p></p>
]]></content:encoded>
			<wfw:commentRss>http://liguoliang.com/2011/about-the-overloading-in-flex/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

