<?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>DaveOnCode &#187; programming</title>
	<atom:link href="http://www.daveoncode.com/tag/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.daveoncode.com</link>
	<description>Objective C, iOS and more programming stuff</description>
	<lastBuildDate>Mon, 19 Dec 2011 12:11:12 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Extending Flex&#8217;s logging framework to write custom log files</title>
		<link>http://www.daveoncode.com/2009/02/23/extending-flexs-logging-framework-to-write-custom-log-files/</link>
		<comments>http://www.daveoncode.com/2009/02/23/extending-flexs-logging-framework-to-write-custom-log-files/#comments</comments>
		<pubDate>Mon, 23 Feb 2009 18:19:06 +0000</pubDate>
		<dc:creator>Davide Zanotti</dc:creator>
				<category><![CDATA[flex]]></category>
		<category><![CDATA[actionscript]]></category>
		<category><![CDATA[debug]]></category>
		<category><![CDATA[logging]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://www.daveoncode.com/?p=308</guid>
		<description><![CDATA[In these days I played with Flex&#8217;s logging framework and I extended it to write log messages to files, both plain text .log files and dynamic HTML, CSS formatted and Javascript powered files with the ability to filter message type (debug, error, fatal and so on). The logging framework is a powerful feature that comes [...]<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://www.daveoncode.com/2009/02/23/extending-flexs-logging-framework-to-write-custom-log-files/' addthis:title='Extending Flex&#8217;s logging framework to write custom log files ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></description>
			<content:encoded><![CDATA[<p>In these days I played with Flex&#8217;s logging framework and I extended it to write log messages to files, both plain text .log files and dynamic HTML, CSS formatted and Javascript powered files with the ability to filter message type (debug, error, fatal and so on).</p>
<p>The logging framework is a powerful feature that comes with Flex&#8217;s sdk and it&#8217;s composed by the classes under <strong>mx.logging </strong>package, which includes the two &#8220;subpackages&#8221; <strong>mx.logging.errors</strong> and <strong>mx.logging.target</strong>.</p>
<p>Java developers should be already confident whit such framework, because logging api are commonly used in Java programming,  Actionscript /Flash/Flex developers may find this tool a novelty (as I did).</p>
<p>The objective of logging framework is to provide a tool that offers a far better, flexible and centralized way to debug an application than simple use a lot of <strong>trace()</strong> callings. With Flex&#8217;s debugging framework we are able to print and filtering among different types of message based on their severity, such:</p>
<ul>
<li>DEBUG</li>
<li>ERROR</li>
<li>FATAL</li>
<li>INFO</li>
<li>WARN</li>
</ul>
<p>We can also print the timestamp of the message and the class it refers to, and finally we can simultaneously print messages to different targets.</p>
<p><span id="more-308"></span></p>
<h3 style="margin: 20px 0">How it works</h3>
<p>The logging framework is basically represented by 3 units: a logger, a target and a log event. The first component is the main class of the framework and its job is to register the different &#8220;loggable classes&#8221;, register one or more targets and dispatch log events. A target is a class which receives a LogEvent event and handles it by printing its information (message, date, level&#8230;) somewhere. A LogEvent event is dispatched when one of the logger methods such: <strong>debug()</strong>, <strong>error()</strong>, <strong>fatal()</strong>, <strong>info()</strong>, <strong>log()</strong> or <strong>warn()</strong> is called.</p>
<p>The steps required to use the logging system are the following:</p>
<p>1. Registering the classes for logging:</p>
<div class="codecolorer-container actionscript3 mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br /></div></td><td><div class="actionscript3 codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #9900cc; font-weight: bold;">package</span> com<span style="color: #000066; font-weight: bold;">.</span>daveoncode <span style="color: #000000;">&#123;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> mx<span style="color: #000066; font-weight: bold;">.</span>logging<span style="color: #000066; font-weight: bold;">.*;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> Foo <span style="color: #000000;">&#123;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> _logger<span style="color: #000066; font-weight: bold;">:</span>ILogger<span style="color: #000066; font-weight: bold;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> Foo<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">this</span><span style="color: #000066; font-weight: bold;">.</span>_logger = Log<span style="color: #000066; font-weight: bold;">.</span>getLogger<span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;com.daveoncode.Foo&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">this</span><span style="color: #000066; font-weight: bold;">.</span>_logger<span style="color: #000066; font-weight: bold;">.</span>debug<span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;debugging message from Foo class&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">this</span><span style="color: #000066; font-weight: bold;">.</span>_logger<span style="color: #000066; font-weight: bold;">.</span>warn<span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;warning message from Foo class&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
<span style="color: #000000;">&#125;</span></div></td></tr></tbody></table></div>
<p>The code above will register the class Foo under the package com.daveoncode and then it will broadcast a debug and a warning message</p>
<p>2. Initialize and configure a logging target such TraceTarget (typically in the main class):</p>
<div class="codecolorer-container actionscript3 mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br /></div></td><td><div class="actionscript3 codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #6699cc; font-weight: bold;">var</span> basicTarget<span style="color: #000066; font-weight: bold;">:</span>TraceTarget = <span style="color: #0033ff; font-weight: bold;">new</span> TraceTarget<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
<span style="color: #009900; font-style: italic;">// Apply filters</span><br />
basicTarget<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">filters</span> = <span style="color: #000000;">&#91;</span><span style="color: #990000;">&quot;com.daveoncode.*&quot;</span><span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
<span style="color: #009900; font-style: italic;">// Log all log levels.</span><br />
basicTarget<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">level</span> = LogEventLevel<span style="color: #000066; font-weight: bold;">.</span>ALL<span style="color: #000066; font-weight: bold;">;</span><br />
<br />
<span style="color: #009900; font-style: italic;">// Add date, time, category, and log level to the output</span><br />
basicTarget<span style="color: #000066; font-weight: bold;">.</span>includeDate = <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000066; font-weight: bold;">;</span><br />
basicTarget<span style="color: #000066; font-weight: bold;">.</span>includeTime = <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000066; font-weight: bold;">;</span><br />
basicTarget<span style="color: #000066; font-weight: bold;">.</span>includeCategory = <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000066; font-weight: bold;">;</span><br />
basicTarget<span style="color: #000066; font-weight: bold;">.</span>includeLevel = <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000066; font-weight: bold;">;</span></div></td></tr></tbody></table></div>
<p>The code above will print log messages of all &#8220;subscribed&#8221; classes inside the package com.daveoncode, including all information available (date, time, category, level)</p>
<p>3. Add the target to the logger:</p>
<div class="codecolorer-container actionscript3 mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="actionscript3 codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">Log<span style="color: #000066; font-weight: bold;">.</span>addTarget<span style="color: #000000;">&#40;</span>basicTarget<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span></div></td></tr></tbody></table></div>
<p>The previous steps can be repeated as many times as we need, in order to registering several classes and several targets (<span onclick="dr4sdgryt(event)">perhaps </span>with different filters and info settings).</p>
<h3 style="margin: 20px 0">How to extend the framework</h3>
<p>To extend the framework we can create new target classes, which print LogEvent data to different location and display data as we like. In my experiment I created a &#8220;mini subframework&#8221; which can print logs to text files or html files. I created the following 7 classes:</p>
<ol>
<li>LogFileTarget</li>
<li>IStreamDataWriter</li>
<li>AbstractDataWriter</li>
<li>PlainTextDataWriter</li>
<li>HTMLDataWriter</li>
<li>InvalidLogFileTargetError</li>
<li>UnsupportedWriteModeError</li>
</ol>
<p>The first, as the name suggest is a custom target class, which extends LineFormattedTarget (a target class available in Flex&#8217;s framework), it has a parametric constructor which allows the user to choose the name of the file, its directory, the type of file (txt or html) and the charset that will be used to write the file. IStreamDataWriter is an interface which simply declares one method called writeData(), the main purpose of this interface is to use it in polymorphism. IStreamDataWriter is implemented by AbstractDataWriter as an abstract method (abstract is not supported yet in as3, but is treated as abstract), this class also has a secondary method which is used by two subclasses <strong>PlainTextDataWriter </strong>and <strong>HTMLDataWriter</strong>. These classes have the duty to physically write data to the file by handling the event received by <strong>LogFileTarget </strong>which delegates the business logic to them and are used based on the writeMode configuration of  <strong>LogFileTarget</strong>, which for ease has two public constants called <strong>MODE_PLAIN_TEXT</strong> and <strong>MODE_HTML. InvalidLogFileTargetError</strong> and <strong>UnsupportedWriteModeError </strong>are obviously two custom error which are both (potentially) thrown by <strong>LogFileTarget.</strong></p>
<p>This is a sample code using my own classes:</p>
<div class="codecolorer-container actionscript3 mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br /></div></td><td><div class="actionscript3 codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #009900; font-style: italic;">// this will print to an html file</span><br />
<span style="color: #6699cc; font-weight: bold;">var</span> HTMLTarget<span style="color: #000066; font-weight: bold;">:</span>LogFileTarget = <span style="color: #0033ff; font-weight: bold;">new</span> LogFileTarget<span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;applicationLog&quot;</span><span style="color: #000066; font-weight: bold;">,</span> File<span style="color: #000066; font-weight: bold;">.</span>desktopDirectory<span style="color: #000066; font-weight: bold;">,</span> LogFileTarget<span style="color: #000066; font-weight: bold;">.</span>MODE_HTML<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
<span style="color: #009900; font-style: italic;">// this will print to a txt file</span><br />
<span style="color: #6699cc; font-weight: bold;">var</span> txtTarget<span style="color: #000066; font-weight: bold;">:</span>LogFileTarget = <span style="color: #0033ff; font-weight: bold;">new</span> LogFileTarget<span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;applicationLog&quot;</span><span style="color: #000066; font-weight: bold;">,</span> File<span style="color: #000066; font-weight: bold;">.</span>desktopDirectory<span style="color: #000066; font-weight: bold;">,</span> LogFileTarget<span style="color: #000066; font-weight: bold;">.</span>MODE_PLAIN_TEXT<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
HTMLTarget<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">filters</span> = <span style="color: #000000;">&#91;</span><span style="color: #990000;">&quot;*&quot;</span><span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
&nbsp;<span style="color: #009900; font-style: italic;">// Log all log levels.</span><br />
HTMLTarget<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">level</span> = LogEventLevel<span style="color: #000066; font-weight: bold;">.</span>ALL<span style="color: #000066; font-weight: bold;">;</span><br />
<br />
<span style="color: #009900; font-style: italic;">// Add date, time, category, and log level to the output.</span><br />
HTMLTarget<span style="color: #000066; font-weight: bold;">.</span>includeDate = <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000066; font-weight: bold;">;</span><br />
HTMLTarget<span style="color: #000066; font-weight: bold;">.</span>includeTime = <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000066; font-weight: bold;">;</span><br />
HTMLTarget<span style="color: #000066; font-weight: bold;">.</span>includeCategory = <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000066; font-weight: bold;">;</span><br />
HTMLTarget<span style="color: #000066; font-weight: bold;">.</span>includeLevel = <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
txtTarget<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">filters</span> = <span style="color: #000000;">&#91;</span><span style="color: #990000;">&quot;*&quot;</span><span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
<span style="color: #009900; font-style: italic;">// Log all log levels.</span><br />
txtTarget<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">level</span> = LogEventLevel<span style="color: #000066; font-weight: bold;">.</span>ALL<span style="color: #000066; font-weight: bold;">;</span><br />
<br />
<span style="color: #009900; font-style: italic;">// Add date, time, category, and log level to the output.</span><br />
txtTarget<span style="color: #000066; font-weight: bold;">.</span>includeDate = <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000066; font-weight: bold;">;</span><br />
txtTarget<span style="color: #000066; font-weight: bold;">.</span>includeTime = <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000066; font-weight: bold;">;</span><br />
txtTarget<span style="color: #000066; font-weight: bold;">.</span>includeCategory = <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000066; font-weight: bold;">;</span><br />
txtTarget<span style="color: #000066; font-weight: bold;">.</span>includeLevel = <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
<span style="color: #009900; font-style: italic;">// Add targets</span><br />
Log<span style="color: #000066; font-weight: bold;">.</span>addTarget<span style="color: #000000;">&#40;</span>HTMLTarget<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
Log<span style="color: #000066; font-weight: bold;">.</span>addTarget<span style="color: #000000;">&#40;</span>txtTarget<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span></div></td></tr></tbody></table></div>
<p>Of course this experiment will works only in AIR applications, because we need to use flash.fileystem classes.</p>
<p>These are the two different output that my classes will generate:<br />
<a href="http://www.daveoncode.com/_dave_stuff/samples/applicationLog.log">Text file</a><br />
<a href="http://www.daveoncode.com/_dave_stuff/samples/applicationLog.html">HTML file</a></p>
<p>The cool aspect of html version (LogFileTarget.MODE_HTML) is that you can filter by log type :)</p>
<p>If you want to use or take a look to my experiment, feel free to download my logging package <a href="http://www.daveoncode.com/_dave_stuff/doc_logging_framework-1.0.zip">here</a> (let me know your opinion)</p>
<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://www.daveoncode.com/2009/02/23/extending-flexs-logging-framework-to-write-custom-log-files/' addthis:title='Extending Flex&#8217;s logging framework to write custom log files ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></content:encoded>
			<wfw:commentRss>http://www.daveoncode.com/2009/02/23/extending-flexs-logging-framework-to-write-custom-log-files/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
		<item>
		<title>Using bitwise operators with Actionscript to create arguments flags</title>
		<link>http://www.daveoncode.com/2009/02/08/using-bitwise-operators-with-actionscript-to-create-arguments-flags/</link>
		<comments>http://www.daveoncode.com/2009/02/08/using-bitwise-operators-with-actionscript-to-create-arguments-flags/#comments</comments>
		<pubDate>Sun, 08 Feb 2009 17:10:01 +0000</pubDate>
		<dc:creator>Davide Zanotti</dc:creator>
				<category><![CDATA[actionscript]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[bitwise]]></category>
		<category><![CDATA[flags]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://www.daveoncode.com/?p=269</guid>
		<description><![CDATA[Among all books I bought (including Java books), I haven&#8217;t one which explain in depth and in a clear manner what bitwise operators are and how to use them. Almost all books has at least a page about the argument but none is able to give an exhaustive explanation. So, after searching the net, I [...]<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://www.daveoncode.com/2009/02/08/using-bitwise-operators-with-actionscript-to-create-arguments-flags/' addthis:title='Using bitwise operators with Actionscript to create arguments flags ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></description>
			<content:encoded><![CDATA[<p>Among all books I bought (including Java books), I haven&#8217;t one which explain in depth and in a clear manner what bitwise operators are and how to use them. Almost all books has at least a page about the argument but none is able to give an exhaustive explanation. So, after searching the net, I found an extreme useful article by Joseph Farrell on gamedev.net (direct link: http://www.gamedev.net/reference/articles/article1563.asp), which explains bitwise operators in C starting from an introduction to Numbers and number system. The article is valid to Actionscript, Java and other languages too. I started to try to understand bitwise operators, after looked to Flex&#8217;s Alert class, which can accept several options (different buttons) as an unique argument (<strong><em>flags</em></strong>). This can be accomplished by using the bitwise OR operator |  (a pipe), which &#8220;joins&#8221; together different constants:</p>
<p><span id="more-269"></span></p>
<pre>Alert.show("Alert message", "Alert title", Alert.OK | Alert.NO | Alert.CANCEL);</pre>
<p>The code above generates an alert with 3 buttons (ok, no and cancel), but how it works exactly? Well, I don&#8217;t want to rewrite the article I read, but I would like to synthesize it and focus on an Actionscript usage, in order to give the basic information required to create custom classes which will accept multiple parameters an unique argument. So&#8230; what Alert.OK, Alert.NO and so on are? They are basically numbers (uint), and the result of the bitwise or operator still returns an integer, so the Alert class will receives a number as the third argument. The | operator, in practice produces a &#8220;binary sum&#8221; of the given numbers. A good way I figured out to understand what is going on when using that operator is to trace the binary representation of every number passed and then the result after the bitwise operation. To convert a &#8220;normal number&#8221; (base 10) into a binary one (base 2&#8230; only 1 or 0 sequence), we can use the <strong><em>toString()</em></strong> method by passing 2 as the radix argument:</p>
<pre>
var myNumber:uint = 3560;
trace(myNumber.toString(2));
</pre>
<p>The code above will trace: 110111101000.</p>
<p>So, let&#8217;s create a dummy class to do some tests:</p>
<pre>package {

    public class BitwiseTest {

        public static const FLAG_1:uint = 1;
        public static const FLAG_2:uint = 2;
        public static const FLAG_3:uint = 4;
        public static const FLAG_4:uint = 8;
        public static const FLAG_5:uint = 16;
        public static const FLAG_6:uint = 32;

        public function BitwiseTest() {

            trace("BitwiseTest.FLAG_1: " + BitwiseTest.FLAG_1.toString(2));
            trace("BitwiseTest.FLAG_3: " + BitwiseTest.FLAG_3.toString(2));
            trace("BitwiseTest.FLAG_5: " + BitwiseTest.FLAG_5.toString(2));
            trace("BitwiseTest.FLAG_6: " + BitwiseTest.FLAG_6.toString(2));

            this.test(BitwiseTest.FLAG_1 | BitwiseTest.FLAG_3 | BitwiseTest.FLAG_5 | BitwiseTest.FLAG_6);

        }

        private function test(flags:uint):void {

            trace("flags: " + flags.toString(2));

        }

    }

}</pre>
<p>The trace output will be:</p>
<pre>
BitwiseTest.FLAG_1: 1
BitwiseTest.FLAG_3: 100
BitwiseTest.FLAG_5: 10000
BitwiseTest.FLAG_6: 100000
flags: 110101
</pre>
<p>To check for a specific flag&#8217;s presence inside flags argument, we can use the bitwise &#8220;and&#8221; operator (&amp;):</p>
<pre>
if ((flags &amp; BitwiseTest.FLAG_1) &gt; 0) {

    trace("BitwiseTest.FLAG_1 passed - (" + String(flags &amp; BitwiseTest.FLAG_1) + ")");

}
</pre>
<p>By using the &amp; operator on flags it will returns the flag&#8217;s value if passed to the method and 0 otherwise. By updating the test method in this manner:</p>
<pre>
private function test(flags:uint):void {

    trace("flags: " + flags.toString(2));

    if ((flags &amp; BitwiseTest.FLAG_1) &gt; 0) {

        trace("BitwiseTest.FLAG_1 passed - (" + String(flags &amp; BitwiseTest.FLAG_1) + ")");

    }

    if ((flags &amp; BitwiseTest.FLAG_2) &gt; 0) {

        trace("BitwiseTest.FLAG_2 passed - (" + String(flags &amp; BitwiseTest.FLAG_2) + ")");

    }

    if ((flags &amp; BitwiseTest.FLAG_3) &gt; 0) {

        trace("BitwiseTest.FLAG_3 passed - (" + String(flags &amp; BitwiseTest.FLAG_3) + ")");

    }

    if ((flags &amp; BitwiseTest.FLAG_4) &gt; 0) {

        trace("BitwiseTest.FLAG_4 passed - (" + String(flags &amp; BitwiseTest.FLAG_4) + ")");

    }

    if ((flags &amp; BitwiseTest.FLAG_5) &gt; 0) {

        trace("BitwiseTest.FLAG_5 passed - (" + String(flags &amp; BitwiseTest.FLAG_5) + ")");

    }

    if ((flags &amp; BitwiseTest.FLAG_6) &gt; 0) {

        trace("BitwiseTest.FLAG_6 passed - (" + String(flags &amp; BitwiseTest.FLAG_6) + ")");

    }		

}</pre>
<p>We will obtain this output:</p>
<pre>BitwiseTest.FLAG_1: 1
BitwiseTest.FLAG_3: 100
BitwiseTest.FLAG_5: 10000
BitwiseTest.FLAG_6: 100000
flags: 110101
BitwiseTest.FLAG_1 passed - (1)
BitwiseTest.FLAG_3 passed - (4)
BitwiseTest.FLAG_5 passed - (16)
BitwiseTest.FLAG_6 passed - (32)</pre>
<p>We have successfully &#8220;intercepted&#8221; what flags has been passed to the method.<br />
Is important to know that flag&#8217;s values can&#8217;t be progressive numbers, but they must be multiples of 2, otherwise when using the bitwise &#8220;or&#8221; operator we will obtain a &#8220;ones overlap&#8221; resulting in an entity we won&#8217;t be able to properly manage. If we replace the flags values used in the previous example in this way:</p>
<pre>public static const FLAG_1:uint = 1;
public static const FLAG_2:uint = 2;
public static const FLAG_3:uint = 3;
public static const FLAG_4:uint = 4;
public static const FLAG_5:uint = 5;
public static const FLAG_6:uint = 6;</pre>
<p>We will get the following output:</p>
<pre>BitwiseTest.FLAG_1: 1
BitwiseTest.FLAG_3: 11
BitwiseTest.FLAG_5: 101
BitwiseTest.FLAG_6: 110
flags: 111
BitwiseTest.FLAG_1 passed - (1)
BitwiseTest.FLAG_2 passed - (2)
BitwiseTest.FLAG_3 passed - (3)
BitwiseTest.FLAG_4 passed - (4)
BitwiseTest.FLAG_5 passed - (5)
BitwiseTest.FLAG_6 passed - (6)</pre>
<p>As we can see our test method is unable to understand what flags it has received due to &#8220;ones overlap&#8221; (looks at te first 5 lines).</p>
<p>In conclusion&#8230; using bitwise operators for flags are pretty simple, however bitwise operators can do much more but understanding the real power of these operators and how to properly use them is not so easy (at least to me :-))</p>
<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://www.daveoncode.com/2009/02/08/using-bitwise-operators-with-actionscript-to-create-arguments-flags/' addthis:title='Using bitwise operators with Actionscript to create arguments flags ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></content:encoded>
			<wfw:commentRss>http://www.daveoncode.com/2009/02/08/using-bitwise-operators-with-actionscript-to-create-arguments-flags/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Learning design patterns with Actionscript 3: episode 1 &#8211; Singleton pattern</title>
		<link>http://www.daveoncode.com/2008/12/28/learning-design-patterns-with-actionscript-3-episode-1-singleton-pattern/</link>
		<comments>http://www.daveoncode.com/2008/12/28/learning-design-patterns-with-actionscript-3-episode-1-singleton-pattern/#comments</comments>
		<pubDate>Sun, 28 Dec 2008 15:22:47 +0000</pubDate>
		<dc:creator>Davide Zanotti</dc:creator>
				<category><![CDATA[actionscript]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[design patterns]]></category>
		<category><![CDATA[pattern]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[singleton]]></category>

		<guid isPermaLink="false">http://daveoncode.wordpress.com/?p=169</guid>
		<description><![CDATA[In these Christmas holidays I bought some new books, among them I purchased &#8220;Actionscript 3 design patterns&#8221; (written by William Sanders and Chandima Cumaranatunge) and I&#8217;m actually studying this one. I never faced before the world of design patterns (which is, for those that never heard about, a way to write code and solve problems [...]<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://www.daveoncode.com/2008/12/28/learning-design-patterns-with-actionscript-3-episode-1-singleton-pattern/' addthis:title='Learning design patterns with Actionscript 3: episode 1 &#8211; Singleton pattern ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></description>
			<content:encoded><![CDATA[<p>In these Christmas holidays I bought some new books, among them I purchased &#8220;Actionscript 3 design patterns&#8221; (written by William Sanders and Chandima Cumaranatunge) and I&#8217;m actually studying this one. I never faced before the world of design patterns (which is, for those that never heard about, a way to write code and solve problems by implementing tested strategies that will guarantee flexibility and extensibility), or better I knew what a design pattern is, but I&#8217;m trying to learn to use them for the first time.<br />
Unfortunately the first thing I learned about implementing design patterns in Actionscript 3 is that for some stuff we have to use workarounds, because actually as3 doesn&#8217;t provides 2 little useful things: <strong><em>abstract classes</em></strong> (on which most of the patterns are based) and not public constructor (in Java we can declare a class constructor as <strong><em>private</em></strong>, in as3 we must declare it as <strong><em>public</em></strong>), anyway with some little efforts, we can do everything :-)</p>
<p><span id="more-169"></span>Another thing I learned is that design patterns provide a way to solve problems and simplify application&#8217;s modification/extension but each pattern can be implemented in a little different way from a language to another and from a developer to another, the only thing that must be unchanged is the goal of the pattern and how it is used.<br />
One, or maybe the simplest, pattern around is the <em><strong>Singleton</strong></em> pattern, which is even one of the most used, even without be aware of it, we used something similar. In fact, Singleton pattern is used when a class must be instantiated only one time in the application (for example a shopping cart in an e-commerce website) or better when a class must exists as only one and be accessible everywhere through a &#8220;common access point&#8221; which is for convenience a static method called <strong><em>getInstance()</em></strong>.</p>
<p>With Java a singleton implementation should be something like this:</p>
<pre>public class ClassicSingleton {

   private static ClassicSingleton instance = null;

   protected ClassicSingleton() {

   }

   public static ClassicSingleton getInstance() {

      if(instance == null) {
         instance = new ClassicSingleton();
      }

      return instance;

   }

}</pre>
<p>(I taken the code above from this article on javaworld.com: http://www.javaworld.com/javaworld/jw-04-2003/jw-0425-designpatterns.html)</p>
<p>In Actionscript 3, the best implementation (in my opinion) of a Singleton pattern is the following:</p>
<pre>package {

    import flash.errors.IllegalOperationError;

    public class SingletonClass {

        private static var instance:SingletonClass = new SingletonClass();

        public function SingletonClass() {

            if (instance != null) {

                throw new IllegalOperationError("SingletonClass can't be instantiated because is a Singleton. Use getInstance() to retrieve a class reference.");

            }

        }

        public static function getInstance():SingletonClass {

            return instance;

        }

    }

}</pre>
<p>In this way if we try to call the SingletonClass constructor by using the new operator:</p>
<pre>var mySingletonClass:SingletonClass = new SingletonClass();</pre>
<p>we will get the error: &#8220;SingletonClass can&#8217;t be instantiated because is a Singleton. Use getInstance() to retrieve a class reference.&#8221;. So, the only and sound way to retrieve our SingletonClass is to use <strong><em>getInstance()</em></strong>:</p>
<pre>var mySingletonClass:SingletonClass = SingletonClass.getInstance();</pre>
<p>Every time we will use <strong><em>getInstance()</em></strong> the same class reference will be returned, avoiding multiple class instantiations.</p>
<p>This is clear and good, but initially I was wondering why to use a method to retrieve the instance, in my own custom implementation I wrote the following code:</p>
<pre>package {

    import flash.errors.IllegalOperationError;

    public class AbnormalSingleton {

        private static var created:Boolean;

        public function AbnormalSingleton()    {

            if (!created) {

                created = true;

            } else {

                throw new IllegalOperationError("AbnormalSingleton can't be instantiated again because is a Singleton.");

            }

        }

    }

}</pre>
<p>With my AbnormalSingleton the first goal of the Singleton pattern is reached (you can&#8217;t get more than one instance), but the pattern has also a second goal: provide a common access point to the reference, and without the getInstance() method, this goal can&#8217;t be accomplished, moreover patterns are used to avoid errors and to be used by several developers in a clear manner. So, my idea was not so smart, because you can use the new operator to instantiate the class for the first time with no errors, but the second time you will get an error, the situation is not clear! Instead with the previous example, is immediately evident that we can&#8217;t use the class to generate multiple instance.</p>
<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://www.daveoncode.com/2008/12/28/learning-design-patterns-with-actionscript-3-episode-1-singleton-pattern/' addthis:title='Learning design patterns with Actionscript 3: episode 1 &#8211; Singleton pattern ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></content:encoded>
			<wfw:commentRss>http://www.daveoncode.com/2008/12/28/learning-design-patterns-with-actionscript-3-episode-1-singleton-pattern/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Playing with Google maps API &#8211; part two: Create custom controls</title>
		<link>http://www.daveoncode.com/2008/11/17/playing-with-google-maps-api-part-two-create-custom-controls/</link>
		<comments>http://www.daveoncode.com/2008/11/17/playing-with-google-maps-api-part-two-create-custom-controls/#comments</comments>
		<pubDate>Mon, 17 Nov 2008 14:11:19 +0000</pubDate>
		<dc:creator>Davide Zanotti</dc:creator>
				<category><![CDATA[javascript]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[controls]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[google maps]]></category>
		<category><![CDATA[map]]></category>
		<category><![CDATA[navigation]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://daveoncode.wordpress.com/?p=50</guid>
		<description><![CDATA[Today we are going to see how to realize custom controls to add to our Google maps powered map. The only concept that should be clear, in order to achive the goal, is what prototype is and why we must use it. Javascript is not a really object oriented language, so we can&#8217;t really talk [...]<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://www.daveoncode.com/2008/11/17/playing-with-google-maps-api-part-two-create-custom-controls/' addthis:title='Playing with Google maps API &#8211; part two: Create custom controls ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></description>
			<content:encoded><![CDATA[<p>Today we are going to see how to realize custom controls to add to our Google maps powered map.</p>
<p>The only concept that should be clear, in order to achive the goal, is what prototype is and why we must use it.</p>
<p>Javascript is not a really object oriented language, so we can&#8217;t really talk about classes and subclassing (using <strong><em>extends </em></strong> like in Java or Actionscript), but however we can create functions that act as constructor for new js objects, and we can inherit properties from an object to another by using the prototyping technique.</p>
<p><span id="more-50"></span></p>
<p>Let&#8217;s consider a simple Javascript constructor function, that can be used to create an Animal object:</p>
<pre>function Animal(name, age, sex) {
    this.name = name;
    this.age = age;
    this.sex = sex;

    this.getInfo = function() {
        alert("Name: " + this.name + "\nAge: " + this.age + "\nSex: " + this.sex);
    }
}</pre>
<p>To extend the Animal class with a Dog class, we have to define the Dog constructor:</p>
<pre>function Dog(name, age, sex, barkPower) {

    Animal.apply(this, arguments);

    this.barkPower = barkPower;

    this.bark = function() {

        var barkBuffer = [this.name, " says: "];

        for (var i=0; i&lt;this.barkPower; i++) {
            barkBuffer.push("bark! ");
        }

        alert(barkBuffer.join(""));

    }

}</pre>
<p>and then prototyping it in this way:</p>
<pre>Dog.prototype = new Animal();</pre>
<p>The Animal.apply() call inside Dog, is like to use super() in Java to call the SuperClass constructor.<br />
Now our Dog has the same methods and properties of Animal, for example we can use the <strong><em>getInfo() </em></strong> method, in addition to <strong><em>bark()</em></strong>:</p>
<pre>var laika = new Dog("Laika", 5, "F", 8);
laika.getInfo();
laika.bark();</pre>
<p>Now, let&#8217;s put the prototyping technique in practice, in order to create a custom control for our map.<br />
The Javascript class that represents a google map&#8217;s control is <strong><em>GControl</em></strong>, so if we want to make something of us own, we must extend that class. Furthermore we have to implements at least 2 methods: <strong><em>initialize()</em></strong> and <strong><em>getDefaultPosition()</em></strong>, in practice the GControl is to be considered an interface.<br />
The first method, must add a DOM node (a graphic button or whatelse represents our control) to the map and return it (with <strong><em>return</em></strong>), the second must return an instance of <strong><em>GControlPosition</em></strong> which is used to place the DOM node (our control) in the right position.<br />
Our goal is to create a custom map navigation (ie: move to north, move to south, move to east and move to west), so we will create 4 js classes that will extend <strong><em>GControl</em></strong> and implements the 2 methods. We call these classes respectively: <strong><em>GoUpButton</em></strong>, <strong><em>GoDownButton</em></strong>, <strong><em>GoLeftButton</em></strong> and <strong><em>GoRightButton</em></strong> .<br />
Let&#8217;s see how <strong><em>GoUpButton</em></strong> is structured and how it works (others buttons will differ only for their position and click handler):</p>
<pre>function GoUpButton(map) {

    this.map = map;
    this.button = document.createElement("a");

}</pre>
<p>The function above, is the <strong><em>GoUpButton</em></strong>&#8216;s constructor, and as you can see it takes one argument: map, that is a reference to the map&#8217;s instance, then it creates an &lt;a&gt; tag that will be our clickable button.<br />
The next step is to extend <strong><em>GControl</em></strong>:</p>
<pre>GoUpButton.prototype = new GControl();</pre>
<p>Now, let&#8217;s implement the <strong><em>initialize()</em></strong> method:</p>
<pre>GoUpButton.prototype.initialize = function() {

    var map = this.map;

    this.button.className = "custom_nav_top";
    this.button.href = "javascript:;";
    this.button.title = "Move the map to the top";
    this.button.innerHTML = "N";

    GEvent.addDomListener(this.button, "click", function() {
        map.panBy(new GSize(0, 100));
    });

    map.getContainer().appendChild(this.button);

    return this.button;

}</pre>
<p>In this method we define the CSS class for the button, set its href attribute to &#8220;javascript:;&#8221; to ensure it won&#8217;t reload the page (is not necessary, but I feel more secure by doing it), set its title attribute and its innerHTML (in this case an N, which stands for North). Then we add an (anonymous) event listener that will be triggered when the user will click the button. This listener will invoke the map&#8217;s <em><em>panBy()</em></em> method, which moves the map by a specific distance by using an animation. The distance is represented by an instance of <em><em>GSize</em></em>, which is essentially a virtual polygon, which dimension are expressed with the two parameters width and height. So with new GSize(0, 100), we will move the map 100 pixels to the top (y axis).<br />
The last two steps in the method are add the node to the DOM (by using map&#8217;s <strong><em>getContainer()</em></strong> method, which returns the node containing the map) and returns it.</p>
<p>Ok, finally there is the <strong><em>getDeafultPosition()</em></strong> implementation:</p>
<pre>GoUpButton.prototype.getDefaultPosition = function() {

    return new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(240, 5));

}</pre>
<p>This is a really simple method that returns an instance of <em><strong>GControlPosition</strong></em>, which will define how to place the control. <em><strong>GControlPosition</strong></em> takes 2 arguments: anchor and offset, the first can be one of the following constants:</p>
<ul>
<li>G_ANCHOR_TOP_RIGHT</li>
<li>G_ANCHOR_TOP_LEFT</li>
<li>G_ANCHOR_BOTTOM_RIGHT</li>
<li>G_ANCHOR_BOTTOM_LEFT</li>
</ul>
<p>that will anchor the control to the 4 possible map&#8217;s corners, the second represents the offset (ie: the distance from the anchor point). In this way we can position our button where we like (GoUpButton will be placed 5 pixel to the top of the map and 240 pixels to the left&#8230; in a map of 500&#215;300 pixels it will appears centered on the top).<br />
We have finished with our custom control!<br />
Now we have to repeat the previous steps for <strong><em>GoDownButton</em></strong>, <strong><em>GoLeftButton</em></strong> and <strong><em>GoRightButton</em></strong>, by replacing the necessary values such button&#8217;s class, innerHTML, title, <em><strong>panBy()</strong></em> argument and <em><strong>GControlPosition()</strong></em> arguments.<br />
In order to add all the 4 controls to the map we will use <strong><em>addControl()</em></strong> method:</p>
<pre>    map.addControl(new GoUpButton(map));
    map.addControl(new GoDownButton(map));
    map.addControl(new GoLeftButton(map));
    map.addControl(new GoRightButton(map));</pre>
<p>The result should be this:</p>
<p><img class="alignnone size-full wp-image-52" title="Custom google map controls" src="http://www.daveoncode.com/wp-content/uploads/2008/11/cmap.jpg" alt="Custom google map controls" /></p>
<p>The full code for the map above is the following:</p>
<pre style="background-repeat:repeat;">/* go top */
function GoUpButton(map) {
    this.map = map;
    this.button = document.createElement("a");
}

GoUpButton.prototype = new GControl();

GoUpButton.prototype.initialize = function() {

    var map = this.map;

    this.button.className = "custom_nav_top";
    this.button.href = "javascript:;";
    this.button.title = "Move the map to the top";
    this.button.innerHTML = "N";

    GEvent.addDomListener(this.button, "click", function() {
        map.panBy(new GSize(0, 100));
    });

    map.getContainer().appendChild(this.button);

    return this.button;

}

GoUpButton.prototype.getDefaultPosition = function() {
    return new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(240, 5));
}

/* go down */
function GoDownButton(map) {
    this.map = map;
    this.button = document.createElement("a");
}

GoDownButton.prototype = new GControl();

GoDownButton.prototype.initialize = function() {

    var map = this.map;

    this.button.className = "custom_nav_down";
    this.button.href = "javascript:;";
    this.button.title = "Move the map to the bottom";
    this.button.innerHTML = "S";

    GEvent.addDomListener(this.button, "click", function() {
         map.panBy(new GSize(0, -100));
    });

    map.getContainer().appendChild(this.button);

    return this.button;

}

GoDownButton.prototype.getDefaultPosition = function() {
    return new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(240, 270));
}

/* go left */
function GoLeftButton(map) {
    this.map = map;
    this.button = document.createElement("a");
}

GoLeftButton.prototype = new GControl();

GoLeftButton.prototype.initialize = function() {

    var map = this.map;

    this.button.className = "custom_nav_left";
    this.button.href = "javascript:;";
    this.button.title = "Move the map to the left";
    this.button.innerHTML = "W";

    GEvent.addDomListener(this.button, "click", function() {
        map.panBy(new GSize(100, 0));
    });

    map.getContainer().appendChild(this.button);

    return this.button;

}

GoLeftButton.prototype.getDefaultPosition = function() {
    return new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(5, 140));
}

/* go right */
function GoRightButton(map) {
    this.map = map;
    this.button = document.createElement("a");
}

GoRightButton.prototype = new GControl();

GoRightButton.prototype.initialize = function() {

    var map = this.map;

    this.button.className = "custom_nav_right";
    this.button.href = "javascript:;";
    this.button.title = "Move the map to the right";
    this.button.innerHTML = "E";

    GEvent.addDomListener(this.button, "click", function() {
         map.panBy(new GSize(-100, 0));
    });

    map.getContainer().appendChild(this.button);

    return this.button;

}

GoRightButton.prototype.getDefaultPosition = function() {
    return new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(470, 140));
}

function initialize() {

    if (GBrowserIsCompatible()) {

        var map = new GMap2(document.getElementById("map_canvas"));

        map.addControl(new GoUpButton(map));
        map.addControl(new GoDownButton(map));
        map.addControl(new GoLeftButton(map));
        map.addControl(new GoRightButton(map));
        map.setCenter(new GLatLng(41.87194, 12.56738), 5);

    }

}</pre>
<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://www.daveoncode.com/2008/11/17/playing-with-google-maps-api-part-two-create-custom-controls/' addthis:title='Playing with Google maps API &#8211; part two: Create custom controls ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></content:encoded>
			<wfw:commentRss>http://www.daveoncode.com/2008/11/17/playing-with-google-maps-api-part-two-create-custom-controls/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Adobe Flex 3 &#8211; Training from the Source&#8230; a new book to read :)</title>
		<link>http://www.daveoncode.com/2008/11/14/adobe-flex-3-training-from-the-source-a-new-book-to-read/</link>
		<comments>http://www.daveoncode.com/2008/11/14/adobe-flex-3-training-from-the-source-a-new-book-to-read/#comments</comments>
		<pubDate>Fri, 14 Nov 2008 20:15:15 +0000</pubDate>
		<dc:creator>Davide Zanotti</dc:creator>
				<category><![CDATA[books]]></category>
		<category><![CDATA[actionscript]]></category>
		<category><![CDATA[adobe]]></category>
		<category><![CDATA[flex]]></category>
		<category><![CDATA[learning flex]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[ria]]></category>
		<category><![CDATA[training]]></category>

		<guid isPermaLink="false">http://daveoncode.wordpress.com/?p=41</guid>
		<description><![CDATA[Directly from Adobe&#8217;s Canadian headquarter and with the amazing efficiency of FedEx shipping (2 days only from Canada to Italy!), this morning I&#8217;ve received a new interesting and fresh book to read: &#8220;Adobe Flex 3 &#8211; Training from the source&#8221;&#8230; yes it talks about Flex 3, Actionscript and RIA and is part of an official [...]<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://www.daveoncode.com/2008/11/14/adobe-flex-3-training-from-the-source-a-new-book-to-read/' addthis:title='Adobe Flex 3 &#8211; Training from the Source&#8230; a new book to read :) ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></description>
			<content:encoded><![CDATA[<p><img class="alignleft size-full wp-image-42" title="Adobe Flex 3 - Training from the source" src="http://www.daveoncode.com/wp-content/uploads/2008/11/41mo3ghu-l_sl500_aa240_.jpg" alt="Adobe Flex 3 - Training from the source" />Directly from Adobe&#8217;s Canadian headquarter and with the amazing efficiency of FedEx shipping (2 days only from Canada to Italy!), this morning I&#8217;ve received a new interesting and fresh book to read: &#8220;Adobe Flex 3 &#8211; Training from the source&#8221;&#8230; yes it talks about Flex 3, Actionscript and RIA and is part of an official books series from Adobe.</p>
<p>I would like to thanks Mike Potter, for the gift. I&#8217;ve appreciated it very much, and I hope to enter in the active Actionscript/Flex community as soon as possible.</p>
<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://www.daveoncode.com/2008/11/14/adobe-flex-3-training-from-the-source-a-new-book-to-read/' addthis:title='Adobe Flex 3 &#8211; Training from the Source&#8230; a new book to read :) ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></content:encoded>
			<wfw:commentRss>http://www.daveoncode.com/2008/11/14/adobe-flex-3-training-from-the-source-a-new-book-to-read/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

