<?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>ADM Blog &#187; flash</title>
	<atom:link href="http://blog.another-d-mention.ro/tag/flash/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.another-d-mention.ro</link>
	<description>No matter how you see things, reality changes when you reach understanding</description>
	<lastBuildDate>Tue, 29 Jun 2010 06:12:27 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Open and Save files to Desktop without going to Server</title>
		<link>http://blog.another-d-mention.ro/programming/java-script/open-and-save-files-to-desktop-without-going-to-server/</link>
		<comments>http://blog.another-d-mention.ro/programming/java-script/open-and-save-files-to-desktop-without-going-to-server/#comments</comments>
		<pubDate>Wed, 05 May 2010 13:21:01 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Java Script]]></category>
		<category><![CDATA[externalinterface]]></category>
		<category><![CDATA[filereference]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[open]]></category>
		<category><![CDATA[save]]></category>

		<guid isPermaLink="false">http://blog.another-d-mention.ro/?p=817</guid>
		<description><![CDATA[Few days ago I was working on a jQuery based tool to QA the JavaScript functionality of a website and I was in need of a method to save and load my scripts to Desktop. In most cases this require a server script where you send the content and it will serve it to download [...]


Related posts:<ol><li><a href='http://blog.another-d-mention.ro/misc/access-all-files-on-your-hard-disk-from-the-system-tray/' rel='bookmark' title='Permanent Link: Access all files on your hard disk from the system tray'>Access all files on your hard disk from the system tray</a></li>
<li><a href='http://blog.another-d-mention.ro/programming/flex-actionscript/serialize-javascript-object-to-json/' rel='bookmark' title='Permanent Link: Serialize JavaScript object to JSON'>Serialize JavaScript object to JSON</a></li>
<li><a href='http://blog.another-d-mention.ro/programming/right-click-and-custom-context-menu-in-flash-flex/' rel='bookmark' title='Permanent Link: Right click and custom context menu in Flash/Flex'>Right click and custom context menu in Flash/Flex</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Few days ago I was working on a jQuery based tool to QA the JavaScript functionality of a website and I was in need of a method to save and load my scripts to Desktop.<br />
In most cases this require a server script where you send the content and it will serve it to download and same for loading it. But a colleague suggested a better solution: to use the FileReference class.<br />
First step was to create a simple flash with the required functionality and send/retrieve data with ExternalInterface. Failed miserably. Why ? Because it seems Flash will not allow you to open a File Dialog from script only. You literally have to click a button from the movie interface to be able to do that. If you knew that good for you, I didn't.</p>
<p>So, I've created another flash movie, where you pass the open and save image and callback and it will insert the flash with the specified images in place and look just like any other buttons. </p>
<p>Here's a small demonstration (other buttons beside open and save are just for show):<br />
<iframe src="http://blog.another-d-mention.ro/stuff/FileDialogs/index.html" with="400" height="170" frameborder="0" style="overflow:hidden"></iframe><br />
So what do you need to set it up ? </p>
<p>First, you have to include the <strong>FileDialogs.js</strong> in your document (or just paste the code inside it into your own script).</p>
<p>Second, you need your JavaScript callbacks.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">function</span> openCallback<span style="color: #009900;">&#40;</span>input<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
     document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'text'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">value</span> <span style="color: #339933;">=</span> input<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">function</span> saveCallback<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
     <span style="color: #000066; font-weight: bold;">return</span> document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'text'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">value</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p><strong>openCallback()</strong> will be called once the user will select a file from the desktop and pass it's content as a parameter<br />
<strong>saveCallback()</strong> will be called when the user clicks save, before the dialog to choose a file name opens, and it must return the content you want to save to disk</p>
<p>Third, you must setup the whole thing.</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
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">// call this function on the onload event so the placeHolder element gets created</span>
<span style="color: #003366; font-weight: bold;">function</span> <span style="color: #000066;">onLoad</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #006600; font-style: italic;">// Create a config object</span>
    <span style="color: #003366; font-weight: bold;">var</span> config <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> FileDialogsConfig<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #006600; font-style: italic;">// width of the entire flash movie (buttons width + padding)</span>
    config.<span style="color: #660066;">width</span> <span style="color: #339933;">=</span> <span style="color: #CC0000;">45</span><span style="color: #339933;">;</span> 
    <span style="color: #006600; font-style: italic;">// height of the movie</span>
    config.<span style="color: #660066;">height</span> <span style="color: #339933;">=</span> <span style="color: #CC0000;">16</span><span style="color: #339933;">;</span>
    <span style="color: #006600; font-style: italic;">// padding between buttons</span>
    config.<span style="color: #660066;">padding</span> <span style="color: #339933;">=</span> <span style="color: #CC0000;">5</span><span style="color: #339933;">;</span>
    <span style="color: #006600; font-style: italic;">// open dialog button image and javascript callback function</span>
    config.<span style="color: #000066;">open</span>.<span style="color: #660066;">image</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;open.png&quot;</span><span style="color: #339933;">;</span>
    config.<span style="color: #000066;">open</span>.<span style="color: #660066;">handler</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;openCallback&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #006600; font-style: italic;">// save dialog button image and javascript callback function</span>
    config.<span style="color: #660066;">save</span>.<span style="color: #660066;">image</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;save.png&quot;</span><span style="color: #339933;">;</span>
    config.<span style="color: #660066;">save</span>.<span style="color: #660066;">handler</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;saveCallback&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #006600; font-style: italic;">// create the movie inside an element with the given id and configuration</span>
    <span style="color: #003366; font-weight: bold;">new</span> FileDialogs<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;placeHolder&quot;</span><span style="color: #339933;">,</span> config<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p><strong>Note:</strong> Handler callbacks in the config must be declared as String and not reference. IE will freak out and I don't want to fix it.</p>
<p>You can have only one button (open or save) if you chose so. Just don't set the other one.</p>
<p>That's about it. The placeHolder can be any container element. The script will set it's style size based on the configuration, the movie will have transparent background so don't worry about that, and it will set it's float property to left so you can add other stuff after it. But all those things are easy to configure if you mess a bit with the FileDialogs.js file. </p>
<p>Cheers!</p>
<p><a href="http://blog.another-d-mention.ro/stuff/FileDialogs/FileDialogs.zip">Download Source and Demo</a></p>


<p>Related posts:<ol><li><a href='http://blog.another-d-mention.ro/misc/access-all-files-on-your-hard-disk-from-the-system-tray/' rel='bookmark' title='Permanent Link: Access all files on your hard disk from the system tray'>Access all files on your hard disk from the system tray</a></li>
<li><a href='http://blog.another-d-mention.ro/programming/flex-actionscript/serialize-javascript-object-to-json/' rel='bookmark' title='Permanent Link: Serialize JavaScript object to JSON'>Serialize JavaScript object to JSON</a></li>
<li><a href='http://blog.another-d-mention.ro/programming/right-click-and-custom-context-menu-in-flash-flex/' rel='bookmark' title='Permanent Link: Right click and custom context menu in Flash/Flex'>Right click and custom context menu in Flash/Flex</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.another-d-mention.ro/programming/java-script/open-and-save-files-to-desktop-without-going-to-server/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Serialize JavaScript object to JSON</title>
		<link>http://blog.another-d-mention.ro/programming/flex-actionscript/serialize-javascript-object-to-json/</link>
		<comments>http://blog.another-d-mention.ro/programming/flex-actionscript/serialize-javascript-object-to-json/#comments</comments>
		<pubDate>Wed, 28 Apr 2010 11:57:51 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Flex / ActionScript]]></category>
		<category><![CDATA[Java Script]]></category>
		<category><![CDATA[deserialize]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[flex]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[json]]></category>
		<category><![CDATA[object]]></category>
		<category><![CDATA[serialize]]></category>

		<guid isPermaLink="false">http://blog.another-d-mention.ro/?p=816</guid>
		<description><![CDATA[Recently, on a project I was working, I needed a function to serialize a JavaScript object and all I could find online were scripts and jquery plugins for serializing a html form. Then, I found this, a script that takes advantage of the .toSource() method available in Gecko-based browsers and for the rest of them [...]


Related posts:<ol><li><a href='http://blog.another-d-mention.ro/programming/how-to-clone-duplicate-an-object-in-actionscript-3/' rel='bookmark' title='Permanent Link: How to clone (duplicate) an object in ActionScript 3'>How to clone (duplicate) an object in ActionScript 3</a></li>
<li><a href='http://blog.another-d-mention.ro/programming/right-click-and-custom-context-menu-in-flash-flex/' rel='bookmark' title='Permanent Link: Right click and custom context menu in Flash/Flex'>Right click and custom context menu in Flash/Flex</a></li>
<li><a href='http://blog.another-d-mention.ro/programming/create-professional-flex-components/' rel='bookmark' title='Permanent Link: Create professional Flex components'>Create professional Flex components</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Recently, on a project I was working, I needed a function to serialize a JavaScript object and all I could find online were scripts and jquery plugins for serializing a html form. Then, I found <a href="http://blog.stchur.com/2007/04/06/serializing-objects-in-javascript/" target="_blank">this</a>, a script that takes advantage of the <i>.toSource()</i> method available in Gecko-based browsers and for the rest of them plain old recursion. But it does the trick as expected and I'm pretty sure someone else might need it.</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="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">function</span> serialize<span style="color: #009900;">&#40;</span>_obj<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
   <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>_obj <span style="color: #339933;">!=</span> undefined <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000066; font-weight: bold;">typeof</span> _obj.<span style="color: #660066;">toSource</span> <span style="color: #339933;">!==</span> <span style="color: #3366CC;">'undefined'</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000066; font-weight: bold;">typeof</span> _obj.<span style="color: #660066;">callee</span> <span style="color: #339933;">===</span> <span style="color: #3366CC;">'undefined'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #000066; font-weight: bold;">return</span> _obj.<span style="color: #660066;">toSource</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #009900;">&#125;</span>
   <span style="color: #000066; font-weight: bold;">switch</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">typeof</span> _obj<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #000066; font-weight: bold;">case</span> <span style="color: #3366CC;">'number'</span><span style="color: #339933;">:</span>
      <span style="color: #000066; font-weight: bold;">case</span> <span style="color: #3366CC;">'boolean'</span><span style="color: #339933;">:</span>
      <span style="color: #000066; font-weight: bold;">case</span> <span style="color: #3366CC;">'function'</span><span style="color: #339933;">:</span>
         <span style="color: #000066; font-weight: bold;">return</span> _obj<span style="color: #339933;">;</span>
         <span style="color: #000066; font-weight: bold;">break</span><span style="color: #339933;">;</span>
      <span style="color: #000066; font-weight: bold;">case</span> <span style="color: #3366CC;">'string'</span><span style="color: #339933;">:</span>
          <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #3366CC;">'&quot;'</span> <span style="color: #339933;">+</span> _obj.<span style="color: #660066;">replace</span><span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/&quot;/mg</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;'&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">'&quot;'</span><span style="color: #339933;">;</span>
          <span style="color: #000066; font-weight: bold;">break</span><span style="color: #339933;">;</span>
      <span style="color: #000066; font-weight: bold;">case</span> <span style="color: #3366CC;">'object'</span><span style="color: #339933;">:</span>
          <span style="color: #003366; font-weight: bold;">var</span> str<span style="color: #339933;">;</span>
          <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>_obj.<span style="color: #660066;">constructor</span> <span style="color: #339933;">===</span> Array <span style="color: #339933;">||</span> <span style="color: #000066; font-weight: bold;">typeof</span> _obj.<span style="color: #660066;">callee</span> <span style="color: #339933;">!==</span> <span style="color: #3366CC;">'undefined'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
              str <span style="color: #339933;">=</span> <span style="color: #3366CC;">'['</span><span style="color: #339933;">;</span>
              <span style="color: #003366; font-weight: bold;">var</span> i<span style="color: #339933;">,</span> len <span style="color: #339933;">=</span> _obj.<span style="color: #660066;">length</span><span style="color: #339933;">;</span>
              <span style="color: #000066; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span>i <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> len<span style="color: #339933;">-</span><span style="color: #CC0000;">1</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> str <span style="color: #339933;">+=</span> Utils.<span style="color: #660066;">serialize</span><span style="color: #009900;">&#40;</span>_obj<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">','</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
              str <span style="color: #339933;">+=</span> Utils.<span style="color: #660066;">serialize</span><span style="color: #009900;">&#40;</span>_obj<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">']'</span><span style="color: #339933;">;</span>
          <span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
              str <span style="color: #339933;">=</span> <span style="color: #3366CC;">'{'</span><span style="color: #339933;">;</span>
              <span style="color: #003366; font-weight: bold;">var</span> key<span style="color: #339933;">;</span>
              <span style="color: #000066; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span>key <span style="color: #000066; font-weight: bold;">in</span> _obj<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> str <span style="color: #339933;">+=</span> key <span style="color: #339933;">+</span> <span style="color: #3366CC;">':'</span> <span style="color: #339933;">+</span> Utils.<span style="color: #660066;">serialize</span><span style="color: #009900;">&#40;</span>_obj<span style="color: #009900;">&#91;</span>key<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">','</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
              str <span style="color: #339933;">=</span> str.<span style="color: #660066;">replace</span><span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/\,$/</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">''</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">'}'</span><span style="color: #339933;">;</span>
          <span style="color: #009900;">&#125;</span>
          <span style="color: #000066; font-weight: bold;">return</span> str<span style="color: #339933;">;</span>
          <span style="color: #000066; font-weight: bold;">break</span><span style="color: #339933;">;</span>
      <span style="color: #003366; font-weight: bold;">default</span><span style="color: #339933;">:</span>
          <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #3366CC;">'&quot;&quot;'</span><span style="color: #339933;">;</span>
          <span style="color: #000066; font-weight: bold;">break</span><span style="color: #339933;">;</span>
      <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>To deserialize it, just use <i>eval()</i>.</p>
<p>Also, if you need the same thing for your Flash/Flex Actionscript3 project, here is a class for that as well -> <a href="http://blog.another-d-mention.ro/stuff/Serializer.as" target="_blank">Click Me</a>.</p>
<p>Cheers!
</pre>


<p>Related posts:<ol><li><a href='http://blog.another-d-mention.ro/programming/how-to-clone-duplicate-an-object-in-actionscript-3/' rel='bookmark' title='Permanent Link: How to clone (duplicate) an object in ActionScript 3'>How to clone (duplicate) an object in ActionScript 3</a></li>
<li><a href='http://blog.another-d-mention.ro/programming/right-click-and-custom-context-menu-in-flash-flex/' rel='bookmark' title='Permanent Link: Right click and custom context menu in Flash/Flex'>Right click and custom context menu in Flash/Flex</a></li>
<li><a href='http://blog.another-d-mention.ro/programming/create-professional-flex-components/' rel='bookmark' title='Permanent Link: Create professional Flex components'>Create professional Flex components</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.another-d-mention.ro/programming/flex-actionscript/serialize-javascript-object-to-json/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Neural networks in ActionScript 3</title>
		<link>http://blog.another-d-mention.ro/programming/neural-networks-in-actionscript-3/</link>
		<comments>http://blog.another-d-mention.ro/programming/neural-networks-in-actionscript-3/#comments</comments>
		<pubDate>Thu, 11 Mar 2010 14:07:00 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Flex / ActionScript]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[actionscript3]]></category>
		<category><![CDATA[ai]]></category>
		<category><![CDATA[artificial]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[flex]]></category>
		<category><![CDATA[intelligence]]></category>
		<category><![CDATA[networks]]></category>
		<category><![CDATA[neural]]></category>

		<guid isPermaLink="false">http://blog.another-d-mention.ro/?p=807</guid>
		<description><![CDATA["An artificial neural network (ANN), usually called "neural network" (NN), is a mathematical model or computational model that tries to simulate the structure and/or functional aspects of biological neural networks. It consists of an interconnected group of artificial neurons and processes information using a connectionist approach to computation. In most cases an ANN is an [...]


Related posts:<ol><li><a href='http://blog.another-d-mention.ro/programming/how-to-clone-duplicate-an-object-in-actionscript-3/' rel='bookmark' title='Permanent Link: How to clone (duplicate) an object in ActionScript 3'>How to clone (duplicate) an object in ActionScript 3</a></li>
<li><a href='http://blog.another-d-mention.ro/programming/create-professional-flex-components/' rel='bookmark' title='Permanent Link: Create professional Flex components'>Create professional Flex components</a></li>
<li><a href='http://blog.another-d-mention.ro/programming/ho-to-install-alchemy/' rel='bookmark' title='Permanent Link: Ho-To: Install Alchemy'>Ho-To: Install Alchemy</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p><img class="alignleft size-full wp-image-808" style="margin: 0px 10px 5px 0px;" title="Neural Network" src="http://blog.another-d-mention.ro/wp-content/uploads/2010/03/neural-network.gif" alt="Neural Network" width="150" height="113" />"An <strong>artificial neural network (ANN)</strong>, usually called "neural  network" (NN), is a mathematical model or computational model that tries to  simulate the structure and/or functional aspects of biological neural  networks. It consists of an interconnected group of artificial neurons and processes information using a connectionist approach to computation. In most cases an ANN is an adaptive system that changes its structure based on external  or internal information that flows through the network during the  learning phase. Neural networks are non-linear statistical data  modeling tools. They can be used to model complex relationships  between inputs and outputs or to find patterns in data." (<a href="http://en.wikipedia.org/wiki/Artificial_neural_network">Wikipedia</a>)</p>
<p><a href="http://blog.another-d-mention.ro/wp-content/uploads/2010/03/mlp3.gif"><img class="alignright size-full wp-image-809" title="Multi Layer Perceptron" src="http://blog.another-d-mention.ro/wp-content/uploads/2010/03/mlp3.gif" alt="Multi Layer Perceptron" width="164" height="224" /></a>So, repetition is the mother of all learning they say. You damn right it is. And you can do it in AS3 of course. Not the fastest choice out there but that's not the point. NN's are usually not that fast but they're useful in so many ways.</p>
<p>So, here is my implementation of a neural network multi-layer-perceptron made in AS3, set to learn a simple XOR problem. It uses 2 inputs neurons , 2 hidden layers, each having 2 neurons and one output neuron. It takes about 2 seconds to train it using 10.000 epochs, but then you can save a snapshot of the NN memory as a byteArray, save it to the server and load it back again in an instant without requiring a new training.  I didn't take the time to thoroughly document the classes just yet but I'm sure you'll find them pretty easy to use.</p>
<p>Some reading material:<br />
<a href="http://en.wikipedia.org/wiki/Artificial_neural_network" target="_blank">http://en.wikipedia.org/wiki/Artificial_neural_network</a><br />
<a href="http://fbim.fh-regensburg.de/~saj39122/jfroehl/diplom/e-index.html" target="_blank">http://fbim.fh-regensburg.de/~saj39122/jfroehl/diplom/e-index.html</a> (this is great)<br />
<a href="http://www.ai-junkie.com/ann/evolved/nnt1.html" target="_blank">http://www.ai-junkie.com/ann/evolved/nnt1.html</a></p>
<div align="center">
<object id="nnet" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="397" height="411" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="quality" value="high" /><param name="bgcolor" value="#FFFFFF" /><param name="allowScriptAccess" value="sameDomain" /><param name="src" value="http://blog.another-d-mention.ro/stuff/nnet/NeuralNetworks.swf" /><param name="name" value="SmartImage" /><param name="align" value="middle" /><embed id="nnet" type="application/x-shockwave-flash" width="397" height="411" src="http://blog.another-d-mention.ro/stuff/nnet/NeuralNetworks.swf" align="middle" name="SmartImage" allowscriptaccess="sameDomain" bgcolor="#FFFFFF" quality="high"></embed></object>
</div>
<p><a href="http://blog.another-d-mention.ro/stuff/nnet/srcview/" target="_blank">Sources</a> and <a href="http://blog.another-d-mention.ro/stuff/nnet/srcview/NeuralNetworks.zip" target="_blank">Download</a></p>


<p>Related posts:<ol><li><a href='http://blog.another-d-mention.ro/programming/how-to-clone-duplicate-an-object-in-actionscript-3/' rel='bookmark' title='Permanent Link: How to clone (duplicate) an object in ActionScript 3'>How to clone (duplicate) an object in ActionScript 3</a></li>
<li><a href='http://blog.another-d-mention.ro/programming/create-professional-flex-components/' rel='bookmark' title='Permanent Link: Create professional Flex components'>Create professional Flex components</a></li>
<li><a href='http://blog.another-d-mention.ro/programming/ho-to-install-alchemy/' rel='bookmark' title='Permanent Link: Ho-To: Install Alchemy'>Ho-To: Install Alchemy</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.another-d-mention.ro/programming/neural-networks-in-actionscript-3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Every day the same dream</title>
		<link>http://blog.another-d-mention.ro/misc/stuff/every-day-the-same-dream/</link>
		<comments>http://blog.another-d-mention.ro/misc/stuff/every-day-the-same-dream/#comments</comments>
		<pubDate>Wed, 20 Jan 2010 09:39:51 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Stuff]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[game]]></category>
		<category><![CDATA[molleindustria]]></category>

		<guid isPermaLink="false">http://blog.another-d-mention.ro/?p=788</guid>
		<description><![CDATA[Just brilliant. By molleindustria No related posts.


No related posts.]]></description>
			<content:encoded><![CDATA[<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="600" height="400" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="src" value="http://blog.another-d-mention.ro/wp-content/uploads/2010/01/everydaythesamedream.swf" /><embed type="application/x-shockwave-flash" width="600" height="400" src="http://blog.another-d-mention.ro/wp-content/uploads/2010/01/everydaythesamedream.swf"></embed></object></p>
<p>Just brilliant. By <a href="http://www.molleindustria.org" target="_blank">molleindustria</a></p>


<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://blog.another-d-mention.ro/misc/stuff/every-day-the-same-dream/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ho-To: Install Alchemy</title>
		<link>http://blog.another-d-mention.ro/programming/ho-to-install-alchemy/</link>
		<comments>http://blog.another-d-mention.ro/programming/ho-to-install-alchemy/#comments</comments>
		<pubDate>Wed, 24 Jun 2009 06:51:53 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Flex / ActionScript]]></category>
		<category><![CDATA[How To's]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[actionscript3]]></category>
		<category><![CDATA[alchemy]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[flex]]></category>
		<category><![CDATA[library]]></category>

		<guid isPermaLink="false">http://blog.another-d-mention.ro/?p=493</guid>
		<description><![CDATA[For those of you who tried but didn't succed, I found some straigthforward instructions for this. Setup Hell: Install cygwin to "c:\cygwin" - make sure to check boxes to install Perl, "Archive" (ZIP), and Devel/gcc:g++ (3.4.4.3 presumably) (is Perl necessary?) Copy the alchemy directory to: c:\cygwin\home\Lee Copy the flex sdk bin dir from c:\program files\etc [...]


Related posts:<ol><li><a href='http://blog.another-d-mention.ro/programming/flex-components-pack/' rel='bookmark' title='Permanent Link: Flex Components Pack'>Flex Components Pack</a></li>
<li><a href='http://blog.another-d-mention.ro/programming/create-professional-flex-components/' rel='bookmark' title='Permanent Link: Create professional Flex components'>Create professional Flex components</a></li>
<li><a href='http://blog.another-d-mention.ro/programming/how-to-clone-duplicate-an-object-in-actionscript-3/' rel='bookmark' title='Permanent Link: How to clone (duplicate) an object in ActionScript 3'>How to clone (duplicate) an object in ActionScript 3</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>For those of you who tried but didn't succed, I found some straigthforward instructions for this.</p>
<h4 class="vspace">Setup Hell:</h4>
<p>Install cygwin to "c:\cygwin" - make sure to check boxes to install Perl, "Archive" (ZIP), and Devel/gcc:g++ (3.4.4.3 presumably) (is Perl necessary?)<br />
Copy the alchemy directory to: c:\cygwin\home\Lee<br />
Copy the flex sdk bin dir from c:\program files\etc to "c:\flex" (to avoid paths with spaces in it!)<br />
Run the alchemy config script once:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">   run cygwin
   <span style="color: #7a0874; font-weight: bold;">cd</span> alchemy
   .<span style="color: #000000; font-weight: bold;">/</span>config</pre></div></div>

<p>Edit the textfile "C:\cygwin\home\Lee\alchemy\alchemy-setup" and uncomment and edit line 22 to: add "export ADL=c:\flex\adl.exe"</p>
<p>Edit .bashrc (in C:\cygwin\home\Lee)</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">   <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;LEE PROFILE&quot;</span>
   <span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">FLEX_HOME</span>=~<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">flex</span>
   <span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">ALCHEMY_HOME</span>=~<span style="color: #000000; font-weight: bold;">/</span>alchemy
&nbsp;
   <span style="color: #666666; font-style: italic;"># &quot;This should be added before your PATH is modified&quot; !!</span>
   <span style="color: #7a0874; font-weight: bold;">source</span> <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>Lee<span style="color: #000000; font-weight: bold;">/</span>alchemy<span style="color: #000000; font-weight: bold;">/</span>alchemy-setup 
&nbsp;
   <span style="color: #007800;">PATH</span>=<span style="color: #007800;">$ALCHEMY_HOME</span><span style="color: #000000; font-weight: bold;">/</span>achacks:<span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>Lee<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">flex</span>:<span style="color: #007800;">$PATH</span>
   <span style="color: #7a0874; font-weight: bold;">export</span> PATH
&nbsp;
   alc-on</pre></div></div>

<p>Do this (just once, I think):</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">   <span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #007800;">$ALCHEMY_HOME</span><span style="color: #000000; font-weight: bold;">/</span>bin
   <span style="color: #c20cb9; font-weight: bold;">ln</span> <span style="color: #660033;">-s</span> llvm-stub llvm-stub.exe</pre></div></div>

<h4 class="vspace">Compiling a SW:</h4>
<p>CD to the directory with the source<br />
Always do "alc-on" before compiling, cuz it doesn't work without it even though i added it to the startup (dunno)</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">    <span style="color: #c20cb9; font-weight: bold;">gcc</span> stringecho.c <span style="color: #660033;">-O3</span> <span style="color: #660033;">-Wall</span> <span style="color: #660033;">-swc</span> <span style="color: #660033;">-o</span> stringecho.swc 
    <span style="color: #660033;">--</span> should give you a swc.</pre></div></div>

<p>Import the swc into your flex builder 4 project and make sure compiler targets SDK v4</p>
<h4 class="vspace">Shortcuts</h4>
<p><strong>alc-home</strong> - takes you to the Alchemy install folder.<br />
<strong>alc-on</strong> - puts Alchemy gcc toolchain replacements at the front of your path.<br />
<strong>alc-off</strong> - restores original path.<br />
<strong>alc-util</strong> - shows you various Alchemy-related environment vars</p>
<p class="vspace">USEFUL TO KNOW</p>
<p><strong>which gcc</strong> - tells you which gcc it will use (should be the one in the achacks dir)<br />
<strong>ln</strong> - links shit<br />
<strong>rm</strong> - deletes links as well as files</p>
<p class="vspace">Ugh: Make sure to do "alc-on" and "alchemy-setup" even though you put it in the startup script <img src='http://blog.another-d-mention.ro/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' title="Ho To: Install Alchemy" />  (?)</p>
<p class="vspace">...</p>
<p>Objects:<br />
	<span class="wikiword">AS3</span>_Val<br />
	<span class="wikiword">AS3</span>_ArrayValue</p>
<p>Methods:<br />
	<span class="wikiword">AS3</span>_Release<br />
	<span class="wikiword">AS3</span>_LibInit</p>


<p>Related posts:<ol><li><a href='http://blog.another-d-mention.ro/programming/flex-components-pack/' rel='bookmark' title='Permanent Link: Flex Components Pack'>Flex Components Pack</a></li>
<li><a href='http://blog.another-d-mention.ro/programming/create-professional-flex-components/' rel='bookmark' title='Permanent Link: Create professional Flex components'>Create professional Flex components</a></li>
<li><a href='http://blog.another-d-mention.ro/programming/how-to-clone-duplicate-an-object-in-actionscript-3/' rel='bookmark' title='Permanent Link: How to clone (duplicate) an object in ActionScript 3'>How to clone (duplicate) an object in ActionScript 3</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.another-d-mention.ro/programming/ho-to-install-alchemy/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Flex Components Pack</title>
		<link>http://blog.another-d-mention.ro/programming/flex-components-pack/</link>
		<comments>http://blog.another-d-mention.ro/programming/flex-components-pack/#comments</comments>
		<pubDate>Tue, 09 Jun 2009 19:50:45 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Flex / ActionScript]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[actionscript3]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[components]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[flex]]></category>
		<category><![CDATA[library]]></category>
		<category><![CDATA[swc]]></category>

		<guid isPermaLink="false">http://blog.another-d-mention.ro/?p=470</guid>
		<description><![CDATA[I've just started working on a set of Flex components which I call Flex Components Pack. I've only managed to make 11 components till now but I'm still working and have a lot of ideas on my to-do list. If any one of you is willing to help I would be very glad to get [...]


Related posts:<ol><li><a href='http://blog.another-d-mention.ro/programming/create-professional-flex-components/' rel='bookmark' title='Permanent Link: Create professional Flex components'>Create professional Flex components</a></li>
<li><a href='http://blog.another-d-mention.ro/programming/ho-to-install-alchemy/' rel='bookmark' title='Permanent Link: Ho-To: Install Alchemy'>Ho-To: Install Alchemy</a></li>
<li><a href='http://blog.another-d-mention.ro/programming/create-flexas3-applications-for-mobile-devices/' rel='bookmark' title='Permanent Link: Create Flex/AS3 applications for Mobile Devices'>Create Flex/AS3 applications for Mobile Devices</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p><img class="alignright size-full wp-image-471" title="list" src="http://blog.another-d-mention.ro/wp-content/uploads/2009/06/list.png" alt="list Flex Components Pack" width="189" height="384" /> I've just started working on a set of Flex components which I call Flex Components Pack. I've only managed to make 11 components till now but I'm still working and have a lot of ideas on my to-do list. If any one of you is willing to help I would be very glad to get an extra brain in here. Just drop me a comment or something and I'll share the road-map and SVN path with you.</p>
<p>I've made a <a href="http://blog.another-d-mention.ro/downloads/components-pack/">page</a> where I will add tutorials, code examples and runnable demos as soon as possible, so check back soon. Till then, you can <a href="http://blog.another-d-mention.ro/stuff/ADMComponents.swc">download</a> the library and take a look.</p>
<p><strong>Update:</strong></p>
<p>(13/06/2009) - Added 5 more components. A simple but nice led light switch and 4 visualisation effects (EQTunnel, EQLine, EQWave, EQBars - winamp style). Just drag and drop the EQ on your app and it will animate any running sound inside your flash.</p>


<p>Related posts:<ol><li><a href='http://blog.another-d-mention.ro/programming/create-professional-flex-components/' rel='bookmark' title='Permanent Link: Create professional Flex components'>Create professional Flex components</a></li>
<li><a href='http://blog.another-d-mention.ro/programming/ho-to-install-alchemy/' rel='bookmark' title='Permanent Link: Ho-To: Install Alchemy'>Ho-To: Install Alchemy</a></li>
<li><a href='http://blog.another-d-mention.ro/programming/create-flexas3-applications-for-mobile-devices/' rel='bookmark' title='Permanent Link: Create Flex/AS3 applications for Mobile Devices'>Create Flex/AS3 applications for Mobile Devices</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.another-d-mention.ro/programming/flex-components-pack/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>How to clone (duplicate) an object in ActionScript 3</title>
		<link>http://blog.another-d-mention.ro/programming/how-to-clone-duplicate-an-object-in-actionscript-3/</link>
		<comments>http://blog.another-d-mention.ro/programming/how-to-clone-duplicate-an-object-in-actionscript-3/#comments</comments>
		<pubDate>Fri, 05 Jun 2009 20:33:44 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Flex / ActionScript]]></category>
		<category><![CDATA[How To's]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[actionscript]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[clone]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[flex]]></category>

		<guid isPermaLink="false">http://blog.another-d-mention.ro/?p=440</guid>
		<description><![CDATA[For a project I needed to clone an object of unknown type. And by clone I mean to create a new instance of that same type and then fill out all its properties (including getters and setters) to mirror the original object. Thanks to a friend, I discovered the describeType function in AS3. But this alone [...]


Related posts:<ol><li><a href='http://blog.another-d-mention.ro/programming/flex-actionscript/serialize-javascript-object-to-json/' rel='bookmark' title='Permanent Link: Serialize JavaScript object to JSON'>Serialize JavaScript object to JSON</a></li>
<li><a href='http://blog.another-d-mention.ro/programming/neural-networks-in-actionscript-3/' rel='bookmark' title='Permanent Link: Neural networks in ActionScript 3'>Neural networks in ActionScript 3</a></li>
<li><a href='http://blog.another-d-mention.ro/programming/how-to-identify-at-runtime-if-swf-is-in-debug-or-release-mode-build/' rel='bookmark' title='Permanent Link: How to identify at runtime if the swf is in debug or release mode/build'>How to identify at runtime if the swf is in debug or release mode/build</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>For a project I needed to clone an object of unknown type. And by clone I mean to create a new instance of that same type and then fill out all its properties (including getters and setters) to mirror the original object.</p>
<p>Thanks to a friend, I discovered the <a href="http://livedocs.adobe.com/flex/2/langref/flash/utils/package.html#describeType%28%29">describeType </a>function in AS3. But this alone will only take care of the copying part. To create an object of the same type as another one we use <a href="http://livedocs.adobe.com/flex/2/langref/flash/utils/package.html#getDefinitionByName%28%29">getDefinitionByName</a>.</p>
<p>Although Flash reflection is pretty basic, with a little work it will do the trick.</p>
<p>Get the <a href="http://blog.another-d-mention.ro/stuff/cloneTest.zip">application files</a>.</p>
<p>Here's the code:</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
</pre></td><td class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;</span> <span style="color: #000000; font-weight: bold;">?</span>xml <span style="color: #004993;">version</span>=<span style="color: #990000;">&quot;1.0&quot;</span> encoding=<span style="color: #990000;">&quot;utf-8&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;</span>mx <span style="color: #000000; font-weight: bold;">:</span>Application xmlns<span style="color: #000000; font-weight: bold;">:</span>mx=<span style="color: #990000;">&quot;http://www.adobe.com/2006/mxml&quot;</span> layout=<span style="color: #990000;">&quot;absolute&quot;</span> xmlns<span style="color: #000000; font-weight: bold;">:</span>local=<span style="color: #990000;">&quot;*&quot;</span> creationComplete=<span style="color: #990000;">&quot;init()&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;/</span>mx<span style="color: #000000; font-weight: bold;">&gt;&lt;</span>mx <span style="color: #000000; font-weight: bold;">:</span>Script<span style="color: #000000; font-weight: bold;">&gt;</span>
 <span style="color: #000000; font-weight: bold;">&lt;</span> <span style="color: #000000; font-weight: bold;">!</span><span style="color: #000000;">&#91;</span>CDATA<span style="color: #000000;">&#91;</span>
&nbsp;
     <span style="color: #0033ff; font-weight: bold;">import</span> mx.controls.Alert;
&nbsp;
     <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> <span style="color: #004993;">source</span><span style="color: #000000; font-weight: bold;">:</span>DataObject = <span style="color: #0033ff; font-weight: bold;">new</span> DataObject<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
     <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> cloneObject<span style="color: #000000; font-weight: bold;">:</span>DataObject;
&nbsp;
&nbsp;
     <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #004993;">init</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span>
&nbsp;
         <span style="color: #004993;">source</span>.<span style="color: #004993;">name</span> = <span style="color: #990000;">'John Doe'</span>;
         <span style="color: #004993;">source</span>.howMany = <span style="color: #000000; font-weight:bold;">4.5</span>;
         <span style="color: #004993;">source</span>.when = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Date</span><span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000;">&#41;</span>;
         <span style="color: #004993;">source</span>.complexProp = <span style="color: #0033ff; font-weight: bold;">new</span> DataObject<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
         <span style="color: #004993;">source</span>.complexProp.<span style="color: #004993;">name</span> = <span style="color: #990000;">'Name in sub-object'</span>;
&nbsp;
         cloneObject = UtilFunctions.<span style="color: #004993;">clone</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">source</span><span style="color: #000000;">&#41;</span> <span style="color: #0033ff; font-weight: bold;">as</span> DataObject;
&nbsp;
         Alert.<span style="color: #004993;">show</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;Clone:<span style="">\n</span>name = &quot;</span> <span style="color: #000000; font-weight: bold;">+</span> cloneObject.<span style="color: #004993;">name</span> <span style="color: #000000; font-weight: bold;">+</span> <span style="color: #990000;">&quot;<span style="">\n</span>howMany = &quot;</span> <span style="color: #000000; font-weight: bold;">+</span> cloneObject.howMany <span style="color: #000000; font-weight: bold;">+</span> <span style="color: #990000;">&quot;<span style="">\n</span>when = &quot;</span> <span style="color: #000000; font-weight: bold;">+</span> cloneObject.when <span style="color: #000000; font-weight: bold;">+</span> <span style="color: #990000;">&quot;<span style="">\n</span>complexProp.name = &quot;</span> <span style="color: #000000; font-weight: bold;">+</span> cloneObject.complexProp.<span style="color: #004993;">name</span><span style="color: #000000;">&#41;</span>;
     <span style="color: #000000;">&#125;</span>
&nbsp;
     <span style="color: #3f5fbf;">/**
&nbsp;
      * describeType will produce this (for a DataObject instance):
      *
      * &lt;type name=&quot;DataObject&quot; base=&quot;Object&quot; isDynamic=&quot;false&quot; isFinal=&quot;false&quot; isStatic=&quot;false&quot;&gt;
&nbsp;
           &lt;extendsclass type=&quot;Object&quot;/&gt;
           &lt;accessor name=&quot;isHandicap&quot; access=&quot;writeonly&quot; type=&quot;Boolean&quot; declaredBy=&quot;DataObject&quot;/&gt;
&nbsp;
           &lt;variable name=&quot;howMany&quot; type=&quot;Number&quot;/&gt;
           &lt;accessor name=&quot;complexProp&quot; access=&quot;readwrite&quot; type=&quot;DataObject&quot; declaredBy=&quot;DataObject&quot;/&gt;
&nbsp;
           &lt;variable name=&quot;name&quot; type=&quot;String&quot;/&gt;
           &lt;variable name=&quot;when&quot; type=&quot;Date&quot;/&gt;
&nbsp;
&nbsp;
      *
      * */</span>
&nbsp;
 <span style="color: #000000;">&#93;</span><span style="color: #000000;">&#93;</span><span style="color: #000000; font-weight: bold;">&gt;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;/</span>mx<span style="color: #000000; font-weight: bold;">&gt;</span></pre></td></tr></table></div>

<p>And the UtilFunctions.as file:</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
</pre></td><td class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #9900cc; font-weight: bold;">package</span>
<span style="color: #000000;">&#123;</span>
 <span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.utils</span>.<span style="color: #004993;">describeType</span>;
 <span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.utils</span>.<span style="color: #004993;">getDefinitionByName</span>;
 <span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.utils</span>.<span style="color: #004993;">getQualifiedClassName</span>;
&nbsp;
 <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> UtilFunctions
 <span style="color: #000000;">&#123;</span>
&nbsp;
&nbsp;
     <span style="color: #0033ff; font-weight: bold;">public</span> static <span style="color: #339966; font-weight: bold;">function</span> newSibling<span style="color: #000000;">&#40;</span>sourceObj<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Object</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:*</span> <span style="color: #000000;">&#123;</span>
         <span style="color: #0033ff; font-weight: bold;">if</span><span style="color: #000000;">&#40;</span>sourceObj<span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
&nbsp;
             <span style="color: #6699cc; font-weight: bold;">var</span> objSibling<span style="color: #000000; font-weight: bold;">:*</span>;
             <span style="color: #0033ff; font-weight: bold;">try</span> <span style="color: #000000;">&#123;</span>
                 <span style="color: #6699cc; font-weight: bold;">var</span> classOfSourceObj<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Class</span> = <span style="color: #004993;">getDefinitionByName</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">getQualifiedClassName</span><span style="color: #000000;">&#40;</span>sourceObj<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span> <span style="color: #0033ff; font-weight: bold;">as</span> <span style="color: #004993;">Class</span>;
                 objSibling = <span style="color: #0033ff; font-weight: bold;">new</span> classOfSourceObj<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
             <span style="color: #000000;">&#125;</span>
&nbsp;
             <span style="color: #0033ff; font-weight: bold;">catch</span><span style="color: #000000;">&#40;</span>e<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Object</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span><span style="color: #000000;">&#125;</span>
&nbsp;
             <span style="color: #0033ff; font-weight: bold;">return</span> objSibling;
         <span style="color: #000000;">&#125;</span>
         <span style="color: #0033ff; font-weight: bold;">return</span> <span style="color: #0033ff; font-weight: bold;">null</span>;
     <span style="color: #000000;">&#125;</span>
&nbsp;
     <span style="color: #0033ff; font-weight: bold;">public</span> static <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #004993;">clone</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">source</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Object</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Object</span> <span style="color: #000000;">&#123;</span>
&nbsp;
         <span style="color: #6699cc; font-weight: bold;">var</span> <span style="color: #004993;">clone</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Object</span>;
         <span style="color: #0033ff; font-weight: bold;">if</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">source</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
             <span style="color: #004993;">clone</span> = newSibling<span style="color: #000000;">&#40;</span><span style="color: #004993;">source</span><span style="color: #000000;">&#41;</span>;
&nbsp;
             <span style="color: #0033ff; font-weight: bold;">if</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">clone</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
                 copyData<span style="color: #000000;">&#40;</span><span style="color: #004993;">source</span>, <span style="color: #004993;">clone</span><span style="color: #000000;">&#41;</span>;
             <span style="color: #000000;">&#125;</span>
         <span style="color: #000000;">&#125;</span>
&nbsp;
         <span style="color: #0033ff; font-weight: bold;">return</span> <span style="color: #004993;">clone</span>;
     <span style="color: #000000;">&#125;</span>
&nbsp;
     <span style="color: #0033ff; font-weight: bold;">public</span> static <span style="color: #339966; font-weight: bold;">function</span> copyData<span style="color: #000000;">&#40;</span><span style="color: #004993;">source</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Object</span>, destination<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Object</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span>
&nbsp;
         <span style="color: #009900;">//copies data from commonly named properties and getter/setter pairs</span>
         <span style="color: #0033ff; font-weight: bold;">if</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">source</span><span style="color: #000000;">&#41;</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #000000;">&#40;</span>destination<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
&nbsp;
             <span style="color: #0033ff; font-weight: bold;">try</span> <span style="color: #000000;">&#123;</span>
                 <span style="color: #6699cc; font-weight: bold;">var</span> sourceInfo<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">XML</span> = <span style="color: #004993;">describeType</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">source</span><span style="color: #000000;">&#41;</span>;
                 <span style="color: #6699cc; font-weight: bold;">var</span> prop<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">XML</span>;
&nbsp;
                 <span style="color: #0033ff; font-weight: bold;">for</span> <span style="color: #0033ff; font-weight: bold;">each</span><span style="color: #000000;">&#40;</span>prop <span style="color: #0033ff; font-weight: bold;">in</span> sourceInfo.variable<span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
&nbsp;
                     <span style="color: #0033ff; font-weight: bold;">if</span><span style="color: #000000;">&#40;</span>destination.<span style="color: #004993;">hasOwnProperty</span><span style="color: #000000;">&#40;</span>prop.@<span style="color: #004993;">name</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
                         destination<span style="color: #000000;">&#91;</span>prop.@<span style="color: #004993;">name</span><span style="color: #000000;">&#93;</span> = <span style="color: #004993;">source</span><span style="color: #000000;">&#91;</span>prop.@<span style="color: #004993;">name</span><span style="color: #000000;">&#93;</span>;
                     <span style="color: #000000;">&#125;</span>
&nbsp;
                 <span style="color: #000000;">&#125;</span>
&nbsp;
                 <span style="color: #0033ff; font-weight: bold;">for</span> <span style="color: #0033ff; font-weight: bold;">each</span><span style="color: #000000;">&#40;</span>prop <span style="color: #0033ff; font-weight: bold;">in</span> sourceInfo.accessor<span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
                     <span style="color: #0033ff; font-weight: bold;">if</span><span style="color: #000000;">&#40;</span>prop.@access == <span style="color: #990000;">&quot;readwrite&quot;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
                         <span style="color: #0033ff; font-weight: bold;">if</span><span style="color: #000000;">&#40;</span>destination.<span style="color: #004993;">hasOwnProperty</span><span style="color: #000000;">&#40;</span>prop.@<span style="color: #004993;">name</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
                             destination<span style="color: #000000;">&#91;</span>prop.@<span style="color: #004993;">name</span><span style="color: #000000;">&#93;</span> = <span style="color: #004993;">source</span><span style="color: #000000;">&#91;</span>prop.@<span style="color: #004993;">name</span><span style="color: #000000;">&#93;</span>;
                         <span style="color: #000000;">&#125;</span>
&nbsp;
                     <span style="color: #000000;">&#125;</span>
                 <span style="color: #000000;">&#125;</span>
             <span style="color: #000000;">&#125;</span>
             <span style="color: #0033ff; font-weight: bold;">catch</span> <span style="color: #000000;">&#40;</span>err<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Object</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
                 ;
             <span style="color: #000000;">&#125;</span>
         <span style="color: #000000;">&#125;</span>
     <span style="color: #000000;">&#125;</span>
 <span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<p>by <a href="http://evolverine.blogspot.com/2008/05/how-to-clone-duplicate-object-in.html">Evolvernie</a><br />
<!-- adman --></p>


<p>Related posts:<ol><li><a href='http://blog.another-d-mention.ro/programming/flex-actionscript/serialize-javascript-object-to-json/' rel='bookmark' title='Permanent Link: Serialize JavaScript object to JSON'>Serialize JavaScript object to JSON</a></li>
<li><a href='http://blog.another-d-mention.ro/programming/neural-networks-in-actionscript-3/' rel='bookmark' title='Permanent Link: Neural networks in ActionScript 3'>Neural networks in ActionScript 3</a></li>
<li><a href='http://blog.another-d-mention.ro/programming/how-to-identify-at-runtime-if-swf-is-in-debug-or-release-mode-build/' rel='bookmark' title='Permanent Link: How to identify at runtime if the swf is in debug or release mode/build'>How to identify at runtime if the swf is in debug or release mode/build</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.another-d-mention.ro/programming/how-to-clone-duplicate-an-object-in-actionscript-3/feed/</wfw:commentRss>
		<slash:comments>19</slash:comments>
		</item>
		<item>
		<title>Create professional Flex components</title>
		<link>http://blog.another-d-mention.ro/programming/create-professional-flex-components/</link>
		<comments>http://blog.another-d-mention.ro/programming/create-professional-flex-components/#comments</comments>
		<pubDate>Fri, 05 Jun 2009 17:50:08 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Flex / ActionScript]]></category>
		<category><![CDATA[How To's]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[components]]></category>
		<category><![CDATA[custom]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[flex]]></category>

		<guid isPermaLink="false">http://blog.another-d-mention.ro/?p=412</guid>
		<description><![CDATA[Flex Builder has a great way to organize its components in tree mode, which is very a good way to organize things and make things clear to any user who are coming to Flex world. By default, every component you create that is not part of default Flex components you will have placed in the [...]


Related posts:<ol><li><a href='http://blog.another-d-mention.ro/programming/flex-components-pack/' rel='bookmark' title='Permanent Link: Flex Components Pack'>Flex Components Pack</a></li>
<li><a href='http://blog.another-d-mention.ro/programming/how-to-identify-at-runtime-if-swf-is-in-debug-or-release-mode-build/' rel='bookmark' title='Permanent Link: How to identify at runtime if the swf is in debug or release mode/build'>How to identify at runtime if the swf is in debug or release mode/build</a></li>
<li><a href='http://blog.another-d-mention.ro/programming/create-flexas3-applications-for-mobile-devices/' rel='bookmark' title='Permanent Link: Create Flex/AS3 applications for Mobile Devices'>Create Flex/AS3 applications for Mobile Devices</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Flex Builder has a great way to organize its components in tree mode, which is very a good way to organize things and make things clear to any user who are coming to Flex world.</p>
<p>By default, every component you create that is not part of default Flex components you will have placed in the [Custom] directory of <strong>Flex Components</strong> view in your <strong>Flex/Flash Builder</strong>, and no matter what properties you add to them, they will never be visible in the <strong>Flex Properties</strong> standard view.</p>
<p>But what if you want to customize that and create a component that have them all like flex components do? Well, it's not that hard so let's do that.</p>
<h4>Create the Component</h4>
<p>First, you have to <strong>create a new Flex Library Project</strong>. Do this by going to File-&gt;New and choose Flex Library Project. Give it a name, a location, choose whatever Flex SDK you wish to build this for and then click finish.</p>
<p>Now you have a blank library project in which you can create whatever components you want.<br />
Is <span style="color: #ff0000;">important</span> to use packages correctly and namespaces and not just drop the component in the [src] folder (you'll see later why). First create a package (eg. com.adm.component) in which you can add your custom component.</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #9900cc; font-weight: bold;">package</span> com.adm.component
<span style="color: #000000;">&#123;</span>
      <span style="color: #0033ff; font-weight: bold;">import</span> mx.containers.Canvas;
&nbsp;
      <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> mycomponent extends Canvas
      <span style="color: #000000;">&#123;</span>
      <span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<p>Okay, now let's create some methods to have something going. We'll make this component be a big button with a method to enable the button and one to change it's caption. We'll use setters and getter's for those properties because some other actions might be required when changing them. So:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #9900cc; font-weight: bold;">package</span> com.adm.component
<span style="color: #000000;">&#123;</span>
     <span style="color: #0033ff; font-weight: bold;">import</span> mx.containers.Canvas;
     <span style="color: #0033ff; font-weight: bold;">import</span> mx.controls.Button;
&nbsp;
      <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> mycomponent extends Canvas
      <span style="color: #000000;">&#123;</span>
            <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> _title <span style="color: #000000; font-weight: bold;">:</span> <span style="color: #004993;">String</span> = <span style="color: #990000;">'Title'</span>;
            <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> _active <span style="color: #000000; font-weight: bold;">:</span> <span style="color: #004993;">Boolean</span> = <span style="color: #0033ff; font-weight: bold;">true</span>;
&nbsp;
            <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> btn <span style="color: #000000; font-weight: bold;">:</span> Button = <span style="color: #0033ff; font-weight: bold;">new</span> Button<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
&nbsp;
            <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> CustomComponent<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
            <span style="color: #000000;">&#123;</span>
                      <span style="color: #0033ff; font-weight: bold;">super</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
                      <span style="color: #0033ff; font-weight: bold;">this</span>.btn.<span style="color: #004993;">width</span> = <span style="color: #000000; font-weight:bold;">100</span>;
                      <span style="color: #0033ff; font-weight: bold;">this</span>.btn.<span style="color: #004993;">height</span> = <span style="color: #000000; font-weight:bold;">100</span>;
                      <span style="color: #0033ff; font-weight: bold;">this</span>.btn.label = <span style="color: #0033ff; font-weight: bold;">this</span>.label;
                      <span style="color: #0033ff; font-weight: bold;">this</span>.<span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">this</span>.btn<span style="color: #000000;">&#41;</span>;
            <span style="color: #000000;">&#125;</span>
&nbsp;
            <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #0033ff; font-weight: bold;">set</span> title<span style="color: #000000;">&#40;</span>val <span style="color: #000000; font-weight: bold;">:</span> <span style="color: #004993;">String</span><span style="color: #000000;">&#41;</span> <span style="color: #000000; font-weight: bold;">:</span> <span style="color: #0033ff; font-weight: bold;">void</span>
            <span style="color: #000000;">&#123;</span>
                      <span style="color: #0033ff; font-weight: bold;">this</span>._title = val;
                      <span style="color: #0033ff; font-weight: bold;">this</span>.btn.label = val;
            <span style="color: #000000;">&#125;</span>
&nbsp;
            <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #0033ff; font-weight: bold;">get</span> title<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000; font-weight: bold;">:</span> <span style="color: #004993;">String</span>
            <span style="color: #000000;">&#123;</span>
                     <span style="color: #0033ff; font-weight: bold;">return</span> <span style="color: #0033ff; font-weight: bold;">this</span>._title;
            <span style="color: #000000;">&#125;</span>
&nbsp;
            <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #0033ff; font-weight: bold;">set</span> <span style="color: #004993;">active</span><span style="color: #000000;">&#40;</span>val <span style="color: #000000; font-weight: bold;">:</span> <span style="color: #004993;">Boolean</span><span style="color: #000000;">&#41;</span> <span style="color: #000000; font-weight: bold;">:</span> <span style="color: #0033ff; font-weight: bold;">void</span>
            <span style="color: #000000;">&#123;</span>
                     <span style="color: #0033ff; font-weight: bold;">this</span>._active = val;
                     <span style="color: #0033ff; font-weight: bold;">this</span>.btn.<span style="color: #004993;">enabled</span>= val;
            <span style="color: #000000;">&#125;</span>
&nbsp;
            <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #0033ff; font-weight: bold;">get</span> <span style="color: #004993;">active</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000; font-weight: bold;">:</span> <span style="color: #004993;">Boolean</span>
            <span style="color: #000000;">&#123;</span>
                    <span style="color: #0033ff; font-weight: bold;">return</span> <span style="color: #0033ff; font-weight: bold;">this</span>._active;
            <span style="color: #000000;">&#125;</span>
      <span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<p>So, if you now build your project, a .swc file will be generated in your [bin] folder, which you can add in other projects and use. But now, the component will be placed in the [Custom] directory in the Components View and not the one you want. We'll do that a bit later now let's just....</p>
<h4>Give it an icon</h4>
<p>This is really simple. All you have to do is get a nice looking .png icon (16x16 pixels preferably) and place it next to your component. Then, use the <strong>IconFile</strong> metadata tag to link it to your component.</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;">....
<span style="color: #000000;">&#91;</span>IconFile<span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;icon.png&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span>
<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> mycomponent extends Canvas
<span style="color: #000000;">&#123;</span>
       <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> _title <span style="color: #000000; font-weight: bold;">:</span> <span style="color: #004993;">String</span> = <span style="color: #990000;">'Title'</span>;
       .......</pre></div></div>

<h4>Inspectable properties</h4>
<p>If you have extra information about the property that will help code hints or the Property Inspector (such as enumeration values or that a String is actually a file path) then also add [Inspectable] metadata with that extra info. For our methods we have:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;">       ...
       <span style="color: #000000;">&#91;</span>Inspectable<span style="color: #000000;">&#40;</span>category=<span style="color: #990000;">&quot;General&quot;</span>, <span style="color: #004993;">type</span>=<span style="color: #990000;">&quot;String&quot;</span>, defaultValue=<span style="color: #990000;">&quot;&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span>
       <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #0033ff; font-weight: bold;">set</span> title<span style="color: #000000;">&#40;</span>val <span style="color: #000000; font-weight: bold;">:</span> <span style="color: #004993;">String</span><span style="color: #000000;">&#41;</span> <span style="color: #000000; font-weight: bold;">:</span> <span style="color: #0033ff; font-weight: bold;">void</span>
       .....
       .....
       <span style="color: #000000;">&#91;</span>Inspectable<span style="color: #000000;">&#40;</span>category=<span style="color: #990000;">&quot;General&quot;</span>, <span style="color: #004993;">type</span>=<span style="color: #990000;">&quot;Boolean&quot;</span>, defaultValue=<span style="color: #990000;">&quot;true&quot;</span>, enumeration=<span style="color: #990000;">&quot;true,false&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span>
       <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #0033ff; font-weight: bold;">set</span> <span style="color: #004993;">active</span><span style="color: #000000;">&#40;</span>val <span style="color: #000000; font-weight: bold;">:</span> <span style="color: #004993;">Boolean</span><span style="color: #000000;">&#41;</span> <span style="color: #000000; font-weight: bold;">:</span> <span style="color: #0033ff; font-weight: bold;">void</span></pre></div></div>

<p>This will also help a lot when we'll add this properties in the Flex Properties panel. For more informations about the [Inspectable] metadata tag visit <a href="http://livedocs.adobe.com/flex/2/docs/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts&amp;file=00001658.html" target="_blank">http://livedocs.adobe.com/flex/2/docs/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts&amp;file=00001658.html</a></p>
<h4>Create custom component folder</h4>
<p>So, if you want to build a professional component, you can't leave Flex add your component in the default [Custom] directory in the Components tree. So, in order to create your own folder, we must use few tricks.</p>
<p>First of all, you need two .xml files to describe the structure you want flex to use and overide it's default behavior.<br />
The first file is the manifest.xml which describes the components in the package and their namespaces. In our case we'll have:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;">&lt; ?xml <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;componentpackage<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;component</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;mycomponent&quot;</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;org.adm.component.mycomponent&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/componentpackage<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>Second, we need another xml to describe the way the designer will interpret all this.</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;">&lt; ?xml <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;design<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;namespaces<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;namespace</span> <span style="color: #000066;">prefix</span>=<span style="color: #ff0000;">&quot;adm&quot;</span> <span style="color: #000066;">uri</span>=<span style="color: #ff0000;">&quot;http://www.adm.org&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/namespaces<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;categories<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;category</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;Test&quot;</span> <span style="color: #000066;">label</span>=<span style="color: #ff0000;">&quot;Test Panel&quot;</span> <span style="color: #000066;">defaultExpand</span>=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/categories<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;components<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;component</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;mycomponent&quot;</span> <span style="color: #000066;">namespace</span>=<span style="color: #ff0000;">&quot;adm&quot;</span> <span style="color: #000066;">category</span>=<span style="color: #ff0000;">&quot;Test&quot;</span> <span style="color: #000066;">displayName</span>=<span style="color: #ff0000;">&quot;Rename Me&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/components<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/design<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>In the design.xml, you can specify the namespaces you used for the components, in this case adm will point to components in the org.adm folder.</p>
<p>Categories tag describes the folders you want added in the Components panel. Each category must have an <strong>id</strong> which you'll use to tell components where they should reside, a <strong>label</strong> for the category to stand as the directory name in the Components panel. <strong>defaultExpand</strong> is an optional parameter which if set to true, the folder will be showed expanded by default.</p>
<p>In the components tag, you specify which component goes in what category and under what title. The <strong>name</strong> parameter must match the id of a component listed in the manifest.xml. All the other parameters are pretty self explanatory.</p>
<p>Next, you have to include this two files in .swc package. To do that, follow the steps:</p>
<p>* Right Click at your project and select Properties<br />
* In the left choose Flex Library Build Path<br />
* Select the assets tab and mark to include manifest.xml and design.xml files<br />
* Now select the Flex Library Compiler and include your namespace URL (in this case http://www.adm.org)<br />
* Include the manifest file .xml you've created<br />
* Click apply and ok to finish</p>
<p><img class="aligncenter size-full wp-image-432" title="design" src="http://blog.another-d-mention.ro/wp-content/uploads/2009/06/design.png" alt="design Create professional Flex components" width="476" height="375" /><br />
<img class="aligncenter size-full wp-image-433" title="manifest" src="http://blog.another-d-mention.ro/wp-content/uploads/2009/06/manifest.png" alt="manifest Create professional Flex components" width="483" height="380" /></p>
<p>After this, you should end up with something like this</p>
<p><img class="aligncenter size-full wp-image-428" title="comppanel" src="http://blog.another-d-mention.ro/wp-content/uploads/2009/06/comppanel.png" alt="comppanel Create professional Flex components" width="297" height="225" /></p>
<h4>Add properties to the Flex Properties view</h4>
<p>As I said before, no matter what properties you add to your component, they will never be visible in the <strong>Flex Properties</strong> standard view, only in the category view and that only if you use the [Inspectable] metadata tag. But few more lines in the design.xml file should take care of that.</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;">	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;component</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;mycomponent&quot;</span> <span style="color: #000066;">namespace</span>=<span style="color: #ff0000;">&quot;adm&quot;</span> <span style="color: #000066;">category</span>=<span style="color: #ff0000;">&quot;Test&quot;</span> <span style="color: #000066;">displayName</span>=<span style="color: #ff0000;">&quot;Rename Me&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mxmlproperties<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;textfield</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;title&quot;</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;Component Title:&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;combo</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;active&quot;</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;Active:&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mxmlproperties<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;defaultattribute</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;active&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/component<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>The id of the mxmlProperties tag should be the function/variable names from your component you want to edit. You can also define default values for those properties using the defaultAttribute tag below. Here we've only used the textfield and the combo type but there are few more you can use.</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;textfiled</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;propertyOrStyle&quot;</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;Label:&quot;</span> <span style="color: #66cc66;">&#91;</span><span style="color: #000066;">multiline</span>=<span style="color: #ff0000;">&quot;false&quot;</span><span style="color: #66cc66;">&#93;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;combo</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;propertyOrStyle&quot;</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;Label:&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;colorpicker</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;propertyOrStyle&quot;</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;Label:&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;filepicker</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;propertyOrStyle&quot;</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;Label:&quot;</span> <span style="color: #66cc66;">&#91;</span><span style="color: #000066;">wrapInEmbed</span>=<span style="color: #ff0000;">&quot;false&quot;</span><span style="color: #66cc66;">&#93;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;slider</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;propertyOrStyle&quot;</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;Label:&quot;</span> <span style="color: #000066;">min</span>=<span style="color: #ff0000;">&quot;0&quot;</span> <span style="color: #000066;">max</span>=<span style="color: #ff0000;">&quot;10&quot;</span> <span style="color: #000066;">increment</span>=<span style="color: #ff0000;">&quot;1&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span></pre></div></div>

<p> For combo boxes, if you use it for a Boolean property, it will automatically be populated with [true,false] values but if want something else, the [Inspectable] metadata tag has the enumeration property where you can define the properties from this combo.</p>
<p><img class="aligncenter size-full wp-image-431" title="flexprop" src="http://blog.another-d-mention.ro/wp-content/uploads/2009/06/flexprop.png" alt="flexprop Create professional Flex components" width="298" height="207" /></p>
<p>Another thing you must do in order to apply the values as soon as you change them from the properties view, is to set the functions/variables as [Bindable].</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;">    ....
    <span style="color: #000000;">&#91;</span>Inspectable<span style="color: #000000;">&#40;</span>category=<span style="color: #990000;">&quot;General&quot;</span>, <span style="color: #004993;">type</span>=<span style="color: #990000;">&quot;String&quot;</span>, defaultValue=<span style="color: #990000;">&quot;&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span>
    <span style="color: #000000;">&#91;</span>Bindable<span style="color: #000000;">&#93;</span>
    <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #0033ff; font-weight: bold;">set</span> title<span style="color: #000000;">&#40;</span>val <span style="color: #000000; font-weight: bold;">:</span> <span style="color: #004993;">String</span><span style="color: #000000;">&#41;</span> <span style="color: #000000; font-weight: bold;">:</span> <span style="color: #0033ff; font-weight: bold;">void</span>
	....
	....
    <span style="color: #000000;">&#91;</span>Inspectable<span style="color: #000000;">&#40;</span>category=<span style="color: #990000;">&quot;General&quot;</span>, <span style="color: #004993;">type</span>=<span style="color: #990000;">&quot;Boolean&quot;</span>, defaultValue=<span style="color: #990000;">&quot;true&quot;</span>, enumeration=<span style="color: #990000;">&quot;true,false&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span>
    <span style="color: #000000;">&#91;</span>Bindable<span style="color: #000000;">&#93;</span>
    <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #0033ff; font-weight: bold;">set</span> <span style="color: #004993;">active</span><span style="color: #000000;">&#40;</span>val <span style="color: #000000; font-weight: bold;">:</span> <span style="color: #004993;">Boolean</span><span style="color: #000000;">&#41;</span> <span style="color: #000000; font-weight: bold;">:</span> <span style="color: #0033ff; font-weight: bold;">void</span>
	....
	....</pre></div></div>

<h4>One more thing</h4>
<p>Now, compiling this will give you a 300 something KB .swc file which is a bit large to distribute. The user will use this component inside a flex component so embedding all the libraries and SDK inside your .swc is useless. So the next step is to go to Properties-&gt;Flex Library Build Path-&gt;Library path tab, expand the build path library try and edit everything inside the SDK tree on Link Type and choose <strong>External</strong></p>
<p><img class="aligncenter size-full wp-image-434" title="paths" src="http://blog.another-d-mention.ro/wp-content/uploads/2009/06/paths.png" alt="paths Create professional Flex components" width="526" height="287" /></p>
<p>Now the swc component only have 4KB. Big cut down, eh ?</p>
<h4>Done</h4>
<p>If this is to much trouble for you or you've missed something, I've attached the sources for this tutorial <a href="http://blog.another-d-mention.ro/stuff/component.zip">here</a>. You can import this skeleton  rename the package, namespace and the component and start building on this. I hope it all made sense and....happy coding.</p>


<p>Related posts:<ol><li><a href='http://blog.another-d-mention.ro/programming/flex-components-pack/' rel='bookmark' title='Permanent Link: Flex Components Pack'>Flex Components Pack</a></li>
<li><a href='http://blog.another-d-mention.ro/programming/how-to-identify-at-runtime-if-swf-is-in-debug-or-release-mode-build/' rel='bookmark' title='Permanent Link: How to identify at runtime if the swf is in debug or release mode/build'>How to identify at runtime if the swf is in debug or release mode/build</a></li>
<li><a href='http://blog.another-d-mention.ro/programming/create-flexas3-applications-for-mobile-devices/' rel='bookmark' title='Permanent Link: Create Flex/AS3 applications for Mobile Devices'>Create Flex/AS3 applications for Mobile Devices</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.another-d-mention.ro/programming/create-professional-flex-components/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Install Windows XP on your Asus Eee PC using a USB flash drive</title>
		<link>http://blog.another-d-mention.ro/misc/eee-pc/install-windows-xp-on-your-asus-eee-pc-using-a-usb-flash-drive/</link>
		<comments>http://blog.another-d-mention.ro/misc/eee-pc/install-windows-xp-on-your-asus-eee-pc-using-a-usb-flash-drive/#comments</comments>
		<pubDate>Fri, 17 Apr 2009 20:28:31 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Eee PC]]></category>
		<category><![CDATA[drive]]></category>
		<category><![CDATA[eee]]></category>
		<category><![CDATA[eeepc]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[hack]]></category>
		<category><![CDATA[install]]></category>
		<category><![CDATA[pc]]></category>
		<category><![CDATA[usb]]></category>
		<category><![CDATA[windows]]></category>
		<category><![CDATA[xp]]></category>

		<guid isPermaLink="false">http://blog.another-d-mention.ro/?p=322</guid>
		<description><![CDATA[This method of running and installing a Windows from a USB flash drive works on all computers not just Asus Eee PC's. To complete this tutorial you'll need: - a 32bit version of Windows XP or Windows Vista installed on your computer - USB_PREP8 - PeToUSB - Bootsect - a Windows XP instalation CD or [...]


Related posts:<ol><li><a href='http://blog.another-d-mention.ro/misc/eee-pc/reset-system-password-for-eeepc/' rel='bookmark' title='Permanent Link: Reset system password for EeePC'>Reset system password for EeePC</a></li>
<li><a href='http://blog.another-d-mention.ro/how-tos/how-to-setup-a-subversion-server-on-windows/' rel='bookmark' title='Permanent Link: How To &#8211; Setup a Subversion server on Windows'>How To &#8211; Setup a Subversion server on Windows</a></li>
<li><a href='http://blog.another-d-mention.ro/misc/really-useful-firefox-keyboard-shortcuts/' rel='bookmark' title='Permanent Link: Really useful firefox keyboard shortcuts'>Really useful firefox keyboard shortcuts</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p><!-- adman --></p>
<p>This method of running and installing a Windows from a USB flash drive works on all computers not just Asus Eee PC's.</p>
<p>To complete this tutorial you'll need:</p>
<p>- a 32bit version of Windows XP or Windows Vista installed on your computer</p>
<p>- <a href="http://blog.another-d-mention.ro/stuff/usb_prep8.zip">USB_PREP8</a></p>
<p>- <a href="http://blog.another-d-mention.ro/stuff/PeToUSB_3.0.0.7.zip">PeToUSB</a></p>
<p>- <a href="http://blog.another-d-mention.ro/stuff/bootsect.zip">Bootsect</a></p>
<p>- a Windows XP instalation CD or image</p>
<p>Extract all the zip archives, copy the PeToUSB content into the USB_prep8 folder. Inside the USB_prep8 folder double click the executable named <em>usb_prep8.cmd</em></p>
<p>The window that opens will look like this:</p>
<p><a href="http://blog.another-d-mention.ro/wp-content/uploads/2009/04/usbprep1.jpg"><img class="aligncenter size-medium wp-image-323" title="Click to enlarge" src="http://blog.another-d-mention.ro/wp-content/uploads/2009/04/usbprep1-300x194.jpg" alt="Click to enlarge" width="300" height="194" /></a>Press any key to continue.</p>
<p>Your next window will look like this:</p>
<p><a href="http://blog.another-d-mention.ro/wp-content/uploads/2009/04/petousb.jpg"><img class="aligncenter size-medium wp-image-324" title="Click to enlarge" src="http://blog.another-d-mention.ro/wp-content/uploads/2009/04/petousb-274x300.jpg" alt="Click to enlarge" width="274" height="300" /></a>These settings are preconfigured for you and all you need to do now is click the <strong>Start</strong> button.</p>
<p>Once the format is complete, <strong>DO NOT</strong> close the window. Just leave everything as it is and open a new command prompt from your start menu (type <em>cmd</em> in the <em>Run</em> box)</p>
<p>Inside the command window, go to the directory you have bootsect.exe extracted and type (see note bellow first)</p>
<p style="text-align: center;"><em>bootsect.exe /nt52 R:</em></p>
<p style="text-align: left;"><strong>Note</strong>: R: is the drive of my USB stick. Open Windows Explorer and see what letters yours is assigned to and change the command accordingly. When running the bootsect.exe command, you must close all windows/programs that are displaying/using the content of the USB stick to allow the boot sector writer to lock the device and write the sector correctly.</p>
<p style="text-align: left;">This part writes the correct boot sector to your USB stick and allows the pc to boot from the stick. Without this noting works.  If all went well with the command, you should see "<em>Bootcode was successfully updated on all targeted volumes</em>"</p>
<p style="text-align: left;">Now you can close this command prompt and the PeToUSB window (but make sure <span style="text-decoration: underline;"><strong>not</strong></span> to close the usb_prep8 one by mistake)</p>
<p style="text-align: left;">The window you see now should look like this:</p>
<p style="text-align: left;"><a href="http://blog.another-d-mention.ro/wp-content/uploads/2009/04/usbprep2.jpg"><img class="aligncenter size-medium wp-image-325" title="Click to enlarge" src="http://blog.another-d-mention.ro/wp-content/uploads/2009/04/usbprep2-300x194.jpg" alt="Click to enlarge" width="300" height="194" /></a></p>
<p style="text-align: left;">Now you need to enter the correct information for number 1, 2 and 3</p>
<p style="text-align: left;">- Press 1 and then enter. A folder browse window will open for you to browse for the location of your XP setup files (cd rom drive, mounted image or a folder somewhere on your system)</p>
<p style="text-align: left;">- Press 2 and enter a letter not curently assigned to a drive on your PC (try x or someting at the end of the alfabet)</p>
<p style="text-align: left;">- Press 3 and enter the drive letter of your USB stick</p>
<p style="text-align: left;">- And finally, press 4 to start the process</p>
<p style="text-align: left;">
<p style="text-align: left;">The script will ask you if its okay to format the virtual tempdrive (the one at step 2). This is just a temp drive the program creates and mounts to cache the windows installation files. You can safely press Y to continue</p>
<p style="text-align: left;">Once it's done formating, press enter to continue again, you can now see the program copying files to the temp drive it created. This will take a while (browse other articles from my blog till then <img src='http://blog.another-d-mention.ro/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' title="Install Windows XP on your Asus Eee PC using a USB flash drive" />  ) but once this is done, press enter to continue again.</p>
<p style="text-align: left;">Next you will see a box pop up asking you to copy the files to USB drive (yes/no options). You want to click yes here.</p>
<p style="text-align: left;">Once the script has completed once again a shit long copying process, another window asking if you would like the USB drive to be preferred boot dive U:. select Yes on this window too.</p>
<p style="text-align: left;">Now select yes to unmount the virtual drive.</p>
<p>Ok we are done the hard part, close the usbprep8 window.</p>
<p>Now make sure your EEE pc is configured with USB as the primary boot device.<br />
Insert your USB drive and boot up the EEE.</p>
<p>On the startup menu you have two options, select option number 2 for text mode setup.</p>
<p>From this point on it is just like any other windows XP installation delete/recreate the primary partition on your EEE pc and format it using NTFS. Make sure you delete ALL partitions and recreate a single partition or you will get the hal.dll error message.</p>
<p>Once the text mode portion of setup is complete it will boot into the GUI mode (you can press enter after the reboot if your too excited to wait the 30 seconds)</p>
<p>Once the GUI portion of setup is complete you will again have to boot into GUI mode this will complete the XP installation and you will end up at you XP desktop. It is very important that you DO NOT REMOVE THE USB STICK before this point. Once you can see your start menu it is safe to remove the usb stick and reboot your pc to make sure everything worked.</p>
<p>This method has advantages over all current no cdrom methods of installing XP to the EEE. You do not have to copy setup files in DOS to the SSD and install from there. It gives you access to the recovery console by booting into text mode setup, and it gives you the ability to run repair installations of XP if you have problems later on.</p>
<p>I hope this worked out for you and please post feedback to the comments section.
</p>
<p style="text-align: left;"><a href="http://blog.another-d-mention.ro/wp-content/uploads/2009/04/xpinstall.jpg"><img class="aligncenter size-medium wp-image-326" title="xpinstall" src="http://blog.another-d-mention.ro/wp-content/uploads/2009/04/xpinstall-300x225.jpg" alt="xpinstall 300x225 Install Windows XP on your Asus Eee PC using a USB flash drive" width="300" height="225" /></a></p>
<p><!-- adman --></p>


<p>Related posts:<ol><li><a href='http://blog.another-d-mention.ro/misc/eee-pc/reset-system-password-for-eeepc/' rel='bookmark' title='Permanent Link: Reset system password for EeePC'>Reset system password for EeePC</a></li>
<li><a href='http://blog.another-d-mention.ro/how-tos/how-to-setup-a-subversion-server-on-windows/' rel='bookmark' title='Permanent Link: How To &#8211; Setup a Subversion server on Windows'>How To &#8211; Setup a Subversion server on Windows</a></li>
<li><a href='http://blog.another-d-mention.ro/misc/really-useful-firefox-keyboard-shortcuts/' rel='bookmark' title='Permanent Link: Really useful firefox keyboard shortcuts'>Really useful firefox keyboard shortcuts</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.another-d-mention.ro/misc/eee-pc/install-windows-xp-on-your-asus-eee-pc-using-a-usb-flash-drive/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Right click and custom context menu in Flash/Flex</title>
		<link>http://blog.another-d-mention.ro/programming/right-click-and-custom-context-menu-in-flash-flex/</link>
		<comments>http://blog.another-d-mention.ro/programming/right-click-and-custom-context-menu-in-flash-flex/#comments</comments>
		<pubDate>Fri, 03 Apr 2009 08:53:56 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Flex / ActionScript]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[context]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[flex]]></category>
		<category><![CDATA[hack]]></category>
		<category><![CDATA[menu]]></category>
		<category><![CDATA[right click]]></category>

		<guid isPermaLink="false">http://blog.another-d-mention.ro/?p=287</guid>
		<description><![CDATA[Anyone know you can customize your flash context menu with ContextMenu class. But what if you want to really get rid of that and use your on context menu or just use the functionality of the right button of the mouse ? The idea is fairly simple: 1 - Use Javascript in the HTML container [...]


Related posts:<ol><li><a href='http://blog.another-d-mention.ro/programming/java-script/open-and-save-files-to-desktop-without-going-to-server/' rel='bookmark' title='Permanent Link: Open and Save files to Desktop without going to Server'>Open and Save files to Desktop without going to Server</a></li>
<li><a href='http://blog.another-d-mention.ro/misc/eee-pc/install-windows-xp-on-your-asus-eee-pc-using-a-usb-flash-drive/' rel='bookmark' title='Permanent Link: Install Windows XP on your Asus Eee PC using a USB flash drive'>Install Windows XP on your Asus Eee PC using a USB flash drive</a></li>
<li><a href='http://blog.another-d-mention.ro/programming/create-professional-flex-components/' rel='bookmark' title='Permanent Link: Create professional Flex components'>Create professional Flex components</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p><!-- adman --><br />
Anyone know you can customize your flash context menu with ContextMenu class. But what if you want to really get rid of that and use your on context menu or just use the functionality of the right button of the mouse ?</p>
<p><strong>The idea is fairly simple:</strong></p>
<p>1 - Use Javascript in the HTML container page to disable the right-click on top of the SWF.<br />
2 - Capture the event and pass it to a function that communicates with Flash via the External Interface<br />
3 - In Actionscript the function called from Javascript does whatever you need to display your own custom context-menu.</p>
<p><strong>Why would anyone want to do this? </strong></p>
<p>Well, there are several very important reasons:</p>
<p><strong>1. Games</strong> – the power of AS3 has brought Flash to the world of digital entertainment. At last it is possible to focus on the idea of your game rather than on how to improve the laggy experience. One thing that is still missing – right click functionality. We had this forever in desktop games, now it is time to let your casual RTS, RPG and FPS creations conquer the web.</p>
<p><strong>2. User Experience</strong> – 2 buttons are better than 1. Every experimentalist's dream is to be able to have more input options, not just one button. I can bet someone would soon create a stunning interface using this new functionality</p>
<p><strong>3. RIA</strong> – Rich Internet Applications. My clients are often asking if it is possible to remove embeded Flash Player menus from their applications and replace them with their company’s branding stuff.</p>
<p>And the answer is : <strong>YES!</strong> You can hack it to use custom right-click functionality in Flash and Flex.</p>
<p>Here is the <a href="http://blog.another-d-mention.ro/stuff/rightclick/RightClickDemo.html">demo</a> and because you won't be able to right click it to View the Sources <img src='http://blog.another-d-mention.ro/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' title="Right click and custom context menu in Flash/Flex" />  <a href="http://blog.another-d-mention.ro/stuff/rightclick/srcview/">here they are</a></p>
<p>Javascript source code looks like this:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> RightClick <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>
	init<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">FlashObjectID</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;RightClickDemo&quot;</span><span style="color: #339933;">;</span>
		<span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">FlashContainerID</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;flashcontent&quot;</span><span style="color: #339933;">;</span>
		<span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">Cache</span> <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">FlashObjectID</span><span style="color: #339933;">;</span>
		<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>window.<span style="color: #660066;">addEventListener</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
			 window.<span style="color: #660066;">addEventListener</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;mousedown&quot;</span><span style="color: #339933;">,</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">onGeckoMouse</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			 document.<span style="color: #660066;">oncontextmenu</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;RightClickDemo&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">rightClick</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
		<span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
&nbsp;
			document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">FlashContainerID</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">onmouseup</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span>RightClick.<span style="color: #660066;">FlashContainerID</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">releaseCapture</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
			document.<span style="color: #660066;">oncontextmenu</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span> <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>window.<span style="color: #660066;">event</span>.<span style="color: #660066;">srcElement</span>.<span style="color: #660066;">id</span> <span style="color: #339933;">==</span> RightClick.<span style="color: #660066;">FlashObjectID</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span> RightClick.<span style="color: #660066;">Cache</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;nan&quot;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#125;</span>
			document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">FlashContainerID</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">onmousedown</span> <span style="color: #339933;">=</span> RightClick.<span style="color: #660066;">onIEMouse</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
	killEvents<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>eventObject<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>eventObject<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>eventObject.<span style="color: #660066;">stopPropagation</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> eventObject.<span style="color: #660066;">stopPropagation</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
			<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>eventObject.<span style="color: #660066;">preventDefault</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> eventObject.<span style="color: #660066;">preventDefault</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
			<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>eventObject.<span style="color: #660066;">preventCapture</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> eventObject.<span style="color: #660066;">preventCapture</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
		    <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>eventObject.<span style="color: #660066;">preventBubble</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> eventObject.<span style="color: #660066;">preventBubble</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
	onGeckoMouse<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>ev<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>ev<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>ev.<span style="color: #660066;">button</span> <span style="color: #339933;">!=</span> <span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			RightClick.<span style="color: #660066;">killEvents</span><span style="color: #009900;">&#40;</span>ev<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>ev.<span style="color: #660066;">target</span>.<span style="color: #660066;">id</span> <span style="color: #339933;">==</span> RightClick.<span style="color: #660066;">FlashObjectID</span> <span style="color: #339933;">&amp;&amp;</span> RightClick.<span style="color: #660066;">Cache</span> <span style="color: #339933;">==</span> RightClick.<span style="color: #660066;">FlashObjectID</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span>RightClick.<span style="color: #660066;">FlashObjectID</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">rightClick</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
			RightClick.<span style="color: #660066;">Cache</span> <span style="color: #339933;">=</span> ev.<span style="color: #660066;">target</span>.<span style="color: #660066;">id</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
	  <span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
	onIEMouse<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #006600; font-style: italic;">// stupid ie fix</span>
        <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span>RightClick.<span style="color: #660066;">FlashObjectID</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">'x'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
            document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span>RightClick.<span style="color: #660066;">FlashObjectID</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">'x'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">id</span> <span style="color: #339933;">=</span>  RightClick.<span style="color: #660066;">FlashObjectID</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>event.<span style="color: #660066;">button</span><span style="color: #339933;">&gt;</span> <span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>window.<span style="color: #660066;">event</span>.<span style="color: #660066;">srcElement</span>.<span style="color: #660066;">id</span> <span style="color: #339933;">==</span> RightClick.<span style="color: #660066;">FlashObjectID</span> <span style="color: #339933;">&amp;&amp;</span> RightClick.<span style="color: #660066;">Cache</span> <span style="color: #339933;">==</span> RightClick.<span style="color: #660066;">FlashObjectID</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				RightClick.<span style="color: #660066;">call</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
			document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span>RightClick.<span style="color: #660066;">FlashContainerID</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">setCapture</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>window.<span style="color: #660066;">event</span>.<span style="color: #660066;">srcElement</span>.<span style="color: #660066;">id</span><span style="color: #009900;">&#41;</span>
			RightClick.<span style="color: #660066;">Cache</span> <span style="color: #339933;">=</span> window.<span style="color: #660066;">event</span>.<span style="color: #660066;">srcElement</span>.<span style="color: #660066;">id</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
	call<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span>RightClick.<span style="color: #660066;">FlashObjectID</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">rightClick</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>On the Flash side is as simple as this code (AS3):</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #004993;">init</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000; font-weight: bold;">:</span> <span style="color: #0033ff; font-weight: bold;">void</span>
<span style="color: #000000;">&#123;</span>
    <span style="color: #004993;">ExternalInterface</span>.<span style="color: #004993;">addCallback</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;rightClick&quot;</span>, onRightClick<span style="color: #000000;">&#41;</span>;
<span style="color: #000000;">&#125;</span>
&nbsp;
<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> onRightClick<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> 
<span style="color: #000000;">&#123;</span>
    <span style="color: #6699cc; font-weight: bold;">var</span> mx<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">int</span> = <span style="color: #004993;">stage</span>.<span style="color: #004993;">mouseX</span>;
    <span style="color: #6699cc; font-weight: bold;">var</span> my<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">int</span> = <span style="color: #004993;">stage</span>.<span style="color: #004993;">mouseY</span>;
&nbsp;
    <span style="color: #0033ff; font-weight: bold;">if</span><span style="color: #000000;">&#40;</span>my <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight:bold;">0</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> my <span style="color: #000000; font-weight: bold;">&lt;</span> <span style="color: #004993;">stage</span>.<span style="color: #004993;">stageHeight</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> mx <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight:bold;">0</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> mx <span style="color: #000000; font-weight: bold;">&lt;</span> <span style="color: #004993;">stage</span>.<span style="color: #004993;">stageWidth</span><span style="color: #000000;">&#41;</span> 
    <span style="color: #000000;">&#123;</span>
        <span style="color: #009900;">// show a custom context menu or do someting here</span>
    <span style="color: #000000;">&#125;</span></pre></div></div>

<p>On Opera this will not work, the browser forces the context menu to appear and blocks mouse events by default.</p>
<p><strong>Few things you shouldn't forget to make this work</strong></p>
<p>- 2 extra parameters you have to add to the flash object in your html<br />
<strong>menu="false"<br />
wmode="opaque"</strong><br />
- add to the body <strong>onload </strong> event <strong>RightClick.init();</strong> function</pre>
<p>Note: If you download the sources, you'll see in the html that the "object" tag has an extra 'x' character in the id. that's important to make it work in ie.<br />
<!-- adman --></p>


<p>Related posts:<ol><li><a href='http://blog.another-d-mention.ro/programming/java-script/open-and-save-files-to-desktop-without-going-to-server/' rel='bookmark' title='Permanent Link: Open and Save files to Desktop without going to Server'>Open and Save files to Desktop without going to Server</a></li>
<li><a href='http://blog.another-d-mention.ro/misc/eee-pc/install-windows-xp-on-your-asus-eee-pc-using-a-usb-flash-drive/' rel='bookmark' title='Permanent Link: Install Windows XP on your Asus Eee PC using a USB flash drive'>Install Windows XP on your Asus Eee PC using a USB flash drive</a></li>
<li><a href='http://blog.another-d-mention.ro/programming/create-professional-flex-components/' rel='bookmark' title='Permanent Link: Create professional Flex components'>Create professional Flex components</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.another-d-mention.ro/programming/right-click-and-custom-context-menu-in-flash-flex/feed/</wfw:commentRss>
		<slash:comments>35</slash:comments>
		</item>
	</channel>
</rss>
