Sunday, March 29, 2009

ActionScript Language Overview

ActionScript is a powerful, object-oriented scripting language. The latest/current version of ActionScript is version 3.0.

ActionScript and MXML are the languages of Flex. ActionScript code is defined in files with the .as extension or in within elements of .mxml files.

Learn more about ActionScript 3.0 at Flex After Dark...

ActionScript 3 Top-Level Data Types:

  • Array - The Array class lets you access and manipulate arrays.
  • Boolean - A Boolean object is a data type that can have one of two values, either true or false, used for logical operations.
  • Class - A Class object is created for each class definition in a program.
  • Date - The Date class represents date and time information.
  • Error - The Error class contains information about an error that occurred in a script.
  • Function - A function is the basic unit of code that can be invoked in ActionScript.
  • int - The int class lets you work with the data type representing a 32-bit signed integer.
  • Number - A data type representing an IEEE-754 double-precision floating-point number.
  • RegExp - The RegExp class lets you work with regular expressions, which are patterns that you can use to perform searches in strings and to replace text in strings.
  • String - The String class is a data type that represents a string of characters.
  • uint - The uint class provides methods for working with a data type representing a 32-bit unsigned integer.
  • XML - The XML class contains methods and properties for working with XML objects.
  • XMLList - The XMLList class contains methods for working with one or more XML elements.
  • (some have been omitted, see http://livedocs.adobe.com/flex/3/langref/package-detail.html for more)

Saturday, March 21, 2009

Search Functionality

I've spent some time this weekend adding search functionality to Flex After Dark. To do this I'm using Whoosh, an excellent full-text indexing and searching library implemented in Python.

I plan on writing quite a bit more about the technology behind Flex After Dark as the site continues to be developed. So stay tuned for future posts about Python and Django.

Thursday, March 19, 2009

Flex and JavaScript Integration

Use the ExternalInterface class for ActionScript-JavaScript communication.

ExternalInterface defines two especially important static functions:

  • call( functionName:String, ... arguments ) - call a container function
  • addCallback( functionName:String, closure:Function ) - expose a Flex function to the container

Calling JavaScript from ActionScript is easy with ExternalInterface . Simply call the static call() function passing the function name and, optionally, any arguments.

   // call a JavaScript function defined in the container page
var result:String =
ExternalInterface.call( "doSomethingInJavaScript", arg1, arg2 );

Learn more about calling JavaScript from ActionScript with ExternalInterface at Flex After Dark...

Monday, March 16, 2009

ActionScript 3 vs. Java

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
Of course there are many differences between Java and ActionScript.

Read more about ActionScript vs. Java at Flex After Dark...

Saturday, March 14, 2009

Responders in Flex

A Responder is simple class encapsulating the handling of a Remote (asynchronous) call and its result and/or fault. A Responder class implements the IResponder interface in the mx.rpc package.

A Responder object has two key methods:

  • result() - function receives a ResultEvent
  • fault() - function receives a FaultEvent

Read more about asynchronous Responders in Flex at Flex After Dark...

Thursday, March 12, 2009

Binding in Flex

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

Learning more about Binding in Flex at Flex After Dark...

Wednesday, March 11, 2009

ActionScript Arrays

Arrays a common data structure in nearly any programming language, including ActionScript.

Characteristics of Arrays in ActionScript:

  • Arrays hold references to other objects, including null
  • Arrays are 0-based (like Java, unlike ColdFusion, for instance)
  • Arrays are unbounded meaning one will automatically grow as items are added
Find about more about Flex and ActionScript Arrays at Flex After Dark...