<?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>FLEX{er} &#187; Events</title>
	<atom:link href="http://www.flexer.info/category/events/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.flexer.info</link>
	<description>flex developers web corner</description>
	<lastBuildDate>Mon, 26 Jul 2010 17:54:21 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=abc</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<image>
  <link>http://www.flexer.info</link>
  <url>http://www.flexer.info/favicon.ico</url>
  <title>FLEX{er}</title>
</image>
		<item>
		<title>Web Seminar &#8211; Multitouch development with Flex</title>
		<link>http://www.flexer.info/2010/03/12/web-seminar-multitouch-development-with-flex/</link>
		<comments>http://www.flexer.info/2010/03/12/web-seminar-multitouch-development-with-flex/#comments</comments>
		<pubDate>Thu, 11 Mar 2010 23:21:11 +0000</pubDate>
		<dc:creator>Stelian Crisan</dc:creator>
				<category><![CDATA[Conferences, Meetings & Events]]></category>
		<category><![CDATA[Events]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Flex 4 SDK]]></category>
		<category><![CDATA[RIA]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[flash platform]]></category>
		<category><![CDATA[flex]]></category>
		<category><![CDATA[multitouch]]></category>
		<category><![CDATA[Piotr Walczyszyn]]></category>
		<category><![CDATA[web seminar]]></category>

		<guid isPermaLink="false">http://www.flexer.info/?p=1476</guid>
		<description><![CDATA[On Wednesday, March 17, 2010 from 12:00 PM &#8211; 1:00 PM (GMT+0200) will be available online an interesting web seminar hosted by Adobe Systems.  
Join Piotr Walczyszyn for this 30 minutes e-seminar followed by 15 minutes of Q&#038;A. Learn how to define mutitouch, how to support it, and how you can handle multitouch events. [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-right: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.flexer.info%2F2010%2F03%2F12%2Fweb-seminar-multitouch-development-with-flex%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.flexer.info%2F2010%2F03%2F12%2Fweb-seminar-multitouch-development-with-flex%2F" height="61" width="51" /></a></div><div style="float: right; margin-right: 10px"><a class="google_buzz"  
href="http://www.google.com/reader/link?url=http://www.flexer.info/2010/03/12/web-seminar-multitouch-development-with-flex/&title=Web+Seminar+&#8211;+Multitouch+development+with+Flex&srcURL=http://www.flexer.info" target="_blank" rel="nofollow"><img
src="http://www.flexer.info/wp-content/plugins/google-buzz-button-for-wordpress/images/google-buzz.png" alt="Google Buzz" /></a></div><p>On Wednesday, March 17, 2010 from 12:00 PM &#8211; 1:00 PM (GMT+0200) will be available online an interesting web seminar hosted by Adobe Systems.  </p>
<p>Join Piotr Walczyszyn for this 30 minutes e-seminar followed by 15 minutes of Q&#038;A. Learn how to define mutitouch, how to support it, and how you can handle multitouch events. Also explore new techniques for interacting with software and devices with the latest capabilities of the Flash Platform. </p>
<p>For registration please go to: <a target="_blank" href="http://multitouchflex.eventbrite.com">multitouchflex.eventbrite.com</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.flexer.info/2010/03/12/web-seminar-multitouch-development-with-flex/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Flex/Flash Keyboard Key Codes</title>
		<link>http://www.flexer.info/2009/12/20/flexflash-keyboard-key-codes/</link>
		<comments>http://www.flexer.info/2009/12/20/flexflash-keyboard-key-codes/#comments</comments>
		<pubDate>Sun, 20 Dec 2009 02:12:25 +0000</pubDate>
		<dc:creator>Andrei Ionescu</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Events]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[flex]]></category>
		<category><![CDATA[keyboard]]></category>

		<guid isPermaLink="false">http://www.flexer.info/?p=1302</guid>
		<description><![CDATA[If you need to know the key codes when implementing a keyboard event use the following application that displays some info about the pressed key. First you need to click on the application to have focus on it then you can start trying out different key strokes.

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_keycodes_908319284"
			class="flashmovie"
			width="440"
			height="284">
	<param name="movie" value="/wp-content/uploads/2009/12/keycodes.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="/wp-content/uploads/2009/12/keycodes.swf"
			name="fm_keycodes_908319284"
			width="440"
			height="284">
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
Some key codes, ASCII codes [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-right: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.flexer.info%2F2009%2F12%2F20%2Fflexflash-keyboard-key-codes%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.flexer.info%2F2009%2F12%2F20%2Fflexflash-keyboard-key-codes%2F" height="61" width="51" /></a></div><div style="float: right; margin-right: 10px"><a class="google_buzz"  
href="http://www.google.com/reader/link?url=http://www.flexer.info/2009/12/20/flexflash-keyboard-key-codes/&title=Flex/Flash+Keyboard+Key+Codes&srcURL=http://www.flexer.info" target="_blank" rel="nofollow"><img
src="http://www.flexer.info/wp-content/plugins/google-buzz-button-for-wordpress/images/google-buzz.png" alt="Google Buzz" /></a></div><p>If you need to know the key codes when implementing a keyboard event use the following application that displays some info about the pressed key. First you need to click on the application to have focus on it then you can start trying out different key strokes.</p>

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_keycodes_1725330037"
			class="flashmovie"
			width="440"
			height="284">
	<param name="movie" value="/wp-content/uploads/2009/12/keycodes.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="/wp-content/uploads/2009/12/keycodes.swf"
			name="fm_keycodes_1725330037"
			width="440"
			height="284">
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
<p>Some key codes, ASCII codes tables are present bellow&#8230;<br />
&nbsp;</p>
<table border="0" cellpadding="0" cellspacing="0" style="border:solid 1px #6699cc">
<tr>
<th nowrap style="text-align:left; background:#6699cc; color:white; padding-left:10px; padding-right:10px">
      Letter or number key
    </th>
<th nowrap style="text-align:left; background:#6699cc; color:white; padding-left:10px; padding-right:10px">
      Key code
    </th>
<th nowrap style="text-align:left; background:#6699cc; color:white; padding-left:10px; padding-right:10px">
      ASCII key code
    </th>
</tr>
<tr>
<td style="padding-left:10px">A</td>
<td style="padding-left:10px">65</td>
<td style="padding-left:10px">65</td>
</tr>
<tr bgcolor="#F8F8F8">
<td style="padding-left:10px">B</td>
<td style="padding-left:10px">66</td>
<td style="padding-left:10px">66</td>
</tr>
<tr>
<td style="padding-left:10px">C</td>
<td style="padding-left:10px">67</td>
<td style="padding-left:10px">67</td>
</tr>
<tr bgcolor="#F8F8F8">
<td style="padding-left:10px">D</td>
<td style="padding-left:10px">68</td>
<td style="padding-left:10px">68</td>
</tr>
<tr>
<td style="padding-left:10px">E</td>
<td style="padding-left:10px">69</td>
<td style="padding-left:10px">69</td>
</tr>
<tr bgcolor="#F8F8F8">
<td style="padding-left:10px">F</td>
<td style="padding-left:10px">70</td>
<td style="padding-left:10px">70</td>
</tr>
<tr>
<td style="padding-left:10px">G</td>
<td style="padding-left:10px">71</td>
<td style="padding-left:10px">71</td>
</tr>
<tr bgcolor="#F8F8F8">
<td style="padding-left:10px">H</td>
<td style="padding-left:10px">72</td>
<td style="padding-left:10px">72</td>
</tr>
<tr>
<td style="padding-left:10px">I</td>
<td style="padding-left:10px">73</td>
<td style="padding-left:10px">73</td>
</tr>
<tr bgcolor="#F8F8F8">
<td style="padding-left:10px">J</td>
<td style="padding-left:10px">74</td>
<td style="padding-left:10px">74</td>
</tr>
<tr>
<td style="padding-left:10px">K</td>
<td style="padding-left:10px">75</td>
<td style="padding-left:10px">75</td>
</tr>
<tr bgcolor="#F8F8F8">
<td style="padding-left:10px">L</td>
<td style="padding-left:10px">76</td>
<td style="padding-left:10px">76</td>
</tr>
<tr>
<td style="padding-left:10px">M</td>
<td style="padding-left:10px">77</td>
<td style="padding-left:10px">77</td>
</tr>
<tr bgcolor="#F8F8F8">
<td style="padding-left:10px">N</td>
<td style="padding-left:10px">78</td>
<td style="padding-left:10px">78</td>
</tr>
<tr>
<td style="padding-left:10px">O</td>
<td style="padding-left:10px">79</td>
<td style="padding-left:10px">79</td>
</tr>
<tr bgcolor="#F8F8F8">
<td style="padding-left:10px">P</td>
<td style="padding-left:10px">80</td>
<td style="padding-left:10px">80</td>
</tr>
<tr>
<td style="padding-left:10px">Q</td>
<td style="padding-left:10px">81</td>
<td style="padding-left:10px">81</td>
</tr>
<tr bgcolor="#F8F8F8">
<td style="padding-left:10px">R</td>
<td style="padding-left:10px">82</td>
<td style="padding-left:10px">82</td>
</tr>
<tr>
<td style="padding-left:10px">S</td>
<td style="padding-left:10px">83</td>
<td style="padding-left:10px">83</td>
</tr>
<tr bgcolor="#F8F8F8">
<td style="padding-left:10px">T</td>
<td style="padding-left:10px">84</td>
<td style="padding-left:10px">84</td>
</tr>
<tr>
<td style="padding-left:10px">U</td>
<td style="padding-left:10px">85</td>
<td style="padding-left:10px">85</td>
</tr>
<tr bgcolor="#F8F8F8">
<td style="padding-left:10px">V</td>
<td style="padding-left:10px">86</td>
<td style="padding-left:10px">86</td>
</tr>
<tr>
<td style="padding-left:10px">W</td>
<td style="padding-left:10px">87</td>
<td style="padding-left:10px">87</td>
</tr>
<tr bgcolor="#F8F8F8">
<td style="padding-left:10px">X</td>
<td style="padding-left:10px">88</td>
<td style="padding-left:10px">88</td>
</tr>
<tr>
<td style="padding-left:10px">Y</td>
<td style="padding-left:10px">89</td>
<td style="padding-left:10px">89</td>
</tr>
<tr bgcolor="#F8F8F8">
<td style="padding-left:10px">Z</td>
<td style="padding-left:10px">90</td>
<td style="padding-left:10px">90</td>
</tr>
<tr>
<td style="padding-left:10px">0</td>
<td style="padding-left:10px">48</td>
<td style="padding-left:10px">48</td>
</tr>
<tr bgcolor="#F8F8F8">
<td style="padding-left:10px">1</td>
<td style="padding-left:10px">49</td>
<td style="padding-left:10px">49</td>
</tr>
<tr>
<td style="padding-left:10px">2</td>
<td style="padding-left:10px">50</td>
<td style="padding-left:10px">50</td>
</tr>
<tr bgcolor="#F8F8F8">
<td style="padding-left:10px">3</td>
<td style="padding-left:10px">51</td>
<td style="padding-left:10px">51</td>
</tr>
<tr>
<td style="padding-left:10px">4</td>
<td style="padding-left:10px">52</td>
<td style="padding-left:10px">52</td>
</tr>
<tr bgcolor="#F8F8F8">
<td style="padding-left:10px">5</td>
<td style="padding-left:10px">53</td>
<td style="padding-left:10px">53</td>
</tr>
<tr>
<td style="padding-left:10px">6</td>
<td style="padding-left:10px">54</td>
<td style="padding-left:10px">54</td>
</tr>
<tr bgcolor="#F8F8F8">
<td style="padding-left:10px">7</td>
<td style="padding-left:10px">55</td>
<td style="padding-left:10px">55</td>
</tr>
<tr>
<td style="padding-left:10px">8</td>
<td style="padding-left:10px">56</td>
<td style="padding-left:10px">56</td>
</tr>
<tr bgcolor="#F8F8F8">
<td style="padding-left:10px">9</td>
<td style="padding-left:10px">57</td>
<td style="padding-left:10px">57</td>
</tr>
<tr>
<td style="padding-left:10px">a</td>
<td style="padding-left:10px">65</td>
<td style="padding-left:10px">97</td>
</tr>
<tr bgcolor="#F8F8F8">
<td style="padding-left:10px">b</td>
<td style="padding-left:10px">66</td>
<td style="padding-left:10px">98</td>
</tr>
<tr>
<td style="padding-left:10px">c</td>
<td style="padding-left:10px">67</td>
<td style="padding-left:10px">99</td>
</tr>
<tr bgcolor="#F8F8F8">
<td style="padding-left:10px">d</td>
<td style="padding-left:10px">68</td>
<td style="padding-left:10px">100</td>
</tr>
<tr>
<td style="padding-left:10px">e</td>
<td style="padding-left:10px">69</td>
<td style="padding-left:10px">101</td>
</tr>
<tr bgcolor="#F8F8F8">
<td style="padding-left:10px">f</td>
<td style="padding-left:10px">70</td>
<td style="padding-left:10px">102</td>
</tr>
<tr>
<td style="padding-left:10px">g</td>
<td style="padding-left:10px">71</td>
<td style="padding-left:10px">103</td>
</tr>
<tr bgcolor="#F8F8F8">
<td style="padding-left:10px">h</td>
<td style="padding-left:10px">72</td>
<td style="padding-left:10px">104</td>
</tr>
<tr>
<td style="padding-left:10px">i</td>
<td style="padding-left:10px">73</td>
<td style="padding-left:10px">105</td>
</tr>
<tr bgcolor="#F8F8F8">
<td style="padding-left:10px">j</td>
<td style="padding-left:10px">74</td>
<td style="padding-left:10px">106</td>
</tr>
<tr>
<td style="padding-left:10px">k</td>
<td style="padding-left:10px">75</td>
<td style="padding-left:10px">107</td>
</tr>
<tr bgcolor="#F8F8F8">
<td style="padding-left:10px">l</td>
<td style="padding-left:10px">76</td>
<td style="padding-left:10px">108</td>
</tr>
<tr>
<td style="padding-left:10px">m</td>
<td style="padding-left:10px">77</td>
<td style="padding-left:10px">109</td>
</tr>
<tr bgcolor="#F8F8F8">
<td style="padding-left:10px">n</td>
<td style="padding-left:10px">78</td>
<td style="padding-left:10px">110</td>
</tr>
<tr>
<td style="padding-left:10px">o</td>
<td style="padding-left:10px">79</td>
<td style="padding-left:10px">111</td>
</tr>
<tr bgcolor="#F8F8F8">
<td style="padding-left:10px">p</td>
<td style="padding-left:10px">80</td>
<td style="padding-left:10px">112</td>
</tr>
<tr>
<td style="padding-left:10px">q</td>
<td style="padding-left:10px">81</td>
<td style="padding-left:10px">113</td>
</tr>
<tr bgcolor="#F8F8F8">
<td style="padding-left:10px">r</td>
<td style="padding-left:10px">82</td>
<td style="padding-left:10px">114</td>
</tr>
<tr>
<td style="padding-left:10px">s</td>
<td style="padding-left:10px">83</td>
<td style="padding-left:10px">115</td>
</tr>
<tr bgcolor="#F8F8F8">
<td style="padding-left:10px">t</td>
<td style="padding-left:10px">84</td>
<td style="padding-left:10px">116</td>
</tr>
<tr>
<td style="padding-left:10px">u</td>
<td style="padding-left:10px">85</td>
<td style="padding-left:10px">117</td>
</tr>
<tr bgcolor="#F8F8F8">
<td style="padding-left:10px">v</td>
<td style="padding-left:10px">86</td>
<td style="padding-left:10px">118</td>
</tr>
<tr>
<td style="padding-left:10px">w</td>
<td style="padding-left:10px">87</td>
<td style="padding-left:10px">119</td>
</tr>
<tr bgcolor="#F8F8F8">
<td style="padding-left:10px">x</td>
<td style="padding-left:10px">88</td>
<td style="padding-left:10px">120</td>
</tr>
<tr>
<td style="padding-left:10px">y</td>
<td style="padding-left:10px">89</td>
<td style="padding-left:10px">121</td>
</tr>
<tr bgcolor="#F8F8F8">
<td style="padding-left:10px">z</td>
<td style="padding-left:10px">90</td>
<td style="padding-left:10px">122</td>
</tr>
</table>
<p>&nbsp;</p>
<table border="0" cellpadding="0" cellspacing="0" style="border:solid 1px #6699cc">
<tr>
<th nowrap style="text-align:left; background:#6699cc; color:white; padding-left:10px; padding-right:10px">
      Numeric keypad key
    </th>
<th nowrap style="text-align:left; background:#6699cc; color:white; padding-left:10px; padding-right:10px">
      Key code
    </th>
<th nowrap style="text-align:left; background:#6699cc; color:white; padding-left:10px; padding-right:10px">
      ASCII key code
    </th>
</tr>
<tr>
<td style="padding-left:10px">Numpad 0</td>
<td style="padding-left:10px">96</td>
<td style="padding-left:10px">48</td>
</tr>
<tr bgcolor="#F8F8F8">
<td style="padding-left:10px">Numpad 1</td>
<td style="padding-left:10px">97</td>
<td style="padding-left:10px">49</td>
</tr>
<tr>
<td style="padding-left:10px">Numpad 2</td>
<td style="padding-left:10px">98</td>
<td style="padding-left:10px">50</td>
</tr>
<tr bgcolor="#F8F8F8">
<td style="padding-left:10px">Numpad 3</td>
<td style="padding-left:10px">99</td>
<td style="padding-left:10px">51</td>
</tr>
<tr>
<td style="padding-left:10px">Numpad 4</td>
<td style="padding-left:10px">100</td>
<td style="padding-left:10px">52</td>
</tr>
<tr bgcolor="#F8F8F8">
<td style="padding-left:10px">Numpad 5</td>
<td style="padding-left:10px">101</td>
<td style="padding-left:10px">53</td>
</tr>
<tr>
<td style="padding-left:10px">Numpad 6</td>
<td style="padding-left:10px">102</td>
<td style="padding-left:10px">54</td>
</tr>
<tr bgcolor="#F8F8F8">
<td style="padding-left:10px">Numpad 7</td>
<td style="padding-left:10px">103</td>
<td style="padding-left:10px">55</td>
</tr>
<tr>
<td style="padding-left:10px">Numpad 8</td>
<td style="padding-left:10px">104</td>
<td style="padding-left:10px">56</td>
</tr>
<tr bgcolor="#F8F8F8">
<td style="padding-left:10px">Numpad 9</td>
<td style="padding-left:10px">105</td>
<td style="padding-left:10px">57</td>
</tr>
<tr>
<td style="padding-left:10px">Multiply</td>
<td style="padding-left:10px">106</td>
<td style="padding-left:10px">42</td>
</tr>
<tr bgcolor="#F8F8F8">
<td style="padding-left:10px">Add</td>
<td style="padding-left:10px">107</td>
<td style="padding-left:10px">43</td>
</tr>
<tr>
<td style="padding-left:10px">Enter</td>
<td style="padding-left:10px">13</td>
<td style="padding-left:10px">13</td>
</tr>
<tr bgcolor="#F8F8F8">
<td style="padding-left:10px">Subtract</td>
<td style="padding-left:10px">109</td>
<td style="padding-left:10px">45</td>
</tr>
<tr>
<td style="padding-left:10px">Decimal</td>
<td style="padding-left:10px">110</td>
<td style="padding-left:10px">46</td>
</tr>
<tr bgcolor="#F8F8F8">
<td style="padding-left:10px">Divide</td>
<td style="padding-left:10px">111</td>
<td style="padding-left:10px">47</td>
</tr>
</table>
<p>&nbsp;</p>
<table border="0" cellpadding="0" cellspacing="0" style="border:solid 1px #6699cc">
<tr>
<th nowrap style="text-align:left; background:#6699cc; color:white; padding-left:10px; padding-right:10px">
      Function key
    </th>
<th nowrap style="text-align:left; background:#6699cc; color:white; padding-left:10px; padding-right:10px">
      Key code
    </th>
<th nowrap style="text-align:left; background:#6699cc; color:white; padding-left:10px; padding-right:10px">
      ASCII key code
    </th>
</tr>
<tr>
<td style="padding-left:10px">F1</td>
<td style="padding-left:10px">112</td>
<td style="padding-left:10px">0</td>
</tr>
<tr bgcolor="#F8F8F8">
<td style="padding-left:10px">F2</td>
<td style="padding-left:10px">113</td>
<td style="padding-left:10px">0</td>
</tr>
<tr>
<td style="padding-left:10px">F3</td>
<td style="padding-left:10px">114</td>
<td style="padding-left:10px">0</td>
</tr>
<tr bgcolor="#F8F8F8">
<td style="padding-left:10px">F4</td>
<td style="padding-left:10px">115</td>
<td style="padding-left:10px">0</td>
</tr>
<tr>
<td style="padding-left:10px">F5</td>
<td style="padding-left:10px">116</td>
<td style="padding-left:10px">0</td>
</tr>
<tr bgcolor="#F8F8F8">
<td style="padding-left:10px">F6</td>
<td style="padding-left:10px">117</td>
<td style="padding-left:10px">0</td>
</tr>
<tr>
<td style="padding-left:10px">F7</td>
<td style="padding-left:10px">118</td>
<td style="padding-left:10px">0</td>
</tr>
<tr bgcolor="#F8F8F8">
<td style="padding-left:10px">F8</td>
<td style="padding-left:10px">119</td>
<td style="padding-left:10px">0</td>
</tr>
<tr>
<td style="padding-left:10px">F9</td>
<td style="padding-left:10px">120</td>
<td style="padding-left:10px">0</td>
</tr>
<tr bgcolor="#F8F8F8">
<td style="padding-left:10px">F10</td>
<td style="padding-left:10px">This key is reserved by the system and cannot be used in ActionScript.</td>
<td style="padding-left:10px">This key is reserved by the system and cannot be used in ActionScript.</td>
</tr>
<tr>
<td style="padding-left:10px">F11</td>
<td style="padding-left:10px">122</td>
<td style="padding-left:10px">0</td>
</tr>
<tr bgcolor="#F8F8F8">
<td style="padding-left:10px">F12</td>
<td style="padding-left:10px">123</td>
<td style="padding-left:10px">0</td>
</tr>
<tr>
<td style="padding-left:10px">F13</td>
<td style="padding-left:10px">124</td>
<td style="padding-left:10px">0</td>
</tr>
<tr bgcolor="#F8F8F8">
<td style="padding-left:10px">F14</td>
<td style="padding-left:10px">125</td>
<td style="padding-left:10px">0</td>
</tr>
<tr>
<td style="padding-left:10px">F15</td>
<td style="padding-left:10px">126</td>
<td style="padding-left:10px">0</td>
</tr>
</table>
<p>&nbsp;</p>
<table border="0" cellpadding="0" cellspacing="0" style="border:solid 1px #6699cc">
<tr>
<th nowrap style="text-align:left; background:#6699cc; color:white; padding-left:10px; padding-right:10px">
      Key
    </th>
<th nowrap style="text-align:left; background:#6699cc; color:white; padding-left:10px; padding-right:10px">
      Key code
    </th>
<th nowrap style="text-align:left; background:#6699cc; color:white; padding-left:10px; padding-right:10px">
      ASCII key code
    </th>
</tr>
<tr>
<td style="padding-left:10px">Backspace</td>
<td style="padding-left:10px">8</td>
<td style="padding-left:10px">8</td>
</tr>
<tr bgcolor="#F8F8F8">
<td style="padding-left:10px">Tab</td>
<td style="padding-left:10px">9</td>
<td style="padding-left:10px">9</td>
</tr>
<tr>
<td style="padding-left:10px">Enter</td>
<td style="padding-left:10px">13</td>
<td style="padding-left:10px">13</td>
</tr>
<tr bgcolor="#F8F8F8">
<td style="padding-left:10px">Shift</td>
<td style="padding-left:10px">16</td>
<td style="padding-left:10px">0</td>
</tr>
<tr>
<td style="padding-left:10px">Control</td>
<td style="padding-left:10px">17</td>
<td style="padding-left:10px">0</td>
</tr>
<tr bgcolor="#F8F8F8">
<td style="padding-left:10px">Caps Lock</td>
<td style="padding-left:10px">20</td>
<td style="padding-left:10px">0</td>
</tr>
<tr>
<td style="padding-left:10px">Esc</td>
<td style="padding-left:10px">27</td>
<td style="padding-left:10px">27</td>
</tr>
<tr bgcolor="#F8F8F8">
<td style="padding-left:10px">Spacebar</td>
<td style="padding-left:10px">32</td>
<td style="padding-left:10px">32</td>
</tr>
<tr>
<td style="padding-left:10px">Page Up</td>
<td style="padding-left:10px">33</td>
<td style="padding-left:10px">0</td>
</tr>
<tr bgcolor="#F8F8F8">
<td style="padding-left:10px">Page Down</td>
<td style="padding-left:10px">34</td>
<td style="padding-left:10px">0</td>
</tr>
<tr>
<td style="padding-left:10px">End</td>
<td style="padding-left:10px">35</td>
<td style="padding-left:10px">0</td>
</tr>
<tr bgcolor="#F8F8F8">
<td style="padding-left:10px">Home</td>
<td style="padding-left:10px">36</td>
<td style="padding-left:10px">0</td>
</tr>
<tr>
<td style="padding-left:10px">Left Arrow</td>
<td style="padding-left:10px">37</td>
<td style="padding-left:10px">0</td>
</tr>
<tr bgcolor="#F8F8F8">
<td style="padding-left:10px">Up Arrow</td>
<td style="padding-left:10px">38</td>
<td style="padding-left:10px">0</td>
</tr>
<tr>
<td style="padding-left:10px">Right Arrow</td>
<td style="padding-left:10px">39</td>
<td style="padding-left:10px">0</td>
</tr>
<tr bgcolor="#F8F8F8">
<td style="padding-left:10px">Down Arrow</td>
<td style="padding-left:10px">40</td>
<td style="padding-left:10px">0</td>
</tr>
<tr>
<td style="padding-left:10px">Insert</td>
<td style="padding-left:10px">45</td>
<td style="padding-left:10px">0</td>
</tr>
<tr bgcolor="#F8F8F8">
<td style="padding-left:10px">Delete</td>
<td style="padding-left:10px">46</td>
<td style="padding-left:10px">127</td>
</tr>
<tr>
<td style="padding-left:10px">Num Lock</td>
<td style="padding-left:10px">144</td>
<td style="padding-left:10px">0</td>
</tr>
<tr bgcolor="#F8F8F8">
<td style="padding-left:10px">ScrLk</td>
<td style="padding-left:10px">145</td>
<td style="padding-left:10px">0</td>
</tr>
<tr>
<td style="padding-left:10px">Pause/Break</td>
<td style="padding-left:10px">19</td>
<td style="padding-left:10px">0</td>
</tr>
</table>
<p>Some stuff about keyboard events bellow:<br />
<a href="http://livedocs.adobe.com/flex/3/html/help.html?content=events_11.html" target="_blank">http://livedocs.adobe.com/flex/3/html/help.html?content=events_11.html</a><br />
<a href="http://cookbooks.adobe.com/post_Global_keyboard_event_handling-304.html" target="_blank">http://cookbooks.adobe.com/post_Global_keyboard_event_handling-304.html</a><br />
<a href="http://livedocs.adobe.com/flex/3/html/help.html?content=Capturing_User_Input_3.html" target="_blank">http://livedocs.adobe.com/flex/3/html/help.html?content=Capturing_User_Input_3.html</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.flexer.info/2009/12/20/flexflash-keyboard-key-codes/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>How To Create Bindable Properties (using Getters and Setters Methods) in Flex</title>
		<link>http://www.flexer.info/2009/06/26/how-to-create-bindable-properties-using-getters-and-setters-methods-in-flex/</link>
		<comments>http://www.flexer.info/2009/06/26/how-to-create-bindable-properties-using-getters-and-setters-methods-in-flex/#comments</comments>
		<pubDate>Fri, 26 Jun 2009 07:25:07 +0000</pubDate>
		<dc:creator>Andrei Ionescu</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Components]]></category>
		<category><![CDATA[Events]]></category>
		<category><![CDATA[Flex resources]]></category>
		<category><![CDATA[How to]]></category>
		<category><![CDATA[MXML]]></category>
		<category><![CDATA[bindable]]></category>
		<category><![CDATA[component]]></category>

		<guid isPermaLink="false">http://www.flexer.info/?p=515</guid>
		<description><![CDATA[Let&#8217;s say you created a new component and you want to add some properties that need to be bindable. Something like this:

&#60;flexer:myComp width=&#34;400&#34; height=&#34;200&#34; myNewSetter=&#34;{_myData}&#34; /&#62;
&#60;mx:Script&#62;
    &#91;Bindable&#93;
    private var _myData:String= &#34;&#34;;
&#60;/mx:Script&#62;

And when we do this

_myData = &#34;new_val_1&#34;;

the myComp component should know that _myData has changed and should modify itself [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-right: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.flexer.info%2F2009%2F06%2F26%2Fhow-to-create-bindable-properties-using-getters-and-setters-methods-in-flex%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.flexer.info%2F2009%2F06%2F26%2Fhow-to-create-bindable-properties-using-getters-and-setters-methods-in-flex%2F" height="61" width="51" /></a></div><div style="float: right; margin-right: 10px"><a class="google_buzz"  
href="http://www.google.com/reader/link?url=http://www.flexer.info/2009/06/26/how-to-create-bindable-properties-using-getters-and-setters-methods-in-flex/&title=How+To+Create+Bindable+Properties+(using+Getters+and+Setters+Methods)+in+Flex&srcURL=http://www.flexer.info" target="_blank" rel="nofollow"><img
src="http://www.flexer.info/wp-content/plugins/google-buzz-button-for-wordpress/images/google-buzz.png" alt="Google Buzz" /></a></div><p>Let&#8217;s say you created a new component and you want to add some properties that need to be bindable. Something like this:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #66cc66;">&lt;</span>flexer:myComp <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">&quot;400&quot;</span> <span style="color: #0066CC;">height</span>=<span style="color: #ff0000;">&quot;200&quot;</span> myNewSetter=<span style="color: #ff0000;">&quot;{_myData}&quot;</span> <span style="color: #66cc66;">/&gt;</span>
<span style="color: #66cc66;">&lt;</span>mx:Script<span style="color: #66cc66;">&gt;</span>
    <span style="color: #66cc66;">&#91;</span>Bindable<span style="color: #66cc66;">&#93;</span>
    <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _myData:<span style="color: #0066CC;">String</span>= <span style="color: #ff0000;">&quot;&quot;</span>;
<span style="color: #66cc66;">&lt;/</span>mx:Script<span style="color: #66cc66;">&gt;</span></pre></div></div>

<p>And when we do this</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;">_myData = <span style="color: #ff0000;">&quot;new_val_1&quot;</span>;</pre></div></div>

<p>the <strong>myComp</strong> component should know that <strong>_myData</strong> has changed and should modify itself according to the new value.</p>
<p>This is quite simple. Do the following:</p>
<ol>
<li>On the getter, just above it, use the bindable meta tag like this<br />&nbsp;

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #66cc66;">&#91;</span>Bindable<span style="color: #66cc66;">&#40;</span>event=<span style="color: #ff0000;">&quot;mySpecialEvent&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#93;</span></pre></div></div>

</li>
<li>On the setter, at the end but in the setter&#8217;s body (just before closing the setter), dispatch the event used at point 1 like this<br />&nbsp;

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;">dispatchEvent<span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> Event<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;mySpecialEvent&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</pre></div></div>

<p></a> </li>
</ol>
<p>Let me show you the following example&#8230;</p>

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_bindablegettersandsetters_1534553252"
			class="flashmovie"
			width="459"
			height="299">
	<param name="movie" value="wp-content/uploads/2009/06/bindablegettersandsetters.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="wp-content/uploads/2009/06/bindablegettersandsetters.swf"
			name="fm_bindablegettersandsetters_1534553252"
			width="459"
			height="299">
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
<p>The second text area field is not a <strong>TextArea</strong> compoment but a new created component that is extending the regular <strong>TextArea</strong>. I called it <strong>AlteredTextArea</strong> because the new property it has will alter its content. This is our component that implements a new property called <strong>alteration</strong> that is bindable.</p>
<p>The combo box will say to the <strong>AlteredTextArea</strong> component in which way to alter the content: lowercase or uppercase.</p>
<p>Now the code. It is short, commented and has 2 files: the main application and the <strong>AlteredTextArea</strong> component.</p>
<p>This is our component <strong>AlteredTextArea</strong>&#8230;</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
</pre></td><td class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #66cc66;">&lt;</span>?<span style="color: #0066CC;">xml</span> <span style="color: #0066CC;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> encoding=<span style="color: #ff0000;">&quot;utf-8&quot;</span>?<span style="color: #66cc66;">&gt;</span>
<span style="color: #66cc66;">&lt;</span>mx:TextArea xmlns:mx=<span style="color: #ff0000;">&quot;http://www.adobe.com/2006/mxml&quot;</span><span style="color: #66cc66;">&gt;</span>
    <span style="color: #66cc66;">&lt;</span>mx:Script<span style="color: #66cc66;">&gt;</span>
        <span style="color: #66cc66;">&lt;!</span><span style="color: #66cc66;">&#91;</span>CDATA<span style="color: #66cc66;">&#91;</span>
            <span style="color: #808080; font-style: italic;">// private variable saving the current alteration</span>
            <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _alteration:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">&quot;&quot;</span>;
&nbsp;
            <span style="color: #808080; font-style: italic;">// Getter</span>
            <span style="color: #808080; font-style: italic;">// Allow other components to bind to this property</span>
            <span style="color: #66cc66;">&#91;</span>Bindable<span style="color: #66cc66;">&#40;</span>event=<span style="color: #ff0000;">&quot;changeAlteration&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#93;</span>
            <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">get</span> alteration<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">String</span>
            <span style="color: #66cc66;">&#123;</span>
                <span style="color: #b1b100;">return</span> _alteration;
            <span style="color: #66cc66;">&#125;</span>
&nbsp;
            <span style="color: #808080; font-style: italic;">// Setter</span>
            <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">set</span> alteration<span style="color: #66cc66;">&#40;</span>s:<span style="color: #0066CC;">String</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
            <span style="color: #66cc66;">&#123;</span>
                _alteration = s;
&nbsp;
                <span style="color: #808080; font-style: italic;">// We dispatch an event when the value changes</span>
                dispatchEvent<span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> Event<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;changeAlteration&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
             <span style="color: #66cc66;">&#125;</span>
&nbsp;
             <span style="color: #808080; font-style: italic;">// overiding the text setter</span>
             override <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">set</span> <span style="color: #0066CC;">text</span><span style="color: #66cc66;">&#40;</span>value:<span style="color: #0066CC;">String</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
             <span style="color: #66cc66;">&#123;</span>
                 <span style="color: #808080; font-style: italic;">// adding alteration to the text</span>
                 <span style="color: #000000; font-weight: bold;">var</span> newValue:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">&quot;&quot;</span>;
                 <span style="color: #b1b100;">switch</span> <span style="color: #66cc66;">&#40;</span>_alteration<span style="color: #66cc66;">&#41;</span> 
                 <span style="color: #66cc66;">&#123;</span>
                     <span style="color: #808080; font-style: italic;">// applying lowercase</span>
                     <span style="color: #b1b100;">case</span> <span style="color: #ff0000;">&quot;toLowerCase&quot;</span>:
                         newValue = value.<span style="color: #0066CC;">toLowerCase</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
                         <span style="color: #b1b100;">break</span>;
                     <span style="color: #808080; font-style: italic;">// applying uppercase</span>
                     <span style="color: #b1b100;">case</span> <span style="color: #ff0000;">&quot;toUpperCase&quot;</span>:
                         newValue = value.<span style="color: #0066CC;">toUpperCase</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
                         <span style="color: #b1b100;">break</span>;
                     <span style="color: #808080; font-style: italic;">// no alteration</span>
                     <span style="color: #000000; font-weight: bold;">default</span>:
                         newValue = value;
                         <span style="color: #b1b100;">break</span>;
                 <span style="color: #66cc66;">&#125;</span>
                 <span style="color: #808080; font-style: italic;">// calling the super</span>
                 <span style="color: #0066CC;">super</span>.<span style="color: #0066CC;">text</span> = newValue;
             <span style="color: #66cc66;">&#125;</span>
        <span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&gt;</span>
    <span style="color: #66cc66;">&lt;/</span>mx:Script<span style="color: #66cc66;">&gt;</span>
<span style="color: #66cc66;">&lt;/</span>mx:TextArea<span style="color: #66cc66;">&gt;</span></pre></td></tr></table></div>

<p>Now the main application&#8230;</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
</pre></td><td class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #66cc66;">&lt;</span>?<span style="color: #0066CC;">xml</span> <span style="color: #0066CC;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> encoding=<span style="color: #ff0000;">&quot;utf-8&quot;</span>?<span style="color: #66cc66;">&gt;</span>
<span style="color: #66cc66;">&lt;</span>mx:Application xmlns:mx=<span style="color: #ff0000;">&quot;http://www.adobe.com/2006/mxml&quot;</span> 
    layout=<span style="color: #ff0000;">&quot;absolute&quot;</span> xmlns:flexer=<span style="color: #ff0000;">&quot;com.flexer.*&quot;</span> 
    <span style="color: #0066CC;">height</span>=<span style="color: #ff0000;">&quot;299&quot;</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">&quot;459&quot;</span><span style="color: #66cc66;">&gt;</span>
    <span style="color: #66cc66;">&lt;</span>mx:ComboBox id=<span style="color: #ff0000;">&quot;alterationCombo&quot;</span> x=<span style="color: #ff0000;">&quot;118&quot;</span> y=<span style="color: #ff0000;">&quot;138&quot;</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">&quot;158&quot;</span>
        dataProvider=<span style="color: #ff0000;">&quot;{_alterations}&quot;</span> 
        change=<span style="color: #ff0000;">&quot;handleAlterationChanges(event)&quot;</span><span style="color: #66cc66;">/&gt;</span>
    <span style="color: #66cc66;">&lt;</span>mx:Label x=<span style="color: #ff0000;">&quot;10&quot;</span> y=<span style="color: #ff0000;">&quot;140&quot;</span> <span style="color: #0066CC;">text</span>=<span style="color: #ff0000;">&quot;Alteration:&quot;</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">&quot;100&quot;</span><span style="color: #66cc66;">/&gt;</span>
    <span style="color: #66cc66;">&lt;</span>mx:Label x=<span style="color: #ff0000;">&quot;10&quot;</span> y=<span style="color: #ff0000;">&quot;11&quot;</span> <span style="color: #0066CC;">text</span>=<span style="color: #ff0000;">&quot;Input text:&quot;</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">&quot;100&quot;</span><span style="color: #66cc66;">/&gt;</span>
    <span style="color: #66cc66;">&lt;</span>mx:Label x=<span style="color: #ff0000;">&quot;10&quot;</span> y=<span style="color: #ff0000;">&quot;169&quot;</span> <span style="color: #0066CC;">text</span>=<span style="color: #ff0000;">&quot;Output:&quot;</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">&quot;100&quot;</span><span style="color: #66cc66;">/&gt;</span>
    <span style="color: #66cc66;">&lt;</span>mx:TextArea id=<span style="color: #ff0000;">&quot;inputText&quot;</span> x=<span style="color: #ff0000;">&quot;118&quot;</span> y=<span style="color: #ff0000;">&quot;10&quot;</span> 
        <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">&quot;330&quot;</span> <span style="color: #0066CC;">height</span>=<span style="color: #ff0000;">&quot;120&quot;</span> 
        <span style="color: #0066CC;">text</span>=<span style="color: #ff0000;">&quot;{_testText}&quot;</span><span style="color: #66cc66;">/&gt;</span>
    <span style="color: #66cc66;">&lt;</span>flexer:AlteredTextArea x=<span style="color: #ff0000;">&quot;118&quot;</span> y=<span style="color: #ff0000;">&quot;168&quot;</span>
        id=<span style="color: #ff0000;">&quot;alteredText&quot;</span> 
        <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">&quot;330&quot;</span> <span style="color: #0066CC;">height</span>=<span style="color: #ff0000;">&quot;120&quot;</span> 
        <span style="color: #0066CC;">text</span>=<span style="color: #ff0000;">&quot;{inputText.text}&quot;</span> 
        alteration=<span style="color: #ff0000;">&quot;{_currentAlteration}&quot;</span>
        editable=<span style="color: #ff0000;">&quot;false&quot;</span><span style="color: #66cc66;">/&gt;</span>
&nbsp;
    <span style="color: #66cc66;">&lt;</span>mx:Script<span style="color: #66cc66;">&gt;</span>
        <span style="color: #66cc66;">&lt;!</span><span style="color: #66cc66;">&#91;</span>CDATA<span style="color: #66cc66;">&#91;</span>
            <span style="color: #808080; font-style: italic;">// alteration available</span>
            <span style="color: #66cc66;">&#91;</span>Bindable<span style="color: #66cc66;">&#93;</span>
            <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _alterations:<span style="color: #0066CC;">Object</span> = <span style="color: #66cc66;">&#91;</span>
                <span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Default&quot;</span>,value:<span style="color: #ff0000;">&quot;&quot;</span><span style="color: #66cc66;">&#125;</span>,
                <span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Lowercase&quot;</span>,value:<span style="color: #ff0000;">&quot;toLowerCase&quot;</span><span style="color: #66cc66;">&#125;</span>,
                <span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">&quot;Uppercase&quot;</span>,value:<span style="color: #ff0000;">&quot;toUpperCase&quot;</span><span style="color: #66cc66;">&#125;</span>
            <span style="color: #66cc66;">&#93;</span>;
&nbsp;
            <span style="color: #808080; font-style: italic;">// the test to start with</span>
            <span style="color: #66cc66;">&#91;</span>Bindable<span style="color: #66cc66;">&#93;</span>
            <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _testText:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">&quot;Test TEST test&quot;</span>;
&nbsp;
            <span style="color: #808080; font-style: italic;">// the current alteration</span>
            <span style="color: #66cc66;">&#91;</span>Bindable<span style="color: #66cc66;">&#93;</span>
            <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _currentAlteration:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">&quot;&quot;</span>;
&nbsp;
            <span style="color: #808080; font-style: italic;">// handler for changes</span>
            <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> handleAlterationChanges<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>:Event<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> 
            <span style="color: #66cc66;">&#123;</span>
                <span style="color: #808080; font-style: italic;">// setting current alteration</span>
                _currentAlteration = <span style="color: #0066CC;">e</span>.<span style="color: #0066CC;">target</span>.<span style="color: #006600;">selectedItem</span>.<span style="color: #006600;">value</span>;
                <span style="color: #808080; font-style: italic;">// setting the text again</span>
                alteredText.<span style="color: #0066CC;">text</span> = inputText.<span style="color: #0066CC;">text</span>;
            <span style="color: #66cc66;">&#125;</span>
        <span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&gt;</span>
    <span style="color: #66cc66;">&lt;/</span>mx:Script<span style="color: #66cc66;">&gt;</span>
&nbsp;
<span style="color: #66cc66;">&lt;/</span>mx:Application<span style="color: #66cc66;">&gt;</span></pre></td></tr></table></div>

<p>I think you already noticed the <strong>get alteration</strong> and <strong>set alteration</strong> methods and understood how is done.</p>
<p>If you want to know more take a look inside the <strong>TextArea</strong> component which has lots of getters and setters using this tehnique.</p>
<p>It seems that it can even be used like this</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #66cc66;">&#91;</span>Bindable<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;changeAlteration&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#93;</span></pre></div></div>

<p>without saying &#8220;<code>event=</code>&#8220;. But to be make the code more readable I use the first case.</p>
<p>Also on DevNet found the following resources:</p>
<ul class="ul">
<li><a href="http://www.adobe.com/devnet/flex/quickstart/building_components_in_mxml/" target="_blank">http://www.adobe.com/devnet/flex/quickstart/building_components_in_mxml/</a> (go to the end and see the last example)</li>
<li><a href="http://www.adobe.com/devnet/flex/quickstart/building_components_in_mxml/src/MxmlComponentAdvanced/index.html" target="_blank">http://www.adobe.com/devnet/flex/quickstart/building_components_in_mxml/src/MxmlComponentAdvanced/index.html</a></li>
</ul>
<p>Happy coding!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.flexer.info/2009/06/26/how-to-create-bindable-properties-using-getters-and-setters-methods-in-flex/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>How To Change The Default Behavior of DisclosureIcon of a Tree Component</title>
		<link>http://www.flexer.info/2009/04/21/how-to-change-the-default-behavior-of-disclosureicon-of-a-tree-component/</link>
		<comments>http://www.flexer.info/2009/04/21/how-to-change-the-default-behavior-of-disclosureicon-of-a-tree-component/#comments</comments>
		<pubDate>Mon, 20 Apr 2009 22:33:12 +0000</pubDate>
		<dc:creator>Andrei Ionescu</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Components]]></category>
		<category><![CDATA[Events]]></category>
		<category><![CDATA[How to]]></category>
		<category><![CDATA[MXML]]></category>
		<category><![CDATA[component]]></category>
		<category><![CDATA[tree]]></category>

		<guid isPermaLink="false">http://www.flexer.info/?p=666</guid>
		<description><![CDATA[This weekend I&#8217;ve been programming a new tree component that is intended to be used as a hierarchical menu. One thing that I have to do was to change the default behavior of the disclosureIcon. If you wonder what is the disclosureIcon, it is the grey arrow that shows if there is a node or [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-right: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.flexer.info%2F2009%2F04%2F21%2Fhow-to-change-the-default-behavior-of-disclosureicon-of-a-tree-component%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.flexer.info%2F2009%2F04%2F21%2Fhow-to-change-the-default-behavior-of-disclosureicon-of-a-tree-component%2F" height="61" width="51" /></a></div><div style="float: right; margin-right: 10px"><a class="google_buzz"  
href="http://www.google.com/reader/link?url=http://www.flexer.info/2009/04/21/how-to-change-the-default-behavior-of-disclosureicon-of-a-tree-component/&title=How+To+Change+The+Default+Behavior+of+DisclosureIcon+of+a+Tree+Component&srcURL=http://www.flexer.info" target="_blank" rel="nofollow"><img
src="http://www.flexer.info/wp-content/plugins/google-buzz-button-for-wordpress/images/google-buzz.png" alt="Google Buzz" /></a></div><p>This weekend I&#8217;ve been programming a new tree component that is intended to be used as a hierarchical menu. One thing that I have to do was to change the default behavior of the <strong>disclosureIcon</strong>. If you wonder what is the <strong>disclosureIcon</strong>, it is the grey arrow that shows if there is a node or a leaf and if that node is opened or not. That is the <strong>disclosureIcon</strong> and it has its own behavior different than the item itself.</p>
<p>I needed to implement the same behavior of a regular item but to do this I had to stop the default behavior. So I created a new item renderer based the default <strong>TreeItemRenderer</strong> in which we will try to modify this behavior.</p>
<p>First I started to study the <strong>TreeItemRenderer</strong>, to see what it implements what can be changed or overridden, etc. <strong>disclosureItem</strong> is a protected object so it can be used in our new tree item renderer that extends <strong>TreeItemRenderer</strong>. </p>
<p>So a logical approach was to remove the event listener of the <strong>disclosureIcon</strong>. Well that is not possible because the function bind to the event is private so we cannot do:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;">disclosureIcon.<span style="color: #006600;">removeEventListener</span><span style="color: #66cc66;">&#40;</span>MouseEvent.<span style="color: #006600;">MOUSE_DOWN</span>, disclosureMouseDownHandler<span style="color: #66cc66;">&#41;</span>;</pre></div></div>

<p>The method <strong>disclosureMouseDownHandler</strong> is private so cannot be accessed.</p>
<p>Digging further into the code I discovered that the <strong>disclosureMouseDownHandler</strong> method just sets some variables and then dispatches a <strong>TreeEvent.ITEM_OPENING</strong> type of event.</p>
<p>With this in my mind and because I didn&#8217;t need the <strong>TreeEvent.ITEM_OPENING</strong> event I just removed the event in the <strong>init</strong> method of my tree component like this:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>15
</pre></td><td class="code"><pre class="actionscript" style="font-family:monospace;">removeEventListener<span style="color: #66cc66;">&#40;</span>TreeEvent.<span style="color: #006600;">ITEM_OPENING</span>, mx_internal::expandItemHandler<span style="color: #66cc66;">&#41;</span>;</pre></td></tr></table></div>

<p>Please notice that the <strong>expandItemHandler</strong> is using <strong>mx_internal</strong> name space so we had to use that name space to be able to access the method.</p>
<p>Now having this removed I started to implement my needed event behavior. For this article I&#8217;ll implement another behavior to be more easily understood &#8211; just an alert pop-up containing the label of the clicked node.</p>
<p>You need to understand that by doing this there is no other default alternative to open the nodes. You may wonder you did I replaced the default behavior of the <strong>disclosureIcon</strong>? Well I needed to have the following behavior of my custom tree:</p>
<ol>
<li>click on a closed item will select it and open it if it has children</li>
<li>click on a opened item will select it and close it if it has children</li>
<li>click on a closed item having already an opened node will close the previous node, then select the one clicked on and will open it</li>
</ol>
<p>This should happen either if we click on the text or on the <strong>disclosureIcon</strong>. But this is not what we will do here only a short explanation regarding why I removed the default <strong>disclosureIcon</strong>&#8217;s behavior.</p>
<p>Bellow is our example. Click on an arrow to see the result &#8211; a simple alert with the name (label) of the clicked node.</p>

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_disclosureiconbehaviorchangeapp_341549469"
			class="flashmovie"
			width="350"
			height="250">
	<param name="movie" value="wp-content/uploads/2009/04/disclosureiconbehaviorchangeapp.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="wp-content/uploads/2009/04/disclosureiconbehaviorchangeapp.swf"
			name="fm_disclosureiconbehaviorchangeapp_341549469"
			width="350"
			height="250">
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
<p>In the following example we used four files (source files are bellow and also downloadable at the end of the article):</p>
<ol>
<li>main application &#8211; <strong>DisclosureIconBehaviorChangeApp.mxml</strong></li>
<li>our tree component &#8211; <strong>CustomTree.mxml</strong></li>
<li>our custom tree item renderer &#8211; <strong>CustomTreeItemRenderer.as</strong></li>
<li>our custom tree event &#8211; <strong>CustomTreeEvent.as</strong></li>
</ol>
<h3>1) DisclosureIconBehaviorChangeApp</h3>
<p>&nbsp;</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
</pre></td><td class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #66cc66;">&lt;</span>?<span style="color: #0066CC;">xml</span> <span style="color: #0066CC;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> encoding=<span style="color: #ff0000;">&quot;utf-8&quot;</span>?<span style="color: #66cc66;">&gt;</span>
<span style="color: #66cc66;">&lt;</span>mx:Application xmlns:mx=<span style="color: #ff0000;">&quot;http://www.adobe.com/2006/mxml&quot;</span> 
    layout=<span style="color: #ff0000;">&quot;absolute&quot;</span> xmlns:flexer=<span style="color: #ff0000;">&quot;com.flexer.*&quot;</span>
    creationComplete=<span style="color: #ff0000;">&quot;start()&quot;</span>
    <span style="color: #66cc66;">&gt;</span>
    <span style="color: #66cc66;">&lt;</span>flexer:CustomTree id=<span style="color: #ff0000;">&quot;myTree&quot;</span>
        x=<span style="color: #ff0000;">&quot;10&quot;</span> y=<span style="color: #ff0000;">&quot;10&quot;</span>
        <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">&quot;200&quot;</span> <span style="color: #0066CC;">height</span>=<span style="color: #ff0000;">&quot;200&quot;</span>
        labelField=<span style="color: #ff0000;">&quot;@label&quot;</span>
        <span style="color: #66cc66;">/&gt;</span>
    <span style="color: #66cc66;">&lt;</span>mx:Script<span style="color: #66cc66;">&gt;</span>
        <span style="color: #66cc66;">&lt;!</span><span style="color: #66cc66;">&#91;</span>CDATA<span style="color: #66cc66;">&#91;</span>
&nbsp;
            <span style="color: #808080; font-style: italic;">// item tree structure</span>
            <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _menuTreeContent:<span style="color: #0066CC;">XML</span> = <span style="color: #66cc66;">&lt;</span>mlb<span style="color: #66cc66;">&gt;</span>
    <span style="color: #66cc66;">&lt;</span>league label=<span style="color: #ff0000;">&quot;American League&quot;</span><span style="color: #66cc66;">&gt;</span>
        <span style="color: #66cc66;">&lt;</span>division label=<span style="color: #ff0000;">&quot;East&quot;</span><span style="color: #66cc66;">&gt;</span>
            <span style="color: #66cc66;">&lt;</span>team label=<span style="color: #ff0000;">&quot;Boston&quot;</span> <span style="color: #66cc66;">/&gt;</span>
            <span style="color: #66cc66;">&lt;</span>team label=<span style="color: #ff0000;">&quot;New York&quot;</span> <span style="color: #66cc66;">/&gt;</span>
            <span style="color: #66cc66;">&lt;</span>team label=<span style="color: #ff0000;">&quot;Toronto&quot;</span> <span style="color: #66cc66;">/&gt;</span>
            <span style="color: #66cc66;">&lt;</span>team label=<span style="color: #ff0000;">&quot;Baltimore&quot;</span> <span style="color: #66cc66;">/&gt;</span>
            <span style="color: #66cc66;">&lt;</span>team label=<span style="color: #ff0000;">&quot;Tampa Bay&quot;</span> <span style="color: #66cc66;">/&gt;</span>
        <span style="color: #66cc66;">&lt;/</span>division<span style="color: #66cc66;">&gt;</span>
        <span style="color: #66cc66;">&lt;</span>division label=<span style="color: #ff0000;">&quot;Central&quot;</span><span style="color: #66cc66;">&gt;</span>
            <span style="color: #66cc66;">&lt;</span>team label=<span style="color: #ff0000;">&quot;Cleveland&quot;</span> <span style="color: #66cc66;">/&gt;</span>
            <span style="color: #66cc66;">&lt;</span>team label=<span style="color: #ff0000;">&quot;Detroit&quot;</span> <span style="color: #66cc66;">/&gt;</span>
            <span style="color: #66cc66;">&lt;</span>team label=<span style="color: #ff0000;">&quot;Minnesota&quot;</span> <span style="color: #66cc66;">/&gt;</span>
            <span style="color: #66cc66;">&lt;</span>team label=<span style="color: #ff0000;">&quot;Chicago&quot;</span> <span style="color: #66cc66;">/&gt;</span>
            <span style="color: #66cc66;">&lt;</span>team label=<span style="color: #ff0000;">&quot;Kansas City&quot;</span> <span style="color: #66cc66;">/&gt;</span>
        <span style="color: #66cc66;">&lt;/</span>division<span style="color: #66cc66;">&gt;</span>
        <span style="color: #66cc66;">&lt;</span>division label=<span style="color: #ff0000;">&quot;West&quot;</span><span style="color: #66cc66;">&gt;</span>
            <span style="color: #66cc66;">&lt;</span>team label=<span style="color: #ff0000;">&quot;Los Angeles&quot;</span> <span style="color: #66cc66;">/&gt;</span>
            <span style="color: #66cc66;">&lt;</span>team label=<span style="color: #ff0000;">&quot;Seattle&quot;</span> <span style="color: #66cc66;">/&gt;</span>
            <span style="color: #66cc66;">&lt;</span>team label=<span style="color: #ff0000;">&quot;Oakland&quot;</span> <span style="color: #66cc66;">/&gt;</span>
            <span style="color: #66cc66;">&lt;</span>team label=<span style="color: #ff0000;">&quot;Texas&quot;</span> <span style="color: #66cc66;">/&gt;</span>
        <span style="color: #66cc66;">&lt;/</span>division<span style="color: #66cc66;">&gt;</span>
    <span style="color: #66cc66;">&lt;/</span>league<span style="color: #66cc66;">&gt;</span>
<span style="color: #66cc66;">&lt;/</span>mlb<span style="color: #66cc66;">&gt;</span>;
&nbsp;
            <span style="color: #808080; font-style: italic;">// initialization</span>
            <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">start</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
            <span style="color: #66cc66;">&#123;</span>
                <span style="color: #808080; font-style: italic;">// setting the data provider</span>
                myTree.<span style="color: #006600;">dataProvider</span> = _menuTreeContent.<span style="color: #006600;">league</span>;
                <span style="color: #808080; font-style: italic;">// expanding the some nodes</span>
                callLater<span style="color: #66cc66;">&#40;</span>
                    <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #66cc66;">&#40;</span>node:<span style="color: #0066CC;">XML</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span>
                        myTree.<span style="color: #006600;">expandItem</span><span style="color: #66cc66;">&#40;</span>node.<span style="color: #006600;">league</span><span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#93;</span>, <span style="color: #000000; font-weight: bold;">true</span><span style="color: #66cc66;">&#41;</span>;
                        myTree.<span style="color: #006600;">expandItem</span><span style="color: #66cc66;">&#40;</span>node.<span style="color: #006600;">league</span><span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#93;</span>.<span style="color: #006600;">division</span><span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span>, <span style="color: #000000; font-weight: bold;">true</span><span style="color: #66cc66;">&#41;</span>;
                    <span style="color: #66cc66;">&#125;</span>,
                    <span style="color: #66cc66;">&#91;</span>_menuTreeContent<span style="color: #66cc66;">&#93;</span>
                <span style="color: #66cc66;">&#41;</span>;
            <span style="color: #66cc66;">&#125;</span>
        <span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&gt;</span>
    <span style="color: #66cc66;">&lt;/</span>mx:Script<span style="color: #66cc66;">&gt;</span>
<span style="color: #66cc66;">&lt;/</span>mx:Application<span style="color: #66cc66;">&gt;</span></pre></td></tr></table></div>

<h3>2) CustomTree</h3>
<p>&nbsp;</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>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
</pre></td><td class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #66cc66;">&lt;</span>?<span style="color: #0066CC;">xml</span> <span style="color: #0066CC;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> encoding=<span style="color: #ff0000;">&quot;utf-8&quot;</span>?<span style="color: #66cc66;">&gt;</span>
<span style="color: #66cc66;">&lt;</span>mx:Tree xmlns:mx=<span style="color: #ff0000;">&quot;http://www.adobe.com/2006/mxml&quot;</span>
    initialize=<span style="color: #ff0000;">&quot;init()&quot;</span>
    itemRenderer=<span style="color: #ff0000;">&quot;com.flexer.CustomTreeItemRenderer&quot;</span>
    <span style="color: #66cc66;">&gt;</span>
    <span style="color: #66cc66;">&lt;</span>mx:Script<span style="color: #66cc66;">&gt;</span>
        <span style="color: #66cc66;">&lt;!</span><span style="color: #66cc66;">&#91;</span>CDATA<span style="color: #66cc66;">&#91;</span>
            <span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">controls</span>.<span style="color: #006600;">Alert</span>;
            <span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">events</span>.<span style="color: #006600;">TreeEvent</span>;
&nbsp;
            <span style="color: #808080; font-style: italic;">// initialization</span>
            <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> init<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
            <span style="color: #66cc66;">&#123;</span>
                <span style="color: #808080; font-style: italic;">// removing the default event on opeining nodes</span>
                removeEventListener<span style="color: #66cc66;">&#40;</span>TreeEvent.<span style="color: #006600;">ITEM_OPENING</span>, 
                    mx_internal::expandItemHandler<span style="color: #66cc66;">&#41;</span>;
                <span style="color: #808080; font-style: italic;">// listening for our custom event</span>
                addEventListener<span style="color: #66cc66;">&#40;</span>CustomTreeEvent.<span style="color: #006600;">ITEM_SELECTED</span>, 
                    handleItemSelected<span style="color: #66cc66;">&#41;</span>;
            <span style="color: #66cc66;">&#125;</span>
&nbsp;
            <span style="color: #808080; font-style: italic;">// handler for our new custom tree event </span>
            <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> handleItemSelected<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>:CustomTreeEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
            <span style="color: #66cc66;">&#123;</span>
                Alert.<span style="color: #0066CC;">show</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>.<span style="color: #0066CC;">data</span>.<span style="color: #66cc66;">@</span>label.<span style="color: #0066CC;">toString</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
            <span style="color: #66cc66;">&#125;</span>
&nbsp;
&nbsp;
        <span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&gt;</span>
    <span style="color: #66cc66;">&lt;/</span>mx:Script<span style="color: #66cc66;">&gt;</span>
<span style="color: #66cc66;">&lt;/</span>mx:Tree<span style="color: #66cc66;">&gt;</span></pre></td></tr></table></div>

<h3>3) CustomTreeItemRenderer</h3>
<p>&nbsp;</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>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
33
</pre></td><td class="code"><pre class="actionscript" style="font-family:monospace;">package com.<span style="color: #006600;">flexer</span> 
<span style="color: #66cc66;">&#123;</span>
&nbsp;
    <span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">events</span>.<span style="color: #006600;">MouseEvent</span>;
&nbsp;
    <span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">collections</span>.<span style="color: #66cc66;">*</span>;
    <span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">controls</span>.<span style="color: #006600;">Tree</span>;
    <span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">controls</span>.<span style="color: #006600;">treeClasses</span>.<span style="color: #66cc66;">*</span>;
&nbsp;
    <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> CustomTreeItemRenderer <span style="color: #0066CC;">extends</span> TreeItemRenderer
    <span style="color: #66cc66;">&#123;</span>
&nbsp;
        <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> CustomTreeItemRenderer<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> 
        <span style="color: #66cc66;">&#123;</span>
            <span style="color: #0066CC;">super</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
        <span style="color: #66cc66;">&#125;</span>
&nbsp;
        override protected <span style="color: #000000; font-weight: bold;">function</span> commitProperties<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
        <span style="color: #66cc66;">&#123;</span>
            <span style="color: #0066CC;">super</span>.<span style="color: #006600;">commitProperties</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
            disclosureIcon.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>MouseEvent.<span style="color: #006600;">MOUSE_DOWN</span>, 
                arrowMouseDownHandler<span style="color: #66cc66;">&#41;</span>;
        <span style="color: #66cc66;">&#125;</span>
&nbsp;
        <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> arrowMouseDownHandler<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>:MouseEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
        <span style="color: #66cc66;">&#123;</span>
            <span style="color: #000000; font-weight: bold;">var</span> stEvent:CustomTreeEvent = <span style="color: #000000; font-weight: bold;">new</span> CustomTreeEvent<span style="color: #66cc66;">&#40;</span>
                CustomTreeEvent.<span style="color: #006600;">ITEM_SELECTED</span>, <span style="color: #0066CC;">this</span>.<span style="color: #0066CC;">data</span><span style="color: #66cc66;">&#41;</span>;
            <span style="color: #66cc66;">&#40;</span>listData.<span style="color: #006600;">owner</span> as Tree<span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">dispatchEvent</span><span style="color: #66cc66;">&#40;</span>stEvent<span style="color: #66cc66;">&#41;</span>;
        <span style="color: #66cc66;">&#125;</span>
&nbsp;
    <span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></td></tr></table></div>

<h3>4) CustomTreeEvent</h3>
<p>&nbsp;</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>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
</pre></td><td class="code"><pre class="actionscript" style="font-family:monospace;">package com.<span style="color: #006600;">flexer</span>
<span style="color: #66cc66;">&#123;</span>
    <span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">events</span>.<span style="color: #006600;">Event</span>;
&nbsp;
    <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> CustomTreeEvent <span style="color: #0066CC;">extends</span> Event
    <span style="color: #66cc66;">&#123;</span>
&nbsp;
        <span style="color: #0066CC;">public</span> <span style="color: #0066CC;">static</span> const ITEM_SELECTED:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">&quot;itemSelected&quot;</span>;
&nbsp;
        <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _obj:<span style="color: #66cc66;">*</span>;
&nbsp;
        <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> CustomTreeEvent<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">type</span>:<span style="color: #0066CC;">String</span>, item:<span style="color: #66cc66;">*</span>, 
            bubbles:<span style="color: #0066CC;">Boolean</span> = <span style="color: #000000; font-weight: bold;">false</span>, cancelable:<span style="color: #0066CC;">Boolean</span> = <span style="color: #000000; font-weight: bold;">false</span><span style="color: #66cc66;">&#41;</span>
        <span style="color: #66cc66;">&#123;</span>
            <span style="color: #0066CC;">super</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">type</span>, bubbles, cancelable<span style="color: #66cc66;">&#41;</span>;
&nbsp;
            _obj = item;
        <span style="color: #66cc66;">&#125;</span>
&nbsp;
        override <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> clone<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:Event
        <span style="color: #66cc66;">&#123;</span>
            <span style="color: #b1b100;">return</span> <span style="color: #000000; font-weight: bold;">new</span> CustomTreeEvent<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">type</span>, _obj, bubbles, cancelable<span style="color: #66cc66;">&#41;</span>;
        <span style="color: #66cc66;">&#125;</span>
&nbsp;
        <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">get</span> <span style="color: #0066CC;">data</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #66cc66;">*</span>
        <span style="color: #66cc66;">&#123;</span>
            <span style="color: #b1b100;">return</span> _obj;
        <span style="color: #66cc66;">&#125;</span>
&nbsp;
    <span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.flexer.info/2009/04/21/how-to-change-the-default-behavior-of-disclosureicon-of-a-tree-component/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How To Find On Which Divider of a HDividerBox a Double Click Event Occured</title>
		<link>http://www.flexer.info/2008/10/08/how-to-find-on-which-divider-of-a-hdividerbox-a-double-click-event-occured/</link>
		<comments>http://www.flexer.info/2008/10/08/how-to-find-on-which-divider-of-a-hdividerbox-a-double-click-event-occured/#comments</comments>
		<pubDate>Wed, 08 Oct 2008 14:53:30 +0000</pubDate>
		<dc:creator>Andrei Ionescu</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Events]]></category>
		<category><![CDATA[How to]]></category>
		<category><![CDATA[MXML]]></category>
		<category><![CDATA[click]]></category>
		<category><![CDATA[event]]></category>

		<guid isPermaLink="false">http://www.flexer.info/?p=265</guid>
		<description><![CDATA[This was a tricky issue&#8230; but solvable. I needed to found a way to collapse the left panel of a HDividedBox. This can be easily done by using moveDividerTo() method or setting getDividerAt().x (for vertical getDividerAt().y) property to the desired value. The problem is this: if you want to collapse the left at double click [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-right: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.flexer.info%2F2008%2F10%2F08%2Fhow-to-find-on-which-divider-of-a-hdividerbox-a-double-click-event-occured%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.flexer.info%2F2008%2F10%2F08%2Fhow-to-find-on-which-divider-of-a-hdividerbox-a-double-click-event-occured%2F" height="61" width="51" /></a></div><div style="float: right; margin-right: 10px"><a class="google_buzz"  
href="http://www.google.com/reader/link?url=http://www.flexer.info/2008/10/08/how-to-find-on-which-divider-of-a-hdividerbox-a-double-click-event-occured/&title=How+To+Find+On+Which+Divider+of+a+HDividerBox+a+Double+Click+Event+Occured&srcURL=http://www.flexer.info" target="_blank" rel="nofollow"><img
src="http://www.flexer.info/wp-content/plugins/google-buzz-button-for-wordpress/images/google-buzz.png" alt="Google Buzz" /></a></div><p>This was a tricky issue&#8230; but solvable. I needed to found a way to collapse the left panel of a <strong>HDividedBox</strong>. This can be easily done by using <strong>moveDividerTo()</strong> method or setting <strong>getDividerAt().x</strong> (for vertical <strong>getDividerAt().y</strong>) property to the desired value. The problem is this: if you want to collapse the left at double click on the divider you cannot easily know on which divider the event occurred. This is because: the the double click event on the <strong>HDividedBox</strong> is triggered everywhere on the object and the <strong>currentTarget</strong> property of the event is always the <strong>HDividedBox</strong> object, and the <strong>target</strong> property of the event object returns two different things when clicking on the divider. If the double click is on the handle the <strong>target</strong> property is a skin, if it is upper or bellow the target is the <strong>BoxDivider</strong> object.</p>
<p>The whole process to find the divider on which the double click event occurred, is in <strong>handleDoubleClick()</strong> method. It should not rise any problems to you. The process is like this:</p>
<ol>
<li>find if the double click is on the divider (on the handle or not) using <strong>e.target.name</strong></li>
<li>if the <strong>e.target</strong> is skin we take its parent (which is <strong>BoxDivider</strong> object) otherwise we take it as it is (which is also <strong>BoxDivider</strong> object)</li>
<li>we iterate through all dividers of the <strong>HDividedBox</strong> (using <strong>numDividers</strong> property) and we compare the names to see which one is</li>
</ol>
<p>Now here is the application&#8230; You can collapse the left panel by double clicking on the left divider, move dividers to the desired position by setting a position in the inputs and follow everything in a debug text area.<br />

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_panel_dividers_1614464644"
			class="flashmovie"
			width="600"
			height="588">
	<param name="movie" value="/wp-content/uploads/2008/10/panel_dividers.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="/wp-content/uploads/2008/10/panel_dividers.swf"
			name="fm_panel_dividers_1614464644"
			width="600"
			height="588">
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object><br />
Please notice that even though we set the left divider position to 0 at double click it is 2. So, the divider will never reach 0 (zero) probably because in <strong>HDividedBox</strong>, in between the children is a gap/padding.</p>
<p>The code is well commented and easily to follow.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
</pre></td><td class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #66cc66;">&lt;</span>?<span style="color: #0066CC;">xml</span> <span style="color: #0066CC;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> encoding=<span style="color: #ff0000;">&quot;utf-8&quot;</span>?<span style="color: #66cc66;">&gt;</span>
<span style="color: #66cc66;">&lt;</span>mx:Application xmlns:mx=<span style="color: #ff0000;">&quot;http://www.adobe.com/2006/mxml&quot;</span> 
    layout=<span style="color: #ff0000;">&quot;absolute&quot;</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">&quot;600&quot;</span> <span style="color: #0066CC;">height</span>=<span style="color: #ff0000;">&quot;588&quot;</span>
    applicationComplete=<span style="color: #ff0000;">&quot;start()&quot;</span><span style="color: #66cc66;">&gt;</span>
    <span style="color: #66cc66;">&lt;</span>mx:HDividedBox 
        id=<span style="color: #ff0000;">&quot;divBox&quot;</span>
        x=<span style="color: #ff0000;">&quot;10&quot;</span> y=<span style="color: #ff0000;">&quot;10&quot;</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">&quot;580&quot;</span> <span style="color: #0066CC;">height</span>=<span style="color: #ff0000;">&quot;380&quot;</span>
        liveDragging=<span style="color: #ff0000;">&quot;true&quot;</span>
        doubleClickEnabled=<span style="color: #ff0000;">&quot;true&quot;</span>
        doubleClick=<span style="color: #ff0000;">&quot;handleDoubleClick(event)&quot;</span><span style="color: #66cc66;">&gt;</span>
        <span style="color: #66cc66;">&lt;</span>mx:Panel title=<span style="color: #ff0000;">&quot;Panel 1&quot;</span> <span style="color: #0066CC;">height</span>=<span style="color: #ff0000;">&quot;100%&quot;</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">&quot;200&quot;</span><span style="color: #66cc66;">&gt;</span>
            <span style="color: #66cc66;">&lt;</span>mx:Canvas id=<span style="color: #ff0000;">&quot;cnv1&quot;</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">&quot;100%&quot;</span> <span style="color: #0066CC;">height</span>=<span style="color: #ff0000;">&quot;100%&quot;</span><span style="color: #66cc66;">&gt;</span>
            <span style="color: #66cc66;">&lt;/</span>mx:Canvas<span style="color: #66cc66;">&gt;</span>
        <span style="color: #66cc66;">&lt;/</span>mx:Panel<span style="color: #66cc66;">&gt;</span>
        <span style="color: #66cc66;">&lt;</span>mx:Panel title=<span style="color: #ff0000;">&quot;Panel 2&quot;</span> <span style="color: #0066CC;">height</span>=<span style="color: #ff0000;">&quot;100%&quot;</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">&quot;100%&quot;</span><span style="color: #66cc66;">&gt;</span>
            <span style="color: #66cc66;">&lt;</span>mx:Canvas id=<span style="color: #ff0000;">&quot;cnv2&quot;</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">&quot;100%&quot;</span> <span style="color: #0066CC;">height</span>=<span style="color: #ff0000;">&quot;100%&quot;</span><span style="color: #66cc66;">&gt;</span>
            <span style="color: #66cc66;">&lt;/</span>mx:Canvas<span style="color: #66cc66;">&gt;</span>
        <span style="color: #66cc66;">&lt;/</span>mx:Panel<span style="color: #66cc66;">&gt;</span>
        <span style="color: #66cc66;">&lt;</span>mx:Panel title=<span style="color: #ff0000;">&quot;Panel 3&quot;</span> <span style="color: #0066CC;">height</span>=<span style="color: #ff0000;">&quot;100%&quot;</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">&quot;250&quot;</span><span style="color: #66cc66;">&gt;</span>
            <span style="color: #66cc66;">&lt;</span>mx:Canvas id=<span style="color: #ff0000;">&quot;cnv3&quot;</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">&quot;100%&quot;</span> <span style="color: #0066CC;">height</span>=<span style="color: #ff0000;">&quot;100%&quot;</span><span style="color: #66cc66;">&gt;</span>
            <span style="color: #66cc66;">&lt;/</span>mx:Canvas<span style="color: #66cc66;">&gt;</span>
        <span style="color: #66cc66;">&lt;/</span>mx:Panel<span style="color: #66cc66;">&gt;</span>
    <span style="color: #66cc66;">&lt;/</span>mx:HDividedBox<span style="color: #66cc66;">&gt;</span>
    <span style="color: #66cc66;">&lt;</span>mx:Label x=<span style="color: #ff0000;">&quot;10&quot;</span> y=<span style="color: #ff0000;">&quot;398&quot;</span> <span style="color: #0066CC;">text</span>=<span style="color: #ff0000;">&quot;First Divider&quot;</span><span style="color: #66cc66;">/&gt;</span>
    <span style="color: #66cc66;">&lt;</span>mx:TextInput x=<span style="color: #ff0000;">&quot;10&quot;</span> y=<span style="color: #ff0000;">&quot;422&quot;</span> id=<span style="color: #ff0000;">&quot;div1&quot;</span><span style="color: #66cc66;">/&gt;</span>
    <span style="color: #66cc66;">&lt;</span>mx:Label x=<span style="color: #ff0000;">&quot;231&quot;</span> y=<span style="color: #ff0000;">&quot;398&quot;</span> <span style="color: #0066CC;">text</span>=<span style="color: #ff0000;">&quot;Second Divider&quot;</span><span style="color: #66cc66;">/&gt;</span>
    <span style="color: #66cc66;">&lt;</span>mx:TextInput x=<span style="color: #ff0000;">&quot;231&quot;</span> y=<span style="color: #ff0000;">&quot;422&quot;</span> id=<span style="color: #ff0000;">&quot;div2&quot;</span><span style="color: #66cc66;">/&gt;</span>
    <span style="color: #66cc66;">&lt;</span>mx:<span style="color: #0066CC;">Button</span> x=<span style="color: #ff0000;">&quot;178&quot;</span> y=<span style="color: #ff0000;">&quot;422&quot;</span> label=<span style="color: #ff0000;">&quot;Set&quot;</span> 
        click=<span style="color: #ff0000;">&quot;handleSetDiv1(event)&quot;</span><span style="color: #66cc66;">/&gt;</span>
    <span style="color: #66cc66;">&lt;</span>mx:<span style="color: #0066CC;">Button</span> x=<span style="color: #ff0000;">&quot;399&quot;</span> y=<span style="color: #ff0000;">&quot;422&quot;</span> label=<span style="color: #ff0000;">&quot;Set&quot;</span> 
        click=<span style="color: #ff0000;">&quot;handleSetDiv2(event)&quot;</span><span style="color: #66cc66;">/&gt;</span>
    <span style="color: #66cc66;">&lt;</span>mx:Label x=<span style="color: #ff0000;">&quot;10&quot;</span> y=<span style="color: #ff0000;">&quot;452&quot;</span> <span style="color: #0066CC;">text</span>=<span style="color: #ff0000;">&quot;Debug&quot;</span><span style="color: #66cc66;">/&gt;</span>
    <span style="color: #66cc66;">&lt;</span>mx:TextArea id=<span style="color: #ff0000;">&quot;debug&quot;</span> x=<span style="color: #ff0000;">&quot;10&quot;</span> y=<span style="color: #ff0000;">&quot;478&quot;</span> 
        <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">&quot;580&quot;</span> <span style="color: #0066CC;">height</span>=<span style="color: #ff0000;">&quot;100&quot;</span><span style="color: #66cc66;">/&gt;</span>
    <span style="color: #66cc66;">&lt;</span>mx:Script<span style="color: #66cc66;">&gt;</span>
        <span style="color: #66cc66;">&lt;!</span><span style="color: #66cc66;">&#91;</span>CDATA<span style="color: #66cc66;">&#91;</span>
            <span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">controls</span>.<span style="color: #006600;">Alert</span>;
&nbsp;
            <span style="color: #808080; font-style: italic;">// variables making possible pannel colapse</span>
            <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _previousDivierPos:<span style="color: #0066CC;">Array</span>;
            <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _isClosed:<span style="color: #0066CC;">Array</span>;
&nbsp;
            <span style="color: #808080; font-style: italic;">// initialization</span>
            <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">start</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
            <span style="color: #66cc66;">&#123;</span>
                _previousDivierPos = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">Array</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
                _isClosed = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">Array</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
                <span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">var</span> i:<span style="color: #0066CC;">int</span> = <span style="color: #cc66cc;">0</span>; i <span style="color: #66cc66;">&lt;</span> divBox.<span style="color: #006600;">numDividers</span>; i++<span style="color: #66cc66;">&#41;</span>
                <span style="color: #66cc66;">&#123;</span>
                    _isClosed<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span> = <span style="color: #000000; font-weight: bold;">false</span>;
                <span style="color: #66cc66;">&#125;</span>
            <span style="color: #66cc66;">&#125;</span>
&nbsp;
            <span style="color: #808080; font-style: italic;">// handle for first set button</span>
            <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> handleSetDiv1<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>:MouseEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
            <span style="color: #66cc66;">&#123;</span>
                <span style="color: #808080; font-style: italic;">// set first divider at specified position</span>
                divBox.<span style="color: #006600;">getDividerAt</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">x</span> = <span style="color: #0066CC;">Number</span><span style="color: #66cc66;">&#40;</span>div1.<span style="color: #0066CC;">text</span><span style="color: #66cc66;">&#41;</span>;
                debug.<span style="color: #0066CC;">text</span> += <span style="color: #ff0000;">&quot;divider 0: &quot;</span> + divBox.<span style="color: #006600;">getDividerAt</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">x</span> + <span style="color: #ff0000;">&quot;px<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>;
            <span style="color: #66cc66;">&#125;</span>
&nbsp;
            <span style="color: #808080; font-style: italic;">// handle for second set button</span>
            <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> handleSetDiv2<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>:MouseEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
            <span style="color: #66cc66;">&#123;</span>
                <span style="color: #808080; font-style: italic;">// set second divider at specified position</span>
                divBox.<span style="color: #006600;">getDividerAt</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">x</span> = <span style="color: #0066CC;">Number</span><span style="color: #66cc66;">&#40;</span>div2.<span style="color: #0066CC;">text</span><span style="color: #66cc66;">&#41;</span>;
                debug.<span style="color: #0066CC;">text</span> += <span style="color: #ff0000;">&quot;divider 1: &quot;</span> + divBox.<span style="color: #006600;">getDividerAt</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">x</span> + <span style="color: #ff0000;">&quot;px<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>;
            <span style="color: #66cc66;">&#125;</span>
&nbsp;
            <span style="color: #808080; font-style: italic;">// Handler for double click event</span>
            <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> handleDoubleClick<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>:MouseEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
            <span style="color: #66cc66;">&#123;</span>
                <span style="color: #808080; font-style: italic;">// get the name of the current target</span>
                <span style="color: #000000; font-weight: bold;">var</span> theName:<span style="color: #0066CC;">String</span> = <span style="color: #0066CC;">e</span>.<span style="color: #0066CC;">target</span>.<span style="color: #0066CC;">name</span>.<span style="color: #0066CC;">toString</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
                <span style="color: #808080; font-style: italic;">// search for &quot;boxdivider&quot; string in the name</span>
                <span style="color: #000000; font-weight: bold;">var</span> found:<span style="color: #0066CC;">int</span> = theName.<span style="color: #006600;">search</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> RegExp<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;boxdivider&quot;</span>,<span style="color: #ff0000;">&quot;i&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
                <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>found <span style="color: #66cc66;">&gt;</span> -<span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span>
                <span style="color: #66cc66;">&#123;</span>
                    <span style="color: #808080; font-style: italic;">// if &quot;boxdivider&quot; found we double clicked </span>
                    <span style="color: #808080; font-style: italic;">// on a divider</span>
                    <span style="color: #000000; font-weight: bold;">var</span> theDividerObject:<span style="color: #0066CC;">Object</span> = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">Object</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
                    <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>.<span style="color: #0066CC;">target</span>.<span style="color: #006600;">hasOwnProperty</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;className&quot;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&amp;&amp;</span> 
                        <span style="color: #0066CC;">e</span>.<span style="color: #0066CC;">target</span>.<span style="color: #006600;">className</span> == <span style="color: #ff0000;">&quot;BoxDivider&quot;</span><span style="color: #66cc66;">&#41;</span>
                        <span style="color: #808080; font-style: italic;">// if the event target is BoxDivider </span>
                        <span style="color: #808080; font-style: italic;">// object its className property </span>
                        <span style="color: #808080; font-style: italic;">// will be &quot;BoxDivider&quot;</span>
                        theDividerObject = <span style="color: #0066CC;">e</span>.<span style="color: #0066CC;">target</span>;
                    <span style="color: #b1b100;">else</span>
                        <span style="color: #808080; font-style: italic;">// otherwise is its skin so we will</span>
                        <span style="color: #808080; font-style: italic;">// use its parent</span>
                        theDividerObject = <span style="color: #0066CC;">e</span>.<span style="color: #0066CC;">target</span>.<span style="color: #006600;">parent</span>;
&nbsp;
                    <span style="color: #808080; font-style: italic;">// we iterate thourgh all dividers to find</span>
                    <span style="color: #808080; font-style: italic;">// its position    </span>
                    <span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">var</span> i:<span style="color: #0066CC;">int</span> = <span style="color: #cc66cc;">0</span>; i <span style="color: #66cc66;">&lt;</span> divBox.<span style="color: #006600;">numDividers</span>; i++<span style="color: #66cc66;">&#41;</span>
                    <span style="color: #66cc66;">&#123;</span>
                        <span style="color: #808080; font-style: italic;">// if names are the same we found our </span>
                        <span style="color: #808080; font-style: italic;">// BoxDivider object</span>
                        <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>theDividerObject.<span style="color: #0066CC;">name</span> == divBox.<span style="color: #006600;">getDividerAt</span><span style="color: #66cc66;">&#40;</span>i<span style="color: #66cc66;">&#41;</span>.<span style="color: #0066CC;">name</span><span style="color: #66cc66;">&#41;</span>
                        <span style="color: #66cc66;">&#123;</span>
                            <span style="color: #808080; font-style: italic;">// display its name and position</span>
                            debug.<span style="color: #0066CC;">text</span> += <span style="color: #ff0000;">&quot;divider &quot;</span> + i + <span style="color: #ff0000;">&quot;: &quot;</span> + 
                                divBox.<span style="color: #006600;">getDividerAt</span><span style="color: #66cc66;">&#40;</span>i<span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">x</span> + <span style="color: #ff0000;">&quot;px <span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>;
                            <span style="color: #808080; font-style: italic;">// we collapse it</span>
                            closePanel<span style="color: #66cc66;">&#40;</span>i<span style="color: #66cc66;">&#41;</span>;
                        <span style="color: #66cc66;">&#125;</span>
                    <span style="color: #66cc66;">&#125;</span>
                <span style="color: #66cc66;">&#125;</span>
            <span style="color: #66cc66;">&#125;</span>
&nbsp;
            <span style="color: #808080; font-style: italic;">// method to colapse the left panel</span>
            <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> closePanel<span style="color: #66cc66;">&#40;</span>divId:<span style="color: #0066CC;">int</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
            <span style="color: #66cc66;">&#123;</span>
&nbsp;
                <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">!</span>_isClosed<span style="color: #66cc66;">&#91;</span>divId<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>
                <span style="color: #66cc66;">&#123;</span>
                    <span style="color: #808080; font-style: italic;">// we close all previous dividers</span>
                    <span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">var</span> i:<span style="color: #0066CC;">int</span> = <span style="color: #cc66cc;">0</span>; i <span style="color: #66cc66;">&lt;</span>= divId; i++<span style="color: #66cc66;">&#41;</span>
                    <span style="color: #66cc66;">&#123;</span>
                        <span style="color: #808080; font-style: italic;">// if already closed no change required</span>
                        <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">!</span>_isClosed<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>
                        <span style="color: #66cc66;">&#123;</span>
                            <span style="color: #808080; font-style: italic;">// getting the current position</span>
                            <span style="color: #000000; font-weight: bold;">var</span> currentDividerPos:<span style="color: #0066CC;">int</span> = 
                                divBox.<span style="color: #006600;">getDividerAt</span><span style="color: #66cc66;">&#40;</span>i<span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">x</span>;
                            <span style="color: #808080; font-style: italic;">// if closed we open</span>
                            <span style="color: #808080; font-style: italic;">// save current position</span>
                            _previousDivierPos<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span> = currentDividerPos;
                            <span style="color: #808080; font-style: italic;">// move to zero position</span>
                            divBox.<span style="color: #006600;">getDividerAt</span><span style="color: #66cc66;">&#40;</span>i<span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">x</span> = <span style="color: #cc66cc;">0</span>;
                            <span style="color: #808080; font-style: italic;">// set close flag</span>
                            _isClosed<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span> = <span style="color: #000000; font-weight: bold;">true</span>;
                        <span style="color: #66cc66;">&#125;</span>
                    <span style="color: #66cc66;">&#125;</span>
                <span style="color: #66cc66;">&#125;</span>
                <span style="color: #b1b100;">else</span>
                <span style="color: #66cc66;">&#123;</span>
                    <span style="color: #808080; font-style: italic;">// othewrwise we close</span>
                    <span style="color: #808080; font-style: italic;">// move to previous saved value</span>
                    divBox.<span style="color: #006600;">getDividerAt</span><span style="color: #66cc66;">&#40;</span>divId<span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">x</span> = _previousDivierPos<span style="color: #66cc66;">&#91;</span>divId<span style="color: #66cc66;">&#93;</span>;
                    <span style="color: #808080; font-style: italic;">// set close flag</span>
                    _isClosed<span style="color: #66cc66;">&#91;</span>divId<span style="color: #66cc66;">&#93;</span> = <span style="color: #000000; font-weight: bold;">false</span>;
                <span style="color: #66cc66;">&#125;</span>
            <span style="color: #66cc66;">&#125;</span>
        <span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&gt;</span>
    <span style="color: #66cc66;">&lt;/</span>mx:Script<span style="color: #66cc66;">&gt;</span>
<span style="color: #66cc66;">&lt;/</span>mx:Application<span style="color: #66cc66;">&gt;</span></pre></td></tr></table></div>

<p>Hope this will get many of you out of the hassle finding the right divider. <img src='http://www.flexer.info/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.flexer.info/2008/10/08/how-to-find-on-which-divider-of-a-hdividerbox-a-double-click-event-occured/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Image Events Dispatch Order</title>
		<link>http://www.flexer.info/2008/09/12/image-events-dispatch-order/</link>
		<comments>http://www.flexer.info/2008/09/12/image-events-dispatch-order/#comments</comments>
		<pubDate>Fri, 12 Sep 2008 10:20:31 +0000</pubDate>
		<dc:creator>Andrei Ionescu</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Debug]]></category>
		<category><![CDATA[Events]]></category>
		<category><![CDATA[How to]]></category>
		<category><![CDATA[Testing]]></category>
		<category><![CDATA[image]]></category>
		<category><![CDATA[load]]></category>
		<category><![CDATA[MXML]]></category>

		<guid isPermaLink="false">http://www.flexer.info/?p=254</guid>
		<description><![CDATA[Yesterday I&#8217;ve been working with images: loading, resizing, removing, etc. I got into a challenging issue: I had to vertically position a label after an image resize &#8211; but a resize that is triggered by setting maxWidth and maxHeight keeping also the aspect ratio.
I tried to get the new width and height after the resize [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-right: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.flexer.info%2F2008%2F09%2F12%2Fimage-events-dispatch-order%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.flexer.info%2F2008%2F09%2F12%2Fimage-events-dispatch-order%2F" height="61" width="51" /></a></div><div style="float: right; margin-right: 10px"><a class="google_buzz"  
href="http://www.google.com/reader/link?url=http://www.flexer.info/2008/09/12/image-events-dispatch-order/&title=Image+Events+Dispatch+Order&srcURL=http://www.flexer.info" target="_blank" rel="nofollow"><img
src="http://www.flexer.info/wp-content/plugins/google-buzz-button-for-wordpress/images/google-buzz.png" alt="Google Buzz" /></a></div><p>Yesterday I&#8217;ve been working with images: loading, resizing, removing, etc. I got into a challenging issue: I had to vertically position a label after an image resize &#8211; but a resize that is triggered by setting <strong>maxWidth </strong>and <strong>maxHeight</strong> keeping also the aspect ratio.</p>
<p>I tried to get the new width and height after the resize event was triggered but no luck. I&#8217;ve been debugging a while and seen that the new width and the new height are in <strong>$height</strong> and <strong>$width</strong> internal variables. I had no luck getting the new width and the new height in this method triggered by the resize event.</p>
<p>So I started to investigate to see which event triggers the last that way making it sure all properties are updated. I created a simple application that will load an arbitrary image in mean time displaying the events triggered. There is also a button that moves the image horizontally by 50 pixels also showing the triggered events.<br />

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_imageeventstest_500958411"
			class="flashmovie"
			width="600"
			height="615">
	<param name="movie" value="/wp-content/uploads/2008/09/imageeventstest.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="/wp-content/uploads/2008/09/imageeventstest.swf"
			name="fm_imageeventstest_500958411"
			width="600"
			height="615">
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object><br />
I found that after resize event update complete event triggers which contains the needed width and height in <strong>contentWidth </strong>and <strong>contentHeight </strong>properties.</p>
<p>I hope this will help you in different scenarios you&#8217;ll encounter in development.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
</pre></td><td class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #66cc66;">&lt;</span>?<span style="color: #0066CC;">xml</span> <span style="color: #0066CC;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> encoding=<span style="color: #ff0000;">&quot;utf-8&quot;</span>?<span style="color: #66cc66;">&gt;</span>
<span style="color: #66cc66;">&lt;</span>mx:Application xmlns:mx=<span style="color: #ff0000;">&quot;http://www.adobe.com/2006/mxml&quot;</span> 
    layout=<span style="color: #ff0000;">&quot;absolute&quot;</span>
    applicationComplete=<span style="color: #ff0000;">&quot;start()&quot;</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">&quot;600&quot;</span> <span style="color: #0066CC;">height</span>=<span style="color: #ff0000;">&quot;615&quot;</span><span style="color: #66cc66;">&gt;</span>
    <span style="color: #66cc66;">&lt;</span>mx:TextInput id=<span style="color: #ff0000;">&quot;imageUrl&quot;</span> x=<span style="color: #ff0000;">&quot;10&quot;</span> y=<span style="color: #ff0000;">&quot;10&quot;</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">&quot;383&quot;</span> 
        <span style="color: #0066CC;">text</span>=<span style="color: #ff0000;">&quot;http://www.flexer.info/wp-content/gallery/wallpapers/fxr_1600x1200.png&quot;</span><span style="color: #66cc66;">/&gt;</span>
    <span style="color: #66cc66;">&lt;</span>mx:<span style="color: #0066CC;">Button</span> x=<span style="color: #ff0000;">&quot;401&quot;</span> y=<span style="color: #ff0000;">&quot;10&quot;</span>  label=<span style="color: #ff0000;">&quot;Start&quot;</span> 
        click=<span style="color: #ff0000;">&quot;handleButtonClick(event)&quot;</span><span style="color: #66cc66;">/&gt;</span>
    <span style="color: #66cc66;">&lt;</span>mx:<span style="color: #0066CC;">Button</span> x=<span style="color: #ff0000;">&quot;464&quot;</span> y=<span style="color: #ff0000;">&quot;10&quot;</span>  label=<span style="color: #ff0000;">&quot;Move it&quot;</span> 
        click=<span style="color: #ff0000;">&quot;handleMoveButtonClick(event)&quot;</span><span style="color: #66cc66;">/&gt;</span>
    <span style="color: #66cc66;">&lt;</span>mx:Image id=<span style="color: #ff0000;">&quot;testImage&quot;</span> maxWidth=<span style="color: #ff0000;">&quot;250&quot;</span> maxHeight=<span style="color: #ff0000;">&quot;250&quot;</span> 
        x=<span style="color: #ff0000;">&quot;10&quot;</span> y=<span style="color: #ff0000;">&quot;40&quot;</span>
        addedToStage=<span style="color: #ff0000;">&quot;handleAddedToStage(event)&quot;</span>
        complete=<span style="color: #ff0000;">&quot;handleComplete(event)&quot;</span>
        creationComplete=<span style="color: #ff0000;">&quot;handleCreationComplete(event)&quot;</span>
        currentStateChange=<span style="color: #ff0000;">&quot;handleCurrentStateChange(event)&quot;</span>
        init=<span style="color: #ff0000;">&quot;handleInit(event)&quot;</span>
        initialize=<span style="color: #ff0000;">&quot;handleInitialize(event)&quot;</span>
        open=<span style="color: #ff0000;">&quot;handleOpen(event)&quot;</span>
        preinitialize=<span style="color: #ff0000;">&quot;handlePreinitialize(event)&quot;</span>
        progress=<span style="color: #ff0000;">&quot;handleProgress(event)&quot;</span>
        removed=<span style="color: #ff0000;">&quot;handleRemoved(event)&quot;</span>
        render=<span style="color: #ff0000;">&quot;handleRender(event)&quot;</span>
        resize=<span style="color: #ff0000;">&quot;handleResize(event)&quot;</span>
        <span style="color: #0066CC;">show</span>=<span style="color: #ff0000;">&quot;handleShow(event)&quot;</span>
        unload=<span style="color: #ff0000;">&quot;handleUnload(event)&quot;</span>
        updateComplete=<span style="color: #ff0000;">&quot;handleUpdateComplete(event)&quot;</span>
        valid=<span style="color: #ff0000;">&quot;handleValid(event)&quot;</span>
        valueCommit=<span style="color: #ff0000;">&quot;handleValueCommit(event)&quot;</span>
        <span style="color: #66cc66;">/&gt;</span>
    <span style="color: #66cc66;">&lt;</span>mx:TextArea x=<span style="color: #ff0000;">&quot;10&quot;</span> y=<span style="color: #ff0000;">&quot;300&quot;</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">&quot;580&quot;</span> <span style="color: #0066CC;">height</span>=<span style="color: #ff0000;">&quot;305&quot;</span> 
        <span style="color: #0066CC;">text</span>=<span style="color: #ff0000;">&quot;{_debug}&quot;</span><span style="color: #66cc66;">/&gt;</span>
    <span style="color: #66cc66;">&lt;</span>mx:Script<span style="color: #66cc66;">&gt;</span>
        <span style="color: #66cc66;">&lt;!</span><span style="color: #66cc66;">&#91;</span>CDATA<span style="color: #66cc66;">&#91;</span>
            <span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">events</span>.<span style="color: #006600;">ResizeEvent</span>;
            <span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">events</span>.<span style="color: #006600;">StateChangeEvent</span>;
            <span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">events</span>.<span style="color: #006600;">FlexEvent</span>;
&nbsp;
            <span style="color: #66cc66;">&#91;</span>Bindable<span style="color: #66cc66;">&#93;</span>
            <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _debug:<span style="color: #0066CC;">String</span>;
&nbsp;
            <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">start</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
            <span style="color: #66cc66;">&#123;</span>
                _debug = <span style="color: #ff0000;">&quot;---&gt; application started!!!<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>;
            <span style="color: #66cc66;">&#125;</span>
&nbsp;
            <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> handleButtonClick<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>:MouseEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
            <span style="color: #66cc66;">&#123;</span>
                testImage.<span style="color: #006600;">source</span> = imageUrl.<span style="color: #0066CC;">text</span>;
                _debug += <span style="color: #ff0000;">&quot;---&gt; handleButtonClick<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>;
            <span style="color: #66cc66;">&#125;</span>
            <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> handleMoveButtonClick<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>:MouseEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
            <span style="color: #66cc66;">&#123;</span>
                testImage.<span style="color: #006600;">x</span> += <span style="color: #cc66cc;">50</span>;
                _debug += <span style="color: #ff0000;">&quot;---&gt; handleMoveButtonClick<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>;
            <span style="color: #66cc66;">&#125;</span>
&nbsp;
            <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> handleAddedToStage<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>:Event<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
            <span style="color: #66cc66;">&#123;</span>
                _debug += <span style="color: #ff0000;">&quot;handleAddedToStage<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>;
            <span style="color: #66cc66;">&#125;</span>
            <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> handleComplete<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>:Event<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> 
            <span style="color: #66cc66;">&#123;</span>
                _debug += <span style="color: #ff0000;">&quot;adddedToStage<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>;
            <span style="color: #66cc66;">&#125;</span>
            <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> handleCreationComplete<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>:FlexEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
            <span style="color: #66cc66;">&#123;</span>
                _debug += <span style="color: #ff0000;">&quot;handleCreationComplete<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>;
            <span style="color: #66cc66;">&#125;</span>
            <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> handleCurrentStateChange<span style="color: #66cc66;">&#40;</span>
                <span style="color: #0066CC;">e</span>:StateChangeEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
            <span style="color: #66cc66;">&#123;</span>
                _debug += <span style="color: #ff0000;">&quot;handleCurrentStateChange<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>;
            <span style="color: #66cc66;">&#125;</span>
            <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> handleInit<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>:Event<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
            <span style="color: #66cc66;">&#123;</span>
                _debug += <span style="color: #ff0000;">&quot;handleInit<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>;
            <span style="color: #66cc66;">&#125;</span>
            <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> handleInitialize<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>:FlexEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
            <span style="color: #66cc66;">&#123;</span>
                _debug += <span style="color: #ff0000;">&quot;handleInitialize<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>;
            <span style="color: #66cc66;">&#125;</span>
            <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> handleOpen<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>:Event<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
            <span style="color: #66cc66;">&#123;</span>
                _debug += <span style="color: #ff0000;">&quot;handleOpen<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>;
            <span style="color: #66cc66;">&#125;</span>
            <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> handlePreinitialize<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>:FlexEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
            <span style="color: #66cc66;">&#123;</span>
                _debug += <span style="color: #ff0000;">&quot;handlePreinitialize<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>;
            <span style="color: #66cc66;">&#125;</span>
            <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> handleProgress<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>:ProgressEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
            <span style="color: #66cc66;">&#123;</span>
                _debug += <span style="color: #ff0000;">&quot;handleProgress<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>;
            <span style="color: #66cc66;">&#125;</span>
            <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> handleRemoved<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>:Event<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
            <span style="color: #66cc66;">&#123;</span>
                _debug += <span style="color: #ff0000;">&quot;handleRemoved<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>;
            <span style="color: #66cc66;">&#125;</span>
            <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> handleRender<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>:Event<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
            <span style="color: #66cc66;">&#123;</span>
                _debug += <span style="color: #ff0000;">&quot;handleRender<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>;
            <span style="color: #66cc66;">&#125;</span>
            <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> handleResize<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>:ResizeEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
            <span style="color: #66cc66;">&#123;</span>
                _debug += <span style="color: #ff0000;">&quot;handleResize<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>;
            <span style="color: #66cc66;">&#125;</span>
            <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> handleShow<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>:FlexEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
            <span style="color: #66cc66;">&#123;</span>
                _debug += <span style="color: #ff0000;">&quot;handleShow<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>;
            <span style="color: #66cc66;">&#125;</span>
            <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> handleUnload<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>:Event<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
            <span style="color: #66cc66;">&#123;</span>
                _debug += <span style="color: #ff0000;">&quot;handleUnload<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>;
            <span style="color: #66cc66;">&#125;</span>
            <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> handleUpdateComplete<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>:Event<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
            <span style="color: #66cc66;">&#123;</span>
                _debug += <span style="color: #ff0000;">&quot;handleUpdateComplete<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>;
                _debug += <span style="color: #ff0000;">&quot;     contentHeight: &quot;</span> + 
                    <span style="color: #0066CC;">e</span>.<span style="color: #006600;">currentTarget</span>.<span style="color: #006600;">contentHeight</span> + <span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>;
                _debug += <span style="color: #ff0000;">&quot;     x: &quot;</span> + <span style="color: #0066CC;">e</span>.<span style="color: #006600;">currentTarget</span>.<span style="color: #006600;">x</span> + <span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>;
            <span style="color: #66cc66;">&#125;</span>
            <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> handleValid<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>:FlexEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
            <span style="color: #66cc66;">&#123;</span>
                _debug += <span style="color: #ff0000;">&quot;handleValid<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>;
            <span style="color: #66cc66;">&#125;</span>
            <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> handleValueCommit<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>:FlexEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
            <span style="color: #66cc66;">&#123;</span>
                _debug += <span style="color: #ff0000;">&quot;handleValueCommit<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>;
            <span style="color: #66cc66;">&#125;</span>
        <span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&gt;</span>
    <span style="color: #66cc66;">&lt;/</span>mx:Script<span style="color: #66cc66;">&gt;</span>
<span style="color: #66cc66;">&lt;/</span>mx:Application<span style="color: #66cc66;">&gt;</span></pre></td></tr></table></div>

<p>I hope you won&#8217;t be offended by the fact that I created one event method for each event type instead of having just one method and &#8220;switching&#8221; for the type inside it. <img src='http://www.flexer.info/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.flexer.info/2008/09/12/image-events-dispatch-order/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>MatrixGrid Component &#8211; Extending The DataGrid</title>
		<link>http://www.flexer.info/2008/06/30/matrixgrid-component-extending-the-datagrid/</link>
		<comments>http://www.flexer.info/2008/06/30/matrixgrid-component-extending-the-datagrid/#comments</comments>
		<pubDate>Mon, 30 Jun 2008 10:49:53 +0000</pubDate>
		<dc:creator>Andrei Ionescu</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Components]]></category>
		<category><![CDATA[Events]]></category>
		<category><![CDATA[MXML]]></category>
		<category><![CDATA[Skin]]></category>
		<category><![CDATA[combo]]></category>
		<category><![CDATA[component]]></category>
		<category><![CDATA[datagrid]]></category>
		<category><![CDATA[event]]></category>

		<guid isPermaLink="false">http://www.flexer.info/?p=217</guid>
		<description><![CDATA[MatrixGrid is a complex component I made that displays a bi-dimensional array and gives the possibility to change its values using combo boxes. These are the changes you can do:

change one single item

change one row at once
change one column at once

The MatrixGrid component receives for objects:

array with the possible values in each combo box 
the [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-right: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.flexer.info%2F2008%2F06%2F30%2Fmatrixgrid-component-extending-the-datagrid%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.flexer.info%2F2008%2F06%2F30%2Fmatrixgrid-component-extending-the-datagrid%2F" height="61" width="51" /></a></div><div style="float: right; margin-right: 10px"><a class="google_buzz"  
href="http://www.google.com/reader/link?url=http://www.flexer.info/2008/06/30/matrixgrid-component-extending-the-datagrid/&title=MatrixGrid+Component+&#8211;+Extending+The+DataGrid&srcURL=http://www.flexer.info" target="_blank" rel="nofollow"><img
src="http://www.flexer.info/wp-content/plugins/google-buzz-button-for-wordpress/images/google-buzz.png" alt="Google Buzz" /></a></div><p><strong>MatrixGrid</strong> is a complex component I made that displays a bi-dimensional array and gives the possibility to change its values using combo boxes. These are the changes you can do:</p>
<ul class="ul">
<li>change one single item
<li>
<li>change one row at once</li>
<li>change one column at once</li>
</ul>
<p>The <strong>MatrixGrid</strong> component receives for objects:</p>
<ul class="ul">
<li>array with the possible values in each combo box </li>
<li>the top header array with (id, name) pairs</li>
<li>the left header array also with (id, name) pairs</li>
<li>the array to be displayed</li>
</ul>
<p>In our application we will have an XML structure that will be transformed to our needed matrix object because we want to be able to test with different structures but keep in mind that the values will be find if there is a correlation between the matrix and the other three objects (the ids must be found).<br />

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_matrixgridapp_1744299240"
			class="flashmovie"
			width="520"
			height="745">
	<param name="movie" value="/wp-content/uploads/2008/06/matrixgridapp.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="/wp-content/uploads/2008/06/matrixgridapp.swf"
			name="fm_matrixgridapp_1744299240"
			width="520"
			height="745">
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object><br />
<strong>MatrixGrid</strong> component is complex and involves a lot of files so it will not be displayed here but everybody will be able to download it. </p>
<p>Now the application that uses the <strong>MatrixGrid</strong>:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
</pre></td><td class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #66cc66;">&lt;</span>?<span style="color: #0066CC;">xml</span> <span style="color: #0066CC;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> encoding=<span style="color: #ff0000;">&quot;utf-8&quot;</span>?<span style="color: #66cc66;">&gt;</span>
<span style="color: #66cc66;">&lt;</span>mx:Application xmlns:mx=<span style="color: #ff0000;">&quot;http://www.adobe.com/2006/mxml&quot;</span> 
    layout=<span style="color: #ff0000;">&quot;absolute&quot;</span> xmlns:flexer=<span style="color: #ff0000;">&quot;com.flexer.MatrixGrid.*&quot;</span>
    creationComplete=<span style="color: #ff0000;">&quot;start()&quot;</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">&quot;520&quot;</span> <span style="color: #0066CC;">height</span>=<span style="color: #ff0000;">&quot;745&quot;</span><span style="color: #66cc66;">&gt;</span>
    <span style="color: #66cc66;">&lt;</span>mx:TextArea x=<span style="color: #ff0000;">&quot;10&quot;</span> y=<span style="color: #ff0000;">&quot;10&quot;</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">&quot;500&quot;</span> <span style="color: #0066CC;">height</span>=<span style="color: #ff0000;">&quot;200&quot;</span> id=<span style="color: #ff0000;">&quot;indata&quot;</span><span style="color: #66cc66;">&gt;</span>
        <span style="color: #66cc66;">&lt;</span>mx:text<span style="color: #66cc66;">&gt;</span>
            <span style="color: #66cc66;">&lt;!</span><span style="color: #66cc66;">&#91;</span>CDATA<span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&lt;</span>matrix<span style="color: #66cc66;">&gt;</span>
    <span style="color: #66cc66;">&lt;</span>row id=<span style="color: #ff0000;">&quot;lid1&quot;</span><span style="color: #66cc66;">&gt;</span>
        <span style="color: #66cc66;">&lt;</span>column id=<span style="color: #ff0000;">&quot;cid1&quot;</span><span style="color: #66cc66;">&gt;</span>q1<span style="color: #66cc66;">&lt;/</span>column<span style="color: #66cc66;">&gt;</span>
        <span style="color: #66cc66;">&lt;</span>column id=<span style="color: #ff0000;">&quot;cid2&quot;</span><span style="color: #66cc66;">&gt;&lt;/</span>column<span style="color: #66cc66;">&gt;</span>
        <span style="color: #66cc66;">&lt;</span>column id=<span style="color: #ff0000;">&quot;cid3&quot;</span><span style="color: #66cc66;">&gt;</span>c<span style="color: #66cc66;">&lt;/</span>column<span style="color: #66cc66;">&gt;</span>
        <span style="color: #66cc66;">&lt;</span>column id=<span style="color: #ff0000;">&quot;cid4&quot;</span><span style="color: #66cc66;">&gt;</span>d<span style="color: #66cc66;">&lt;/</span>column<span style="color: #66cc66;">&gt;</span>
        <span style="color: #66cc66;">&lt;</span>column id=<span style="color: #ff0000;">&quot;cid5&quot;</span><span style="color: #66cc66;">&gt;</span>q1<span style="color: #66cc66;">&lt;/</span>column<span style="color: #66cc66;">&gt;</span>
        <span style="color: #66cc66;">&lt;</span>column id=<span style="color: #ff0000;">&quot;cid6&quot;</span><span style="color: #66cc66;">&gt;</span>q1<span style="color: #66cc66;">&lt;/</span>column<span style="color: #66cc66;">&gt;</span>
        <span style="color: #66cc66;">&lt;</span>column id=<span style="color: #ff0000;">&quot;cid7&quot;</span><span style="color: #66cc66;">&gt;</span>q1<span style="color: #66cc66;">&lt;/</span>column<span style="color: #66cc66;">&gt;</span>
    <span style="color: #66cc66;">&lt;/</span>row<span style="color: #66cc66;">&gt;</span>
    <span style="color: #66cc66;">&lt;</span>row id=<span style="color: #ff0000;">&quot;lid2&quot;</span><span style="color: #66cc66;">&gt;</span>
        <span style="color: #66cc66;">&lt;</span>column id=<span style="color: #ff0000;">&quot;cid1&quot;</span><span style="color: #66cc66;">&gt;</span>q1<span style="color: #66cc66;">&lt;/</span>column<span style="color: #66cc66;">&gt;</span>
        <span style="color: #66cc66;">&lt;</span>column id=<span style="color: #ff0000;">&quot;cid2&quot;</span><span style="color: #66cc66;">&gt;&lt;/</span>column<span style="color: #66cc66;">&gt;</span>
        <span style="color: #66cc66;">&lt;</span>column id=<span style="color: #ff0000;">&quot;cid3&quot;</span><span style="color: #66cc66;">&gt;</span>c<span style="color: #66cc66;">&lt;/</span>column<span style="color: #66cc66;">&gt;</span>
        <span style="color: #66cc66;">&lt;</span>column id=<span style="color: #ff0000;">&quot;cid4&quot;</span><span style="color: #66cc66;">&gt;</span>d<span style="color: #66cc66;">&lt;/</span>column<span style="color: #66cc66;">&gt;</span>
        <span style="color: #66cc66;">&lt;</span>column id=<span style="color: #ff0000;">&quot;cid5&quot;</span><span style="color: #66cc66;">&gt;</span>q1<span style="color: #66cc66;">&lt;/</span>column<span style="color: #66cc66;">&gt;</span>
        <span style="color: #66cc66;">&lt;</span>column id=<span style="color: #ff0000;">&quot;cid6&quot;</span><span style="color: #66cc66;">&gt;</span>q1<span style="color: #66cc66;">&lt;/</span>column<span style="color: #66cc66;">&gt;</span>
        <span style="color: #66cc66;">&lt;</span>column id=<span style="color: #ff0000;">&quot;cid7&quot;</span><span style="color: #66cc66;">&gt;</span>q1<span style="color: #66cc66;">&lt;/</span>column<span style="color: #66cc66;">&gt;</span>
    <span style="color: #66cc66;">&lt;/</span>row<span style="color: #66cc66;">&gt;</span>
    <span style="color: #66cc66;">&lt;</span>row id=<span style="color: #ff0000;">&quot;lid3&quot;</span><span style="color: #66cc66;">&gt;</span>
        <span style="color: #66cc66;">&lt;</span>column id=<span style="color: #ff0000;">&quot;cid1&quot;</span><span style="color: #66cc66;">&gt;</span>q1<span style="color: #66cc66;">&lt;/</span>column<span style="color: #66cc66;">&gt;</span>
        <span style="color: #66cc66;">&lt;</span>column id=<span style="color: #ff0000;">&quot;cid2&quot;</span><span style="color: #66cc66;">&gt;</span>b<span style="color: #66cc66;">&lt;/</span>column<span style="color: #66cc66;">&gt;</span>
        <span style="color: #66cc66;">&lt;</span>column id=<span style="color: #ff0000;">&quot;cid3&quot;</span><span style="color: #66cc66;">&gt;</span>c<span style="color: #66cc66;">&lt;/</span>column<span style="color: #66cc66;">&gt;</span>
        <span style="color: #66cc66;">&lt;</span>column id=<span style="color: #ff0000;">&quot;cid4&quot;</span><span style="color: #66cc66;">&gt;</span>d<span style="color: #66cc66;">&lt;/</span>column<span style="color: #66cc66;">&gt;</span>
        <span style="color: #66cc66;">&lt;</span>column id=<span style="color: #ff0000;">&quot;cid5&quot;</span><span style="color: #66cc66;">&gt;</span>q1<span style="color: #66cc66;">&lt;/</span>column<span style="color: #66cc66;">&gt;</span>
        <span style="color: #66cc66;">&lt;</span>column id=<span style="color: #ff0000;">&quot;cid6&quot;</span><span style="color: #66cc66;">&gt;</span>q1<span style="color: #66cc66;">&lt;/</span>column<span style="color: #66cc66;">&gt;</span>
        <span style="color: #66cc66;">&lt;</span>column id=<span style="color: #ff0000;">&quot;cid7&quot;</span><span style="color: #66cc66;">&gt;</span>q1<span style="color: #66cc66;">&lt;/</span>column<span style="color: #66cc66;">&gt;</span>
    <span style="color: #66cc66;">&lt;/</span>row<span style="color: #66cc66;">&gt;</span>
    <span style="color: #66cc66;">&lt;</span>row id=<span style="color: #ff0000;">&quot;lid4&quot;</span><span style="color: #66cc66;">&gt;</span>
        <span style="color: #66cc66;">&lt;</span>column id=<span style="color: #ff0000;">&quot;cid1&quot;</span><span style="color: #66cc66;">&gt;</span>q1<span style="color: #66cc66;">&lt;/</span>column<span style="color: #66cc66;">&gt;</span>
        <span style="color: #66cc66;">&lt;</span>column id=<span style="color: #ff0000;">&quot;cid2&quot;</span><span style="color: #66cc66;">&gt;</span>b<span style="color: #66cc66;">&lt;/</span>column<span style="color: #66cc66;">&gt;</span>
        <span style="color: #66cc66;">&lt;</span>column id=<span style="color: #ff0000;">&quot;cid3&quot;</span><span style="color: #66cc66;">&gt;</span>c<span style="color: #66cc66;">&lt;/</span>column<span style="color: #66cc66;">&gt;</span>
        <span style="color: #66cc66;">&lt;</span>column id=<span style="color: #ff0000;">&quot;cid4&quot;</span><span style="color: #66cc66;">&gt;</span>d<span style="color: #66cc66;">&lt;/</span>column<span style="color: #66cc66;">&gt;</span>
        <span style="color: #66cc66;">&lt;</span>column id=<span style="color: #ff0000;">&quot;cid5&quot;</span><span style="color: #66cc66;">&gt;</span>q1<span style="color: #66cc66;">&lt;/</span>column<span style="color: #66cc66;">&gt;</span>
        <span style="color: #66cc66;">&lt;</span>column id=<span style="color: #ff0000;">&quot;cid6&quot;</span><span style="color: #66cc66;">&gt;</span>q1<span style="color: #66cc66;">&lt;/</span>column<span style="color: #66cc66;">&gt;</span>
        <span style="color: #66cc66;">&lt;</span>column id=<span style="color: #ff0000;">&quot;cid7&quot;</span><span style="color: #66cc66;">&gt;</span>q1<span style="color: #66cc66;">&lt;/</span>column<span style="color: #66cc66;">&gt;</span>
    <span style="color: #66cc66;">&lt;/</span>row<span style="color: #66cc66;">&gt;</span>
    <span style="color: #66cc66;">&lt;</span>row id=<span style="color: #ff0000;">&quot;lid5&quot;</span><span style="color: #66cc66;">&gt;</span>
        <span style="color: #66cc66;">&lt;</span>column id=<span style="color: #ff0000;">&quot;cid1&quot;</span><span style="color: #66cc66;">&gt;</span>q1<span style="color: #66cc66;">&lt;/</span>column<span style="color: #66cc66;">&gt;</span>
        <span style="color: #66cc66;">&lt;</span>column id=<span style="color: #ff0000;">&quot;cid2&quot;</span><span style="color: #66cc66;">&gt;</span>b<span style="color: #66cc66;">&lt;/</span>column<span style="color: #66cc66;">&gt;</span>
        <span style="color: #66cc66;">&lt;</span>column id=<span style="color: #ff0000;">&quot;cid3&quot;</span><span style="color: #66cc66;">&gt;</span>c<span style="color: #66cc66;">&lt;/</span>column<span style="color: #66cc66;">&gt;</span>
        <span style="color: #66cc66;">&lt;</span>column id=<span style="color: #ff0000;">&quot;cid4&quot;</span><span style="color: #66cc66;">&gt;</span>d<span style="color: #66cc66;">&lt;/</span>column<span style="color: #66cc66;">&gt;</span>
        <span style="color: #66cc66;">&lt;</span>column id=<span style="color: #ff0000;">&quot;cid5&quot;</span><span style="color: #66cc66;">&gt;</span>q1<span style="color: #66cc66;">&lt;/</span>column<span style="color: #66cc66;">&gt;</span>
        <span style="color: #66cc66;">&lt;</span>column id=<span style="color: #ff0000;">&quot;cid6&quot;</span><span style="color: #66cc66;">&gt;</span>q1<span style="color: #66cc66;">&lt;/</span>column<span style="color: #66cc66;">&gt;</span>
        <span style="color: #66cc66;">&lt;</span>column id=<span style="color: #ff0000;">&quot;cid7&quot;</span><span style="color: #66cc66;">&gt;</span>q1<span style="color: #66cc66;">&lt;/</span>column<span style="color: #66cc66;">&gt;</span>
    <span style="color: #66cc66;">&lt;/</span>row<span style="color: #66cc66;">&gt;</span>
    <span style="color: #66cc66;">&lt;</span>row id=<span style="color: #ff0000;">&quot;lid6&quot;</span><span style="color: #66cc66;">&gt;</span>
        <span style="color: #66cc66;">&lt;</span>column id=<span style="color: #ff0000;">&quot;cid1&quot;</span><span style="color: #66cc66;">&gt;</span>q1<span style="color: #66cc66;">&lt;/</span>column<span style="color: #66cc66;">&gt;</span>
        <span style="color: #66cc66;">&lt;</span>column id=<span style="color: #ff0000;">&quot;cid2&quot;</span><span style="color: #66cc66;">&gt;</span>b<span style="color: #66cc66;">&lt;/</span>column<span style="color: #66cc66;">&gt;</span>
        <span style="color: #66cc66;">&lt;</span>column id=<span style="color: #ff0000;">&quot;cid3&quot;</span><span style="color: #66cc66;">&gt;</span>c<span style="color: #66cc66;">&lt;/</span>column<span style="color: #66cc66;">&gt;</span>
        <span style="color: #66cc66;">&lt;</span>column id=<span style="color: #ff0000;">&quot;cid4&quot;</span><span style="color: #66cc66;">&gt;</span>d<span style="color: #66cc66;">&lt;/</span>column<span style="color: #66cc66;">&gt;</span>
        <span style="color: #66cc66;">&lt;</span>column id=<span style="color: #ff0000;">&quot;cid5&quot;</span><span style="color: #66cc66;">&gt;</span>q1<span style="color: #66cc66;">&lt;/</span>column<span style="color: #66cc66;">&gt;</span>
        <span style="color: #66cc66;">&lt;</span>column id=<span style="color: #ff0000;">&quot;cid6&quot;</span><span style="color: #66cc66;">&gt;</span>q1<span style="color: #66cc66;">&lt;/</span>column<span style="color: #66cc66;">&gt;</span>
        <span style="color: #66cc66;">&lt;</span>column id=<span style="color: #ff0000;">&quot;cid7&quot;</span><span style="color: #66cc66;">&gt;</span>q1<span style="color: #66cc66;">&lt;/</span>column<span style="color: #66cc66;">&gt;</span>
    <span style="color: #66cc66;">&lt;/</span>row<span style="color: #66cc66;">&gt;</span>
    <span style="color: #66cc66;">&lt;</span>row id=<span style="color: #ff0000;">&quot;lid7&quot;</span><span style="color: #66cc66;">&gt;</span>
        <span style="color: #66cc66;">&lt;</span>column id=<span style="color: #ff0000;">&quot;cid1&quot;</span><span style="color: #66cc66;">&gt;</span>q1<span style="color: #66cc66;">&lt;/</span>column<span style="color: #66cc66;">&gt;</span>
        <span style="color: #66cc66;">&lt;</span>column id=<span style="color: #ff0000;">&quot;cid2&quot;</span><span style="color: #66cc66;">&gt;</span>b<span style="color: #66cc66;">&lt;/</span>column<span style="color: #66cc66;">&gt;</span>
        <span style="color: #66cc66;">&lt;</span>column id=<span style="color: #ff0000;">&quot;cid3&quot;</span><span style="color: #66cc66;">&gt;</span>c<span style="color: #66cc66;">&lt;/</span>column<span style="color: #66cc66;">&gt;</span>
        <span style="color: #66cc66;">&lt;</span>column id=<span style="color: #ff0000;">&quot;cid4&quot;</span><span style="color: #66cc66;">&gt;</span>d<span style="color: #66cc66;">&lt;/</span>column<span style="color: #66cc66;">&gt;</span>
        <span style="color: #66cc66;">&lt;</span>column id=<span style="color: #ff0000;">&quot;cid5&quot;</span><span style="color: #66cc66;">&gt;</span>q1<span style="color: #66cc66;">&lt;/</span>column<span style="color: #66cc66;">&gt;</span>
        <span style="color: #66cc66;">&lt;</span>column id=<span style="color: #ff0000;">&quot;cid6&quot;</span><span style="color: #66cc66;">&gt;</span>q1<span style="color: #66cc66;">&lt;/</span>column<span style="color: #66cc66;">&gt;</span>
        <span style="color: #66cc66;">&lt;</span>column id=<span style="color: #ff0000;">&quot;cid7&quot;</span><span style="color: #66cc66;">&gt;</span>q1<span style="color: #66cc66;">&lt;/</span>column<span style="color: #66cc66;">&gt;</span>
    <span style="color: #66cc66;">&lt;/</span>row<span style="color: #66cc66;">&gt;</span>
    <span style="color: #66cc66;">&lt;</span>row id=<span style="color: #ff0000;">&quot;lid8&quot;</span><span style="color: #66cc66;">&gt;</span>
        <span style="color: #66cc66;">&lt;</span>column id=<span style="color: #ff0000;">&quot;cid1&quot;</span><span style="color: #66cc66;">&gt;</span>q1<span style="color: #66cc66;">&lt;/</span>column<span style="color: #66cc66;">&gt;</span>
        <span style="color: #66cc66;">&lt;</span>column id=<span style="color: #ff0000;">&quot;cid2&quot;</span><span style="color: #66cc66;">&gt;</span>b<span style="color: #66cc66;">&lt;/</span>column<span style="color: #66cc66;">&gt;</span>
        <span style="color: #66cc66;">&lt;</span>column id=<span style="color: #ff0000;">&quot;cid3&quot;</span><span style="color: #66cc66;">&gt;</span>c<span style="color: #66cc66;">&lt;/</span>column<span style="color: #66cc66;">&gt;</span>
        <span style="color: #66cc66;">&lt;</span>column id=<span style="color: #ff0000;">&quot;cid4&quot;</span><span style="color: #66cc66;">&gt;</span>d<span style="color: #66cc66;">&lt;/</span>column<span style="color: #66cc66;">&gt;</span>
        <span style="color: #66cc66;">&lt;</span>column id=<span style="color: #ff0000;">&quot;cid5&quot;</span><span style="color: #66cc66;">&gt;</span>q1<span style="color: #66cc66;">&lt;/</span>column<span style="color: #66cc66;">&gt;</span>
        <span style="color: #66cc66;">&lt;</span>column id=<span style="color: #ff0000;">&quot;cid6&quot;</span><span style="color: #66cc66;">&gt;</span>q1<span style="color: #66cc66;">&lt;/</span>column<span style="color: #66cc66;">&gt;</span>
        <span style="color: #66cc66;">&lt;</span>column id=<span style="color: #ff0000;">&quot;cid7&quot;</span><span style="color: #66cc66;">&gt;</span>q1<span style="color: #66cc66;">&lt;/</span>column<span style="color: #66cc66;">&gt;</span>
    <span style="color: #66cc66;">&lt;/</span>row<span style="color: #66cc66;">&gt;</span>
    <span style="color: #66cc66;">&lt;</span>row id=<span style="color: #ff0000;">&quot;lid9&quot;</span><span style="color: #66cc66;">&gt;</span>
        <span style="color: #66cc66;">&lt;</span>column id=<span style="color: #ff0000;">&quot;cid1&quot;</span><span style="color: #66cc66;">&gt;</span>q1<span style="color: #66cc66;">&lt;/</span>column<span style="color: #66cc66;">&gt;</span>
        <span style="color: #66cc66;">&lt;</span>column id=<span style="color: #ff0000;">&quot;cid2&quot;</span><span style="color: #66cc66;">&gt;</span>b<span style="color: #66cc66;">&lt;/</span>column<span style="color: #66cc66;">&gt;</span>
        <span style="color: #66cc66;">&lt;</span>column id=<span style="color: #ff0000;">&quot;cid3&quot;</span><span style="color: #66cc66;">&gt;</span>c<span style="color: #66cc66;">&lt;/</span>column<span style="color: #66cc66;">&gt;</span>
        <span style="color: #66cc66;">&lt;</span>column id=<span style="color: #ff0000;">&quot;cid4&quot;</span><span style="color: #66cc66;">&gt;</span>d<span style="color: #66cc66;">&lt;/</span>column<span style="color: #66cc66;">&gt;</span>
        <span style="color: #66cc66;">&lt;</span>column id=<span style="color: #ff0000;">&quot;cid5&quot;</span><span style="color: #66cc66;">&gt;</span>q1<span style="color: #66cc66;">&lt;/</span>column<span style="color: #66cc66;">&gt;</span>
        <span style="color: #66cc66;">&lt;</span>column id=<span style="color: #ff0000;">&quot;cid6&quot;</span><span style="color: #66cc66;">&gt;</span>q1<span style="color: #66cc66;">&lt;/</span>column<span style="color: #66cc66;">&gt;</span>
        <span style="color: #66cc66;">&lt;</span>column id=<span style="color: #ff0000;">&quot;cid7&quot;</span><span style="color: #66cc66;">&gt;</span>q1<span style="color: #66cc66;">&lt;/</span>column<span style="color: #66cc66;">&gt;</span>
    <span style="color: #66cc66;">&lt;/</span>row<span style="color: #66cc66;">&gt;</span>
<span style="color: #66cc66;">&lt;/</span>matrix<span style="color: #66cc66;">&gt;</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&gt;</span>
        <span style="color: #66cc66;">&lt;/</span>mx:text<span style="color: #66cc66;">&gt;</span>
    <span style="color: #66cc66;">&lt;/</span>mx:TextArea<span style="color: #66cc66;">&gt;</span>
    <span style="color: #66cc66;">&lt;</span>mx:<span style="color: #0066CC;">Button</span> horizontalCenter=<span style="color: #ff0000;">&quot;0&quot;</span> y=<span style="color: #ff0000;">&quot;218&quot;</span> label=<span style="color: #ff0000;">&quot;SetData&quot;</span>
        click=<span style="color: #ff0000;">&quot;handleSetClick(event)&quot;</span><span style="color: #66cc66;">/&gt;</span>
    <span style="color: #66cc66;">&lt;</span>flexer:MatrixGrid id=<span style="color: #ff0000;">&quot;mdg&quot;</span>
        <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">&quot;500&quot;</span> <span style="color: #0066CC;">height</span>=<span style="color: #ff0000;">&quot;250&quot;</span> x=<span style="color: #ff0000;">&quot;10&quot;</span> y=<span style="color: #ff0000;">&quot;248&quot;</span><span style="color: #66cc66;">/&gt;</span>
    <span style="color: #66cc66;">&lt;</span>mx:<span style="color: #0066CC;">Button</span> horizontalCenter=<span style="color: #ff0000;">&quot;0&quot;</span> y=<span style="color: #ff0000;">&quot;506&quot;</span> label=<span style="color: #ff0000;">&quot;GetData&quot;</span>
        click=<span style="color: #ff0000;">&quot;handleGetClick(event)&quot;</span><span style="color: #66cc66;">/&gt;</span>
    <span style="color: #66cc66;">&lt;</span>mx:TextArea id=<span style="color: #ff0000;">&quot;debug&quot;</span> x=<span style="color: #ff0000;">&quot;10&quot;</span> y=<span style="color: #ff0000;">&quot;536&quot;</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">&quot;500&quot;</span> <span style="color: #0066CC;">height</span>=<span style="color: #ff0000;">&quot;200&quot;</span><span style="color: #66cc66;">/&gt;</span>
    <span style="color: #66cc66;">&lt;</span>mx:Script<span style="color: #66cc66;">&gt;</span>
        <span style="color: #66cc66;">&lt;!</span><span style="color: #66cc66;">&#91;</span>CDATA<span style="color: #66cc66;">&#91;</span>
            <span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">utils</span>.<span style="color: #006600;">ObjectUtil</span>;
            <span style="color: #0066CC;">import</span> com.<span style="color: #006600;">flexer</span>.<span style="color: #006600;">Debug</span>;
            <span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">charts</span>.<span style="color: #006600;">chartClasses</span>.<span style="color: #006600;">DualStyleObject</span>;
&nbsp;
            <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> xml2Matrix<span style="color: #66cc66;">&#40;</span>x:<span style="color: #0066CC;">XML</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">Object</span>
            <span style="color: #66cc66;">&#123;</span>
                <span style="color: #000000; font-weight: bold;">var</span> retObj:<span style="color: #0066CC;">Object</span> = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">Object</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
                <span style="color: #b1b100;">for</span> each <span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">var</span> item:<span style="color: #0066CC;">XML</span> <span style="color: #b1b100;">in</span> x.<span style="color: #006600;">children</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
                <span style="color: #66cc66;">&#123;</span>
                    <span style="color: #000000; font-weight: bold;">var</span> rowName:<span style="color: #0066CC;">String</span> = item.<span style="color: #006600;">attribute</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;id&quot;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #0066CC;">toString</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
                    retObj<span style="color: #66cc66;">&#91;</span>rowName<span style="color: #66cc66;">&#93;</span> = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">Object</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
                    <span style="color: #b1b100;">for</span> each <span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">var</span> item2:<span style="color: #0066CC;">XML</span> <span style="color: #b1b100;">in</span> item.<span style="color: #006600;">children</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
                    <span style="color: #66cc66;">&#123;</span>
                        <span style="color: #000000; font-weight: bold;">var</span> colName:<span style="color: #0066CC;">String</span> = item2.<span style="color: #006600;">attribute</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;id&quot;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #0066CC;">toString</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
                        retObj<span style="color: #66cc66;">&#91;</span>rowName<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#91;</span>colName<span style="color: #66cc66;">&#93;</span> = item2.<span style="color: #0066CC;">toString</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
                    <span style="color: #66cc66;">&#125;</span>
                <span style="color: #66cc66;">&#125;</span>
                <span style="color: #b1b100;">return</span> retObj;
            <span style="color: #66cc66;">&#125;</span>
&nbsp;
            <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">start</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
            <span style="color: #66cc66;">&#123;</span>
                <span style="color: #808080; font-style: italic;">// our matrix</span>
                <span style="color: #808080; font-style: italic;">// every item is defined by coordinates </span>
                <span style="color: #808080; font-style: italic;">// like this: (rowId, colId)</span>
                <span style="color: #000000; font-weight: bold;">var</span> testdata:<span style="color: #0066CC;">Object</span> = xml2Matrix<span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">XML</span><span style="color: #66cc66;">&#40;</span>indata.<span style="color: #0066CC;">text</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
                <span style="color: #808080; font-style: italic;">// the left header</span>
                <span style="color: #808080; font-style: italic;">// contains pairs of: (rowName, rowId)</span>
                <span style="color: #000000; font-weight: bold;">var</span> leftHeader:<span style="color: #0066CC;">Object</span> = <span style="color: #66cc66;">&#123;</span>
                    <span style="color: #ff0000;">&quot;lid1&quot;</span>:<span style="color: #ff0000;">&quot;row1&quot;</span>,
                    <span style="color: #ff0000;">&quot;lid2&quot;</span>:<span style="color: #ff0000;">&quot;row3&quot;</span>,
                    <span style="color: #ff0000;">&quot;lid3&quot;</span>:<span style="color: #ff0000;">&quot;row3&quot;</span>,
                    <span style="color: #ff0000;">&quot;lid4&quot;</span>:<span style="color: #ff0000;">&quot;row3&quot;</span>,
                    <span style="color: #ff0000;">&quot;lid5&quot;</span>:<span style="color: #ff0000;">&quot;row3&quot;</span>,
                    <span style="color: #ff0000;">&quot;lid6&quot;</span>:<span style="color: #ff0000;">&quot;row6&quot;</span>,
                    <span style="color: #ff0000;">&quot;lid7&quot;</span>:<span style="color: #ff0000;">&quot;row7&quot;</span>,
                    <span style="color: #ff0000;">&quot;lid8&quot;</span>:<span style="color: #ff0000;">&quot;row8&quot;</span>,
                    <span style="color: #ff0000;">&quot;lid9&quot;</span>:<span style="color: #ff0000;">&quot;row9&quot;</span>
                <span style="color: #66cc66;">&#125;</span>;
                <span style="color: #808080; font-style: italic;">// the top header </span>
                <span style="color: #808080; font-style: italic;">// contains pairs of: (columnName, columnId)</span>
                <span style="color: #000000; font-weight: bold;">var</span> topHeader:<span style="color: #0066CC;">Object</span> = <span style="color: #66cc66;">&#123;</span>
                    <span style="color: #ff0000;">&quot;cid1&quot;</span>:<span style="color: #ff0000;">&quot;col1&quot;</span>,
                    <span style="color: #ff0000;">&quot;cid2&quot;</span>:<span style="color: #ff0000;">&quot;col1&quot;</span>,
                    <span style="color: #ff0000;">&quot;cid3&quot;</span>:<span style="color: #ff0000;">&quot;col1&quot;</span>,
                    <span style="color: #ff0000;">&quot;cid4&quot;</span>:<span style="color: #ff0000;">&quot;col4&quot;</span>,
                    <span style="color: #ff0000;">&quot;cid5&quot;</span>:<span style="color: #ff0000;">&quot;col5&quot;</span>,
                    <span style="color: #ff0000;">&quot;cid6&quot;</span>:<span style="color: #ff0000;">&quot;col6&quot;</span>,
                    <span style="color: #ff0000;">&quot;cid7&quot;</span>:<span style="color: #ff0000;">&quot;col7&quot;</span>
                <span style="color: #66cc66;">&#125;</span>
                <span style="color: #808080; font-style: italic;">// possible values for comboboxes</span>
                <span style="color: #000000; font-weight: bold;">var</span> _possibleValues:<span style="color: #0066CC;">Array</span> = <span style="color: #66cc66;">&#91;</span>
                    <span style="color: #66cc66;">&#123;</span><span style="color: #0066CC;">data</span>:<span style="color: #ff0000;">&quot;&quot;</span>,label:<span style="color: #ff0000;">&quot;&quot;</span><span style="color: #66cc66;">&#125;</span>,
                    <span style="color: #66cc66;">&#123;</span><span style="color: #0066CC;">data</span>:<span style="color: #ff0000;">&quot;q1&quot;</span>,label:<span style="color: #ff0000;">&quot;v1&quot;</span><span style="color: #66cc66;">&#125;</span>,
                    <span style="color: #66cc66;">&#123;</span><span style="color: #0066CC;">data</span>:<span style="color: #ff0000;">&quot;b&quot;</span>,label:<span style="color: #ff0000;">&quot;v2&quot;</span><span style="color: #66cc66;">&#125;</span>,
                    <span style="color: #66cc66;">&#123;</span><span style="color: #0066CC;">data</span>:<span style="color: #ff0000;">&quot;c&quot;</span>,label:<span style="color: #ff0000;">&quot;v3&quot;</span><span style="color: #66cc66;">&#125;</span>,
                    <span style="color: #66cc66;">&#123;</span><span style="color: #0066CC;">data</span>:<span style="color: #ff0000;">&quot;d&quot;</span>,label:<span style="color: #ff0000;">&quot;v4&quot;</span><span style="color: #66cc66;">&#125;</span>
                <span style="color: #66cc66;">&#93;</span>;
                <span style="color: #808080; font-style: italic;">// setting the left header width</span>
                mdg.<span style="color: #006600;">leftHeaderWidth</span> = <span style="color: #cc66cc;">150</span>;
                <span style="color: #808080; font-style: italic;">// setting the possible values for comboboxes</span>
                mdg.<span style="color: #006600;">possibleValues</span> = _possibleValues;
                <span style="color: #808080; font-style: italic;">// setting the left header</span>
                <span style="color: #808080; font-style: italic;">// the leftheader is an object that </span>
                <span style="color: #808080; font-style: italic;">// contains pairs of: (rowName, rowId)</span>
                mdg.<span style="color: #006600;">leftHeader</span> = leftHeader;
                <span style="color: #808080; font-style: italic;">// setting the top header</span>
                <span style="color: #808080; font-style: italic;">// the top header is an object that </span>
                <span style="color: #808080; font-style: italic;">// contains pairs of: (columnName, columnId)</span>
                mdg.<span style="color: #006600;">topHeader</span> = topHeader;
                <span style="color: #808080; font-style: italic;">// setting our matrix</span>
                <span style="color: #808080; font-style: italic;">// every item is defined by coordinates </span>
                <span style="color: #808080; font-style: italic;">// like this: (rowId, colId)</span>
                mdg.<span style="color: #006600;">matrix</span> = testdata;
            <span style="color: #66cc66;">&#125;</span>
&nbsp;
            <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> handleSetClick<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>:MouseEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
            <span style="color: #66cc66;">&#123;</span>
                mdg.<span style="color: #006600;">matrix</span> = xml2Matrix<span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">XML</span><span style="color: #66cc66;">&#40;</span>indata.<span style="color: #0066CC;">text</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
            <span style="color: #66cc66;">&#125;</span>
&nbsp;
            <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> handleGetClick<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>:MouseEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
            <span style="color: #66cc66;">&#123;</span>
                <span style="color: #000000; font-weight: bold;">var</span> newData:<span style="color: #0066CC;">Object</span> = mdg.<span style="color: #006600;">matrix</span>;
                debug.<span style="color: #0066CC;">text</span> = Debug.<span style="color: #006600;">dump</span><span style="color: #66cc66;">&#40;</span>newData<span style="color: #66cc66;">&#41;</span>;
            <span style="color: #66cc66;">&#125;</span>
        <span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&gt;</span>
    <span style="color: #66cc66;">&lt;/</span>mx:Script<span style="color: #66cc66;">&gt;</span>
<span style="color: #66cc66;">&lt;/</span>mx:Application<span style="color: #66cc66;">&gt;</span></pre></td></tr></table></div>

<p>This component uses about 10 files to implement the following:</p>
<ul class="ul">
<li>dataGrid</li>
<li>comboBox</li>
<li>itemRenderers:
<ul class="ul">
<li>top header</li>
<li>left header</li>
<li>items</li>
</ul>
</li>
<li>events</li>
<li>skins</li>
</ul>
<p>Some interesting things I found when I implemented this <strong>MatrixGrid</strong>:</p>
<ol>
<li>is that is hard to link back to the columns and the data grid from within an item renderer. It is possible to access the data grid by using <strong>owner</strong> property, but is hard to find out the current position from an item renderer, relative to the data grid &#8211; more precise to find the column and the row</li>
<li>is even harder to dispatch an event from the item renderer to the data grid</li>
</ol>
<p>But there are ways, as you can see in the source files, but that involves to dive into the Flex framework to understand how data grid is working, in order to be able to take code and use it in you item renderers.</p>
<p>I hope <strong>MatrixGrid</strong> will be helpful for you and if it is please leave a comment and do not delete the licensing text inside source files.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.flexer.info/2008/06/30/matrixgrid-component-extending-the-datagrid/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How To Add New Rows To DataGrid And Scroll To Last Added Row</title>
		<link>http://www.flexer.info/2008/06/18/how-to-add-new-rows-to-datagrid-and-scroll-to-last-added-row/</link>
		<comments>http://www.flexer.info/2008/06/18/how-to-add-new-rows-to-datagrid-and-scroll-to-last-added-row/#comments</comments>
		<pubDate>Wed, 18 Jun 2008 10:50:45 +0000</pubDate>
		<dc:creator>Andrei Ionescu</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Events]]></category>
		<category><![CDATA[How to]]></category>
		<category><![CDATA[MXML]]></category>
		<category><![CDATA[datagrid]]></category>
		<category><![CDATA[scroll]]></category>

		<guid isPermaLink="false">http://www.flexer.info/?p=207</guid>
		<description><![CDATA[This will be a simple solution to be able to scroll to the last added row in a data grid. First of all I&#8217;ll explain what I mean and what I encountered when I needed to implement it. 
The expected behavior is after adding a new row into a data grid, it should scroll to [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-right: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.flexer.info%2F2008%2F06%2F18%2Fhow-to-add-new-rows-to-datagrid-and-scroll-to-last-added-row%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.flexer.info%2F2008%2F06%2F18%2Fhow-to-add-new-rows-to-datagrid-and-scroll-to-last-added-row%2F" height="61" width="51" /></a></div><div style="float: right; margin-right: 10px"><a class="google_buzz"  
href="http://www.google.com/reader/link?url=http://www.flexer.info/2008/06/18/how-to-add-new-rows-to-datagrid-and-scroll-to-last-added-row/&title=How+To+Add+New+Rows+To+DataGrid+And+Scroll+To+Last+Added+Row&srcURL=http://www.flexer.info" target="_blank" rel="nofollow"><img
src="http://www.flexer.info/wp-content/plugins/google-buzz-button-for-wordpress/images/google-buzz.png" alt="Google Buzz" /></a></div><p>This will be a simple solution to be able to scroll to the last added row in a data grid. First of all I&#8217;ll explain what I mean and what I encountered when I needed to implement it. </p>
<p>The expected behavior is after adding a new row into a data grid, it should scroll to that item if that row is not visible. First of all I tried to put <strong>scrollToIndex</strong> method right into the add method and unwanted behavior appeared. The data grid was just scrolling to the previous row of the last row leaving the last added row just under the bottom edge. </p>
<p>I started to look into the Flex Framework code and I found out the into the <strong>scrollToIndex</strong> method of <strong>ListBase</strong> class is a variable called <strong>maxVerticalScrollPosition</strong> which is calculated/updated into the <strong>ScrollControlBase</strong> class when the scroll bar is displayed. If the scroll bar is not visible <strong>maxVerticalScrollPosition</strong> variable will be 0. </p>
<p>Why is this happening to us? Because we try to scroll to the last added row before updating the data grid control visually. Finding that out I moved the <strong>scrollToIndex </strong>method into update complete event (<strong>FlexEvent.UPDATE_COMPLETE</strong>) and that fixed the problem because at that point the control is updated and the scroll bar is displayed.</p>
<p>So here is the application&#8230;<br />

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_datagridscrollto_357285116"
			class="flashmovie"
			width="379"
			height="163">
	<param name="movie" value="/wp-content/uploads/2008/06/datagridscrollto.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="/wp-content/uploads/2008/06/datagridscrollto.swf"
			name="fm_datagridscrollto_357285116"
			width="379"
			height="163">
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object><br />
&#8230;and the code as usual.<br />
&nbsp;</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
</pre></td><td class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #66cc66;">&lt;</span>?<span style="color: #0066CC;">xml</span> <span style="color: #0066CC;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> encoding=<span style="color: #ff0000;">&quot;utf-8&quot;</span>?<span style="color: #66cc66;">&gt;</span>
<span style="color: #66cc66;">&lt;</span>mx:Application xmlns:mx=<span style="color: #ff0000;">&quot;http://www.adobe.com/2006/mxml&quot;</span> layout=<span style="color: #ff0000;">&quot;absolute&quot;</span>
    <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">&quot;379&quot;</span> <span style="color: #0066CC;">height</span>=<span style="color: #ff0000;">&quot;163&quot;</span><span style="color: #66cc66;">&gt;</span>
    <span style="color: #66cc66;">&lt;</span>mx:DataGrid x=<span style="color: #ff0000;">&quot;10&quot;</span> y=<span style="color: #ff0000;">&quot;10&quot;</span> id=<span style="color: #ff0000;">&quot;dg&quot;</span> dataProvider=<span style="color: #ff0000;">&quot;{dgdp}&quot;</span> <span style="color: #0066CC;">height</span>=<span style="color: #ff0000;">&quot;112&quot;</span>
        updateComplete=<span style="color: #ff0000;">&quot;handleUpdateComplete(event)&quot;</span><span style="color: #66cc66;">&gt;</span>
        <span style="color: #66cc66;">&lt;</span>mx:columns<span style="color: #66cc66;">&gt;</span>
            <span style="color: #66cc66;">&lt;</span>mx:DataGridColumn headerText=<span style="color: #ff0000;">&quot;Column 1&quot;</span> dataField=<span style="color: #ff0000;">&quot;col1&quot;</span><span style="color: #66cc66;">/&gt;</span>
            <span style="color: #66cc66;">&lt;</span>mx:DataGridColumn headerText=<span style="color: #ff0000;">&quot;Column 2&quot;</span> dataField=<span style="color: #ff0000;">&quot;col2&quot;</span><span style="color: #66cc66;">/&gt;</span>
            <span style="color: #66cc66;">&lt;</span>mx:DataGridColumn headerText=<span style="color: #ff0000;">&quot;Column 3&quot;</span> dataField=<span style="color: #ff0000;">&quot;col3&quot;</span><span style="color: #66cc66;">/&gt;</span>
        <span style="color: #66cc66;">&lt;/</span>mx:columns<span style="color: #66cc66;">&gt;</span>
    <span style="color: #66cc66;">&lt;/</span>mx:DataGrid<span style="color: #66cc66;">&gt;</span>
    <span style="color: #66cc66;">&lt;</span>mx:<span style="color: #0066CC;">Button</span> x=<span style="color: #ff0000;">&quot;320&quot;</span> y=<span style="color: #ff0000;">&quot;9&quot;</span> label=<span style="color: #ff0000;">&quot;Add&quot;</span> click=<span style="color: #ff0000;">&quot;handleAddRow(event)&quot;</span><span style="color: #66cc66;">/&gt;</span>
    <span style="color: #66cc66;">&lt;</span>mx:NumericStepper x=<span style="color: #ff0000;">&quot;75&quot;</span> y=<span style="color: #ff0000;">&quot;130&quot;</span> 
        minimum=<span style="color: #ff0000;">&quot;0&quot;</span> maximum=<span style="color: #ff0000;">&quot;{dg.dataProvider.length-1}&quot;</span>
        change=<span style="color: #ff0000;">&quot;handleScrollToChange(event)&quot;</span><span style="color: #66cc66;">/&gt;</span>
    <span style="color: #66cc66;">&lt;</span>mx:Label x=<span style="color: #ff0000;">&quot;10&quot;</span> y=<span style="color: #ff0000;">&quot;132&quot;</span> <span style="color: #0066CC;">text</span>=<span style="color: #ff0000;">&quot;Scroll To:&quot;</span><span style="color: #66cc66;">/&gt;</span>
    <span style="color: #66cc66;">&lt;</span>mx:Script<span style="color: #66cc66;">&gt;</span>
        <span style="color: #66cc66;">&lt;!</span><span style="color: #66cc66;">&#91;</span>CDATA<span style="color: #66cc66;">&#91;</span>
            <span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">events</span>.<span style="color: #006600;">NumericStepperEvent</span>;
&nbsp;
            <span style="color: #66cc66;">&#91;</span>Bindable<span style="color: #66cc66;">&#93;</span>
            <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> dgdp:<span style="color: #0066CC;">Array</span> = <span style="color: #66cc66;">&#91;</span>
                <span style="color: #66cc66;">&#123;</span>
                    <span style="color: #ff0000;">&quot;col1&quot;</span>:<span style="color: #cc66cc;">0</span>,
                    <span style="color: #ff0000;">&quot;col2&quot;</span>:<span style="color: #ff0000;">&quot;a1&quot;</span>,
                    <span style="color: #ff0000;">&quot;col3&quot;</span>:<span style="color: #ff0000;">&quot;b1&quot;</span>
                <span style="color: #66cc66;">&#125;</span>,
                <span style="color: #66cc66;">&#123;</span>
                    <span style="color: #ff0000;">&quot;col1&quot;</span>:<span style="color: #cc66cc;">1</span>,
                    <span style="color: #ff0000;">&quot;col2&quot;</span>:<span style="color: #ff0000;">&quot;a2&quot;</span>,
                    <span style="color: #ff0000;">&quot;col3&quot;</span>:<span style="color: #ff0000;">&quot;b2&quot;</span>
                <span style="color: #66cc66;">&#125;</span>
            <span style="color: #66cc66;">&#93;</span>;
&nbsp;
            <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> handleScrollToChange<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>:NumericStepperEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
            <span style="color: #66cc66;">&#123;</span>
                dg.<span style="color: #006600;">scrollToIndex</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>.<span style="color: #006600;">value</span><span style="color: #66cc66;">&#41;</span>;
            <span style="color: #66cc66;">&#125;</span>
&nbsp;
            <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> handleAddRow<span style="color: #66cc66;">&#40;</span>event:MouseEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
            <span style="color: #66cc66;">&#123;</span>
                dg.<span style="color: #006600;">dataProvider</span>.<span style="color: #006600;">addItem</span><span style="color: #66cc66;">&#40;</span>
                    <span style="color: #66cc66;">&#123;</span>
                        <span style="color: #ff0000;">&quot;col1&quot;</span>: dg.<span style="color: #006600;">dataProvider</span>.<span style="color: #0066CC;">length</span>,
                        <span style="color: #ff0000;">&quot;col2&quot;</span>: <span style="color: #ff0000;">&quot;__CUST__&quot;</span>,
                        <span style="color: #ff0000;">&quot;col3&quot;</span>: <span style="color: #ff0000;">&quot;__CUST__&quot;</span>
                    <span style="color: #66cc66;">&#125;</span>
                <span style="color: #66cc66;">&#41;</span>;
            <span style="color: #66cc66;">&#125;</span>
&nbsp;
            <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> handleUpdateComplete<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>:Event<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
            <span style="color: #66cc66;">&#123;</span>
                <span style="color: #000000; font-weight: bold;">var</span> currLen:uint = dg.<span style="color: #006600;">dataProvider</span>.<span style="color: #0066CC;">length</span>;
                dg.<span style="color: #006600;">scrollToIndex</span><span style="color: #66cc66;">&#40;</span>currLen<span style="color: #66cc66;">&#41;</span>;
            <span style="color: #66cc66;">&#125;</span>
        <span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&gt;</span>
    <span style="color: #66cc66;">&lt;/</span>mx:Script<span style="color: #66cc66;">&gt;</span>
<span style="color: #66cc66;">&lt;/</span>mx:Application<span style="color: #66cc66;">&gt;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.flexer.info/2008/06/18/how-to-add-new-rows-to-datagrid-and-scroll-to-last-added-row/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Resizable Canvas &#8211; &#8230;both directions</title>
		<link>http://www.flexer.info/2008/05/19/resizable-canvas-both-directions/</link>
		<comments>http://www.flexer.info/2008/05/19/resizable-canvas-both-directions/#comments</comments>
		<pubDate>Mon, 19 May 2008 14:01:19 +0000</pubDate>
		<dc:creator>Andrei Ionescu</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Events]]></category>
		<category><![CDATA[How to]]></category>
		<category><![CDATA[Skin]]></category>
		<category><![CDATA[canvas]]></category>
		<category><![CDATA[event]]></category>
		<category><![CDATA[resize]]></category>

		<guid isPermaLink="false">http://www.flexer.info/?p=174</guid>
		<description><![CDATA[In the previous articles in this series I explained how to create a horizontally and vertically resizable canvas. In this third article we will add the possibility to resize in both direction by dragging the right bottom corner.
What we will do:

add the new UI control (the right bottom button)
create the necessary events for it
create CSS [...]]]></description>
			<content:encoded><![CDATA[<div class='series_toc'><h3>Table of contents<!-- for Resizable Canvas --></h3><ol><li><a href='http://www.flexer.info/2008/04/25/resizable-canvas-horizontally/' title='Resizable Canvas &#8211; Horizontally'>Resizable Canvas &#8211; Horizontally</a></li><li><a href='http://www.flexer.info/2008/04/29/resizable-canvas-and-vertically/' title='Resizable Canvas &#8211; &#8230;and Vertically'>Resizable Canvas &#8211; &#8230;and Vertically</a></li><li>Resizable Canvas &#8211; &#8230;both directions</li></ol></div> <div class="tweetmeme_button" style="float: right; margin-right: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.flexer.info%2F2008%2F05%2F19%2Fresizable-canvas-both-directions%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.flexer.info%2F2008%2F05%2F19%2Fresizable-canvas-both-directions%2F" height="61" width="51" /></a></div><div style="float: right; margin-right: 10px"><a class="google_buzz"  
href="http://www.google.com/reader/link?url=http://www.flexer.info/2008/05/19/resizable-canvas-both-directions/&title=Resizable+Canvas+&#8211;+&#8230;both+directions&srcURL=http://www.flexer.info" target="_blank" rel="nofollow"><img
src="http://www.flexer.info/wp-content/plugins/google-buzz-button-for-wordpress/images/google-buzz.png" alt="Google Buzz" /></a></div><p>In the previous articles in this series I explained how to create a horizontally and vertically resizable canvas. In this third article we will add the possibility to resize in both direction by dragging the right bottom corner.</p>
<p>What we will do:</p>
<ol>
<li>add the new UI control (the right bottom button)</li>
<li>create the necessary events for it</li>
<li>create CSS &#038; skin</li>
</ol>
<p>Because we already have both properties for horizontal and vertical resize we will use them. So inside each setter (horizontalResizable and verticalResizable) we will add our new button not before checking if it already exists.</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">// if the right-bottom button is already added</span>
<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">!</span>_bothEdges<span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#123;</span>
    <span style="color: #808080; font-style: italic;">// we add the right bottom button</span>
    _bothEdges = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">Button</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
    <span style="color: #808080; font-style: italic;">// no label</span>
    _bothEdges.<span style="color: #006600;">label</span> = <span style="color: #ff0000;">&quot;&quot;</span>;
    <span style="color: #808080; font-style: italic;">// no tooltip</span>
    _bothEdges.<span style="color: #006600;">toolTip</span> = <span style="color: #000000; font-weight: bold;">null</span>;
    _bothEdges.<span style="color: #0066CC;">tabEnabled</span> = <span style="color: #000000; font-weight: bold;">false</span>;
    _bothEdges.<span style="color: #0066CC;">setStyle</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;right&quot;</span>, <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span>;
    _bothEdges.<span style="color: #0066CC;">setStyle</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;bottom&quot;</span>,<span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span>;
    _bothEdges.<span style="color: #0066CC;">height</span> = <span style="color: #cc66cc;">12</span>;
    _bothEdges.<span style="color: #0066CC;">width</span> = <span style="color: #cc66cc;">12</span>;
    <span style="color: #808080; font-style: italic;">// set its style</span>
    <span style="color: #808080; font-style: italic;">// in this style we set the skin to not show anything</span>
    _bothEdges.<span style="color: #006600;">styleName</span> = <span style="color: #ff0000;">&quot;canvasBothEdges&quot;</span>;
&nbsp;
    <span style="color: #808080; font-style: italic;">// if the canvas is only horizontally resizable</span>
    <span style="color: #808080; font-style: italic;">// we use the same events and handlers like in that case</span>
    _bothEdges.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>MouseEvent.<span style="color: #006600;">MOUSE_OVER</span>, 
            handleBothResizeOver, <span style="color: #000000; font-weight: bold;">false</span>, <span style="color: #cc66cc;">0</span> ,<span style="color: #000000; font-weight: bold;">true</span><span style="color: #66cc66;">&#41;</span>;
    _bothEdges.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>MouseEvent.<span style="color: #006600;">MOUSE_MOVE</span>, 
            handleBothResizeOver, <span style="color: #000000; font-weight: bold;">false</span>, <span style="color: #cc66cc;">0</span> ,<span style="color: #000000; font-weight: bold;">true</span><span style="color: #66cc66;">&#41;</span>;
    _bothEdges.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>MouseEvent.<span style="color: #006600;">MOUSE_OUT</span>, 
            handleResizeOut, <span style="color: #000000; font-weight: bold;">false</span>, <span style="color: #cc66cc;">0</span> ,<span style="color: #000000; font-weight: bold;">true</span><span style="color: #66cc66;">&#41;</span>;
    _bothEdges.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>MouseEvent.<span style="color: #006600;">MOUSE_DOWN</span>, 
            handleBothDragStart, <span style="color: #000000; font-weight: bold;">false</span>, <span style="color: #cc66cc;">0</span> ,<span style="color: #000000; font-weight: bold;">true</span><span style="color: #66cc66;">&#41;</span>;
    _bothEdges.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>Event.<span style="color: #006600;">ENTER_FRAME</span>, 
            handleBothDragMove, <span style="color: #000000; font-weight: bold;">false</span>, <span style="color: #cc66cc;">0</span> ,<span style="color: #000000; font-weight: bold;">true</span><span style="color: #66cc66;">&#41;</span>;
    _bothEdges.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>MouseEvent.<span style="color: #006600;">MOUSE_UP</span>, 
            handleDragStop, <span style="color: #000000; font-weight: bold;">false</span>, <span style="color: #cc66cc;">0</span> ,<span style="color: #000000; font-weight: bold;">true</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
    addChild<span style="color: #66cc66;">&#40;</span>_bothEdges<span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>After adding all those we have to remove the event handlers in case we set it not resizable (in both setters).</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">// we remove the events for the right bottom corner (button)	</span>
<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>_bothEdges<span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#123;</span>
    <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>_bothEdges.<span style="color: #006600;">hasEventListener</span><span style="color: #66cc66;">&#40;</span>MouseEvent.<span style="color: #006600;">MOUSE_OVER</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
        _bothEdges.<span style="color: #006600;">removeEventListener</span><span style="color: #66cc66;">&#40;</span>MouseEvent.<span style="color: #006600;">MOUSE_OVER</span>, 
                handleBothResizeOver<span style="color: #66cc66;">&#41;</span>;
    <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>_bothEdges.<span style="color: #006600;">hasEventListener</span><span style="color: #66cc66;">&#40;</span>MouseEvent.<span style="color: #006600;">MOUSE_OUT</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
        _bothEdges.<span style="color: #006600;">removeEventListener</span><span style="color: #66cc66;">&#40;</span>MouseEvent.<span style="color: #006600;">MOUSE_OUT</span>, 
                handleResizeOut<span style="color: #66cc66;">&#41;</span>;
    <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>_bothEdges.<span style="color: #006600;">hasEventListener</span><span style="color: #66cc66;">&#40;</span>MouseEvent.<span style="color: #006600;">MOUSE_DOWN</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
        _bothEdges.<span style="color: #006600;">removeEventListener</span><span style="color: #66cc66;">&#40;</span>MouseEvent.<span style="color: #006600;">MOUSE_DOWN</span>, 
                handleBothDragStart<span style="color: #66cc66;">&#41;</span>;
    <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>_bothEdges.<span style="color: #006600;">hasEventListener</span><span style="color: #66cc66;">&#40;</span>MouseEvent.<span style="color: #006600;">MOUSE_UP</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
        _bothEdges.<span style="color: #006600;">removeEventListener</span><span style="color: #66cc66;">&#40;</span>MouseEvent.<span style="color: #006600;">MOUSE_UP</span>, 
                handleDragStop<span style="color: #66cc66;">&#41;</span>;
    <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>_bothEdges.<span style="color: #006600;">hasEventListener</span><span style="color: #66cc66;">&#40;</span>Event.<span style="color: #006600;">ENTER_FRAME</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
        _bothEdges.<span style="color: #006600;">removeEventListener</span><span style="color: #66cc66;">&#40;</span>Event.<span style="color: #006600;">ENTER_FRAME</span>, 
                handleBothDragMove<span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>We add three new event handlers:</p>
<ul class="ul">
<li><strong>handleBothResizeOver</strong> &#8211; used just to display the cursor</li>
<li><strong>handleBothDragStart</strong> &#8211; if it is resizable in both directions we save the initial position</li>
<li><strong>handleBothDragMove</strong> &#8211; this will resize the canvas</li>
</ul>
<h4>handleBothResizeOver</h4>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">// event handler to show the resize cursor</span>
<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> handleBothResizeOver<span style="color: #66cc66;">&#40;</span>event:MouseEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
<span style="color: #66cc66;">&#123;</span>
    <span style="color: #808080; font-style: italic;">// check if we already have the resize cursor set</span>
    <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>_currentCursorId == -<span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span>
        _currentCursorId = 
                CursorManager.<span style="color: #006600;">setCursor</span><span style="color: #66cc66;">&#40;</span>_cResizeCursor,<span style="color: #cc66cc;">2</span>,-<span style="color: #cc66cc;">10</span>,-<span style="color: #cc66cc;">10</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<h4>handleBothDragStart</h4>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">// event handler to start the drag</span>
<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> handleBothDragStart<span style="color: #66cc66;">&#40;</span>event:MouseEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
<span style="color: #66cc66;">&#123;</span>
    <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>_isResizableHorizontally<span style="color: #66cc66;">&#41;</span>
    <span style="color: #66cc66;">&#123;</span>
        _dragHStarted = <span style="color: #000000; font-weight: bold;">true</span>;
        <span style="color: #808080; font-style: italic;">// we save the initial position and width</span>
        _dragStartHPosition = <span style="color: #0066CC;">stage</span>.<span style="color: #006600;">mouseX</span>;
        _dragLastWidth = <span style="color: #0066CC;">width</span>;
    <span style="color: #66cc66;">&#125;</span>
    <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>_isResizableVertically<span style="color: #66cc66;">&#41;</span>
    <span style="color: #66cc66;">&#123;</span>
        _dragVStarted = <span style="color: #000000; font-weight: bold;">true</span>;
        <span style="color: #808080; font-style: italic;">// we save the initial position and width</span>
        _dragStartVPosition = <span style="color: #0066CC;">stage</span>.<span style="color: #006600;">mouseY</span>;
        _dragLastHeight = <span style="color: #0066CC;">height</span>;
    <span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<h4>handleBothDragMove</h4>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">// event handler for real rezise and other important stuff</span>
<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> handleBothDragMove<span style="color: #66cc66;">&#40;</span>event:Event<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
<span style="color: #66cc66;">&#123;</span>
    <span style="color: #808080; font-style: italic;">// we put the right-bottom always on the top of the other children</span>
    <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>getChildIndex<span style="color: #66cc66;">&#40;</span>_bothEdges<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&lt;</span> numChildren-<span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span>
    setChildIndex<span style="color: #66cc66;">&#40;</span>_bothEdges,numChildren-<span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span>;
    <span style="color: #808080; font-style: italic;">// we add the event to stop the drag also on the stage</span>
    <span style="color: #808080; font-style: italic;">// we cannot add this event in set resizable because the</span>
    <span style="color: #808080; font-style: italic;">// stage is not created because set resizable is done at</span>
    <span style="color: #808080; font-style: italic;">// constructor time and stage is set after adding our</span>
    <span style="color: #808080; font-style: italic;">// canvas to the application</span>
    <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">stage</span> <span style="color: #66cc66;">!</span>= <span style="color: #000000; font-weight: bold;">null</span> <span style="color: #66cc66;">&amp;&amp;</span> <span style="color: #66cc66;">!</span><span style="color: #0066CC;">stage</span>.<span style="color: #006600;">hasEventListener</span><span style="color: #66cc66;">&#40;</span>MouseEvent.<span style="color: #006600;">MOUSE_UP</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
        <span style="color: #0066CC;">stage</span>.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>MouseEvent.<span style="color: #006600;">MOUSE_UP</span>, 
                handleDragStop, <span style="color: #000000; font-weight: bold;">false</span>, <span style="color: #cc66cc;">0</span> ,<span style="color: #000000; font-weight: bold;">true</span><span style="color: #66cc66;">&#41;</span>;
    <span style="color: #808080; font-style: italic;">// we resize our canvas only if drag started</span>
    <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>_dragHStarted<span style="color: #66cc66;">&#41;</span>
    <span style="color: #66cc66;">&#123;</span>
        <span style="color: #808080; font-style: italic;">// get the amount of movement</span>
        <span style="color: #808080; font-style: italic;">// difference between the current mouse x position relative </span>
        <span style="color: #808080; font-style: italic;">// to the stage and the saved position at mouse down event</span>
        <span style="color: #000000; font-weight: bold;">var</span> hMovement:<span style="color: #0066CC;">int</span> = <span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">stage</span>.<span style="color: #006600;">mouseX</span> - _dragStartHPosition<span style="color: #66cc66;">&#41;</span>;
        <span style="color: #808080; font-style: italic;">// if the canvas is positioned relative to the center</span>
        <span style="color: #808080; font-style: italic;">// the width will be changed in both left and right directions</span>
        <span style="color: #808080; font-style: italic;">// so we will double the movement</span>
        <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">getStyle</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;horizontalCenter&quot;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">!</span>= <span style="color: #0066CC;">undefined</span><span style="color: #66cc66;">&#41;</span>
        <span style="color: #66cc66;">&#123;</span>
            hMovement <span style="color: #66cc66;">*</span>= <span style="color: #cc66cc;">2</span>;
        <span style="color: #66cc66;">&#125;</span>
        <span style="color: #808080; font-style: italic;">// if we move to the left</span>
        <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>hMovement <span style="color: #66cc66;">&lt;</span>= <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span>
        <span style="color: #66cc66;">&#123;</span>
            <span style="color: #808080; font-style: italic;">// check not to pass the minimum width</span>
            <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>minWidth <span style="color: #66cc66;">&lt;</span> _dragLastWidth + hMovement<span style="color: #66cc66;">&#41;</span>
                <span style="color: #0066CC;">width</span> = _dragLastWidth + hMovement;
            <span style="color: #b1b100;">else</span>
                <span style="color: #0066CC;">width</span> = minWidth;
        <span style="color: #66cc66;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #66cc66;">&#123;</span>
            <span style="color: #808080; font-style: italic;">// check not to pass the maximum width</span>
            <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>maxWidth <span style="color: #66cc66;">&gt;</span> _dragLastWidth + hMovement<span style="color: #66cc66;">&#41;</span>
                <span style="color: #0066CC;">width</span> = _dragLastWidth + hMovement;
            <span style="color: #b1b100;">else</span>
                <span style="color: #0066CC;">width</span> = maxWidth;
        <span style="color: #66cc66;">&#125;</span>
    <span style="color: #66cc66;">&#125;</span>
    <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>_dragVStarted<span style="color: #66cc66;">&#41;</span>
    <span style="color: #66cc66;">&#123;</span>
        <span style="color: #808080; font-style: italic;">// get the amount of movement</span>
        <span style="color: #808080; font-style: italic;">// difference between the current mouse x position relative </span>
        <span style="color: #808080; font-style: italic;">// to the stage and the saved position at mouse down event</span>
        <span style="color: #000000; font-weight: bold;">var</span> vMovement:<span style="color: #0066CC;">int</span> = <span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">stage</span>.<span style="color: #006600;">mouseY</span> - _dragStartVPosition<span style="color: #66cc66;">&#41;</span>;
        <span style="color: #808080; font-style: italic;">// if the canvas is positioned relative to the center</span>
        <span style="color: #808080; font-style: italic;">// the width will be changed in both left and right directions</span>
        <span style="color: #808080; font-style: italic;">// so we will double the movement</span>
        <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">getStyle</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;veticalCenter&quot;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">!</span>= <span style="color: #0066CC;">undefined</span><span style="color: #66cc66;">&#41;</span>
        <span style="color: #66cc66;">&#123;</span>
            vMovement <span style="color: #66cc66;">*</span>= <span style="color: #cc66cc;">2</span>;
        <span style="color: #66cc66;">&#125;</span>
        <span style="color: #808080; font-style: italic;">// if we move to the left</span>
        <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>vMovement <span style="color: #66cc66;">&lt;</span>= <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span>
        <span style="color: #66cc66;">&#123;</span>
            <span style="color: #808080; font-style: italic;">// check not to pass the minimum width</span>
            <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>minHeight <span style="color: #66cc66;">&lt;</span> _dragLastHeight + vMovement<span style="color: #66cc66;">&#41;</span>
                <span style="color: #0066CC;">height</span> = _dragLastHeight + vMovement;
            <span style="color: #b1b100;">else</span>
                <span style="color: #0066CC;">height</span> = minHeight;
        <span style="color: #66cc66;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #66cc66;">&#123;</span>
            <span style="color: #808080; font-style: italic;">// check not to pass the maximum width</span>
            <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>maxHeight <span style="color: #66cc66;">&gt;</span> _dragLastHeight + vMovement<span style="color: #66cc66;">&#41;</span>
                <span style="color: #0066CC;">height</span> = _dragLastHeight + vMovement;
            <span style="color: #b1b100;">else</span>
                <span style="color: #0066CC;">height</span> = maxHeight;
        <span style="color: #66cc66;">&#125;</span>
    <span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>We added also a new class in CSS, a new skin and a new icon for the right bottom button. These are the changes made to have the resize functionality in both directions. Now, enjoy the working application.<br />

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_resizablecanvasapplication_2099754764"
			class="flashmovie"
			width="450"
			height="300">
	<param name="movie" value="/wp-content/uploads/2008/05/resizablecanvasapplication.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="/wp-content/uploads/2008/05/resizablecanvasapplication.swf"
			name="fm_resizablecanvasapplication_2099754764"
			width="450"
			height="300">
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
 <div class='series_links'><a href='http://www.flexer.info/2008/04/29/resizable-canvas-and-vertically/' title='Resizable Canvas &#8211; &#8230;and Vertically'>Previous in series</a> </div>]]></content:encoded>
			<wfw:commentRss>http://www.flexer.info/2008/05/19/resizable-canvas-both-directions/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How To Build a Download Application in Flex</title>
		<link>http://www.flexer.info/2008/05/12/how-to-build-a-download-application-in-flex/</link>
		<comments>http://www.flexer.info/2008/05/12/how-to-build-a-download-application-in-flex/#comments</comments>
		<pubDate>Mon, 12 May 2008 12:41:40 +0000</pubDate>
		<dc:creator>Andrei Ionescu</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Events]]></category>
		<category><![CDATA[How to]]></category>
		<category><![CDATA[MXML]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web Service]]></category>
		<category><![CDATA[xml]]></category>
		<category><![CDATA[application]]></category>
		<category><![CDATA[download]]></category>
		<category><![CDATA[drag]]></category>
		<category><![CDATA[drop]]></category>
		<category><![CDATA[FileReference]]></category>
		<category><![CDATA[HTTPService]]></category>
		<category><![CDATA[URLRequest]]></category>

		<guid isPermaLink="false">http://www.flexer.info/?p=144</guid>
		<description><![CDATA[In this article I&#8217;ll show the same application I presented at FlexCamp Bucharest Romania 2008 &#8211; the video from the conference is available here and although it is in Romanian it might be useful. In the presentation I&#8217;m showing the power of Flex: doing complex applications with a few lines of codding. 
With this article [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-right: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.flexer.info%2F2008%2F05%2F12%2Fhow-to-build-a-download-application-in-flex%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.flexer.info%2F2008%2F05%2F12%2Fhow-to-build-a-download-application-in-flex%2F" height="61" width="51" /></a></div><div style="float: right; margin-right: 10px"><a class="google_buzz"  
href="http://www.google.com/reader/link?url=http://www.flexer.info/2008/05/12/how-to-build-a-download-application-in-flex/&title=How+To+Build+a+Download+Application+in+Flex&srcURL=http://www.flexer.info" target="_blank" rel="nofollow"><img
src="http://www.flexer.info/wp-content/plugins/google-buzz-button-for-wordpress/images/google-buzz.png" alt="Google Buzz" /></a></div><p>In this article I&#8217;ll show the same application I presented at <a href="http://myadobe.ro/2008/04/11/flex-camp-aprilie-2008-agenda-a-fost-stabilita/" target="_blank">FlexCamp Bucharest Romania 2008</a> &#8211; the video from the conference is available <a href="http://my.adobe.acrobat.com/p90199006/" target="_blank">here</a> and although it is in Romanian it might be useful. In the presentation I&#8217;m showing the power of Flex: doing complex applications with a few lines of codding. </p>
<p>With this article we are just starting because everything is explained in the powerpoint presentation  and by the comments inside the source code found at the end of this article.</p>
<p>The application is simple &#8211; only one mxml file &#8211; and we will study:</p>
<ul class="ul">
<li>Multiple Drag and drop (<strong>events</strong>)</li>
<li><strong>HTTPService</strong></li>
<li><strong>FileReference</strong></li>
<li><strong>URLRequest</strong></li>
</ul>
<p>On the server-side:</p>
<ul class="ul">
<li><strong>dir.php</strong> &#8211; browsing (http service) – no parameters needed – returns a simple XML</li>
<li><strong>download.php</strong> &#8211; download (url request) – array with the paths that will be included in archive as parameters – returns an archive (tgz)</li>
<li><strong>archive.php</strong> &#8211; class to create arhives</li>
</ul>
<p>On the client-side:</p>
<ul class="ul">
<li>Tree &rArr; HTTPService &rArr; dir.php &rArr; HTTPService &rArr; Tree</li>
<li>Refresh &rArr; HTTPService &rArr; dir.php &rArr; HTTPService &rArr; Tree</li>
<li>Download &rArr; List &rArr; URLRequest &rArr; FileReference &rArr; file download</li>
</ul>
<p>We are using multiple selection and dragging so you can drag more that one item from the list. Also the delete key erases the selected items from the list on the right. You can start over by pressing refresh button.</p>
<p>This is the start of it and you can get into it more and more reading the powerpoints and trying the source codes. All this can be downloaded from the end of this article. </p>
<p>Working example is bellow:<br />

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_draganddrop_459347994"
			class="flashmovie"
			width="439"
			height="271">
	<param name="movie" value="/wp-content/uploads/2008/05/draganddrop.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="/wp-content/uploads/2008/05/draganddrop.swf"
			name="fm_draganddrop_459347994"
			width="439"
			height="271">
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object><br />
What can be added in the future:</p>
<ol>
<li>download progress with cancellation possibility</li>
<li>upload functionality</li>
<li>user account functionality</li>
</ol>
<p>The last two points are more difficult because it involves some work on the server-side but is doable.</p>
<p>I&#8217;ve posted also the whole flex source code because it is easier to follow the article and study the code in the same page.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
</pre></td><td class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #66cc66;">&lt;</span>?<span style="color: #0066CC;">xml</span> <span style="color: #0066CC;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> encoding=<span style="color: #ff0000;">&quot;utf-8&quot;</span>?<span style="color: #66cc66;">&gt;</span>
<span style="color: #66cc66;">&lt;</span>mx:Application xmlns:mx=<span style="color: #ff0000;">&quot;http://www.adobe.com/2006/mxml&quot;</span> layout=<span style="color: #ff0000;">&quot;absolute&quot;</span> 
    <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">&quot;439&quot;</span> creationComplete=<span style="color: #ff0000;">&quot;init()&quot;</span> <span style="color: #0066CC;">height</span>=<span style="color: #ff0000;">&quot;271&quot;</span><span style="color: #66cc66;">&gt;</span>
    <span style="color: #66cc66;">&lt;</span>mx:HTTPService id=<span style="color: #ff0000;">&quot;dir&quot;</span> <span style="color: #0066CC;">url</span>=<span style="color: #ff0000;">&quot;{SERVER_URL}dir.php&quot;</span> resultFormat=<span style="color: #ff0000;">&quot;e4x&quot;</span> <span style="color: #66cc66;">/&gt;</span>
    <span style="color: #66cc66;">&lt;</span>mx:Tree id=<span style="color: #ff0000;">&quot;leftTree&quot;</span> x=<span style="color: #ff0000;">&quot;10&quot;</span> y=<span style="color: #ff0000;">&quot;10&quot;</span> <span style="color: #0066CC;">height</span>=<span style="color: #ff0000;">&quot;250&quot;</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">&quot;204&quot;</span> 
        dataProvider=<span style="color: #ff0000;">&quot;{dir.lastResult}&quot;</span> labelField=<span style="color: #ff0000;">&quot;@name&quot;</span> showRoot=<span style="color: #ff0000;">&quot;false&quot;</span> 
        dragEnabled=<span style="color: #ff0000;">&quot;true&quot;</span> dropEnabled=<span style="color: #ff0000;">&quot;false&quot;</span> allowMultipleSelection=<span style="color: #ff0000;">&quot;true&quot;</span> 
        click=<span style="color: #ff0000;">&quot;showThumb(event)&quot;</span><span style="color: #66cc66;">/&gt;</span>
    <span style="color: #66cc66;">&lt;</span>mx:<span style="color: #0066CC;">List</span> id=<span style="color: #ff0000;">&quot;downloadList&quot;</span> x=<span style="color: #ff0000;">&quot;222&quot;</span> y=<span style="color: #ff0000;">&quot;10&quot;</span> <span style="color: #0066CC;">height</span>=<span style="color: #ff0000;">&quot;135&quot;</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">&quot;207&quot;</span> 
        allowMultipleSelection=<span style="color: #ff0000;">&quot;true&quot;</span> dataProvider=<span style="color: #ff0000;">&quot;{fileListProvider}&quot;</span> 
        dragEnter=<span style="color: #ff0000;">&quot;handleDragEnter(event)&quot;</span> dragOver=<span style="color: #ff0000;">&quot;handleDragOver(event)&quot;</span> 
        dragDrop=<span style="color: #ff0000;">&quot;handleDragDrop(event)&quot;</span> dragExit=<span style="color: #ff0000;">&quot;handleDragExit(event)&quot;</span> 
        click=<span style="color: #ff0000;">&quot;showThumb(event)&quot;</span> keyUp=<span style="color: #ff0000;">&quot;handleKeyUp(event)&quot;</span><span style="color: #66cc66;">/&gt;</span>
    <span style="color: #66cc66;">&lt;</span>mx:<span style="color: #0066CC;">Button</span> id=<span style="color: #ff0000;">&quot;downloadButton&quot;</span> x=<span style="color: #ff0000;">&quot;347&quot;</span> y=<span style="color: #ff0000;">&quot;153&quot;</span> label=<span style="color: #ff0000;">&quot;Download&quot;</span> 
        <span style="color: #0066CC;">enabled</span>=<span style="color: #ff0000;">&quot;false&quot;</span> click=<span style="color: #ff0000;">&quot;initializeDownload(event)&quot;</span> <span style="color: #66cc66;">/&gt;</span>
    <span style="color: #66cc66;">&lt;</span>mx:<span style="color: #0066CC;">Button</span> id=<span style="color: #ff0000;">&quot;refreshButton&quot;</span> x=<span style="color: #ff0000;">&quot;347&quot;</span> y=<span style="color: #ff0000;">&quot;239&quot;</span> label=<span style="color: #ff0000;">&quot;Refresh&quot;</span> 
        click=<span style="color: #ff0000;">&quot;refresh(event)&quot;</span>  <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">&quot;82&quot;</span><span style="color: #66cc66;">/&gt;</span>
    <span style="color: #66cc66;">&lt;</span>mx:Canvas id=<span style="color: #ff0000;">&quot;imageHolder&quot;</span> x=<span style="color: #ff0000;">&quot;222&quot;</span> y=<span style="color: #ff0000;">&quot;153&quot;</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">&quot;117&quot;</span> <span style="color: #0066CC;">height</span>=<span style="color: #ff0000;">&quot;108&quot;</span><span style="color: #66cc66;">&gt;</span>
        <span style="color: #66cc66;">&lt;</span>mx:Image id=<span style="color: #ff0000;">&quot;imageThumb&quot;</span> x=<span style="color: #ff0000;">&quot;0&quot;</span> y=<span style="color: #ff0000;">&quot;0&quot;</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">&quot;117&quot;</span> <span style="color: #0066CC;">height</span>=<span style="color: #ff0000;">&quot;108&quot;</span> 
            source=<span style="color: #ff0000;">&quot;{currentPhotoPath}&quot;</span><span style="color: #66cc66;">/&gt;</span>
    <span style="color: #66cc66;">&lt;/</span>mx:Canvas<span style="color: #66cc66;">&gt;</span>
    <span style="color: #66cc66;">&lt;</span>mx:Script<span style="color: #66cc66;">&gt;</span>
        <span style="color: #66cc66;">&lt;!</span><span style="color: #66cc66;">&#91;</span>CDATA<span style="color: #66cc66;">&#91;</span>
            <span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">messaging</span>.<span style="color: #006600;">channels</span>.<span style="color: #006600;">StreamingAMFChannel</span>;
            <span style="color: #808080; font-style: italic;">/* File downloading application
               Drag and drop between two different controlers: tree and list */</span>
&nbsp;
            <span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">rpc</span>.<span style="color: #006600;">events</span>.<span style="color: #006600;">ResultEvent</span>;
            <span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">collections</span>.<span style="color: #006600;">ArrayCollection</span>;
            <span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">controls</span>.<span style="color: #006600;">listClasses</span>.<span style="color: #006600;">ListBase</span>;
            <span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">core</span>.<span style="color: #006600;">UIComponent</span>;
            <span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">managers</span>.<span style="color: #006600;">DragManager</span>;
            <span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">core</span>.<span style="color: #006600;">DragSource</span>;
            <span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">controls</span>.<span style="color: #0066CC;">List</span>;
            <span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">events</span>.<span style="color: #006600;">DragEvent</span>;
&nbsp;
            <span style="color: #808080; font-style: italic;">// internet - on flexer</span>
            <span style="color: #0066CC;">public</span> const SERVER_URL:<span style="color: #0066CC;">String</span> = 
                <span style="color: #ff0000;">&quot;http://www.flexer.info/wp-content/uploads/2008/05/&quot;</span>;
&nbsp;
            <span style="color: #808080; font-style: italic;">// bindable variable used for the list</span>
            <span style="color: #66cc66;">&#91;</span>Bindable<span style="color: #66cc66;">&#93;</span>
            <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">var</span> fileListProvider:ArrayCollection = <span style="color: #000000; font-weight: bold;">new</span> ArrayCollection<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
            <span style="color: #808080; font-style: italic;">// bindable variable used for thumbnail</span>
            <span style="color: #66cc66;">&#91;</span>Bindable<span style="color: #66cc66;">&#93;</span>
            <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">var</span> currentPhotoPath:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">&quot;&quot;</span>;
&nbsp;
            <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">var</span> fRef:FileReference = <span style="color: #000000; font-weight: bold;">new</span> FileReference<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
            <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> init<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
            <span style="color: #66cc66;">&#123;</span>
                <span style="color: #808080; font-style: italic;">/* initialization function */</span>
&nbsp;
                <span style="color: #808080; font-style: italic;">// file reference events - used for debug purposes</span>
                fRef.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>Event.<span style="color: #006600;">CANCEL</span>, doEvent<span style="color: #66cc66;">&#41;</span>;
                fRef.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>Event.<span style="color: #006600;">COMPLETE</span>, doEvent<span style="color: #66cc66;">&#41;</span>;
                fRef.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>Event.<span style="color: #006600;">OPEN</span>, doEvent<span style="color: #66cc66;">&#41;</span>;
                fRef.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>Event.<span style="color: #006600;">SELECT</span>, doEvent<span style="color: #66cc66;">&#41;</span>;
                fRef.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>HTTPStatusEvent.<span style="color: #006600;">HTTP_STATUS</span>, doEvent<span style="color: #66cc66;">&#41;</span>;
                fRef.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>IOErrorEvent.<span style="color: #006600;">IO_ERROR</span>, doEvent<span style="color: #66cc66;">&#41;</span>;
                fRef.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>ProgressEvent.<span style="color: #006600;">PROGRESS</span>, doEvent<span style="color: #66cc66;">&#41;</span>;
                fRef.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>SecurityErrorEvent.<span style="color: #006600;">SECURITY_ERROR</span>, doEvent<span style="color: #66cc66;">&#41;</span>;				
&nbsp;
                <span style="color: #808080; font-style: italic;">// getting folder content</span>
                dir.<span style="color: #0066CC;">send</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
            <span style="color: #66cc66;">&#125;</span>
&nbsp;
            <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> handleDragEnter<span style="color: #66cc66;">&#40;</span>event:DragEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
            <span style="color: #66cc66;">&#123;</span>
                <span style="color: #808080; font-style: italic;">/* this function validates the drop */</span>
&nbsp;
                <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>event.<span style="color: #006600;">dragInitiator</span> is Tree<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
                    <span style="color: #000000; font-weight: bold;">var</span> ds:DragSource = event.<span style="color: #006600;">dragSource</span>;
                    <span style="color: #808080; font-style: italic;">// check if the format is what we need - treeItems</span>
                    <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">!</span>ds.<span style="color: #006600;">hasFormat</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;treeItems&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> 
                        <span style="color: #b1b100;">return</span>;
                    <span style="color: #000000; font-weight: bold;">var</span> items:<span style="color: #0066CC;">Array</span> = ds.<span style="color: #006600;">dataForFormat</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;treeItems&quot;</span><span style="color: #66cc66;">&#41;</span> as <span style="color: #0066CC;">Array</span>;
                    <span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">var</span> i:<span style="color: #0066CC;">Number</span>=<span style="color: #cc66cc;">0</span>; i <span style="color: #66cc66;">&lt;</span> items.<span style="color: #0066CC;">length</span>; i++<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
                        <span style="color: #000000; font-weight: bold;">var</span> item:<span style="color: #0066CC;">XML</span> = <span style="color: #0066CC;">XML</span><span style="color: #66cc66;">&#40;</span>items<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>;
                        <span style="color: #808080; font-style: italic;">// we want only files to be dragable</span>
                        <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>item.<span style="color: #66cc66;">@</span><span style="color: #0066CC;">type</span> <span style="color: #66cc66;">!</span>= <span style="color: #ff0000;">&quot;file&quot;</span><span style="color: #66cc66;">&#41;</span> 
                            <span style="color: #b1b100;">return</span>; 
                    <span style="color: #66cc66;">&#125;</span>   
&nbsp;
                    <span style="color: #808080; font-style: italic;">// check for the item to be unique</span>
                    <span style="color: #000000; font-weight: bold;">var</span> paths:ArrayCollection = 
                        downloadList.<span style="color: #006600;">dataProvider</span> as ArrayCollection;
                    <span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">var</span> j:<span style="color: #0066CC;">Number</span>=<span style="color: #cc66cc;">0</span>; j <span style="color: #66cc66;">&lt;</span> paths.<span style="color: #0066CC;">length</span>; j++<span style="color: #66cc66;">&#41;</span>
                    <span style="color: #66cc66;">&#123;</span>
                        <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>item.<span style="color: #66cc66;">@</span>path == paths<span style="color: #66cc66;">&#91;</span>j<span style="color: #66cc66;">&#93;</span>.<span style="color: #006600;">path</span>.<span style="color: #0066CC;">toString</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #b1b100;">return</span>;
                    <span style="color: #66cc66;">&#125;</span>
                <span style="color: #66cc66;">&#125;</span>
&nbsp;
                <span style="color: #808080; font-style: italic;">// accept the drop</span>
                DragManager.<span style="color: #006600;">acceptDragDrop</span><span style="color: #66cc66;">&#40;</span>UIComponent<span style="color: #66cc66;">&#40;</span>event.<span style="color: #006600;">currentTarget</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
            <span style="color: #66cc66;">&#125;</span>
&nbsp;
            <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> handleDragOver<span style="color: #66cc66;">&#40;</span>event:DragEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
            <span style="color: #66cc66;">&#123;</span>
                <span style="color: #808080; font-style: italic;">/* this function shows feedback to the user */</span>
&nbsp;
                <span style="color: #808080; font-style: italic;">// show feedback icon</span>
                DragManager.<span style="color: #006600;">showFeedback</span><span style="color: #66cc66;">&#40;</span>DragManager.<span style="color: #0066CC;">COPY</span><span style="color: #66cc66;">&#41;</span>;
            <span style="color: #66cc66;">&#125;</span>
&nbsp;
            <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> handleDragDrop<span style="color: #66cc66;">&#40;</span>event:DragEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
            <span style="color: #66cc66;">&#123;</span>
                <span style="color: #808080; font-style: italic;">/* this function adds new items to the list */</span>
&nbsp;
                <span style="color: #808080; font-style: italic;">// getting source</span>
                <span style="color: #000000; font-weight: bold;">var</span> ds:DragSource = event.<span style="color: #006600;">dragSource</span>;
                <span style="color: #808080; font-style: italic;">// getting target</span>
                <span style="color: #000000; font-weight: bold;">var</span> dropTarget:<span style="color: #0066CC;">List</span> = <span style="color: #0066CC;">List</span><span style="color: #66cc66;">&#40;</span>event.<span style="color: #006600;">currentTarget</span><span style="color: #66cc66;">&#41;</span>;
                <span style="color: #808080; font-style: italic;">// tempoaray array used to add items to list</span>
                <span style="color: #000000; font-weight: bold;">var</span> arr:<span style="color: #0066CC;">Array</span>;
&nbsp;
                <span style="color: #808080; font-style: italic;">// getting the nodes dragged </span>
                <span style="color: #808080; font-style: italic;">// multiple selection is allowed so we have arrays</span>
                <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>ds.<span style="color: #006600;">hasFormat</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;items&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
                    arr = ds.<span style="color: #006600;">dataForFormat</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;items&quot;</span><span style="color: #66cc66;">&#41;</span> as <span style="color: #0066CC;">Array</span>;
                <span style="color: #66cc66;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>ds.<span style="color: #006600;">hasFormat</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;treeItems&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
                    arr = ds.<span style="color: #006600;">dataForFormat</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;treeItems&quot;</span><span style="color: #66cc66;">&#41;</span> as <span style="color: #0066CC;">Array</span>;
                <span style="color: #66cc66;">&#125;</span>
&nbsp;
                <span style="color: #808080; font-style: italic;">// adding the dragged nodes to list</span>
                <span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">var</span> i:<span style="color: #0066CC;">Number</span>=<span style="color: #cc66cc;">0</span>; i <span style="color: #66cc66;">&lt;</span> arr.<span style="color: #0066CC;">length</span>; i++<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
                    <span style="color: #808080; font-style: italic;">// getting node</span>
                    <span style="color: #000000; font-weight: bold;">var</span> node:<span style="color: #0066CC;">XML</span> = <span style="color: #0066CC;">XML</span><span style="color: #66cc66;">&#40;</span>arr<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>;
                    <span style="color: #808080; font-style: italic;">// creating new list item</span>
                    <span style="color: #000000; font-weight: bold;">var</span> item:<span style="color: #0066CC;">Object</span> = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">Object</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
                    <span style="color: #808080; font-style: italic;">// setting item's properties</span>
                    item.<span style="color: #006600;">label</span> = node.<span style="color: #66cc66;">@</span><span style="color: #0066CC;">name</span>;
                    <span style="color: #808080; font-style: italic;">// we set path also which is needed for download</span>
                    item.<span style="color: #006600;">path</span> = node.<span style="color: #66cc66;">@</span>path;
                    <span style="color: #808080; font-style: italic;">// add to data provider</span>
                    fileListProvider.<span style="color: #006600;">addItem</span><span style="color: #66cc66;">&#40;</span>item<span style="color: #66cc66;">&#41;</span>;
                <span style="color: #66cc66;">&#125;</span>
                <span style="color: #808080; font-style: italic;">// finish drag</span>
                handleDragExit<span style="color: #66cc66;">&#40;</span>event<span style="color: #66cc66;">&#41;</span>;
            <span style="color: #66cc66;">&#125;</span>			
&nbsp;
            <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> handleDragExit<span style="color: #66cc66;">&#40;</span>event:DragEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
            <span style="color: #66cc66;">&#123;</span>
                <span style="color: #808080; font-style: italic;">/* this function finishes the drag and drop */</span>
&nbsp;
                <span style="color: #808080; font-style: italic;">// we hide the feedback</span>
                <span style="color: #000000; font-weight: bold;">var</span> dropTarget:ListBase=ListBase<span style="color: #66cc66;">&#40;</span>event.<span style="color: #006600;">currentTarget</span><span style="color: #66cc66;">&#41;</span>;
                dropTarget.<span style="color: #006600;">hideDropFeedback</span><span style="color: #66cc66;">&#40;</span>event<span style="color: #66cc66;">&#41;</span>;
                <span style="color: #808080; font-style: italic;">// we check the data provider to enable the download button</span>
                <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>dropTarget.<span style="color: #006600;">dataProvider</span>.<span style="color: #0066CC;">length</span> <span style="color: #66cc66;">&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span>
                    downloadButton.<span style="color: #0066CC;">enabled</span> = <span style="color: #000000; font-weight: bold;">true</span>;
            <span style="color: #66cc66;">&#125;</span>
&nbsp;
            <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> showThumb<span style="color: #66cc66;">&#40;</span>event:MouseEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
            <span style="color: #66cc66;">&#123;</span>
                <span style="color: #808080; font-style: italic;">/* this function shows the thumbnail 
                   used for both tree and list click events */</span>
&nbsp;
                <span style="color: #808080; font-style: italic;">// if click is on the tree</span>
                <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>event.<span style="color: #006600;">currentTarget</span>.<span style="color: #0066CC;">name</span> == <span style="color: #ff0000;">&quot;leftTree&quot;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
                    <span style="color: #808080; font-style: italic;">// folders cannot show thumbnail</span>
                    <span style="color: #808080; font-style: italic;">// other file types than images are automatically not shown </span>
                    <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>leftTree.<span style="color: #006600;">selectedItem</span>.<span style="color: #66cc66;">@</span><span style="color: #0066CC;">type</span> == <span style="color: #ff0000;">&quot;file&quot;</span><span style="color: #66cc66;">&#41;</span>
                        currentPhotoPath = SERVER_URL + leftTree.<span style="color: #006600;">selectedItem</span>.<span style="color: #66cc66;">@</span>path;
                    <span style="color: #b1b100;">else</span>
                        currentPhotoPath = <span style="color: #ff0000;">&quot;&quot;</span>;
                <span style="color: #808080; font-style: italic;">// if click is on the list</span>
                <span style="color: #66cc66;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>event.<span style="color: #006600;">currentTarget</span>.<span style="color: #0066CC;">name</span> == <span style="color: #ff0000;">&quot;downloadList&quot;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
                    currentPhotoPath = <span style="color: #66cc66;">&#40;</span>downloadList.<span style="color: #006600;">selectedItem</span> ? SERVER_URL + 
                                        downloadList.<span style="color: #006600;">selectedItem</span>.<span style="color: #006600;">path</span> : <span style="color: #ff0000;">&quot;&quot;</span><span style="color: #66cc66;">&#41;</span>;
                <span style="color: #66cc66;">&#125;</span>
            <span style="color: #66cc66;">&#125;</span>
&nbsp;
            <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> handleKeyUp<span style="color: #66cc66;">&#40;</span>event:KeyboardEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
            <span style="color: #66cc66;">&#123;</span>
                <span style="color: #808080; font-style: italic;">/* this function is used for deleting items from the list */</span>
&nbsp;
                <span style="color: #808080; font-style: italic;">// if we have pressed the DELETE key and </span>
                <span style="color: #808080; font-style: italic;">// also there is at least one item selected</span>
                <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>event.<span style="color: #006600;">keyCode</span> == Keyboard.<span style="color: #0066CC;">DELETE</span> <span style="color: #66cc66;">&amp;&amp;</span> 
                        downloadList.<span style="color: #006600;">selectedIndex</span> <span style="color: #66cc66;">&gt;</span> -<span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
                    <span style="color: #000000; font-weight: bold;">var</span> removeItems:<span style="color: #0066CC;">Array</span> = downloadList.<span style="color: #006600;">selectedIndices</span>;
                    <span style="color: #808080; font-style: italic;">// remove selected items</span>
                    <span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">var</span> i:<span style="color: #0066CC;">Number</span> = <span style="color: #cc66cc;">0</span>; i <span style="color: #66cc66;">&lt;</span> removeItems.<span style="color: #0066CC;">length</span>; i++<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
                        downloadList.<span style="color: #006600;">dataProvider</span>.<span style="color: #006600;">removeItemAt</span><span style="color: #66cc66;">&#40;</span>removeItems<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>;
                    <span style="color: #66cc66;">&#125;</span>
                    currentPhotoPath = <span style="color: #ff0000;">&quot;&quot;</span>;
                    <span style="color: #808080; font-style: italic;">// if the list is empty we disable the download button</span>
                    <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>downloadList.<span style="color: #006600;">dataProvider</span>.<span style="color: #0066CC;">length</span> <span style="color: #66cc66;">&lt;</span>= <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span>
                        downloadButton.<span style="color: #0066CC;">enabled</span> = <span style="color: #000000; font-weight: bold;">false</span>;
                <span style="color: #66cc66;">&#125;</span>
            <span style="color: #66cc66;">&#125;</span>
&nbsp;
            <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> initializeDownload<span style="color: #66cc66;">&#40;</span>event:MouseEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
            <span style="color: #66cc66;">&#123;</span>
                <span style="color: #808080; font-style: italic;">/* this function starts the download 
                   we use FileReference to download */</span>
&nbsp;
                <span style="color: #808080; font-style: italic;">// get the items dragged in the list</span>
                <span style="color: #000000; font-weight: bold;">var</span> paths:ArrayCollection = 
                    downloadList.<span style="color: #006600;">dataProvider</span> as ArrayCollection;
                <span style="color: #808080; font-style: italic;">// initialize the query/url string</span>
                <span style="color: #000000; font-weight: bold;">var</span> qStr:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">&quot;&quot;</span>;
                <span style="color: #808080; font-style: italic;">// compose the query/url string</span>
                <span style="color: #808080; font-style: italic;">// we are sending an array to the server</span>
                <span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">var</span> i:<span style="color: #0066CC;">int</span> = <span style="color: #cc66cc;">0</span>; i <span style="color: #66cc66;">&lt;</span> paths.<span style="color: #0066CC;">length</span>; i++<span style="color: #66cc66;">&#41;</span>
                    qStr += <span style="color: #ff0000;">&quot;&amp;name[]=&quot;</span>+escape<span style="color: #66cc66;">&#40;</span>paths<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>.<span style="color: #006600;">path</span>.<span style="color: #0066CC;">toString</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
                <span style="color: #808080; font-style: italic;">// get the file</span>
                <span style="color: #808080; font-style: italic;">// the file download.php on the server gets the array</span>
                <span style="color: #808080; font-style: italic;">// and in the memory creates an tgz archive</span>
                <span style="color: #808080; font-style: italic;">// and sends it back as being a file (using http headers)</span>
                <span style="color: #808080; font-style: italic;">// we are using FileReference for this</span>
                fRef.<span style="color: #006600;">download</span><span style="color: #66cc66;">&#40;</span>
                    <span style="color: #000000; font-weight: bold;">new</span> URLRequest<span style="color: #66cc66;">&#40;</span>SERVER_URL + <span style="color: #ff0000;">&quot;download.php?&quot;</span> + qStr<span style="color: #66cc66;">&#41;</span>,
                    <span style="color: #ff0000;">&quot;archive.tgz&quot;</span><span style="color: #66cc66;">&#41;</span>;
            <span style="color: #66cc66;">&#125;</span>
&nbsp;
            <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> doEvent<span style="color: #66cc66;">&#40;</span>evt:Event<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span>
                <span style="color: #808080; font-style: italic;">/* Function is displaying events reached when downloading 
                   For debug purposes */</span>
&nbsp;
                <span style="color: #000000; font-weight: bold;">var</span> fr:FileReference = evt.<span style="color: #006600;">currentTarget</span> as FileReference;   
                <span style="color: #808080; font-style: italic;">// for debug purposes */</span>
                <span style="color: #808080; font-style: italic;">//trace(&quot;type:&quot;+evt.type+&quot;, eventString:&quot;+evt.toString()); </span>
                <span style="color: #808080; font-style: italic;">//trace(fr.creationDate);</span>
                <span style="color: #808080; font-style: italic;">//trace(fr.creator);</span>
                <span style="color: #808080; font-style: italic;">//trace(fr.modificationDate);</span>
                <span style="color: #808080; font-style: italic;">//trace(fr.name);</span>
                <span style="color: #808080; font-style: italic;">//trace(fr.size);</span>
                <span style="color: #808080; font-style: italic;">//trace(fr.type);</span>
            <span style="color: #66cc66;">&#125;</span> 		
&nbsp;
            <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> refresh<span style="color: #66cc66;">&#40;</span>evt:Event<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span>
                <span style="color: #808080; font-style: italic;">/* Function is refresing both the tree and the list and 
                   disables the download button */</span>
&nbsp;
                <span style="color: #808080; font-style: italic;">// empty the list</span>
                fileListProvider = <span style="color: #000000; font-weight: bold;">new</span> ArrayCollection<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
                <span style="color: #808080; font-style: italic;">// disable the download button</span>
                downloadButton.<span style="color: #0066CC;">enabled</span> = <span style="color: #000000; font-weight: bold;">false</span>;
                <span style="color: #808080; font-style: italic;">// refresh the tree</span>
                dir.<span style="color: #0066CC;">send</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
            <span style="color: #66cc66;">&#125;</span>
        <span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&gt;</span>
    <span style="color: #66cc66;">&lt;/</span>mx:Script<span style="color: #66cc66;">&gt;</span>
<span style="color: #66cc66;">&lt;/</span>mx:Application<span style="color: #66cc66;">&gt;</span></pre></td></tr></table></div>

<p>This is it! As I just wrote at the beginning of the article, the power and beauty of Flex framework is that you can do great things with a few lines of codding. So enjoy Flex!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.flexer.info/2008/05/12/how-to-build-a-download-application-in-flex/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
	</channel>
</rss>
