Sunday, March 29, 2009

H is for HTTPService

Flex's HTTPService is used to make HTTP requests and handle the results. When you call the HTTPService object's send() method, it makes an HTTP request to the specified URL, and an HTTP response is returned (asynchrnously).

The HTTPService is part of Flex's Remoting/RPC library.

Making an HTTP request in ActionScript:

  1. Create an instance of mx.rpc.http.HttpService
  2. Set the HTTP url
  3. Set the result format
  4. Send a request
  5. Handle the result or fault
    1. via pre-registered event listeners
    2. or via responders
Learn more about the Flex HTTPService at Flex After Dark...

Wednesday, March 25, 2009

G is for Get/Set Functions

In a lot of programming languages we're use to seeing "getter and setter" functions "wrapped" around private properties. The idea is to encapsulate the access of variables behind these "accessor" functions.

You won't see nearly as many getter/setter functions in ActionScript. It's not because of laziness or "bad OOP". It is because ActionScript has support for special get and set functions that can encapsulate property access behind function calls, but without changing the property access syntax.

public class Person
{
private var _name:String;

public function get name():String
{
return this.name;
}

public function set name( value:String ):void
{
this.name = value;
}
}
Learn more about ActionScript Get/Set Functions at Flex After Dark...

Monday, March 23, 2009

F is for Forms

Forms in Flex are supported through special container classes that assist in laying
out label and input elements. The form container classes are found in the mx.containers package.

A Form is made of the following components:
  • The outer Form container
  • One or more FormItem's, each can contain one or more input elements
  • Zero or more FormHeading's

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

Friday, March 20, 2009

E is for E4X

E4X stands for ECMAScript for XML. (Remember that ActionScript is ECMAScript.)

E4X makes XML a first-class citizen in ActionScript.

   var xmlAlbum:XML =
<album name="Sky Blue Sky" artist="Wilco">
<tracks>
<track name="Either Way" seconds="187"/>
<track name="You Are My Face" seconds="278"/>
<track name="Impossible Germany" seconds="358"/>
<track name="Sky Blue Sky" seconds="203"/>
<track name="Side With The Seeds" seconds="256"/>
<track name="Shake It Off" seconds="342"/>
<track name="Please Be Patient With Me" seconds="199"/>
<track name="Hate It Here" seconds="273"/>
<track name="Leave Me (Like You Found Me)" seconds=""/>
<track name="Walken" seconds="267"/>
<track name="What Light" seconds="216"/>
<track name="On And On And On" seconds=""/>
</tracks>

Notice in the example that you are not wrapping the XML in quotes or treating it as a string. Just type the XML as a literal.

Learn more about Flex and ActionScript support for XML via E4X at Flex After Dark...

Wednesday, March 18, 2009

D is for Dynamic Classes

ActionScript allows classes to be defined as dynamic. A dynamic class can have public properties and functions attached to it at runtime.
   public dynamic class DynamicClass
{
public DynamicClass()
{

}
}
Note the dynamic keyword used in the class declaration. So even though DynamicClass has not properties or functions defined (besides those of its super-class, Object), we can still attach properties and functions to it dynamically.

Learn more about ActionScript Dyanmic Classes at Flex After Dark...

Monday, March 16, 2009

C is for Canvas

The Canvas is a container used for absolute positioning of its children. The Canvas class is found in the mx.containers package.

A Canvas layout container defines a rectangular region in which you place child containers and controls. It is the only container that lets you explicitly specify the location of its children within the container by using the x and y properties of each child.

Unique characteristics of the Canvas container:

  • Child components are absolutely positioned using x and y coordinates
  • Child components can overlap
  • Can be used for constraint based layouts

Canvas related links:

Sunday, March 15, 2009

B is for Binding

Flex Data Binding enables objects and their values to be bound together so that when a source changes a target automatically gets updated.

Data binding players:

  • Source - the object/value we are interested in observing
  • Target - the object/value we going to copy the source value to
  • Trigger - the event from the source that triggers the copy from source to target
Binding related links:

Saturday, March 14, 2009

A is for ActionScript

ActionScript is the language of Flex (and Flash). ActionScript is Adobe's implementation of ECMA Script, thus is similar in many ways to JavaScript.

Characteristics of ActionScript:

  • Is object oriented
  • Uses single inheritance
  • Uses strongly typed variables
  • Has Packages, Classes, and Interfaces
  • Supports static functions and variables
  • Supports dynamic classes and objects
ActionScript related links: