Wednesday, January 23, 2013

What is MXML ?

MXML is an XML tag-based markup language, used in the layout and design of components and

data assets for Flex-based user interfaces. As an XML format, MXML is also structured, so there

are several rules you have to follow when you write it, and the contents must be well formed and

valid XML to preserve the integrity of the document.

Every MXML fi le is a class, but instead of having a .as fi le extension, it has a .mxml fi le extension.

And instead of simply having AS3 code and syntax, it can contain both the MXML markup and AS3.

A short idea about flex freamwork

Flex is a framework that leverages an underlying library of AS3 classes to provide

UI components that allow developers to build rich media applications and

compile to the SWF format. Adobe Flex builds on top of the core runtime APIs

provided by Flash Player and Adobe AIR.

Flex is available through the Flash Builder IDE, a tool that you will take a look

at in the next chapter. Flex is also available through a software development kit

(SDK) allowing SWF format content to be created through command line tools.

About Flash Player 10.x

Flash Player 10.1 was the fi rst release of Flash Player aimed at supporting the development of

content and SWF format deployment to both traditional web browser and mobile devices.

At the time of writing, a beta for Adobe Flash Player 11 was underway, allowing developers to

preview new and enhanced features targeting the next release of the run time. With the potential for

new APIs to be dropped, none of the features could be covered in this book, but look for an

update. For more information, visit the Adobe Labs website ( and

search for Adobe Flash Player 11.

This book centers on the development of Flash content targeting the latest release, Adobe Flash

Player 10.3 using AS3.

Flash is fully supported on Google Android and the BlackBerry Tablet OS mobile platforms. Unless

you’ve been hiding under a rock for the past few years, you’ll know Flash isn’t supported on the

Apple iOS platform. However, using AS3 and AIR, you can target your applications to run on the

platform via standalone applications.

Types of Mobile Applications

It is important to understand the different types of mobile applications. I will put them in

two categories, according to what they do.

1. Standalone mobile applications

2. Mobile applications (based on web services)

Standalone mobile applications are applications such as alarms, phone dialers, and

offline games. Web service-backed mobile applications are applications like e-mails,

calendars, Twitter clients, online games, and applications that interact with web


This distinction between mobile applications is unique to the context of this book.

Although PhoneGap can be used to implement standalone mobile applications, the

nature of PhoneGap-based mobile applications typically falls into the category of

“service-backed mobile applications.”

Understanding Cross-Platform Mobile Application Development

This book is about mobile application development; more specifically, about easing the

pain of mobile application development. There are many smartphone platforms on the

market: Android, iPhone, BlackBerry, Nokia, the Windows 7 Phone, and WebOS. Newer

platforms are on the rise as well, such as Samsung’s Bada and Meego.

The sheer number of development platforms for mobile applications may seem

overwhelming. This is the first of many points you must keep in mind when dealing with

mobile application development.

Thursday, January 17, 2013

Optimizing Fibonacci

The first optimization we are going to perform eliminates a method call, as

shown in Listing 1–3. As this implementation is recursive, removing a single

call in the method dramatically reduces the total number of calls. For example,

computeRecursively(30) generated 2,692,537 calls while

computeRecursivelyWithLoop(30) generated “only” 1,346,269. However, the

performance of this method is still not acceptable considering the responsetime

criteria defined above, 100 milliseconds or less, as

computeRecursivelyWithLoop(30) takes about 270 milliseconds to complete.

Listing 1–3. Optimized Recursive Implementation of Fibonacci Series

public class Fibonacci {

public static long computeRecursivelyWithLoop (int n)


if (n > 1) {

long result = 1;

do {

result += computeRecursivelyWithLoop(n-2);


} while (n > 1);

return result;


return n;