<?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; Programming</title>
	<atom:link href="http://blog.another-d-mention.ro/category/programming/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>How to run python code in Windows batch (bat) files</title>
		<link>http://blog.another-d-mention.ro/programming/how-to-run-python-code-in-windows-batch-bat-files/</link>
		<comments>http://blog.another-d-mention.ro/programming/how-to-run-python-code-in-windows-batch-bat-files/#comments</comments>
		<pubDate>Wed, 23 Jun 2010 12:58:05 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[bat]]></category>
		<category><![CDATA[batch]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[py]]></category>
		<category><![CDATA[window]]></category>

		<guid isPermaLink="false">http://blog.another-d-mention.ro/?p=829</guid>
		<description><![CDATA[Here’s the bit of tricky batch file magic that does it: 1 2 3 @setlocal enabledelayedexpansion &#38;&#38; python -x &#34;%~f0&#34; %* &#38; exit /b !ERRORLEVEL! #start python code here print &#34;hello world&#34; The way it works is that the first line of the file does two different things. 1. starts python interpreter passing the name [...]


Related posts:<ol><li><a href='http://blog.another-d-mention.ro/programming/sudoku-solver-in-python/' rel='bookmark' title='Permanent Link: Sudoku solver in python'>Sudoku solver in python</a></li>
<li><a href='http://blog.another-d-mention.ro/programming/python/quick-python-script-explanation/' rel='bookmark' title='Permanent Link: Quick Python Script Explanation'>Quick Python Script Explanation</a></li>
<li><a href='http://blog.another-d-mention.ro/misc/view-hidden-files-with-a-keyboard-shortcut/' rel='bookmark' title='Permanent Link: View hidden files with a keyboard shortcut'>View hidden files with a keyboard shortcut</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Here’s the bit of tricky batch file magic that does it:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="python" style="font-family:monospace;">@setlocal enabledelayedexpansion <span style="color: #66cc66;">&amp;&amp;</span> python -x <span style="color: #483d8b;">&quot;%~f0&quot;</span> <span style="color: #66cc66;">%*</span> <span style="color: #66cc66;">&amp;</span> exit /b <span style="color: #66cc66;">!</span>ERRORLEVEL<span style="color: #66cc66;">!</span>
<span style="color: #808080; font-style: italic;">#start python code here</span>
<span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;hello world&quot;</span></pre></td></tr></table></div>

<p>The way it works is that the first line of the file does two different things.</p>
<p>1. starts python interpreter passing the name of the file in, and the -x option will tell it to skip the first line (containing .bat file code)<br />
2. When python finishes the script exits.</p>
<p>This nifty trick makes it much nicer for writing admin scripts with python on Windows. </p>


<p>Related posts:<ol><li><a href='http://blog.another-d-mention.ro/programming/sudoku-solver-in-python/' rel='bookmark' title='Permanent Link: Sudoku solver in python'>Sudoku solver in python</a></li>
<li><a href='http://blog.another-d-mention.ro/programming/python/quick-python-script-explanation/' rel='bookmark' title='Permanent Link: Quick Python Script Explanation'>Quick Python Script Explanation</a></li>
<li><a href='http://blog.another-d-mention.ro/misc/view-hidden-files-with-a-keyboard-shortcut/' rel='bookmark' title='Permanent Link: View hidden files with a keyboard shortcut'>View hidden files with a keyboard shortcut</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.another-d-mention.ro/programming/how-to-run-python-code-in-windows-batch-bat-files/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>FlashBuilder network issue</title>
		<link>http://blog.another-d-mention.ro/programming/flashbuilder-network-issue/</link>
		<comments>http://blog.another-d-mention.ro/programming/flashbuilder-network-issue/#comments</comments>
		<pubDate>Fri, 21 May 2010 20:54:21 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Flex / ActionScript]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[amfphp]]></category>
		<category><![CDATA[flash builder]]></category>
		<category><![CDATA[flex]]></category>
		<category><![CDATA[monitor]]></category>
		<category><![CDATA[network]]></category>

		<guid isPermaLink="false">http://blog.another-d-mention.ro/?p=822</guid>
		<description><![CDATA[Like most of my articles here, I try to post solutions for unusual problems I encounter now and then that may help someone someday. And this one almost made me scream. So here's the story. My DEV environment (http://dev/) is a Virtual Host mapped in the Windows host file to point to a sandboxed directory [...]


No related posts.]]></description>
			<content:encoded><![CDATA[<p><img class="alignleft size-thumbnail wp-image-823" style="margin-right: 10px; margin-bottom: 10px;" title="ARGHHHHHHHHHHHH" src="http://blog.another-d-mention.ro/wp-content/uploads/2010/05/girl-scream-150x150.jpg" alt="girl scream 150x150 FlashBuilder network issue" width="150" height="150" />Like most of my articles here, I try to post solutions for unusual problems I encounter now and then that may help someone someday. And this one almost made me scream.</p>
<p>So here's the story. My DEV environment (http://dev/) is a Virtual Host mapped in the Windows host file to point to a sandboxed directory somewhere on my hard drive. The Flex project I'm building uses a RemoteObject and tries to communicate with a AMFPHP gateway to do it's stuff. All good till here.</p>
<p>The weird part is that when I try to run the app, even though my flash is coming from the DEV host and the path to the gateway points to the same DEV host, the AMF calls either failed with a security exception or if they worked, they were extremely slow. The delay between a service call and a response/error was somewhere between 6 and 10 seconds.</p>
<p>Why oh why !? The AMFPHP Browser app that comes with the package works just fine so my app was at fault somehow. Tried some investigations and thanks to Firebug I found the vital clue.</p>
<p>It seems that my app was trying to make the connection to the gateway through <strong>http://localhost:37813/</strong>. WTF ?? I didn't had any reference to 'localhost' in my code, yet the app was trying to connect using that address for some reason. And quite often, the crossdomain.xml failed to load resulting in a security error.</p>
<p>So what in the world is the problem then ? Well, Flash Builder seems to be the problem (and me for not RTFM).</p>
<p>It seems that if you compile your swf with<strong> Network Monitor</strong> active, which you may not realize, especially if the window is not even opened, you have just told your swf to redirect all traffic to localhost:37813. It will compile the redirect info into your flash. Traffic may work if you have Flash Builder debugger running but try to deploy that somewhere. Heh.</p>
<p>All you have to do is turn network monitor off. Recompile your swf. Redeploy.</p>
<p>Ta da !</p>


<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://blog.another-d-mention.ro/programming/flashbuilder-network-issue/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Check if user visited certain websites</title>
		<link>http://blog.another-d-mention.ro/programming/check-if-user-visited-certain-websites/</link>
		<comments>http://blog.another-d-mention.ro/programming/check-if-user-visited-certain-websites/#comments</comments>
		<pubDate>Tue, 11 May 2010 13:21:53 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Java Script]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[browser]]></category>
		<category><![CDATA[history]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://blog.another-d-mention.ro/?p=819</guid>
		<description><![CDATA[Today I found a website called http://www.stayinvisible.com/ that uses a really clever technique to peak in your browser history. They can't see everything of course but they can see whatever they are interested in and that is a list of web-proxy websites. So how are they doing it ? First, they have a list of [...]


Related posts:<ol><li><a href='http://blog.another-d-mention.ro/misc/firefox-and-user-agent-switcher/' rel='bookmark' title='Permanent Link: Firefox and User Agent Switcher'>Firefox and User Agent Switcher</a></li>
<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>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Today I found a website called http://www.stayinvisible.com/ that uses a really clever technique to peak in your browser history. They can't see everything of course but they can see whatever they are interested in and that is a list of web-proxy websites. </p>
<p><strong>So how are they doing it ? </strong></p>
<p>First, they have a list of websites they are interested in, like i said, a list of web-proxies.</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;">var</span> sites <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #3366CC;">&quot;hidemyass.com&quot;</span><span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span><span style="color: #3366CC;">&quot;http://www.hidemyass.com&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;http://forum.hidemyass.com&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
    <span style="color: #3366CC;">&quot;freeproxy.ca&quot;</span><span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span><span style="color: #3366CC;">&quot;http://www.freeproxy.ca&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
    <span style="color: #3366CC;">&quot;proxy4free.com&quot;</span><span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span><span style="color: #3366CC;">&quot;http://www.proxy4free.com&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
    ....
    ....
    <span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Second, they create a temporary IFRAME where they write a simple 2 lines CSS that does the magic</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="css" style="font-family:monospace;">a <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#000</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">none</span><span style="color: #00AA00;">&#125;</span>
a<span style="color: #00AA00;">:</span> visited <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#F00</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">inline</span> <span style="color: #00AA00;">&#125;</span></pre></td></tr></table></div>

<p>... and in the body they append all the links from the <string>sites list. </p>
<p>The browser renders the links, and all the sites that appear in your history will use the "<strong>a:visited</strong>" CSS class. The others use the normal "<strong>a</strong>" class that has a display:none property and will be hidden. </p>
<p>What's left to do is iterate all the links from the frame and check if they are visible or not to know which of them are in your history and which of them aren't. Pretty simple eh ?</p>
<p>So here's the class:</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
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> bHistory <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: #003366; font-weight: bold;">var</span> sites <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #3366CC;">&quot;hidemyass.com&quot;</span><span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span><span style="color: #3366CC;">&quot;http://www.hidemyass.com&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;http://forum.hidemyass.com&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
    <span style="color: #3366CC;">&quot;freeproxy.ca&quot;</span><span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span><span style="color: #3366CC;">&quot;http://www.freeproxy.ca&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
    <span style="color: #3366CC;">&quot;proxy.org&quot;</span><span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span><span style="color: #3366CC;">&quot;http://www.proxy.org&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;http://www.proxy.org/cgi_proxies.shtml&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;http://www.proxy.org/forum/index.html&quot;</span><span style="color: #009900;">&#93;</span>
  <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
  <span style="color: #003366; font-weight: bold;">var</span> visited <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
  <span style="color: #003366; font-weight: bold;">function</span> getStyle<span style="color: #009900;">&#40;</span>el<span style="color: #339933;">,</span> scopeDoc<span style="color: #339933;">,</span>styleProp<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>el.<span style="color: #660066;">currentStyle</span><span style="color: #009900;">&#41;</span> <span style="color: #003366; font-weight: bold;">var</span> y <span style="color: #339933;">=</span> el.<span style="color: #660066;">currentStyle</span><span style="color: #009900;">&#91;</span>styleProp<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
    <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>window.<span style="color: #660066;">getComputedStyle</span><span style="color: #009900;">&#41;</span> <span style="color: #003366; font-weight: bold;">var</span> y <span style="color: #339933;">=</span> scopeDoc.<span style="color: #660066;">defaultView</span>.<span style="color: #660066;">getComputedStyle</span><span style="color: #009900;">&#40;</span>el<span style="color: #339933;">,</span><span style="color: #003366; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">getPropertyValue</span><span style="color: #009900;">&#40;</span>styleProp<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000066; font-weight: bold;">return</span> y<span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
  <span style="color: #003366; font-weight: bold;">function</span> remove<span style="color: #009900;">&#40;</span> el <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    el.<span style="color: #660066;">parentNode</span>.<span style="color: #660066;">removeChild</span><span style="color: #009900;">&#40;</span> el <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
  <span style="color: #003366; font-weight: bold;">function</span> createIframe<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #003366; font-weight: bold;">var</span> iframe <span style="color: #339933;">=</span> document.<span style="color: #660066;">createElement</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;iframe&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    iframe.<span style="color: #660066;">style</span>.<span style="color: #660066;">position</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;absolute&quot;</span><span style="color: #339933;">;</span>
    iframe.<span style="color: #660066;">style</span>.<span style="color: #660066;">visibility</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;hidden&quot;</span><span style="color: #339933;">;</span>
    document.<span style="color: #660066;">body</span>.<span style="color: #660066;">appendChild</span><span style="color: #009900;">&#40;</span>iframe<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>iframe.<span style="color: #660066;">contentDocument</span><span style="color: #009900;">&#41;</span> iframe.<span style="color: #660066;">doc</span> <span style="color: #339933;">=</span> iframe.<span style="color: #660066;">contentDocument</span><span style="color: #339933;">;</span>
    <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>iframe.<span style="color: #660066;">contentWindow</span><span style="color: #009900;">&#41;</span> iframe.<span style="color: #660066;">doc</span> <span style="color: #339933;">=</span> iframe.<span style="color: #660066;">contentWindow</span>.<span style="color: #660066;">document</span><span style="color: #339933;">;</span>
    iframe.<span style="color: #660066;">doc</span>.<span style="color: #000066;">open</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  	iframe.<span style="color: #660066;">doc</span>.<span style="color: #000066; font-weight: bold;">write</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'&lt;style&gt;'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  	iframe.<span style="color: #660066;">doc</span>.<span style="color: #000066; font-weight: bold;">write</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;a{color: #000000; display:none;}&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>  	
  	iframe.<span style="color: #660066;">doc</span>.<span style="color: #000066; font-weight: bold;">write</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;a:visited {color: #FF0000; display:inline;}&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>  	
  	iframe.<span style="color: #660066;">doc</span>.<span style="color: #000066; font-weight: bold;">write</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'&lt;/style&gt;'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    iframe.<span style="color: #660066;">doc</span>.<span style="color: #000066;">close</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;">return</span> iframe<span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>  
  <span style="color: #003366; font-weight: bold;">var</span> iframe <span style="color: #339933;">=</span> createIframe<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #003366; font-weight: bold;">function</span> embedLinkInIframe<span style="color: #009900;">&#40;</span> href<span style="color: #339933;">,</span> text <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #003366; font-weight: bold;">var</span> a <span style="color: #339933;">=</span> iframe.<span style="color: #660066;">doc</span>.<span style="color: #660066;">createElement</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;a&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    a.<span style="color: #660066;">href</span> <span style="color: #339933;">=</span> href<span style="color: #339933;">;</span>
    a.<span style="color: #660066;">innerHTML</span> <span style="color: #339933;">=</span> site<span style="color: #339933;">;</span>
    iframe.<span style="color: #660066;">doc</span>.<span style="color: #660066;">body</span>.<span style="color: #660066;">appendChild</span><span style="color: #009900;">&#40;</span> a <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
  <span style="color: #000066; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span> <span style="color: #003366; font-weight: bold;">var</span> site <span style="color: #000066; font-weight: bold;">in</span> sites <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #003366; font-weight: bold;">var</span> urls <span style="color: #339933;">=</span> sites<span style="color: #009900;">&#91;</span>site<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
    <span style="color: #000066; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span> <span style="color: #003366; font-weight: bold;">var</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>urls .<span style="color: #660066;">length</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      embedLinkInIframe<span style="color: #009900;">&#40;</span> urls<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> site <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> urls<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">match</span><span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/www\./</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        <span style="color: #003366; font-weight: bold;">var</span> sansWWW <span style="color: #339933;">=</span> urls<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">replace</span><span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/www\./</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        embedLinkInIframe<span style="color: #009900;">&#40;</span> sansWWW<span style="color: #339933;">,</span> site <span style="color: #009900;">&#41;</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>
        <span style="color: #003366; font-weight: bold;">var</span> httpLen <span style="color: #339933;">=</span> urls<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">indexOf</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;//&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #CC0000;">2</span><span style="color: #339933;">;</span>
        <span style="color: #003366; font-weight: bold;">var</span> withWWW <span style="color: #339933;">=</span> urls<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">substring</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> httpLen <span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">&quot;www.&quot;</span> <span style="color: #339933;">+</span> urls<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">substring</span><span style="color: #009900;">&#40;</span> httpLen <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        embedLinkInIframe<span style="color: #009900;">&#40;</span> withWWW<span style="color: #339933;">,</span> site <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: #003366; font-weight: bold;">var</span> links <span style="color: #339933;">=</span> iframe.<span style="color: #660066;">doc</span>.<span style="color: #660066;">body</span>.<span style="color: #660066;">childNodes</span><span style="color: #339933;">;</span>
  <span style="color: #000066; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span> <span style="color: #003366; font-weight: bold;">var</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>links.<span style="color: #660066;">length</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #003366; font-weight: bold;">var</span> displayValue <span style="color: #339933;">=</span> getStyle<span style="color: #009900;">&#40;</span>links<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> iframe.<span style="color: #660066;">doc</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;display&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #003366; font-weight: bold;">var</span> didVisit <span style="color: #339933;">=</span> displayValue <span style="color: #339933;">!=</span> <span style="color: #3366CC;">&quot;none&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span> didVisit <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
      visited<span style="color: #009900;">&#91;</span> links<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">innerHTML</span> <span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
  <span style="color: #009900;">&#125;</span>
  remove<span style="color: #009900;">&#40;</span> iframe <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #003366; font-weight: bold;">var</span> usedSites <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
  <span style="color: #000066; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span> <span style="color: #003366; font-weight: bold;">var</span> site <span style="color: #000066; font-weight: bold;">in</span> visited <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    usedSites.<span style="color: #660066;">push</span><span style="color: #009900;">&#40;</span> site <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
  <span style="color: #000066; font-weight: bold;">return</span> usedSites<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>To use it:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;">   <span style="color: #003366; font-weight: bold;">var</span> visited <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> bHistory<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span>visited<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// an array with visited websites from the defined list</span></pre></td></tr></table></div>

<p>All credits go to the smart man who did this. Cheers!</urls></pre>
<p></string></p>


<p>Related posts:<ol><li><a href='http://blog.another-d-mention.ro/misc/firefox-and-user-agent-switcher/' rel='bookmark' title='Permanent Link: Firefox and User Agent Switcher'>Firefox and User Agent Switcher</a></li>
<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>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.another-d-mention.ro/programming/check-if-user-visited-certain-websites/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<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>Use clipboard (copy/paste) in C# console application</title>
		<link>http://blog.another-d-mention.ro/programming/c/use-clipboard-copypaste-in-c-console-application/</link>
		<comments>http://blog.another-d-mention.ro/programming/c/use-clipboard-copypaste-in-c-console-application/#comments</comments>
		<pubDate>Mon, 01 Mar 2010 20:04:23 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[clipboard]]></category>
		<category><![CDATA[copy]]></category>
		<category><![CDATA[paste]]></category>

		<guid isPermaLink="false">http://blog.another-d-mention.ro/?p=805</guid>
		<description><![CDATA[This took me few minutes to figure out and was quite annoying. First you must add a reference to System.Windows.Forms in your application. Go to Project -&#62; Add reference, select System.Windows.Forms from .NET tab in the window that just opened.  You must avoid the ThreadStateException by applying the STAThread attribute to your Main() function. Then [...]


Related posts:<ol><li><a href='http://blog.another-d-mention.ro/programming/communicate-betwen-c-and-an-embeded-flash-application/' rel='bookmark' title='Permanent Link: Communicate betwen C# and an embeded Flash application'>Communicate betwen C# and an embeded Flash application</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p><img src="http://blog.another-d-mention.ro/wp-content/uploads/2010/03/net_logo.jpg-150x150.png" alt="net logo.jpg 150x150 Use clipboard (copy/paste) in C# console application" title="net_logo.jpg" width="150" height="150" class="alignleft size-thumbnail wp-image-806" />This took me few minutes to figure out and was quite annoying. First you must add a reference to System.Windows.Forms in your application. Go to Project -&gt; Add reference, select <strong>System.Windows.Forms</strong> from .NET tab in the window that just opened.  You must avoid the ThreadStateException by applying the STAThread attribute to your Main()  function. Then you can use the Clipboard functions without any problems.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
</pre></td><td class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF;">using</span> <span style="color: #008080;">System</span><span style="color: #008000;">;</span>
<span style="color: #0600FF;">using</span> <span style="color: #008080;">System.Windows.Forms</span><span style="color: #008000;">;</span>
&nbsp;
<span style="color: #FF0000;">class</span> Program <span style="color: #000000;">&#123;</span>
    <span style="color: #000000;">&#91;</span>STAThread<span style="color: #000000;">&#93;</span>
    <span style="color: #0600FF;">static</span> <span style="color: #0600FF;">void</span> Main<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">string</span><span style="color: #000000;">&#91;</span><span style="color: #000000;">&#93;</span> args<span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
         Clipboard.<span style="color: #0000FF;">SetText</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;this is in clipboard now&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>



<p>Related posts:<ol><li><a href='http://blog.another-d-mention.ro/programming/communicate-betwen-c-and-an-embeded-flash-application/' rel='bookmark' title='Permanent Link: Communicate betwen C# and an embeded Flash application'>Communicate betwen C# and an embeded Flash application</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.another-d-mention.ro/programming/c/use-clipboard-copypaste-in-c-console-application/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Create Flex/AS3 applications for Mobile Devices</title>
		<link>http://blog.another-d-mention.ro/programming/create-flexas3-applications-for-mobile-devices/</link>
		<comments>http://blog.another-d-mention.ro/programming/create-flexas3-applications-for-mobile-devices/#comments</comments>
		<pubDate>Mon, 01 Feb 2010 14:17:00 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Flex / ActionScript]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[elips]]></category>
		<category><![CDATA[flex]]></category>
		<category><![CDATA[iphone]]></category>
		<category><![CDATA[mobile]]></category>
		<category><![CDATA[symbian]]></category>
		<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://blog.another-d-mention.ro/?p=801</guid>
		<description><![CDATA[Yup! Flex Apps on your mobile. And I'm not talking about Flash Lite and you won't need CS5 either. ELIPS Studio converts the Flex code in native code for Windows Mobile, Symbian, Android, iPhone and mass-market mobiles. It's still beta and you have to register for a beta account to get it but I think [...]


Related posts:<ol><li><a href='http://blog.another-d-mention.ro/misc/flex-and-visual-studio/' rel='bookmark' title='Permanent Link: Flex and Visual Studio'>Flex and Visual Studio</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/flex-components-pack/' rel='bookmark' title='Permanent Link: Flex Components Pack'>Flex Components Pack</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p><a href="http://developer.openplug.com/" target="_blank"><img class="alignleft size-thumbnail wp-image-802" title="elips-studio-3-box" src="http://blog.another-d-mention.ro/wp-content/uploads/2010/02/elips-studio-3-box-150x150.jpg" alt="elips studio 3 box 150x150 Create Flex/AS3 applications for Mobile Devices" width="150" height="150" /></a>Yup! Flex Apps on your mobile. And I'm not talking about <a href="http://www.adobe.com/products/flashlite/" target="_blank">Flash Lite</a> and you won't need CS5 either.<br />
<a href="http://developer.openplug.com/" target="_blank">ELIPS Studio</a> converts the Flex code in native code for Windows Mobile, Symbian, Android, iPhone and mass-market mobiles. It's still beta and you have to register for a beta account to get it but I think will do wonders for the mobile dev. world.</p>
<p>And in their words:</p>
<p>"ELIPS Studio 3 is a plug-in for Adobe Flex Builder, a widely used IDE for internet &amp; desktop application. Our plug-in allows Flex to go mobile!</p>
<p>The product offers a mobile-optimized Flex Framework, plus numerous Flex extensions, including mobile UI components &amp; access to mobile device features (voice call, SMS, access to calendar and contacts, to the camera, etc.)</p>
<p>The product includes a form-factor device simulator allowing you to see your application behavior on different devices. It also includes a network simulator allowing to generate calls, SMS, etc."</p>
<p>So..get it while it's hot <img src='http://blog.another-d-mention.ro/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' title="Create Flex/AS3 applications for Mobile Devices" /> </p>


<p>Related posts:<ol><li><a href='http://blog.another-d-mention.ro/misc/flex-and-visual-studio/' rel='bookmark' title='Permanent Link: Flex and Visual Studio'>Flex and Visual Studio</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/flex-components-pack/' rel='bookmark' title='Permanent Link: Flex Components Pack'>Flex Components Pack</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.another-d-mention.ro/programming/create-flexas3-applications-for-mobile-devices/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Static files locked by Jetty in Eclipse</title>
		<link>http://blog.another-d-mention.ro/programming/java/static-files-locked-by-jetty-in-eclipse/</link>
		<comments>http://blog.another-d-mention.ro/programming/java/static-files-locked-by-jetty-in-eclipse/#comments</comments>
		<pubDate>Mon, 25 Jan 2010 12:26:11 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[eclipse]]></category>
		<category><![CDATA[files]]></category>
		<category><![CDATA[jetty]]></category>
		<category><![CDATA[locked]]></category>
		<category><![CDATA[static]]></category>
		<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://blog.another-d-mention.ro/?p=795</guid>
		<description><![CDATA[If you use Jetty you might notice that once it's running you can't edit any static files because it says they are already in use and locked. Why ? Because Jetty buffers static content for webapps such as html files, css files, images etc and uses memory mapped files to do this if the NIO [...]


Related posts:<ol><li><a href='http://blog.another-d-mention.ro/misc/view-hidden-files-with-a-keyboard-shortcut/' rel='bookmark' title='Permanent Link: View hidden files with a keyboard shortcut'>View hidden files with a keyboard shortcut</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p><img class="alignleft size-full wp-image-798" title="jetty_logo" src="http://blog.another-d-mention.ro/wp-content/uploads/2010/01/jetty_logo2.png" alt="jetty logo2 Static files locked by Jetty in Eclipse" hspace="10" vspace="10" width="142" height="40" /> If you use Jetty you might notice that once it's running you can't edit any static files because it says they are already in use and locked.<br />
Why ? Because Jetty buffers static content for webapps such as html files, css files, images etc and uses memory mapped files to do this if the NIO connectors are being used. The problem is that on Windows, memory mapping a file causes the file to be locked, so that the file cannot be updated or replaced. This means that effectively you have to stop Jetty in order to update a file.</p>
<p><strong>In case this happens follow these steps:</strong></p>
<p>1. Extract the runjettyrun_1.0.1.jar in the eclipse plugin directory<br />
2. Extract the jetty-6.1.6.jar in the lib directory of the previous jar.<br />
3. Edit the file org\mortbay\jetty\webapp\webdefault.xml and change the "useFileMappedBuffer" to false. It should look like the following:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;init</span> -param<span style="color: #000000; font-weight: bold;">&gt;</span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;param</span> -name<span style="color: #000000; font-weight: bold;">&gt;</span></span>useFileMappedBuffer<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/param<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;param</span> -value<span style="color: #000000; font-weight: bold;">&gt;</span></span>false<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/param<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/init<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>4. Pack everything back up and overwrite the runjettyrun jar in the plugin directory.<br />
5. If you still get the error after step 4 start eclipse.exe with -clean and then recreate the Jetty configuration. (It just need to replace whatever jar's it copies in your workspace .plugins dir)</p>


<p>Related posts:<ol><li><a href='http://blog.another-d-mention.ro/misc/view-hidden-files-with-a-keyboard-shortcut/' rel='bookmark' title='Permanent Link: View hidden files with a keyboard shortcut'>View hidden files with a keyboard shortcut</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.another-d-mention.ro/programming/java/static-files-locked-by-jetty-in-eclipse/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Adding ellipsis points in a TextArea component in Flex</title>
		<link>http://blog.another-d-mention.ro/programming/flex-actionscript/adding-ellipsis-points-in-a-textarea-component-in-flex/</link>
		<comments>http://blog.another-d-mention.ro/programming/flex-actionscript/adding-ellipsis-points-in-a-textarea-component-in-flex/#comments</comments>
		<pubDate>Fri, 15 Jan 2010 14:55:12 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Flex / ActionScript]]></category>
		<category><![CDATA[ellipsis]]></category>
		<category><![CDATA[flex]]></category>
		<category><![CDATA[points]]></category>
		<category><![CDATA[recursion]]></category>
		<category><![CDATA[textarea]]></category>

		<guid isPermaLink="false">http://blog.another-d-mention.ro/?p=779</guid>
		<description><![CDATA[The goal here is to use a TextArea component to display some text that doesn't quite fit in the specified region and ellipsis points (...) should be showed to let user know the text is trimmed. Standard stuff right ? But Flex doesn't do it by itself and I thought someone might look for this. [...]


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/extendedimage-component/' rel='bookmark' title='Permanent Link: ExtendedImage Component'>ExtendedImage Component</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>The goal here is to use a TextArea component to display some text that doesn't quite fit in the specified region and ellipsis points (...) should be showed to let user know the text is trimmed. Standard stuff right ? But Flex doesn't do it by itself and I thought someone might look for this.</p>
<p>My problem was with a Flex app that uses i18n and in some languages the text didn't fit the box, the scroll bar policy was off and user had no idea there was more text in there and didn't had the possibility to scroll further. Anyway, here it is :</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
</pre></td><td class="code"><pre class="actionscript3" style="font-family:monospace;">	<span style="color: #000000; font-weight: bold;">&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: #000000;">&#91;</span>Bindable<span style="color: #000000;">&#93;</span>
			<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> <span style="color: #004993;">text</span> <span style="color: #000000; font-weight: bold;">:</span> <span style="color: #004993;">String</span> = <span style="color: #990000;">'The quick brown fox jumped over the lazy dog. '</span> <span style="color: #000000; font-weight: bold;">+</span>
						    <span style="color: #990000;">'The quick brown fox jumped over the lazy dog. '</span> <span style="color: #000000; font-weight: bold;">+</span>
						    <span style="color: #990000;">'The quick brown fox jumped over the lazy dog. '</span> <span style="color: #000000; font-weight: bold;">+</span>
						    <span style="color: #990000;">'The quick brown fox jumped over the lazy dog. '</span> <span style="color: #000000; font-weight: bold;">+</span>
						    <span style="color: #990000;">'The quick brown fox jumped over the lazy dog. '</span>;
&nbsp;
			<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> trim<span style="color: #000000;">&#40;</span><span style="color: #004993;">text</span> <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: #004993;">String</span> 
			<span style="color: #000000;">&#123;</span>
				box.<span style="color: #004993;">text</span> = <span style="color: #004993;">text</span>;
				box.validateNow<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
				<span style="color: #0033ff; font-weight: bold;">if</span><span style="color: #000000;">&#40;</span>box.maxVerticalScrollPosition <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
					<span style="color: #004993;">text</span> = <span style="color: #004993;">text</span>.<span style="color: #004993;">replace</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;...&quot;</span>, <span style="color: #990000;">&quot;&quot;</span><span style="color: #000000;">&#41;</span>;
					<span style="color: #004993;">text</span> = <span style="color: #004993;">text</span>.<span style="color: #004993;">substr</span><span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">0</span>, <span style="color: #004993;">text</span>.<span style="color: #004993;">length</span> <span style="color: #000000; font-weight: bold;">-</span> <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000000;">&#41;</span> <span style="color: #000000; font-weight: bold;">+</span> <span style="color: #990000;">&quot;...&quot;</span>;
				<span style="color: #000000;">&#125;</span> <span style="color: #0033ff; font-weight: bold;">else</span> <span style="color: #000000;">&#123;</span>
					<span style="color: #0033ff; font-weight: bold;">return</span> <span style="color: #004993;">text</span>
				<span style="color: #000000;">&#125;</span>
				<span style="color: #0033ff; font-weight: bold;">return</span> trim<span style="color: #000000;">&#40;</span><span style="color: #004993;">text</span><span style="color: #000000;">&#41;</span>;	
			<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #000000;">&#93;</span><span style="color: #000000;">&#93;</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;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">&lt;</span>mx <span style="color: #000000; font-weight: bold;">:</span>TextArea id=<span style="color: #990000;">&quot;box&quot;</span>
		verticalScrollPolicy=<span style="color: #990000;">&quot;off&quot;</span>
		<span style="color: #004993;">width</span>=<span style="color: #990000;">&quot;250&quot;</span>
		<span style="color: #004993;">height</span>=<span style="color: #990000;">&quot;50&quot;</span>
		<span style="color: #004993;">wordWrap</span>=<span style="color: #990000;">&quot;true&quot;</span>	
		<span style="color: #004993;">text</span>=<span style="color: #990000;">&quot;{trim(this.text)}&quot;</span>
		paddingBottom=<span style="color: #990000;">&quot;0&quot;</span>	
		editable=<span style="color: #990000;">&quot;false&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></pre></td></tr></table></div>

<p><img src="http://blog.another-d-mention.ro/wp-content/uploads/2010/01/untitled.PNG" alt="Flex Output" title="Flex Output" width="278" height="74" class="aligncenter size-full wp-image-784" /></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/extendedimage-component/' rel='bookmark' title='Permanent Link: ExtendedImage Component'>ExtendedImage Component</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/flex-actionscript/adding-ellipsis-points-in-a-textarea-component-in-flex/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
