<?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>Zeh Fernando</title>
	<atom:link href="http://zehfernando.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://zehfernando.com</link>
	<description></description>
	<lastBuildDate>Tue, 24 Jan 2012 22:30: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>Android for ActionScript developers, part 3: Threads and blocking</title>
		<link>http://zehfernando.com/2012/android-for-actionscript-developers-part-3-threads-and-blocking/</link>
		<comments>http://zehfernando.com/2012/android-for-actionscript-developers-part-3-threads-and-blocking/#comments</comments>
		<pubDate>Tue, 24 Jan 2012 22:19:37 +0000</pubDate>
		<dc:creator>Zeh</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[Mobile]]></category>

		<guid isPermaLink="false">http://zehfernando.com/?p=1099</guid>
		<description><![CDATA[Multithreading support &#8211; the ability to run different blocks of code separately, in parallel &#8211; has always been a requested feature in the Flash/ActionScript community (and it&#8217;s, indeed, coming). But the reality is, due to the way the platform is designed, reasons to use concurrency in Flash are very rare. I&#8217;m sure some exist, but [...]]]></description>
			<content:encoded><![CDATA[<p>Multithreading support &#8211; the ability to run different blocks of code separately, in parallel &#8211; has always been a requested feature in the Flash/ActionScript community (and it&#8217;s, indeed, <a href="http://matthewfabb.com/blog/2010/11/11/multithreading-is-finally-coming-to-flash/">coming</a>). But the reality is, due to the way the platform is designed, reasons to use concurrency in Flash are very rare. I&#8217;m sure some exist, but it&#8217;s not part of the tasks you normally have to program into a website or even a generic application.</p>
<p>The reason is simple. Consider the following code:</p>
<pre>var loader:Loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoadComplete);
loader.load("myimage.jpg");

protected function onLoadComplete(__e:Event) {
	trace("Image loaded!");
}</pre>
<p>The code will attempt to load an image and, when that is complete, display a message stating it did so.</p>
<p>The important thing to notice about this code is that it is <em><a href="http://en.wikipedia.org/wiki/Non-blocking_algorithm">non-blocking</a></em>; when the call to <code>load()</code> is made, Flash just continues execution of your next line of code as if nothing happened. This is one of the many moments where Flash executes your requests <em>asynchronously</em>, letting you know later (via an event) when that request has been completed (or reporting on its progress, or any other event conditions necessary).</p>
<p>One big hurdle I had when I started working with Java is realizing that the language is, indeed, blocking everything you&#8217;re doing. Consider a similar code to load an image on Android:</p>
<pre>URL fileURL = null;
try {
	fileURL = new URL("http://domain.com/myimage.jpg");
} catch (MalformedURLException e) {
	Log.e("", "Error: URL is malformed");
}
try {
	HttpURLConnection connection = (HttpURLConnection)fileURL.openConnection();
	connection.setDoInput(true);
	connection.connect();
	InputStream inputStream = connection.getInputStream();

	Bitmap bitmap = BitmapFactory.decodeStream(inputStream);
	myImageView.setImageBitmap(bitmap);
} catch (IOException e) {
	Log.e("", "Error: I/O Exception");
}</pre>
<p>Apart from syntactical differences, the big distinction about this code is that when the Android system reaches the lines that make the connection and download the file, <em>the whole execution thread hangs</em> and waits for the file to download, continuing after it&#8217;s done. That&#8217;s why a completion event is not necessary; no code will be executed until the task is complete anyway.</p>
<p>This creates a situation where it&#8217;s very easy for a developer to write code that will technically work, but also hijack the main (UI) thread while running complex pieces of code, freezing the application. In an environment like this, it&#8217;s easy to see why threading is <em>extremely</em> relevant. It&#8217;s not just sugar; it&#8217;s something absolutely needed for a responsive user experience.</p>
<p>The solution in Android is creating a separate process for that kind of problem &#8211; a thread that executes a task, then, implements event or message dispatching as needed. The code is <a href="http://stackoverflow.com/questions/2957287/web-image-loaded-by-thread-in-android">a bit more involved</a> and there are different ways to do it; you have to decide between <a href="http://developer.android.com/reference/java/lang/Thread.html">Threads</a> or <a href="http://developer.android.com/reference/android/os/AsyncTask.html">AsyncTasks</a>, for starters. That&#8217;s why one of the first things I&#8217;ve done when working with the Android platform was build classes that allow me to work on the main UI thread without having to worry about blocking user execution all the time. With names like <code>TextLoader</code>, <code>Loader</code>, and <code>XMLLoader</code>, they essentially emulate what the Flash platform already does by default.</p>
<p>Maybe because they&#8217;re not as necessary in Flash, I used to think that working with threads was this untouchable apogee of low-level programming techniques that would only be necessary in crazily computationally expensive tasks. The reality, however, is quite different: on a platform like Android, if you don&#8217;t use separate threads for things that take more than a few milliseconds, you are doing something wrong.</p>
]]></content:encoded>
			<wfw:commentRss>http://zehfernando.com/2012/android-for-actionscript-developers-part-3-threads-and-blocking/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Android for ActionScript developers, part 2: Events and listeners</title>
		<link>http://zehfernando.com/2012/android-for-actionscript-developers-part-2-events-and-listeners/</link>
		<comments>http://zehfernando.com/2012/android-for-actionscript-developers-part-2-events-and-listeners/#comments</comments>
		<pubDate>Tue, 17 Jan 2012 22:09:26 +0000</pubDate>
		<dc:creator>Zeh</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[Mobile]]></category>

		<guid isPermaLink="false">http://zehfernando.com/?p=1087</guid>
		<description><![CDATA[The first thing that made me pause when working with Java is discovering that it doesn&#8217;t have event listeners &#8211; at least not in the sense that I&#8217;ve come to expect based on my ActionScript experience. In ActionScript 3, you attach an event to an object like so: myObject.addEventListener(MouseEvent.MOUSE_DOWN, onMouseDown); protected function onMouseDown(e:Event): void { [...]]]></description>
			<content:encoded><![CDATA[<p>The first thing that made me pause when working with Java is discovering that it doesn&#8217;t have event listeners &#8211; at least not in the sense that I&#8217;ve come to expect based on my ActionScript experience.</p>
<p>In ActionScript 3, you attach an event to an object like so:</p>
<pre>myObject.addEventListener(MouseEvent.MOUSE_DOWN, onMouseDown);

protected function onMouseDown(e:Event): void {
    trace("The object " + e.target + " was clicked.");
}</pre>
<p>Considering that the second parameter to the <code>addEventListener</code> method is a function reference &#8211; a <em><a href="http://en.wikipedia.org/wiki/Closure_(computer_science)">closure</a></em> &#8211; you can reuse the same function in as many instances of as many objects as you like. Furthermore, you can attach several <em>listeners</em> to the same event on the same instance; this means that several different objects can track the same event.</p>
<p>Creating <em>custom events</em> is also fairly easy. In way, you don&#8217;t need any real class; just a string. You can certainly do something like:</p>
<pre>myObject.addEventListener("mysuperevent", onSuperEventTriggered);</pre>
<p>And you can easily trigger them from your object:</p>
<pre>dispatchEvent(new Event("mysuperevent"));</pre>
<p>You can also create new custom events, if you wish, so the event dispatched can carry more data with it. This can be done with separate event classes, like so:</p>
<pre>public class DestructionEvent extends Event {

	// Enums
	public static const EXPLODED:String = "exploded";	// Object has exploded
	public static const IMPLODED:String = "imploded";	// Object has imploded

	// Properties
	_customData = __customData;

	// ================================================================================================================
	// CONSTRUCTOR ----------------------------------------------------------------------------------------------------

	public function DestructionEvent(__type:String, __customData:Object, __bubbles:Boolean = false, __cancelable:Boolean = false) {
		super(__type, __bubbles, __cancelable);
		_customData = __customData;
	}

	override public function clone(): Event {
		return new NavigableSpriteEvent(type, bubbles, cancelable);
	}

	public function get customData(): Object {
		return _customData;
	}</pre>
<p>They can be easily dispatched:</p>
<pre>dispatchEvent(new DestructionEvent(DestructionEvent.EXPLODED, {id:myId, somedata:"Some data"}));</pre>
<p>And easily caught:</p>
<pre>myObject.addEventListener(DestructionEvent.EXPLODED, onExploded);

protected function onExploded(e:DestructionEvent): void {
    trace("The object " + e.target + " has exploded, and it was carrying the " + e.customData + " custom data with it.");
}</pre>
<p>Despite some syntax awkwardness (especially when transitioning from the ActionScript 1 and ActionScript 2 models), some performance problems, and <a href="https://github.com/robertpenner/as3-signals">some great alternatives</a>, this system does the job well, allowing developers to glue together encapsulated pieces of code pretty seamlessly, and is supported consistently through the AS3 ecosystem.</p>
<p>Hence my surprise when I got to Java.</p>
<p>First of all, Java doesn&#8217;t allow closures (at least <a href="http://javac.info/">not yet</a>), so you can&#8217;t pass functions as parameters for anything. This means I couldn&#8217;t even build an event dispatching (or signals) system like the ones I was used to in ActionScript 3.</p>
<p>The first examples I found covering the event model on Java were pretty awful. They were something like this:</p>
<pre>public class MyClass implements OnClickListener {

	public MyClass() {
		Button myButton = new Button();
		myButton.setOnClickListener(this);
	}

	public void onClick(Object o) {
		Log.v("", "Object " + o + " was clicked);
	}
}</pre>
<p>The problem with this is obvious: by forcing the instance that contains an object to implement a listener interface to the object, it doesn&#8217;t allow me to track the same event from two objects at the same time (or even listeners that have method name collisions). In my above example, if I wanted to have two buttons, I would need an additional condition inside <code>onClick</code> to detect where the event came from. This could easily get ugly.</p>
<p>The reason why I&#8217;m mentioning it here is because that kind of example was quite easy to find and it baffled me for a while that someone would adopt that kind of design for complex applications.</p>
<p>As it turns out, however, event listeners in Java are a little bit better than what that typical example makes it look like. You can create and extend an object of a class (even an interface!) <em>inline</em> &#8211; so the real way to write the above code is something like this:</p>
<pre>public class MyClass {

	public MyClass() {
		Button myButton = new Button();
		myButton.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(Object o) {
				Log.v("", "Object " + o + " was clicked);
			}
		});
	}
}</pre>
<p>Still a little bit strange to me (still used to AS3 I suppose), but much easier to read and use.</p>
<p>Implementing custom events is also pretty easy. Here, again, I did a mistake initially &#8211; I thought you had to create a separate class for every kind of event you wanted. My initial classes were always awkwardly accompanied by a bunch of separate interfaces for events, making my own packages pretty polluted.</p>
<p>As it turns out, there&#8217;s a better, cleaner way of declaring events too: as interfaces declared inside the classes themselves, and then referenced from outside. This seems to be the norm in Java conventions. In a nutshell, my classes that require an event look like so (in a hypothetical button clas):</p>
<pre>public class MyButton {

	// Instance references
	protected OnClickListener onClickListener;

	// Constructor
	public MyButton() {
		...
	}

	// Public methods
	public void setOnClickListener(OnClickListener __listener) {
		onClickListener = __listener;
	}

	// Interfaces
	public interface OnClickListener {
		public void onClick(MyButton __button);
	}

	// Internal dispatching
	protected void dispatchOnClick() {
		if (onClickListener != null) onClickListener.onClick(this);
	}
}</pre>
<p>And using it is just like before:</p>
<pre>myButton.setOnClickListener(new MyButton.OnClickListener() {
	@Override
	public void onClick(Object o) {
		Log.v("", "Object " + o + " was clicked);
	}
});</pre>
<p>Notice how the name is used when instantiating (<code>new MyButton.OnClickListener()</code>) to avoid collisions. I&#8217;ve seen this in several differenr packages (mainly Android&#8217;s own framework) and it&#8217;s a pretty clever solution to avoid name collision given that so many events can share the same name.</p>
<p>All in all, despite the syntactical differences, event dispatching in Java works the same as in ActionScript 3, expect for one major caveat: listeners are normally <em>set</em>, not <em>added</em>. This means you cannot have more than one listener to the same event on the same object.</p>
<p>Personally, I&#8217;ve added a multi-listener feature to some of my classes (it&#8217;s just a matter of adding to an <code>ArrayList</code> afterall), but the real problem is that none of the established classes follow that pattern. So&#8230; be careful when adding your listeners in Java, lest you erase a listener that was set previously.</p>
]]></content:encoded>
			<wfw:commentRss>http://zehfernando.com/2012/android-for-actionscript-developers-part-2-events-and-listeners/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Android for ActionScript developers, part 1: Getters and setters</title>
		<link>http://zehfernando.com/2012/android-for-actionscript-developers-part-1-getters-and-setters/</link>
		<comments>http://zehfernando.com/2012/android-for-actionscript-developers-part-1-getters-and-setters/#comments</comments>
		<pubDate>Thu, 12 Jan 2012 15:23:06 +0000</pubDate>
		<dc:creator>Zeh</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[Mobile]]></category>

		<guid isPermaLink="false">http://zehfernando.com/?p=1062</guid>
		<description><![CDATA[I&#8217;m just in the process of finishing the development of an Android application at work. This reminds me that since I&#8217;ve been a dedicated Flash developer for more than a decade, switching to a different platform was an interesting challenge, and one worth sharing. Luckily, I saved a lot of notes in the process, and [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m just in the process of finishing the development of an Android application at work. This reminds me that since I&#8217;ve been a dedicated Flash developer for more than a decade, switching to a different platform was an interesting challenge, and one worth sharing.</p>
<p>Luckily, I saved a lot of notes in the process, and I thought I&#8217;d share my impressions here, so other developers &#8211; of any platform, but Flash/ActionScript especially &#8211; could read them and know what to expect when doing development for the Android platform. My posts will focus on specific topics and while they won&#8217;t cover the whole range of features or capabilities of the Android platform (there are many other places and better articles for that), they&#8217;ll cover what surprised me the most.</p>
<p>My first note is: Java has no getters and setters to work as <a href="http://en.wikipedia.org/wiki/Mutator_method">mutators and accessors</a> in the same way that ActionScript (or C#, or others) support them.</p>
<p>Consider the following code:</p>
<pre>protected var _position:int;

public function get position():int {
    return _position:int;
}

public function set position(__position:int):void {
    _position = __position;
}</pre>
<p>What this code does is create a <code>position</code> pseudo-variable. When you read its value, it simply returns the value of the protected variable <code>_position</code>, which wouldn&#8217;t normally be accessible to other objects. Likewise, when you set that property to a value, it simply sets the value of <code>position</code>. This means those methods could then be used as if they were a normal variable, like so:</p>
<pre>someObject.position = 0;
trace (someObject.position); // 0</pre>
<p>Using a getter/setter combination like that is, of course, fairly useless, since it&#8217;s just passing values along, without providing any additional benefit. The real advantage is when you need to have additional code bound to either method. Consider, for instance, that a getter method doesn&#8217;t need to be bound to the value of an existing variable, but instead generate its own return value as needed:</p>
<pre>public function get numBrokenItems():int {
    // Calculate the number of broken items on a list
    var brokenItems:int = 0;
    for (int i = 0; i &lt; items.length; i++) {
        if (items[i].isBroken) brokenItems++;
    }

    return brokenItems;
}

// Traces the number of "broken items" in this instance
trace(someObject.numBrokenItems);</pre>
<p>In the same way, a setter can be used to run additional code after a variable is changed:</p>
<pre>public function set x(__x:int):void {
    // Simple implementation of a redrawing method for illustration purposes only
    // This is not very efficient; for a real implementation of position getter/setters
    // it'd be better to have display invalidation and a deferred redraw()

    // Sets the new value
    _x = __x;

    // Redraws the item
    redraw();

    // Dispatches an event
    dispatchEvent(new MyObjectEvents(MyObjectEvents.MOVED));
}

// Changes myObject's 'x' variable, redraws it, and dispatches an event that it has moved
myObject.x = 10;</pre>
<p>It should be obvious by now that <a href="http://zehfernando.com/2009/using-numeric-values-for-state-control/">I&#8217;m particularly fond of using getters and setters</a> &#8211; I believe they give developers a lot of control, especially for fluid, animated interfaces; getters and setters are a requirement if you need easy tweening with any generic tweening library out there, for example.</p>
<p>Alas, <a href="http://stackoverflow.com/questions/875033/getters-setters-in-java">it is not so</a> in the Java world, where Android developers finds themselves in.</p>
<p>In Java, you can still have accessors and mutators (even though <a href="http://www.javaworld.com/javaworld/jw-09-2003/jw-0905-toolbox.html">some people hate them</a>), but they are normal functions and methods. It&#8217;d look like this:</p>
<pre>protected int _position;

public int getPosition() {
    return _position;
}

public void setPosition(int __position) {
    _position = __position;
}</pre>
<p>This means you access them as you would normally access functions:</p>
<pre>someObject.setPosition(0);
Log.v("", someObject.getPosition()); // 0</pre>
<p>It works well; I&#8217;m yet to see a real disadvantage (you can&#8217;t do the typical ActionScript-style tween syntax on Java anyway, so the main advantage of having a pseudo-variable like in ActionScript is moot). But the result is a situation where you&#8217;ll always dealing with a bunch of different functions for every class, and, in my opinion, a polluted interface where every variable access is duplicated and actual variables are pretty much never used. There&#8217;s probably an argument to be made here in favor of simplicity and encapsulation (whether the value is generated or comes from a hidden variable), but not sure whether that&#8217;s enough; right now I&#8217;m keeping an open mind and accepting the language for what it is (my love for getter/setters notwithstanding) since it&#8217;s a new platform and assumptions can be risky.</p>
]]></content:encoded>
			<wfw:commentRss>http://zehfernando.com/2012/android-for-actionscript-developers-part-1-getters-and-setters/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>A mobile AIR application post-mortem</title>
		<link>http://zehfernando.com/2011/a-mobile-air-application-post-mortem/</link>
		<comments>http://zehfernando.com/2011/a-mobile-air-application-post-mortem/#comments</comments>
		<pubDate>Wed, 09 Nov 2011 16:47:30 +0000</pubDate>
		<dc:creator>Zeh</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[Mobile]]></category>

		<guid isPermaLink="false">http://zehfernando.com/?p=1036</guid>
		<description><![CDATA[With Kana Mind released (even if still in beta form), I figured I&#8217;d talk a little bit about the experience of writing a mobile application using Flash (and Adobe AIR) as a platform (there&#8217;s also the weird timing of Adobe announcing they won&#8217;t be updating the Flash plugin for mobile devices anymore, focusing instead on AIR apps). The [...]]]></description>
			<content:encoded><![CDATA[<p>With <a href="http://zehfernando.com/2011/kana-mind-a-mobile-air-application-to-help-you-learn-japanese/">Kana Mind</a> released (even if still in beta form), I figured I&#8217;d talk a little bit about the experience of writing a mobile application using Flash (and Adobe AIR) as a platform (there&#8217;s also the weird timing of Adobe <a href="http://blogs.adobe.com/conversations/2011/11/flash-focus.html">announcing</a> they won&#8217;t be updating the Flash plugin for mobile devices anymore, focusing instead on AIR apps).</p>
<p>The application was written in &#8220;pure&#8221; AS3 (no components or frameworks used), using <a href="http://fdt.powerflasher.com/">FDT 4</a>, and compiled with Flex SDK 4.5.1.21328, and AIR 3.0.0.4080.  The project was mostly adapted from the built-in mobile templates provided by Powerflasher, but the iOS and Android project versions (and desktop) were merged together.</p>
<div id="attachment_1037" class="wp-caption aligncenter" style="width: 310px"><a href="http://zehfernando.com/wp-content/uploads/2011/11/kana1.png"><img class="size-medium wp-image-1037" title="FDT 4 with the Kana Mind project opened" src="http://zehfernando.com/wp-content/uploads/2011/11/kana1-300x182.png" alt="FDT 4 with the Kana Mind project opened" width="300" height="182" /></a><p class="wp-caption-text">FDT 4 with the Kana Mind project opened</p></div>
<p>Even though the application is only available in the Android platform now, all versions were built together and use the same code. I just haven&#8217;t tried releasing an iOS version on Apple&#8217;s app store because I&#8217;m still adding features to it and fixing some bugs (as far as I know, Apple&#8217;s policy doesn&#8217;t allow beta applications on their store).</p>
<p>Interestingly, I&#8217;ve also been developing a native Android application at work for the past few weeks, so developing this small project allowed me some important insight on how using each platform compares. I&#8217;ll talk about it in parts.</p>
<h3>Coding</h3>
<p>The cool thing is that for an ActionScript developer like me, it&#8217;s pretty easy to just leverage your knowledge to another platform. You basically learn about the interface caveats and you&#8217;re good to go &#8211; continue building your mobile application as you would do with a normal website. It&#8217;s a pretty rapid development.</p>
<div id="attachment_1046" class="wp-caption aligncenter" style="width: 235px"><a href="http://zehfernando.com/wp-content/uploads/2011/11/kana3.jpg"><img class="size-medium wp-image-1046" title="Kana Mind TO-DO notes" src="http://zehfernando.com/wp-content/uploads/2011/11/kana3-225x300.jpg" alt="Kana Mind TO-DO notes" width="225" height="300" /></a><p class="wp-caption-text">Kana Mind TO-DO notes</p></div>
<p>Comparing AIR to Android, things can be both good and bad. For example, it&#8217;s interesting how it is easy to create custom visual content in Flash &#8211; it&#8217;s all vector-based (you can resize anything), the display list is pretty easy to deal with. Other important point is that Flash is <em>a pretty mature platform</em>, and many of the most things you&#8217;d need in order to develop a proper, rich, user interface are already available in the platform, in the form of easy-to-use libraries, or built-in Flash Player capabilities (don&#8217;t get me started with using Events or XML loading in Android &#8211; Flash is heaven in comparison).</p>
<p>On the other hand, when developing for a native platform, you can take advantage of the built-in interface frameworks &#8211; buttons, scrollers, etc &#8211; that are already there and used by everyone. With Flash, you have to build them yourself, and given the differences in user interactivity patterns (e.g., I had to build a <code>MobileButton</code> class so I could have a <code>LONG_PRESS</code> event), you can&#8217;t just use anything that was developed for the desktop. I also ended up having to rebuild my editable textfield classes to take advantage of native features like <a href="http://help.adobe.com/en_US/FlashPlatform/beta/reference/actionscript/3/flash/text/StageText.html">StageText</a>. Third-party libraries for all of that already exist, of course, but my point is that if you&#8217;re like me and you like to have complete control over your interface elements, expect to have to adapt them to that platform.</p>
<p>Developing the application probably took around 50 hours, on and off, split around my free time. No tablet version is available yet (I don&#8217;t have a tablet I can test on), but I believe doing so is trivial &#8211; just making sure things work and coming up with slightly different layouts based on screen size conditions (right now, the application <em>works</em>, but of course things are just resized and there&#8217;s no landscape mode).</p>
<h3>Testing</h3>
<p>One interesting thing is that testing is, in most ways, easier when you&#8217;re using AIR. For Kana Mind, I&#8217;d normally compile the application and run it as a desktop application &#8211; no emulator needed and, of course, very fast.</p>
<div id="attachment_1040" class="wp-caption aligncenter" style="width: 204px"><a href="http://zehfernando.com/wp-content/uploads/2011/11/kana2.png"><img class="size-medium wp-image-1040" title="Kana Mind running as a desktop application" src="http://zehfernando.com/wp-content/uploads/2011/11/kana2-194x300.png" alt="Kana Mind running as a desktop application" width="194" height="300" /></a><p class="wp-caption-text">Kana Mind running as a desktop application (purple boxes are for debugging purposes)</p></div>
<p>Compiling and deploying to an Android mobile device was also pretty easy, since installation on a device can easily be done automatically after compilation.</p>
<p>The issue here is, of course, developing for iOS. Deployment isn&#8217;t automatic &#8211; you have to compile a new .ipa file and the sync it using iTunes. Luckily, though, I didn&#8217;t have to do that very often as the application simply worked the same in Android and iOS.</p>
<div id="attachment_1047" class="wp-caption aligncenter" style="width: 310px"><a href="http://zehfernando.com/wp-content/uploads/2011/11/kana4.jpg"><img class="size-medium wp-image-1047" title="Some Kana Mind device testing" src="http://zehfernando.com/wp-content/uploads/2011/11/kana4-300x225.jpg" alt="Some Kana Mind device testing" width="300" height="225" /></a><p class="wp-caption-text">Some Kana Mind device testing</p></div>
<p>Finally, at least in my case (I wasn&#8217;t many mobile-exclusive features), testing on the devices wasn&#8217;t frequently needed; I&#8217;d usually spend a few hours coding and testing in the desktop, and then doing a round of tests on a device to make sure performance was OK, and that was it.</p>
<h3>Adaptation</h3>
<p>Flash developers are generally very well prepared for most fragmentation woes &#8211; they&#8217;re used to dealing with different screen sizes and CPUs. Doing mobile development introduces news challenges, however: you have to deal with <a href="http://tv.adobe.com/watch/training-with-trani/screen-density/">screen density</a> (rounded corners, text size, or element margins, for example, can&#8217;t just be pixel-based), and different input schemes (what to do if you want to make your application available to a device that doesn&#8217;t support touch screens?).</p>
<p>None of this is a showstopper, however. For screen density, I created a function that takes <a href="http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/system/Capabilities.html">Capabilities.screenDPI</a> (which is useless in desktops, but <a href="http://renaun.com/blog/2011/01/air-capabilities-screendpi-on-devices/">mostly correct</a> on devices) into consideration and I use that instead of any actual pixel dimension.</p>
<h3>Performance</h3>
<p>Performance is one of those topics that are very difficult to discuss. People can easily have unrealistic expectations, especially from a platform that is being ported from the desktop to a mobile device. One can easily expect their code to work the same, forgetting it&#8217;s a completely different device &#8211; with a lot less processing power and memory.</p>
<p>With that being said, it&#8217;s easy to be critical of AIR (and Flash) performance in a mobile device. Obviously, it doesn&#8217;t work the same as in a PC. My general assessment, however, is that performance of a mobile AIR application is <strong>for the most part OK, but not great</strong>.</p>
<p>Overall, user interaction and screen updates work well. It is difficult for one to achieve, say, 60fps on an animation, but as long as you keep all your screen rendering in check (knowing when to use bitmap caches and when not to, how to avoid re-renderings of unnecessary elements, etc), it is easy to make a responsive application that works at around 30fps.</p>
<p>The negatives about the platform are the ones that pertain to points the developer has no control over. To me, these are especially true during the application initialization.</p>
<p>The problem for me is that regardless of what you have on your first frame, application initialization takes a long time &#8211; up to 6 seconds, on my experience &#8211; before any code is even ran or anything is displayed (this is probably especially true of the <a href="http://www.tricedesigns.com/2011/08/10/air-3-0-captive-runtime/">Android captive runtime</a>, which I have used for Kana Mind). This is true even if you split the application in two frames, like you&#8217;d do with an online SWF, to offload code initialization and asset loading.</p>
<p>After the application is initialized, there&#8217;s also a few seconds where the application is unresponsive (doing some major memory swapping, I&#8217;m guessing), causing user interaction to be glitchy or not work at all.</p>
<p>A long startup time for applications is one of those things that can drive a user crazy. You click an icon and you expect feedback &#8211; when that doesn&#8217;t happen and you&#8217;re just starting at a black screen for too long, it&#8217;s easy to just assume the application has crashed or that it&#8217;s just some shitty code. It taints the user&#8217;s opinion of your application, regardless of what happens later.</p>
<h3>Size</h3>
<p>When it comes to mobile applications, size matters. Because of this, it&#8217;s important to remember the AIR captive runtime adds around 8mb (Android) or 5mb (iOS) to the application size, so it can be pretty bulky. Of course, this expands a little bit once it&#8217;s actually installed on a device &#8211; Kana Mind itself takes around 20mb of space once it&#8217;s installed in my Nexus S.</p>
<p>In Android&#8217;s case, if you choose to have a non-captive application instead, it works better &#8211; it&#8217;s basically your SWF size &#8211; but then it requires users to install the AIR runtime.</p>
<h3>Conclusion</h3>
<p>Regardless of the result, building an application using AIR is one of those things I really wanted to do, to get a chance to test the platform and find its pros and cons myself. As it turns out, there&#8217;s plenty of those, so it&#8217;s hard to get to a final verdict on whether someone should use it or not.</p>
<p>If you&#8217;re building something quickly or free and you want to use the same code on iOS and Android (including mobile devices and tablets) and potentially desktop, AIR is the way to go. You can have the same project (with maybe just some conditional layout or user interface elements) and, at least in my case, cross-platform testing is seldom necessary. It&#8217;s a very rapid development and testing workflow and, if you spend time building some user interface and application libraries to work around the caveats of the platform, you&#8217;ll be able to create cross-platform applications in the blink of an eye.</p>
<p>On the other hand, it looks like the platform has reached its limits in terms of performance and there&#8217;s not much that can be done (I&#8217;d love to be wrong, though). Mobile AIR applications are usable, but not exactly snappy, even if you take all the performance tricks out of the bag. The unavoidable truth is, if you want the best performance for your application, there&#8217;s no way around it: it has to be a native application.</p>
<p>I&#8217;m pretty proud of how Kana Mind turned out and I&#8217;ll probably do a few parallel applications for other languages, as I like how well the teaching algorithm works, and still use it as my excuse to play with AIR. But if I was developing a serious, bigger, commercial application, I&#8217;m not sure I&#8217;d have gone the AIR route.</p>
<p>TL;DR: AIR is good. But not for every case.</p>
]]></content:encoded>
			<wfw:commentRss>http://zehfernando.com/2011/a-mobile-air-application-post-mortem/feed/</wfw:commentRss>
		<slash:comments>17</slash:comments>
		</item>
		<item>
		<title>Kana Mind, a mobile AIR Application to help you learn Japanese</title>
		<link>http://zehfernando.com/2011/kana-mind-a-mobile-air-application-to-help-you-learn-japanese/</link>
		<comments>http://zehfernando.com/2011/kana-mind-a-mobile-air-application-to-help-you-learn-japanese/#comments</comments>
		<pubDate>Fri, 04 Nov 2011 15:01:51 +0000</pubDate>
		<dc:creator>Zeh</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[Mobile]]></category>

		<guid isPermaLink="false">http://zehfernando.com/?p=1022</guid>
		<description><![CDATA[Almost 20 years ago, I decided I wanted to try and learn Japanese. Other than studying the language&#8217;s grammar and vocabulary, I also had to learn the basic symbols used by the Japanese language &#8211; the Kana &#8211; so I could read Japanese properly. The Kana consists of 96 symbols (plus variants) which are to [...]]]></description>
			<content:encoded><![CDATA[<p>Almost 20 years ago, I decided I wanted to try and learn Japanese. Other than studying the language&#8217;s grammar and vocabulary, I also had to learn the basic symbols used by the Japanese language &#8211; the <a href="http://en.wikipedia.org/wiki/Kana">Kana</a> &#8211; so I could read Japanese properly. The Kana consists of 96 symbols (plus variants) which are to syllables in the roman alphabet (the romaji). This process of reading or writing a symbol as a syllable is called <a href="http://en.wikipedia.org/wiki/Romanization_of_Japanese">romanization</a>. In short, if you know how to read Kana, you can read simple Japanese aloud, even if you don&#8217;t know what it means.</p>
<p>I learned the symbols with the help of books and software, and I got to a point where I could read Kana-based Japanese writing pretty well. Then I promptly forgot everything. I&#8217;d remember a symbol or two, but in general, one year later, my knowledge of Kana was back to the starting point.</p>
<p>The problem with learning a new language is that if you don&#8217;t practice frequently, it&#8217;s very easy to forget everything you&#8217;ve learned, maybe especially one that depends so much on learning new characters. That&#8217;s when it dawned on me &#8211; I needed to have some software that helped me keep the symbols and their romaji counterparts memorized. A software that would understand when I <em>forgot</em> something, and help me record that again in my brain. Not just something to test me, but something to <em>target</em> the testing in what was more relevant for me.</p>
<p>I kept that idea in my mind for many years, and testing development of an Adobe AIR-based application was the perfect excuse to build it in my free time. Therefore, I have just submitted a new application to the Android market that does just that. It&#8217;s called <a href="https://market.android.com/details?id=air.com.zehfernando.KanaMind">Kana Mind</a>.</p>
<p><a href="https://market.android.com/details?id=air.com.zehfernando.KanaMind"><img class="aligncenter size-medium wp-image-1023" title="Kana Mind" src="http://zehfernando.com/wp-content/uploads/2011/11/kana1-180x300.jpg" alt="" width="180" height="300" /></a></p>
<p>The application is still in beta. This means it works well, but it&#8217;s missing some features like proper support for big screens (tablets) and landscape mode. I&#8217;m still working on it. The iOS version is working pretty well too, but will only be submitted to the market once it&#8217;s out of beta. But even in beta form, this is the kind of application I wish I had many years ago (and, luckily, beta-testing and playing it is already making me relearn Kana in the subway).</p>
<p>There are many games that get you to test your Kana knowledge by matching it with their romaji equivalent &#8211; memory games, crossword games, dictionary games, and the alike. However, none of them seem to be as serious about teaching, testing and reinforcing memorization, nor as focused on the task of memorizing Kana, as I believe Kana Mind is.</p>
<p>The way Kana Mind works is by slowly presenting you just a handful of symbols at first. So when you start the game, it cycles through the same 8 symbols &#8211; those are the &#8220;active&#8221; characters you&#8217;re being tested against.</p>
<p>While playing, if you pick the wrong pair, the game marks that option as wrong. Then you need to try again, until you get it right; the game then proceeds to the next character in the series of active characters, cycling through them in a randomized fashion.</p>
<p>After you get the same character right 7 times in a row, the game assumes you&#8217;re proficient with that character, so it marks as learned and adds a new symbol to the mix. So get something wrong again and again, and you&#8217;ll see it often; get it right several times in a row, and it&#8217;ll be skipped pretty quickly. This goes on until you reach &#8220;proficiency&#8221; in all characters. Symbols get more difficult to match as you progress, too, since symbols are grouped into levels of difficulty (although this is invisible to the user).</p>
<p>One additional aspect of the whole algorithm is that after 7 days of reaching proficiency with a specific character, the game assumes your knowledge of that character is decaying, and it throws it again in the mix of characters. Get it right once, and it won&#8217;t bother you again; get it wrong, and back it is to the list of characters you&#8217;re being tested again.</p>
<p>After you &#8220;finish&#8221; the game &#8211; reaching proficiency in all characters &#8211; the game uses its &#8220;maintenance&#8221; algorithm, always testing you against characters that you haven&#8217;t seen in a while.</p>
<p>This helps students that are already proficient enough with the language to keep their knowledge fresh &#8211; one needs only to play the game once in a while to test themselves. If you have trouble with any character, the game will be sure to make note of that and test you again and again.</p>
<p>And finally, Kana Mind is a serious application, but overall it was done more as a test than anything else. Therefore, it&#8217;s a free application.</p>
<p>I&#8217;ll have a more technical post about the pros and cons of the Adobe AIR platform soon. In the meantime, comments and suggestions about the application are always welcome.</p>
]]></content:encoded>
			<wfw:commentRss>http://zehfernando.com/2011/kana-mind-a-mobile-air-application-to-help-you-learn-japanese/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Using StageText for AIR applications</title>
		<link>http://zehfernando.com/2011/using-stagetext-for-air-applications/</link>
		<comments>http://zehfernando.com/2011/using-stagetext-for-air-applications/#comments</comments>
		<pubDate>Thu, 27 Oct 2011 21:35:31 +0000</pubDate>
		<dc:creator>Zeh</dc:creator>
				<category><![CDATA[Flash]]></category>

		<guid isPermaLink="false">http://zehfernando.com/?p=1012</guid>
		<description><![CDATA[Adobe AIR 3 includes a great new feature: StageText. Using the normal TextField for text input works just fine, but this new TextField-like class allows you to control your text input more closely (especially on mobile devices) with many options like auto capitalization, software keyboard type, and more. It has its caveats (it&#8217;s a separate class, [...]]]></description>
			<content:encoded><![CDATA[<p>Adobe AIR 3 includes a great new feature: <a href="http://blogs.adobe.com/cantrell/archives/2011/09/native-text-input-with-stagetext.html">StageText</a>. Using the normal TextField for text input works just fine, but this new TextField-like class allows you to control your text input more closely (especially on mobile devices) with <a href="http://help.adobe.com/en_US/FlashPlatform/beta/reference/actionscript/3/flash/text/StageText.html">many options</a> like auto capitalization, software keyboard type, and more. It has its caveats (it&#8217;s a separate class, and it gets added to the top of the stage, so there&#8217;s no display list control) but overall it&#8217;s a great feature addition to Adobe AIR and the Flash platform as a whole.</p>
<p>Only that when I was trying to use it (with Flex 4.5 and AIR 3), it wouldn&#8217;t work, but instead fail with this error message during execution (even though <code>StageText</code> <em>was</em> included on airglobal.swc):</p>
<pre>Exception fault: VerifyError: Error #1014: Class flash.text::StageText could not be found.</pre>
<p>An online search for the error and its meaning provided no results (!) &#8211; information on the new class is pretty hard to come by. So after some trial and error (and luckily stumbling into <a href="http://fdt.powerflasher.com/2011/08/setting-up-fdt-for-air-3-and-flash-player-11/">this video</a> about setting up FDT for Adobe AIR 3 and Flash Player 11 development), the reason is: you need to tell the Flex SDK compiler to compile against a newer version of the SWF format that enables that feature.</p>
<p>So the solution is simple: just add this parameter to your Flex SDK compilation settings (this is <em>in addition</em> to any <code>target-player</code> switch already present).</p>
<pre>--swf-version=13</pre>
<p>It should then work flawlessly.</p>
<p><a href="http://zehfernando.com/wp-content/uploads/2011/10/stagetext.png"><img class="aligncenter size-full wp-image-1014" title="Stage Text example" src="http://zehfernando.com/wp-content/uploads/2011/10/stagetext.png" alt="Stage Text example" width="240" height="400" /></a></p>
<p>Read more about that switch <a href="http://help.adobe.com/en_US/flex/using/WS2db454920e96a9e51e63e3d11c0bf69084-7ee0.html">here</a>. The same applies <a href="http://swfhead.com/blog/?p=1617">when using StageVideo</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://zehfernando.com/2011/using-stagetext-for-air-applications/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>The developer&#8217;s guide to browser adoption rates</title>
		<link>http://zehfernando.com/2011/the-developers-guide-to-browser-adoption-rates/</link>
		<comments>http://zehfernando.com/2011/the-developers-guide-to-browser-adoption-rates/#comments</comments>
		<pubDate>Thu, 13 Oct 2011 15:25:07 +0000</pubDate>
		<dc:creator>Zeh</dc:creator>
				<category><![CDATA[Flash]]></category>

		<guid isPermaLink="false">http://zehfernando.com/?p=1001</guid>
		<description><![CDATA[Just posted a new article on NetMagazine: the developer&#8217;s guide to browser adoption rates. It analyzes the speed of adoption of new browser versions and compare them to each other, and to the Flash Player plugin adoption. Much like my old Flash video playback benchmark, this is one of those things that started with an [...]]]></description>
			<content:encoded><![CDATA[<p>Just posted a new article on NetMagazine: <a href="http://www.netmagazine.com/features/developers-guide-browser-adoption-rates">the developer&#8217;s guide to browser adoption rates</a>. It analyzes the speed of adoption of new browser versions and compare them to each other, and to the Flash Player plugin adoption.</p>
<p>Much like my old <a href="http://zehfernando.com/2010/benchmarking-video-playback-performance-in-flash/">Flash video playback benchmark</a>, this is one of those things that started with an assumption that I wanted to investigate further (in this case, &#8220;browser updates take much longer than Flash Player updates&#8221;) but that ended up with unexpected results that made me look at things from a different perspective.</p>
<p><a href="http://www.netmagazine.com/features/developers-guide-browser-adoption-rates"><img class="aligncenter size-full wp-image-1002" title="Platform adoption rates" src="http://zehfernando.com/wp-content/uploads/2011/10/adoption_rates.png" alt="Platform adoption rates" width="615" height="419" /></a></p>
<p>The takeout of all of it is that while the adoption rate of new Flash Player versions is pretty good (and getting better), browser update rates are getting better too, and Google Chrome is leading the pack, with a user adoption rate that is even faster than Flash, overall (and the <em>frequency</em> of updates released has nothing to do with it). It means new HTML features are making it out to user&#8217;s computers faster than ever, with the exception of IE, which continues to hold the platform in the past.</p>
<p>There&#8217;s more to it, of course, as it&#8217;s a lengthy article (but one with pretty charts to look at). So for the full story, continue on to <a href="http://www.netmagazine.com/features/developers-guide-browser-adoption-rates">the developer&#8217;s guide to browser adoption rates</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://zehfernando.com/2011/the-developers-guide-to-browser-adoption-rates/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Farewell Hell&#8217;s Kitchen</title>
		<link>http://zehfernando.com/2011/farewell-hells-kitchen/</link>
		<comments>http://zehfernando.com/2011/farewell-hells-kitchen/#comments</comments>
		<pubDate>Fri, 16 Sep 2011 14:20:28 +0000</pubDate>
		<dc:creator>Zeh</dc:creator>
				<category><![CDATA[Personal]]></category>

		<guid isPermaLink="false">http://zehfernando.com/?p=960</guid>
		<description><![CDATA[About 20 years ago, I was reading a Daredevil comic book story and it mentioned the neighborhood where most of the story takes place. It was called Hell&#8217;s Kitchen, and it translates to &#8220;Cozinha do Inferno&#8221; in Brazilian Portuguese (the language of the comic I was reading it in). I thought that was a funny name and had [...]]]></description>
			<content:encoded><![CDATA[<p>About 20 years ago, I was reading a <a href="http://en.wikipedia.org/wiki/Daredevil_(Marvel_Comics)">Daredevil</a> comic book story and it mentioned the neighborhood where most of the story takes place. It was called <a href="http://en.wikipedia.org/wiki/Hell%27s_Kitchen,_Manhattan">Hell&#8217;s Kitchen</a>, and it translates to &#8220;Cozinha do Inferno&#8221; in Brazilian Portuguese (the language of the comic I was reading it in). I thought that was a funny name and had no idea what it was, so I asked my dad, my local New York expert, about it. I think he told me it was like the <a href="http://en.wikipedia.org/wiki/Central_Zone_of_S%C3%A3o_Paulo">old downtown</a> area of my native city of <a href="http://en.wikipedia.org/wiki/S%C3%A3o_Paulo">São Paulo</a>, and that was enough for me to understand the place where the story took place, more or less.</p>
<p>Little did I know that two decades later, I&#8217;d be working at this neighborhood myself &#8211; no hero costume required &#8211; since that&#8217;s where <a href="http://firstborn.com/">Firstborn</a> offices were when I started working here in 2009.</p>
<p>Today is the last day we&#8217;ll be in Hell&#8217;s Kitchen, though. Firstborn is now moving to a new office in <a href="http://en.wikipedia.org/wiki/TriBeCa">Tribeca</a>, and that&#8217;s where the NYC subway will be taking me to starting next week.</p>
<p>We&#8217;ll all very excited for it, but there&#8217;s a bittersweet sentiment going around as we count the things we&#8217;ll miss from this area.</p>
<p>Our awesome doorman, the T. <a href="http://www.rudysbarnyc.com/">Rudy&#8217;s</a> bar, doorman or no doorman. <a href="http://www.lennysnyc.com/main.asp">Lenny&#8217;s</a> sandwiches (how come those are not all over town?). <a href="http://www.rioandyou.com/">Rio &amp; You</a>&#8216;s friendly service and grandma-like owner. <a href="http://www.yelp.com/biz/kodama-sushi-new-york">Kodama</a>&#8216;s curry and the takeout attendant&#8217;s looks of bewilderment when we invaded the small shop in 6 or more people. Eating outside at <a href="http://motherburger.com/">Motherburger</a>. Standing in line for <a href="http://www.shakeshack.com/">Shake shack</a>. Pretending you&#8217;re Sean Connery when you say <a href="http://www.schnippers.com/">Schnippers</a>. Picking a random option at <a href="http://nymag.com/listings/restaurant/island-burgers-and-shakes/">Island burgers</a>. Ordering late <a href="http://5napkinburger.com/">Five Napkin</a>. Heck, even stuffing your face with some <a href="http://www.chipotle.com/">Chipotle</a>.</p>
<p>(And as far as I know, no super hero lives in Tribeca.)</p>
<p>There&#8217;s certainly a lot we&#8217;ll come to love in the new neighborhood. But, for a long time, there&#8217;s a lot we&#8217;ll be missing.</p>
<p>Thanks, Hell&#8217;s Kitchen. You&#8217;re half of New York for me, and it has been a pleasure.</p>
<p><iframe src="http://www.youtube.com/embed/Xhvc46HklDU?rel=0" frameborder="0" width="640" height="360"></iframe></p>
]]></content:encoded>
			<wfw:commentRss>http://zehfernando.com/2011/farewell-hells-kitchen/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Setting up an Android environment for Flash mobile applications development</title>
		<link>http://zehfernando.com/2011/setting-up-an-android-environment-for-flash-mobile-applications-development/</link>
		<comments>http://zehfernando.com/2011/setting-up-an-android-environment-for-flash-mobile-applications-development/#comments</comments>
		<pubDate>Mon, 15 Aug 2011 14:36:54 +0000</pubDate>
		<dc:creator>Zeh</dc:creator>
				<category><![CDATA[Flash]]></category>

		<guid isPermaLink="false">http://zehfernando.com/?p=874</guid>
		<description><![CDATA[There&#8217;s something wonderful about using the same code base for an application and running it on several different devices. I knew that was possible with the Flash platform &#8211; given the newly found ubiquity of Adobe AIR support on mobile devices &#8211; but that&#8217;s still the kind of thing that always warrants setting up your development [...]]]></description>
			<content:encoded><![CDATA[<p>There&#8217;s something wonderful about using the same code base for an application and running it on several different devices. I knew that was possible with the Flash platform &#8211; given the newly found ubiquity of Adobe AIR support on mobile devices &#8211; but that&#8217;s still the kind of thing that always warrants setting up your development workflow first.</p>
<p>I finally spent part of this weekend setting up such an environment for Flash development that allows me to run my application locally (on the desktop) and on a device (Android) without any porting hassle and I can state that things are nearly as good as they get when it comes to ease of development; it just takes a while to get it running.</p>
<p>(I haven&#8217;t tried iOS yet because I don&#8217;t have an iOS device at home, but that&#8217;s the next step).</p>
<p>I&#8217;m using <a href="http://www.fdt.powerflasher.com/">FDT</a> and the <a href="http://opensource.adobe.com/wiki/display/flexsdk/Flex+SDK">Flex SDK</a> with <a href="http://www.adobe.com/products/air/">Adobe AIR</a> for development. And while <a href="http://fdt.powerflasher.com/blog/">FDT&#8217;s blog</a> has a ton of information on how to set up an environment for mobile devices, it&#8217;s not complete as it skips the mobile device SDK parts (I guess it assumes the developer already has everything in place). So because of this, I thought I&#8217;d share my notes on how to set up a  Flash development environment with Android as a target, with links to the necessary information on each step.</p>
<p>(I&#8217;m using FDT because it&#8217;s my IDE of choice. Everything I&#8217;m doing is possible with other ActionScript development tools &#8211; even Notepad &#8211; and luckily no commercial tools are required for compilation or deployment, but of course setting up your environment and project templates will be very different depending on your preferred IDE).</p>
<p>So those are the steps:</p>
<ol>
<li><a href="http://www.fdt.powerflasher.com/">Download and install FDT</a> in case you don&#8217;t have it.</li>
<li>Install the <a href="http://opensource.adobe.com/wiki/display/flexsdk/Download+Flex+4.5">Flex SDK 4.5.1</a> and <a href="http://www.adobe.com/products/air/sdk/">Adobe AIR 2.7.1</a>. Extract them to the same folder (Flex already comes with AIR, but it&#8217;s an older version). For a tutorial on this, see <a href="http://fdt.powerflasher.com/docs/Setting_Up_and_Using_Mobile_Templates">this blog post</a> (first video).</li>
<li>Install the Android SDK. This can be done by following the instructions <a href="http://developer.android.com/sdk/installing.html">on this page</a>. You don&#8217;t need to download Eclipse, Eclipse plugins, samples, or the different APIs, however; that&#8217;s for native Android development. You&#8217;ll only be using the Android tools and, sometimes, the driver for your specific device.</li>
<li>Setup your phone for debugging by <a href="http://developer.android.com/guide/developing/device.html#setting-up">following these notes</a> (skip step 1, this is done automatically). This includes installing the drivers for your device, if needed.</li>
<ul>
<li>Note for Nexus S users on a Windows machine: the documentation mentions that the USB Drivers for your devices are at &#8220;<em>&#8230;/android-sdk-windows/usb_driver</em>&#8220;. This is incorrect; that&#8217;s version 3 of the drivers. You need version 4, which is actually at &#8220;<em>&#8230;/android-sdk-windows/extras/google/usb_driver</em>&#8220;.</li>
</ul>
<li>Connect your device to your computer using the USB cable.</li>
<li>Test your device. If you did everything correctly, running the command like <code>adb devices</code> (from &#8220;<em>&#8230;/android-sdk-windows/platform-tools/</em>&#8220;)  should list a connected device ID.</li>
<li>You can now run FDT and create a new project using the built-in mobile development templates. See <a href="http://fdt.powerflasher.com/docs/Setting_Up_and_Using_Mobile_Templates">this blog post again</a> for more information (second video). Make sure to create your project on the default FDT workspace &#8211; if you use a separate folder, the ANT tool won&#8217;t work so your application will be compiled but never deployed (I&#8217;m still investigating this, as I always use separate folders).</li>
<li>Now you can finally write your application&#8217;s code. When testing, run the wireless-based debug profile (found on &#8220;Run&#8221; &gt; &#8220;Debug Configurations&#8221;) as explained in <a href="http://fdt.powerflasher.com/docs/Setting_Up_and_Using_Mobile_Templates">that blog post again</a>. Your application will be automatically compiled, installed and ran on the device. Notice that you&#8217;ll need a wireless network already setup so the device can connect back to your computer to get the result of the <code>trace()</code> statements; for more information on how debugging is done, see the reference to the <a href="http://fdt.powerflasher.com/docs/FDT_Ant_Tasks#fdt.startDebugger">fdt.startDebugger</a> command, and to AIR&#8217;s <a href="http://fdt.powerflasher.com/blog/2011/06/remote-debugging-with-fdt/">-connect</a> parameter.</li>
</ol>
<p>The cool thing about compiling and debugging like that is, if you use the first launch profile, you compile a normal application running on your computer, like you would do with a normal AIR or Flash application; but if you use the other launch profiles, it runs on your device. It&#8217;s a super easy testing and deploying method and it certainly beats, say, using the Android emulator for native Android development (although, of course, you&#8217;ll have to keep performance in mind since your application will run much faster as a desktop AIR application).</p>
<p>With a few conditionals (or even different &#8220;Main&#8221; classes), it should be easy to have the same code based being used for deployment on several different platforms. Right now, FDT&#8217;s mobile templates offer two separate templates for Android and iOS development, but merging them together for a single project that supports everything should be possible. I plan to create a template that does that as soon as I have some free time and can get my hands on an iOS device.</p>
]]></content:encoded>
			<wfw:commentRss>http://zehfernando.com/2011/setting-up-an-android-environment-for-flash-mobile-applications-development/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Meet the Firstborn developers</title>
		<link>http://zehfernando.com/2011/meet-the-firstborn-developers/</link>
		<comments>http://zehfernando.com/2011/meet-the-firstborn-developers/#comments</comments>
		<pubDate>Sun, 14 Aug 2011 13:58:14 +0000</pubDate>
		<dc:creator>Zeh</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://zehfernando.com/?p=908</guid>
		<description><![CDATA[Figured I&#8217;d post my acting debut here. I&#8217;m the guy wearing the green shirt and frowning at the dog.]]></description>
			<content:encoded><![CDATA[<p>Figured I&#8217;d post my acting debut here. I&#8217;m the guy wearing the green shirt and frowning at the dog.</p>
<p><iframe width="640" height="390" src="http://www.youtube.com/embed/g0mmhQDvawc?rel=0" frameborder="0" allowfullscreen></iframe></p>
]]></content:encoded>
			<wfw:commentRss>http://zehfernando.com/2011/meet-the-firstborn-developers/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

