Showing posts with label actionscript. Show all posts
Showing posts with label actionscript. Show all posts

Thursday, June 11, 2009

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)

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...

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...