Thursday, April 30, 2009

O is for Object Oriented ActionScript

ActionScript is powerful, object oriented programming language. ActionScript and MXML are the languages of Flex.

ActionScript requires classes/interfaces to be declared in a package and the explicit import of used classes/interfaces that are not in the same package.

package packageName
{
import another.packageName.*;

public class ClassName extends SuperClassName implements InterfaceName
{
public ClassName()
{
// constructor
}
}
}

Learn more about Object Oriented ActionScript at Flex After Dark...

Monday, April 27, 2009

N is for Namespaces in MXML

If you want to use custom components (outside of the mx or flash packages) in your Flex application, first you'll have to setup a namespace to tell Flex where to find your custom controls. (Using custom controls in your MXML can be a little tricky at first.)


xmlns:mycontrols="my.custom.controls.*"
>


Learn more about MXML Namespaces at Flex After Dark...

Monday, April 20, 2009

M is for Menus

The Flex Menu control creates pop-up menus of individually selectable choices, that can have cascading sub-menus. (Similar to the application menus (e.g. File, Edit) or right-click menus in most application.)

A Menu is created with a call to the Menu class static createMenu() function. Of course you'll have to pass some data representing the menu items and structure to the createMenu() call.

   // create the menu data structure
var menuData:Array = [ "Item 1", "Item 2", "Item 3" ];

// create the menu
var menu:Menu = Menu.createMenu( parent, menuData, false );

// show the menu
menu.show()

Learn more about Menus in Flex at Flex After Dark...

Tuesday, April 14, 2009

L is for Libraries

A Library is collection of Flex/ActionScript classes and resources compiled to a .swc file.

A library is different than a Flex application in that you cannot launch a library. Rather, a library is a code reuse and packaging mechanism.

Learn more about Flex libraries at Flex After Dark...

Saturday, April 11, 2009

K is for Keyboard Shortcuts

Flex Builder is a full-fledged IDE for Flex development. These keyboard shortcuts may prove handy.

Search across multiple files:

  1. Press Ctrl + Shift + F
Import a class in an ActionScript file:
  1. Type a class name
  2. Press Ctrl + Space

Clone a chunk of code without having to copy and paste it:

  1. Select a chunk of code
  2. Press Ctrl + Alt + (Down Arrow)
Learn more about Flex Builder Keyboard Shortcuts at Flex After Dark...

Sunday, April 5, 2009

J is for Java (vs ActionScript)

ActionScript and Java are both powerful, object-oriented languages with many similarities.

Both Java and ActionScript:

  • Are object-oriented
  • Use single inheritance
  • Have a base Object class (which is automatically sub-classed)
  • Use strongly typed variables
  • Have Packages, Classes, and Interfaces
  • Support public, protected, and private methods and variables
  • Support static functions and variables
  • Support try/catch/finally exception handling

There are also many differences between ActionScript and Java.

Important differences between Java and ActionScript:

  • ActionScript has get/set functions
  • ActionScript supports dynamic classes
  • ActionScript supports closure functions
  • ActionScript supports optional function arguments, but does not support overloading
  • ActionScript does not allow private classes or constructors
Learn more about the ActionScript language, and it's similarities and differences to Java, at Flex After Dark...

Wednesday, April 1, 2009

I is for Images and Icons

In Flex images can be embedded or loaded.

Embedded images load immediately, because they are already part of the Flex SWF file. However, they add to the size of your application and slow down the application initialization process. Embedded images also require you to recompile your applications whenever your image files change.
The alternative to embedding a resource is to load the resource at runtime. You can load a resource from the local file system in which the SWF file runs, or you can access a remote resource, typically though an HTTP request over a network. These images are independent of your Flex application, so you can change them without causing a recompile operation as long as the names of the modified images remain the same. The referenced images add no additional overhead to an application's initial loading time. However, you might experience a delay when you use the images and load them.
Learn more about Images and Icons in Flex, and see some examples, at Flex After Dark...