<?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/tag/actionscript/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>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>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>
		<item>
		<title>Let the Flex thread sleep for a while</title>
		<link>http://liguoliang.com/2011/let-the-flex-thread-sleep-for-a-while/</link>
		<comments>http://liguoliang.com/2011/let-the-flex-thread-sleep-for-a-while/#comments</comments>
		<pubDate>Fri, 15 Jul 2011 14:26:44 +0000</pubDate>
		<dc:creator>Guoliang</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Flex]]></category>

		<guid isPermaLink="false">http://liguoliang.com/2011/let-the-flex-thread-sleep-for-a-while/</guid>
		<description><![CDATA[Sometimes we use thread.sleep to let the thread stop running for a while in Java, but in Flex, we can’t&#160; control the thread, but sometimes we wan<p class='read-more'><a href='http://liguoliang.com/2011/let-the-flex-thread-sleep-for-a-while/'>More...</a></p><p><p>

----------Post from: <a href="http://liguoliang.com">@LiGuoliang.com, 欢迎回来~</a>----------</p></p>
]]></description>
			<content:encoded><![CDATA[<p>Sometimes we use thread.sleep to let the thread stop running for a while in Java, but in Flex, we can’t&nbsp; control the thread, but sometimes we want to let the method sleeping,&nbsp; and here is what I’ll do:</p>
<pre class="java" name="code">public class SleepUtils
{
	// Constructor
	public function SleepUtils() {
	}

	/**
	 * Let the thread sleep.
	 * @param ms Million seconds you want to sleep.
	 *
	 */
	public static function startSleep(ms:Number):void {
		var timeBegin:Date = new Date();
		trace("Sleep begin: " + timeBegin.toTimeString());
		while((new Date()).getTime() - timeBegin.getTime() &lt; ms) {
		}
		trace("Sleep end: " + new Date().toTimeString());
	}

} // End of class
</pre>
<p><p>

----------Post from: <a href="http://liguoliang.com">@LiGuoliang.com, 欢迎回来~</a>----------</p></p>
]]></content:encoded>
			<wfw:commentRss>http://liguoliang.com/2011/let-the-flex-thread-sleep-for-a-while/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Flex Event stopimmediatepropagation VS stoppropagation</title>
		<link>http://liguoliang.com/2011/flex-event-stopimmediatepropagation-vs-stoppropagation/</link>
		<comments>http://liguoliang.com/2011/flex-event-stopimmediatepropagation-vs-stoppropagation/#comments</comments>
		<pubDate>Fri, 17 Jun 2011 09:35:00 +0000</pubDate>
		<dc:creator>Guoliang</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Event]]></category>

		<guid isPermaLink="false">http://liguoliang.com/2011/flex-event-stopimmediatepropagation-vs-stoppropagation/</guid>
		<description><![CDATA[What’s the difference ? Here is the test codes:
We will create a button in a Group, and listen the button click event(MouseEvent.Click):
		protected f<p class='read-more'><a href='http://liguoliang.com/2011/flex-event-stopimmediatepropagation-vs-stoppropagation/'>More...</a></p><p><p>

----------Post from: <a href="http://liguoliang.com">@LiGuoliang.com, 欢迎回来~</a>----------</p></p>
]]></description>
			<content:encoded><![CDATA[<p>What’s the difference ? Here is the test codes:</p>
<p>We will create a button in a Group, and listen the button click event(MouseEvent.Click):</p>
<pre class="java" name="code">		protected function windowedapplication1_creationCompleteHandler(event:FlexEvent):void {
			//  Create button and container
			var hbox:HGroup = new HGroup();
			var button:Button = new Button();
			button.label = "Button";

			// Add Eventer litener
			button.addEventListener(MouseEvent.CLICK, onButtonClick1);
			button.addEventListener(MouseEvent.CLICK, onButtonClick2);
			hbox.addEventListener(MouseEvent.CLICK, onButtonClick3);

			hbox.addElement(button);
			addElement(hbox);
		}

			// Button click handler 1
			private function onButtonClick1(e:MouseEvent):void {
				e.stopImmediatePropagation(); // or e.stopPropagation();
				trace("Handler 1");
			}

			// Button click handler 2
			private function onButtonClick2(e:MouseEvent):void {
				trace("Handler 2");
			}

			// Button click handler 3 listened by hbox
			private function onButtonClick3(e:MouseEvent):void {
				trace("Handler 3");
			}</pre>
<p>Here is the difference:</p>
<p><strong>when use stop propagation in the handler 1st, the trace is:</strong></p>
<p><em>Handler 1<br />
Handler 2</em></p>
<p><strong>but when use stopImmediatePropagation(), the trace is:</strong></p>
<p><em>Handler 1</em></p>
<p>That’s pretty easy to find the differences:</p>
<p>“The <samp>stopImmediatePropagation()</samp> method also prevents the Event objects from moving on to the next node, but it does not allow any other event listeners on the current node to execute.” (<a href="http://livedocs.adobe.com/flex/3/html/help.html?content=events_08.html">Adobe livedocs</a>)</p>
<p><p>

----------Post from: <a href="http://liguoliang.com">@LiGuoliang.com, 欢迎回来~</a>----------</p></p>
]]></content:encoded>
			<wfw:commentRss>http://liguoliang.com/2011/flex-event-stopimmediatepropagation-vs-stoppropagation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Flex 自定义Event 低级错误一例: 未重写Clone方法, 导致类型转换失败</title>
		<link>http://liguoliang.com/2010/custom-event-must-override-clone-method/</link>
		<comments>http://liguoliang.com/2010/custom-event-must-override-clone-method/#comments</comments>
		<pubDate>Fri, 10 Dec 2010 05:59:25 +0000</pubDate>
		<dc:creator>Guoliang</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Custom Event]]></category>
		<category><![CDATA[Event]]></category>

		<guid isPermaLink="false">http://liguoliang.com/2010/custom-event-must-override-clone-method/</guid>
		<description><![CDATA[自定义Event必须及时重写Clone与toString方法....<p class='read-more'><a href='http://liguoliang.com/2010/custom-event-must-override-clone-method/'></a></p><p><p>

----------Post from: <a href="http://liguoliang.com">@LiGuoliang.com, 欢迎回来~</a>----------</p></p>
]]></description>
			<content:encoded><![CDATA[<p>在Event监听并转发过程中, 因为没用重写Clone方法, 导致实例被Clone为普通Event实例.</p>
<p>情况是这样的:    <br />自定义Event: EventTest: 继承Event, 增加了一些属性, 重写了toString(), 未重写Clone.</p>
<p>出现问题: 创建EventTest实例后, 多次监听并转发, 在监听, 转发过程中, Event实例对象被Clone, 因为未重写Clone方法, 会通过Event类的Clone方法进行复制, 仅会复制其EventType, 且类型为Event.</p>
<p>形象的说就是: eventTest –&gt; 被监听到, 准发 -&gt;框架Clone eventTest(EventTest类中未重写Clone方法, 于是eventTest被克隆为一个普通Event) –&gt; 再次监听, Event类型不吻合, 报错.</p>
<p>公司代码规范中严格规定了<strong>自定义Event必须及时重写Clone与toString方法</strong>, 写了这么久, 我才领悟到原因. 败了</p>
<p><p>

----------Post from: <a href="http://liguoliang.com">@LiGuoliang.com, 欢迎回来~</a>----------</p></p>
]]></content:encoded>
			<wfw:commentRss>http://liguoliang.com/2010/custom-event-must-override-clone-method/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Flex4 Spark TextArea 设置自适应大小及派发鼠标滚动事件</title>
		<link>http://liguoliang.com/2010/auto-resizable-text-area-component/</link>
		<comments>http://liguoliang.com/2010/auto-resizable-text-area-component/#comments</comments>
		<pubDate>Sun, 14 Nov 2010 08:43:16 +0000</pubDate>
		<dc:creator>Guoliang</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[TextArea]]></category>

		<guid isPermaLink="false">http://liguoliang.com/2010/auto-resizable-text-area-component/</guid>
		<description><![CDATA[记得在使用Flex4之前, 看过一篇<a href="http://www.flexer.info/2009/02/06/auto-resizable-text-area-component/">介绍TextArea自适应高度的文章</a>, 监听Event, 动态改变高度.&#160; 很少用TextArea, 也没用过. 在Flex4， 使用Spark界面时, TextArea可设为自动适应. 
设置heightInLines = NaN -&#160; 如果<p class='read-more'><a href='http://liguoliang.com/2010/auto-resizable-text-area-component/'>More...</a></p><p><p>

----------Post from: <a href="http://liguoliang.com">@LiGuoliang.com, 欢迎回来~</a>----------</p></p>
]]></description>
			<content:encoded><![CDATA[<p>记得在使用Flex4之前, 看过一篇<a href="http://www.flexer.info/2009/02/06/auto-resizable-text-area-component/">介绍TextArea自适应高度的文章</a>, 监听Event, 动态改变高度.&#160; 很少用TextArea, 也没用过. 在Flex4， 使用Spark界面时, TextArea可设为自动适应. </p>
<p>设置heightInLines = NaN -&#160; 如果该属性为 <code>NaN</code>（默认值），则组件的默认高度由要显示的文本确定。     <br />See: <a title="http://tinyurl.com/2ubwrta" href="http://tinyurl.com/2ubwrta">http://tinyurl.com/2ubwrta</a></p>
<p>但当鼠标在TextArea之上时, 鼠标滚动, 整个Application的scrollbar竟然没反应&#8230;猜是没有dispatch event, 于是增加监听函数:</p>
<pre class="code" name="java">	/** 响应TextArea的鼠标滚动事件, 接收到后派发出去, 以便引起外部UI可获得该事件, 并进行响应的滚动. */
	protected function onMouseEventWheel(e:MouseEvent):void {
		dispatchEvent(e);
	}</pre>
<p>妥了. </p>
<p><p>

----------Post from: <a href="http://liguoliang.com">@LiGuoliang.com, 欢迎回来~</a>----------</p></p>
]]></content:encoded>
			<wfw:commentRss>http://liguoliang.com/2010/auto-resizable-text-area-component/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

