<?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>munky.net &#187; Software</title>
	<atom:link href="http://www.munky.net/category/software/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.munky.net</link>
	<description>design and open source</description>
	<lastBuildDate>Mon, 19 Jul 2010 23:25:39 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Samba file synchronization with GoodSync vs Offline Files</title>
		<link>http://www.munky.net/design/reviews/samba-file-synchronization-with-goodsync-vs-offline-files/</link>
		<comments>http://www.munky.net/design/reviews/samba-file-synchronization-with-goodsync-vs-offline-files/#comments</comments>
		<pubDate>Mon, 20 Feb 2006 23:09:38 +0000</pubDate>
		<dc:creator>rdo</dc:creator>
				<category><![CDATA[Reviews]]></category>
		<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://www.munky.net/design/reviews/samba-file-synchronization-with-goodsync-vs-offline-files/</guid>
		<description><![CDATA[Since I&#8217;m starting to use a laptop more frequently these days, I decided to reconfigure my home network a bit so as to centralize my work files. Previously I had kept my work files on my desktop PC and used the Offline Files feature built into Windows 2000 and XP to synchronize a small number [...]]]></description>
			<content:encoded><![CDATA[<p>Since I&#8217;m starting to use a laptop more frequently these days, I decided to reconfigure my home network a bit so as to centralize my work files. Previously I had kept my work files on my desktop PC and used the Offline Files feature built into Windows 2000 and XP to synchronize a small number of files with an older laptop that I used only occasionally. That scheme worked fine at the time, but since I&#8217;m now planning on doing an increasing amount of work on my laptop instead of my desktop I didn&#8217;t want to require that my desktop machine be turned on to synchronize files.</p>
<p>Since I have a third machine running linux and <a href="http://www.munky.net/wp-admin/www.mythtv.org">MythTV</a> that is on all the time anyway, I decided to set up a <a href="http://us1.samba.org/samba/">Samba</a> share on that machine and make that my work files&#8217; primary repository. An added advantage of the Samba configuration is that I can use <a href="http://www.nongnu.org/rdiff-backup/">rdiff-backup</a> for easy remote backups of the repository. Configuring Samba was relatively painless, and far simpler than I remember it being from a few years ago.</p>
<p>Problems arose when I attempted to set up Offline Files on my laptop to create a local mirror of the files on the Samba share. <span id="more-30"></span>For some reason, once I activated Offline Files on the laptop, it had trouble consistently connecting to the file server on my home network. Often it would only show the cached, offline version of the share even though it was clearly connected to the network and able to resolve and ping the file server. Restarting the laptop solved the problem about half the time, which suggests to me that the problem may have something to do with a race condition between connecting to the wireless network and/or Samba, and determining the Offline Files state upon startup.</p>
<p>Offline Files comes with a couple other annoyances that made it a less than optimal solution. For one thing, the local cache is kept in a folder at the root of the C: drive, which can only be relocated using a special tool on the Windows administrator tools CD. Since I normally keep my OS and program installations on C: and all data on D:, I don&#8217;t care for anything that keeps user data on C:. In addition, Offline Files has a habit of being somewhat noisy when it can&#8217;t find a network share, which can be distracting when you&#8217;re away from your home network. There is a way to change behavior based on which network interface is being used, but that didn&#8217;t help me since I use the wireless interface both at home and at school.</p>
<p>Ultimately I gave up on Samba in favor of a free (for personal use) piece of software called <a href="http://www.munky.net/wp-admin/www.goodsync.com">GoodSync</a> from Siber Systems. Siber makes <a href="http://www.munky.net/wp-admin/www.roboform.com">RoboForm</a>, a very useful and well-regarded Windows tool for password management. I chose GoodSync (despite it silly name) because I am generally happy with the way RoboForm works, and so far it has fit my needs perfectly. And ever since I turned Offline Files off, my laptop has had absolutely no problem connecting to the Samba share at home.</p>
<p>GoodSync has a number of options for both one-way and bidirectional synchronization, and supports sophisticated options and filters for which files get synchronized. It is entirely transaction based at a file level and keeps its own database of states and changes instead of just looking at modification dates. The &#8220;analyze&#8221; feature tells you exactly what changes  will be made upon synchronization, which is helpful when configuring complicated jobs. Synchronization can be set up to occur automatically similar to the way Offline Files works, but for now I&#8217;m doing it manually whenever I know a synch is necessary.</p>
<p>The only issue I&#8217;ve had is that GoodSync leaves _SYNCAPP directories at the bases of the file hierarchies that it&#8217;s synchronizing. Presumably this is where it keeps its internal database. While this may have been the best solution in terms of organizing and protecting the database, the presence of these files is distracting. A quick change to my Samba configuration allowed me to hide these directories automatically. However, I&#8217;m still not sure whether they ought to be included in the repository backups.</p>
<p><strong>Update 3/08/06:</strong> I contacted Siber to ask about this and received a reply in broken English that didn&#8217;t really answer my question, just saying that the _SYNCAPP folders were important. I&#8217;m going to have to do some tests on my own to see if the metadata is rebuilt automatically if lost.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.munky.net/design/reviews/samba-file-synchronization-with-goodsync-vs-offline-files/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>More on system-config-network</title>
		<link>http://www.munky.net/software/linux/more-on-system-config-network/</link>
		<comments>http://www.munky.net/software/linux/more-on-system-config-network/#comments</comments>
		<pubDate>Wed, 30 Mar 2005 01:44:43 +0000</pubDate>
		<dc:creator>rdo</dc:creator>
				<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://www.munky.net/?p=18</guid>
		<description><![CDATA[Now that I&#8217;ve been using my linux laptop with its new wireless connection, I wanted a way to switch between configurations for home (specific ESSID with encryption) and school (various ESSIDs with no encryption). I struggled with this for awhile using the system-config-network tool, which shows up in xfce as &#8220;Network Device Control&#8221; under the [...]]]></description>
			<content:encoded><![CDATA[<p>Now that I&#8217;ve been using my linux laptop with its new wireless connection, I wanted a way to switch between configurations for home (specific ESSID with encryption) and school (various ESSIDs with no encryption). I struggled with this for awhile using the system-config-network tool, which shows up in xfce as &#8220;Network Device Control&#8221; under the System menu and used to be called redhat-config-network in the RedHat days. However, I was having trouble getting multiple profiles to work, and the documentation wasn&#8217;t helping.</p>
<p>Finally I figured it out with the help of <a href="http://linuxplanet.com/linuxplanet/tutorials/5779/2/">this guide on LinuxPlanet</a>. Apparently settings in the default &#8220;Common&#8221; profile actually affects all profiles, which is why I was unable to get my Common (home) and School profiles to maintain separate settings. The key is to ignore the Common profile and create discrete new profiles for each actual set of settings you want to use.</p>
<p><span id="more-18"></span>Now if I could only figure out how to get the wireless card to just connect to any available AP without having to tell it an ESSID, since there are many AP&#8217;s in my department building. Apparently that problem is solved by <a href="http://www.gnome.org/projects/NetworkManager/">NetworkManager</a>, which is a replacement for the standard linux network service, but I haven&#8217;t had any luck getting that to work yet (for one thing, the UI component doesn&#8217;t work under xfce).</p>
<p>For now the way I&#8217;m dealing with this is to set up a profile in the system network tool for each AP that I connect to, and use the netprofile=[profile name] kernel param in grub.conf to choose between which one I want at startup.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.munky.net/software/linux/more-on-system-config-network/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Getting a wireless card working in Fedora Core 3 using ndiswrapper</title>
		<link>http://www.munky.net/software/linux/getting-a-wireless-card-working-using-ndiswrapper/</link>
		<comments>http://www.munky.net/software/linux/getting-a-wireless-card-working-using-ndiswrapper/#comments</comments>
		<pubDate>Wed, 23 Mar 2005 08:49:27 +0000</pubDate>
		<dc:creator>rdo</dc:creator>
				<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://www.munky.net/?p=17</guid>
		<description><![CDATA[My (ultimately successful) experiences getting a cheap wireless card working using the ndiswrapper drivers.]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m posting this with the hope that someone in a similar situation might come across it on a Google search and find some helpful information.</p>
<p>This evening I managed to get a cheap ($10 after rebates at Fry&#8217;s) <a href="http://www.buffalotech.com/wireless/products/airstation/WLICBG54L.html">Buffalo WLI-CB-G54L wireless PCMCIA card</a> working in my aging Sony Vaio PCG-F540 (Pentium III) laptop, which I just upgraded to Fedora Core 3. This card is based on the Texas Instruments ACX 111 chip, which lacks any sort of official Linux driver support from the manufacturer. Although <a href="http://acx100.sourceforge.net/">there is an open-source project to create a native Linux driver for this device</a>, that driver in its present state does not support WEP encryption, and I wasn&#8217;t about to run an unsecured wireless network. My only other option was to use the <a href="http://ndiswrapper.sourceforge.net">ndiswrapper</a> package, which basically allows binary Windows XP wireless drivers to work in Linux. Amazingly enough, it ended up working.</p>
<p><span id="more-17"></span>There&#8217;s a <a href="http://ndiswrapper.sourceforge.net/mediawiki/index.php/Installation">pretty good install guide for ndiswrapper</a> as part of the Wiki on their site. I basically followed the instructions there, but there are a few things worth mentioning.</p>
<p>First, it&#8217;s not necessary to install the Fedora 3 kernel sources as the install guide implies. Doing this is actually a pain in FC3 because they&#8217;ve gotten rid of the kernel-sources rpm; you now have to get the sources by installing the kernel SRPM (which is different) and going through a few additional steps (this is documented in the <a href="http://download.fedora.redhat.com/pub/fedora/linux/core/3/i386/os/RELEASE-NOTES-en.html">Fedora Core 3 Release Notes</a>). The ndiswrapper source only needs the kernel module sources to be present, which you will find in /lib/modules on a stock FC3 install.</p>
<p>So I build ndiswrapper with the usual <code>make</code>, <code>make install</code> procedure, and then downloaded the card&#8217;s windows drivers from <a href="http://www.buffalotech.com/downloads/CBG54L.zip">Buffalo&#8217;s site</a>. Following the instructions on the Wiki, I installed those drivers using <code>ndiswrapper -i</code>, modprobe&#8217;d the ndiswrapper kernel module, and was able to see my AP with <code>iwlist wlan0 scan</code>.</p>
<p>At this point I encountered the first big problem, which was that when I tried to set the WEP key using <code>iwconfig wlan key restricted [key]</code>, I ended up with a segfault that pretty much locked up the machine. Looking back through the Wiki, I suspected that the problem was that the FC3 kernel has a stack size limited to 4k. Windows drivers apparently often use much more than that. I couldn&#8217;t even find the right option to change that in the Fedora kernel config (<code>CONFIG_4KSTACKS</code>); evidently I&#8217;d have to compile a totally generic kernel in order to change that setting. Fortunately <a href="http://www.linuxant.com">Linuxant</a>, a software company that sells a commercial version of what ndiswrapper does has provided <a href="http://www.linuxant.com/driverloader/wlan/full/downloads-fc3-kernel-i686.php">versions of the Fedora kernel that allow larger stack sizes</a>. I downloaded and installed their kernel RPM, and no more segfault when turning on WEP.</p>
<p>The next step was to get the wireless card to connect to the AP using <code>iwconfig wlan0 essid [my AP's ESSID]</code>. That took a lot longer than it should have, because I forgot that my wireless AP was set up to only take connections from certain preregistered MAC addresses. So once I remembered that and added the new card&#8217;s MAC address to the list, I was able to establish a link to the AP.</p>
<p>The final step was to set up linux networking to use the wireless link. At first I tried writing my own <code>/etc/sysconfig/network-scripts/ifcfg-wlan0</code> file, but I kept getting something wrong and it wouldn&#8217;t work. Every time I tried <code>/sbin/ifup</code> the card try to get a DHCP address, fail, reset, and no longer be connected to the AP.</p>
<p>A few more Google searches led me to try the built in network config tool, which lives at <code>/usr/sbin/system-config-network-gui</code>. I never used to pay much attention to those RedHat system config tools, but it really saved me in this case. First, though, I had to run <code>ndiswrapper -m</code>, which added a line to <code>/etc/modprobe.conf</code> that allowed the system-config tool to recognize the ndiswrapper process as a wlan device. From there I just set it up using the GUI, saved the configuration, and hit Activate. Actually that ended up crashing the machine on the first try, but after I restarted my net connection was up and running just like magic.</p>
<p>This all involved a bit more fussing around than I normally like to have to do to get a network connection going these days, but I&#8217;m glad it worked out eventually and hope that this post can point some others in the right direction.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.munky.net/software/linux/getting-a-wireless-card-working-using-ndiswrapper/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Using a preloader with v2 components</title>
		<link>http://www.munky.net/software/flash-actionscript/using-a-preloader-with-v2-components/</link>
		<comments>http://www.munky.net/software/flash-actionscript/using-a-preloader-with-v2-components/#comments</comments>
		<pubDate>Fri, 20 Aug 2004 06:34:22 +0000</pubDate>
		<dc:creator>rdo</dc:creator>
				<category><![CDATA[Flash ActionScript]]></category>

		<guid isPermaLink="false">http://www.munky.net/?p=16</guid>
		<description><![CDATA[I've finally nailed down a good way to use a preloader with Flash Player 7 movies that use the v2 component framework.]]></description>
			<content:encoded><![CDATA[<p>Ever since Flash MX 2004 Pro was released, I&#8217;ve been struggling with the question of how to create a lightweight preloader for movies that use v2 components. The basic problem is that the v2 components come with a large ActionScript class library that can add a substantial amount to even small movies that use even one component.</p>
<p>For awhile I&#8217;d been using an approach that involved a small preloader movie that displayed a loading animation and progress bar, and used loadMovie() to load the content movie (with components) into an empty clip. This worked in many cases, but it turns out that there are some v2 components, such as ComboBox and Window, that don&#8217;t work properly when they&#8217;re loaded into a sub-clip in this manner. Basically, those components contain code that makes explicit references to the _root timeline, which is a no-no. The Macromedia docs suggest using the _lockroot property on the target clip in order to trick the components into seeing the proper timeline as _root, but in my experiments I have found that this does not always work.</p>
<p>Recently, thanks to an entry in Jesse Warden&#8217;s blog, have been able to create a preloader that works with movies that use v2 components. As an added bonus, the preloader does not need to reside in a separate swf file, and thus doesn&#8217;t need to mess with _lockroot &#8212; it can be implemented as part of the main movie. I&#8217;ll describe the steps needed to accomplish this below, if for no other purpose than to remind myself of what I did!</p>
<p>Start with a movie that uses v2 components. Open up the library and identify these two types of symbols:</p>
<ol>
<li>all component symbols (Button, ComboBox, Label, Window, etc.)</li>
<li>all compiled clips and/or movie clips that will be dynamically instantiated at runtime; this includes View symbols for window and accordion contents, component skin symbols, etc.</li>
</ol>
<p>I usually keep these types of symbols in a separate folder in the library. For each of these symbols, right click and open the &#8220;Linkage&#8230;&#8221; dialog, and deselect &#8220;Export in first frame&#8221;. This prevents the code and assets for those symbols from being loaded at the very beginning of the movie, which means we&#8217;ll be able to put up a preloader before those start loading. It&#8217;s very imporant to indentify all components and dynamically instantiated symbols used in the movie and edit their library symbol entries in this way.</p>
<p>One important exception to this is the DataBindingClasses symbol that gets added to the library automatically whenever you use a v2 component in a movie. This symbol needs to have &#8220;Export in first frame&#8221; checked. I think the reason for this is that it needs to load before any components do. At any rate, even though we&#8217;re leaving it as one of the things that gets loaded at the very beginning of the movie, it&#8217;s not very large so it shouldn&#8217;t affect the preloader loading time too much.</p>
<p>The next step is to add three blank keyframes to the very beginning of the main timeline. There should initially be nothing at all on the stage on these frames; in other words, all your main movie content needs to be shifted three frames to the right. At this point I also usually add a new movie layer called &#8220;preloader&#8221;, and I&#8217;m also assuming that you already have a &#8220;script&#8221; or &#8220;code&#8221; layer that contains only frame actions.</p>
<p>The first two of the three new frames will be used for the preloader loop. Frame 1 actions should look like this:</p>
<p><code>// Frame 1 actions<br />
trace(getBytesLoaded()+" of "+getBytesTotal());<br />
if (getBytesLoaded() > 0 &#038;&#038; getBytesLoaded() >= getBytesTotal()) gotoAndPlay(3);</code></p>
<p>Of course the trace is optional, and could be replaced with a line that sets the percentage loaded value on a progress bar or other indicator. Next, set this line as the frame 2 action:</p>
<p><code>// Frame 2 actions<br />
gotoAndPlay(1);</code></p>
<p>These two frame actions are just the typical way to &#8220;pause&#8221; a movie until the whole swf file has loaded on the client machine. Once the entire movie has loaded, the playhead is allowed to proceed to frame 3. Your lightweight preloader animation and/or loading indicator can be put on the stage on the &#8220;preloader&#8221; layer spanning frames 1 and 2, so that they are visible during the preloading process.</p>
<p>The next step is to create a special frame on frame 3, which contains instances of all the symbols for which we unchecked &#8220;Export in first frame&#8221; in the first step (this is why we organized them into a special library folder earlier). Create a blank keyframe at frame 3 on the preloader layer and drag one instance of each such component onto the stage but outside the movie&#8217;s viewable area. What we&#8217;re doing here is telling the Flash compiler that it will indeed need to load these assets for use on frame 3 and beyond (since it&#8217;s not going to load them at the beginning of the movie as usual). These component instances don&#8217;t have to stay on the stage past frame 3; a brief appearance on this single frame is enough to tell the compiler when they need to be loaded.</p>
<p>The observant reader will note that it&#8217;s not actually necessary for each and every one of these clips to be instantiated on frame 3, since many of them probably appear on the timeline later on past frame 3 anyway. Technically this is true &#8212; all we really need is for each symbol that gets dynamically instantiated by application ActionScript code, and therefore isn&#8217;t statically placed on the timeline in the authoring environment &#8212; to be instantiated in this way on frame 3. This includes some components, namely Window, which tends to be instantiated at runtime using the PopupManager class. However, it doesn&#8217;t hurt just to instantiate everything on frame 3, so I&#8217;m recommending that as a less error-prone approach.</p>
<p>The final &#8212; and quite critical &#8212; step is to tell the compiler that ActionScript classes should be loaded on frame 3 instead of frame 1. This can be done by going to the dialog at File Publish Settings&#8230; Flash (ActionScript) Settings&#8230; and setting the &#8220;Export Frame for Classes&#8221; value to 3. This prevents the huge chunk of ActionScript class code that comes along with the v2 components from being loaded at the beginning of the movie and thus trumping the preloader. The important thing is that the class export frame be no later than the frame on which the symbols that use those classes first appear.</p>
<p>At this point your timeline should look something like this:</p>
<p><img alt="Timeline" src="http://www.munky.net/blog_img/preloader_timeline.png" /></p>
<p>In the above image, the frame colors correspond to:</p>
<ul>
<li>orange: the two script frames with the preloader loop actions described above</li>
<li>green: any lightweight preloader animation and/or loading indicator clips</li>
<li>yellow: the special frame on which any dynamically instantiated symbols are manually instantiated on the stage but outside the viewable area</li>
<li>blue: the main movie that is being preloaded</li>
</ul>
<p>You should be able to verify that the loading sequence is working as intended by selecting &#8220;generate size report&#8221; on the Flash Publish Settings dialog, and examining the report to ensure that the bulk of the movie doesn&#8217;t get loaded until frame 3.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.munky.net/software/flash-actionscript/using-a-preloader-with-v2-components/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Using a static initializer in AS2.0</title>
		<link>http://www.munky.net/software/flash-actionscript/using-a-static-initializer-in-as20/</link>
		<comments>http://www.munky.net/software/flash-actionscript/using-a-static-initializer-in-as20/#comments</comments>
		<pubDate>Thu, 19 Aug 2004 06:30:26 +0000</pubDate>
		<dc:creator>rdo</dc:creator>
				<category><![CDATA[Flash ActionScript]]></category>

		<guid isPermaLink="false">http://www.munky.net/?p=15</guid>
		<description><![CDATA[Some design patterns require the use of a static initializer, a block of code that should execute once and only once the first time a class is referred to. The typical use for this pattern in ActionScript programming is when a mix-in class needs to be used, as in the case of the mx.events.EventDispatcher class. [...]]]></description>
			<content:encoded><![CDATA[<p>Some design patterns require the use of a static initializer, a block of code that should execute once and only once the first time a class is referred to. The typical use for this pattern in ActionScript programming is when a mix-in class needs to be used, as in the case of the mx.events.EventDispatcher class. EventDispatcher contains a static method, EventDispatcher.initialize(), which can be invoked to add the event framework methods to any arbitrary class.</p>
<p>Say we have a class called ActionManager that needs the event handling mix-in methods. One approach would be to invoke EventDispatcher.initialize(this) in ActionManager&#8217;s constructor method; however, this approach suffers from the drawback that the EventDispatcher initializer could be invoked multiple times (each time a new ActionManger instance is created), when it really only should be invoked once.</p>
<p>If we were programming in Java, we&#8217;d be able to do something like this, using the static initializer syntax:</p>
<pre>public class ActionManager {
static {
mx.events.EventDispatcher.initialize(ActionManager.class);
}
public ActionManager() {
...
}
...
}</pre>
<p>Now, ActionScript doesn&#8217;t have this sort of static block syntax, but fortunately there is a way to accomplish the same thing:</p>
<pre>class ActionManager {
private var staticInitialized:Boolean = staticInitializer();
private static function staticInitializer(Void):Boolean {
mx.events.EventDispatcher.initialize(ActionManager.prototype);
return true;
}
public function ActionManager(Void) {
...
}
}</pre>
<p>The ActionScript pattern illustrated above does the same thing as Java&#8217;s static initializer block syntax &#8212; the staticInitializer() method will only be called once, the first time the class is referenced, and before the constructor method is invoked.</p>
<p>Although this pattern is typically used to set up mix-in classes such as EventDispatcher, it is also useful for setting up arbitrary static class memebers such as lookup tables, etc., which only need to be calculated once across all instances of a class.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.munky.net/software/flash-actionscript/using-a-static-initializer-in-as20/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Differences between AS2.0 and Java</title>
		<link>http://www.munky.net/software/flash-actionscript/differences-between-as20-and-java/</link>
		<comments>http://www.munky.net/software/flash-actionscript/differences-between-as20-and-java/#comments</comments>
		<pubDate>Tue, 24 Feb 2004 04:01:55 +0000</pubDate>
		<dc:creator>rdo</dc:creator>
				<category><![CDATA[Flash ActionScript]]></category>

		<guid isPermaLink="false">http://www.munky.net/?p=2</guid>
		<description><![CDATA[ActionScript 2.0 is much more object oriented and Java-like than its predecessor, which makes it easy to learn for Java programmers. Here are some key differences, which may help make the transition easier.]]></description>
			<content:encoded><![CDATA[<p>ActionScript 2.0 is much more object oriented and Java-like than its predecessor, which makes it easy to learn for Java programmers. Here are some key differences, which may help make the transition easier:</p>
<p><strong>Static Classes</strong></p>
<p>Although AS2.0 does support static classes, a crucial difference from Java is that static members cannot be accessed through instance variables. For example, if we have a Java class Foo that defines a public static field BAR, the following would output the value of BAR:</p>
<p><code>Foo myFoo = new Foo();<br />
System.out.println("BAR is "+myFoo.BAR);<br />
</code></p>
<p>However, this will not work in AS2.0 since static members can&#8217;t be accessed through instance variables. Instead, we&#8217;d only be able to access BAR through the static reference Foo.BAR. In my opinion, this is a significant shortcoming that breaks some important design patterns that rely on static members.</p>
<p><strong>No Multithreading</strong></p>
<p>ActionScript is not multithreaded. This relieves us from having to worry about thread management with synchronized blocks. For example, a Singleton can be implemented without concern for multiple threads inadvertently creating more than one initial instance. However, there are still cases in which one must watch out for race conditions, since ActionScript is full of event-driven callback mechanisms in which execution order cannot be known ahead of time (loading external assets and XML data, for example). In other words, while we don&#8217;t have to worry about two methods (or statements, for that matter) executing at the same time, or two threads executing the same method at the same time, we do still need to be concerned about the order in which methods execute. As far as I can tell, methods themselves can be guaranteed to execute atomically.</p>
<p><strong>No Method Overloading</strong></p>
<p>In Java, it&#8217;s possible to define more than one signature for a given method, varying based on the number, type, and ordering of parameters. In AS2.0, only one signature is allowed per method (including constructors). However, this disadvantage is offset somewhat by the fact that the AS compiler does not require that all parameters be specified when invoking a method; this allows us to write a method in which optional parameters follow required ones. For example, consider the constructor for the built-in Date object:</p>
<p><code>new Date(year, month [, date [, hour [, minute [, second [, millisecond ]]]]])</code></p>
<p>The Date constructor is written to accept seven parameters, but they are optional from least to most specific (right to left); that is, one could construct a Date by specifying only year, month, and date. In that case, the constructor would only see values for the first three parameters, and the rest would be undefined.</p>
<p>I&#8217;ll add more items to this list as I think of them.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.munky.net/software/flash-actionscript/differences-between-as20-and-java/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Using the event framework outside Components</title>
		<link>http://www.munky.net/software/flash-actionscript/using-the-event-framework-outside-components/</link>
		<comments>http://www.munky.net/software/flash-actionscript/using-the-event-framework-outside-components/#comments</comments>
		<pubDate>Sat, 21 Feb 2004 04:14:25 +0000</pubDate>
		<dc:creator>rdo</dc:creator>
				<category><![CDATA[Flash ActionScript]]></category>

		<guid isPermaLink="false">http://www.munky.net/?p=3</guid>
		<description><![CDATA[The v2 component architecture introduced a new event dispatching and handling framework, in which event objects are produced by components and consumed by whatever listeners are attached to them. For more information on this, refer to the Flash documentation under &#8220;Using the event object&#8221;. The following sample code illustrates the basic principles. listener = new [...]]]></description>
			<content:encoded><![CDATA[<p>The v2 component architecture introduced a new event dispatching and handling framework, in which event objects are produced by components and consumed by whatever listeners are attached to them. For more information on this, refer to the Flash documentation under &#8220;Using the event object&#8221;. The following sample code illustrates the basic principles.</p>
<pre>listener = new Object();
listener.click = function(evtObj) {
trace("Button clicked: "+evt.target);
}
myButton.addEventListener("click", listener);</pre>
<p>The myButton component generates a &#8220;click&#8221; event when pressed using the following code:</p>
<p><code>this.dispatchEvent({type:"click", target:this});</code></p>
<p>which creates a new (anonymous) event object (with the requisite type and target properties) and submits it to the event handling framework. The event framework then passes the event along to the listener object, which itself was previously registered as a listener for events of type &#8220;click&#8221; coming from myButton.</p>
<p>One very nice feature of the new event framework is that it is also possible to use it outside the context of v2 components. This can be useful, for example, when creating a modular application in which various elements need to communicate with one another yet making those elements into full-fledged components would be overkill.</p>
<p>Any object can be made into an event producer by invoking the EventDispatcher mix-in. A mix-in is a special class that dynamically adds methods and fields to a given object in order to expand its functionality. Such constructs are used liberally throughout the core classes in Flash MX 2004. Using the EventDispatcher mix-in adds the following methods to a given object:</p>
<p><strong><code>dispatchEvent(evtObj):Void</code></strong></p>
<p>Dispatches the given event object to the event framework, allowing it to be sent to any attached listeners</p>
<p><strong><code>addEventListener(eventType:String, handler):Void</code></strong></p>
<p>Registers the specified handler object as a listener for the specified event type coming from the current object</p>
<p><strong><code>removeEventListener(eventType:String, handler):Void</code></strong></p>
<p>Unregisters the specified handler for the specified event type</p>
<p>An additional method called dispatchQueue is also added, but that method is for internal use by the event framework.</p>
<p>In order to add these events to an object, simply invoke EventDispatcher.initialize:</p>
<pre>class MyCalendar extends MovieClip {

public function MyCalendar(Void) {
...
// this adds (mixes in) the dispatchEvent, etc. methods
mx.events.EventDispatcher.initialize(this);
}
...
}</pre>
<p>Once the initialize method is invoked at runtime, the MyCalendar class will have dispatchEvent and the add/remove listener methods, and will work just like any other event producer in the event framework.</p>
<p>One problem with the fact that the event methods are added through a mix-in at runtime is that the compiler won&#8217;t know about those methods while it is compiling the class. Therefore, if we just invoke dispatchEvent within the example class above, the compiler will generate an error since dispatchEvent isn&#8217;t defined within MyCalendar or within MovieClip, its superclass.</p>
<p>There are two ways to get around this problem. The easiest is just to define three additional class fields of type Function, one for each method that&#8217;s going to be added by the mixin:</p>
<pre>class MyCalendar extends MovieClip {

var dispatchEvent:Function;
var addEventListener:Function;
var removeEventListener:Function;

public function MyCalendar(Void) {
...
// this adds (mixes in) the dispatchEvent, etc. methods
mx.events.EventDispatcher.initialize(this);
}
...
}</pre>
<p>A slightly more rigorous method is to add a &#8220;stub&#8221; for each of the mix-in methods, which will be overridden once the mix-in attaches the real methods at runtime but will satisfy the compiler in the meantime. Write the stubs to throw Errors by default, just to make sure that the mix-in did in fact override those methods as expected:</p>
<pre>class MyCalendar extends MovieClip {

public function MyCalendar(Void) {
...
// this adds (mixes in) the dispatchEvent, etc. methods
mx.events.EventDispatcher.initialize(this);
}

public function dispatchEvent(evtObj):Void {
throw new Error("dispatchEvent method not overridden!");
}

public function addEventListener(eventType:String, listener) {
throw new Error("addEventListener method not overridden!");
}

public function removeEventListener(eventType:String, listener) {
throw new Error("removeEventListener method not overridden!");
}

...
}</pre>
<p>By doing this, the compiler will see that MyCalendar does in fact define the event methods, even though those methods will be overridden at runtime by the EventDispatcher class.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.munky.net/software/flash-actionscript/using-the-event-framework-outside-components/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Useful undocumented properties of the Loader.progress event</title>
		<link>http://www.munky.net/software/flash-actionscript/undocumented-loader-event/</link>
		<comments>http://www.munky.net/software/flash-actionscript/undocumented-loader-event/#comments</comments>
		<pubDate>Fri, 13 Feb 2004 06:03:07 +0000</pubDate>
		<dc:creator>rdo</dc:creator>
				<category><![CDATA[Flash ActionScript]]></category>

		<guid isPermaLink="false">http://www.munky.net/?p=5</guid>
		<description><![CDATA[I discovered two useful undocumented properties of the event object emitted by the Loader class.]]></description>
			<content:encoded><![CDATA[<p>Two very useful additional properties of the event object passed to the hander for the Loader.progress event are evt.current  (current number of bytes loaded) and evt.total (total bytes to load).</p>
<p>Example:</p>
<pre>var loadListener = new Object();
loadListener.handleEvent = function(evt) {
if (evt.type == "progress") {
trace("PROGRESS: "+evt.current+" of "+evt.total);
}
};
myFormOrSlideOrWhatever.addEventListener("progress", loadListener);
myFormOrSlideOrWhatever.load();</pre>
<p>Looks like the Loader component is probably based on the MovieClipLoader AS object. The MovieClipLoader.onLoadProgress entry in the docs mention the current and total properties of that event.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.munky.net/software/flash-actionscript/undocumented-loader-event/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Setting styles for a component class</title>
		<link>http://www.munky.net/software/flash-actionscript/setting-styles-for-a-component-class/</link>
		<comments>http://www.munky.net/software/flash-actionscript/setting-styles-for-a-component-class/#comments</comments>
		<pubDate>Tue, 03 Feb 2004 06:08:25 +0000</pubDate>
		<dc:creator>rdo</dc:creator>
				<category><![CDATA[Flash ActionScript]]></category>

		<guid isPermaLink="false">http://www.munky.net/?p=6</guid>
		<description><![CDATA[Details on how exactly to set the default style for all instances of a particular component.]]></description>
			<content:encoded><![CDATA[<p>The docs say that this can be used to set a global style for a particular component:</p>
<p><code>_global.styles.RadioButton.setStyle("color", "blue");</code></p>
<p>What&#8217;s not quite clear from this is that before doing that, you&#8217;d need to create the style object for the RadioButton class first:</p>
<p><code>_global.styles.RadioButton = new mx.styles.CSSStyleDeclaration();</code></p>
<p>Otherwise you&#8217;re calling setStyle on a null reference.</p>
<p>Also interesting to note is the fact that setStyle is not actually a method of CSSStyleDeclaration. I don&#8217;t know where it comes from, actually (UIObject? Some kind of mixin?). Therefore you can&#8217;t use strict typing on style objects if you&#8217;re going to call setStyle on them.</p>
<p><strong>Update:</strong> Got some more information on this from a response on FlashCoders. Turns out that setStyle does indeed come from a mixin &#8212; in short, UIComponent loads in UIComponentExtensions, which calls mx.styles.CSSSetStyle.enableRunTimeCSS(), which in turn causes the CSSSetStyle methods to be mixed in to CSSStyleDeclaration.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.munky.net/software/flash-actionscript/setting-styles-for-a-component-class/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Math.log() is really ln</title>
		<link>http://www.munky.net/software/flash-actionscript/mathlog-is-really-ln/</link>
		<comments>http://www.munky.net/software/flash-actionscript/mathlog-is-really-ln/#comments</comments>
		<pubDate>Tue, 13 Jan 2004 06:09:02 +0000</pubDate>
		<dc:creator>rdo</dc:creator>
				<category><![CDATA[Flash ActionScript]]></category>

		<guid isPermaLink="false">http://www.munky.net/?p=7</guid>
		<description><![CDATA[In AS2.0, the Math.log(x) function actually gives you ln x (base e).]]></description>
			<content:encoded><![CDATA[<p>Note that the Math.log(x) function actually gives you ln x (base e). Luckily, high school algebra comes to the rescue. If you need log base 10, use</p>
<p><code>Math.log(x)/Math.LN10</code></p>
<p>which divides ln x by ln 10.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.munky.net/software/flash-actionscript/mathlog-is-really-ln/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
