Home arrow Flash arrow Page 4 - Manipulating Data with ActionScript in Flex Applications

Manipulating Data with ActionScript in Flex Applications

In this third part of a five-part series focused on using Flex and ActionScript together, you will learn about methods, arrays, and more. This article is excerpted from chapter four of the book Programming Flex 2, written by Chafic Kazoun and Joey Lott (O'Reilly, 2007; ISBN: 059652689X). Copyright 2007 O'Reilly Media, Inc. All rights reserved. Used with permission from the publisher. Available from booksellers or direct from O'Reilly Media.

Author Info:
By: O'Reilly Media
Rating: 5 stars5 stars5 stars5 stars5 stars / 4
May 15, 2008
  1. · Manipulating Data with ActionScript in Flex Applications
  2. · Expressions
  3. · Arrays
  4. · Objects
  5. · Inheritance

print this article

Manipulating Data with ActionScript in Flex Applications - Objects
(Page 4 of 5 )


Objects are composites of state and functionality that you can use as elements within ActionScript code. There are potentially an infinite range of object types, including those from the built-in Flash Player types to Flex framework types to custom types.

An object is an instance of a class, which is a blueprint of sorts. Although there are other mechanisms for creating objects, the most common is to use anewstatement with a constructor. The constructor for a class is a special function that shares the same name as the class. For example, the constructor for theArray class is calledArray. Like any other functions a constructor may or may not expect parameters. The only way to know whether a particular constructor expects parameters is to consult the API documentation. However, unlike most functions, a constructor must be used as part of anew statement, and it always creates a new instance of the class. The following example creates a new array using anewstatement:

  var books:Array = new Array();

Objects may have properties and methods depending on the type. Properties are essentially variables associated with an object, and methods are essentially functions associated with the object. You can reference properties and methods of an object in ActionScript using dot-syntax. Dot-syntax uses a dot between the name of the object and the property of the method. The following example uses dot-syntax to call thepush() method of the array object (thepush()method appends the value as an array element):

  books.push("Programming Flex 2");

The next example uses dot-syntax to reference thelengthproperty of the array object:


blog comments powered by Disqus

- More Top Flash Game Tutorials
- Top Flash Game Tutorials
- Best Flash Photo Gallery Tutorials
- The Top Flash Tutorials for Menus
- 7 Great Flash Tutorials
- Adobe Creative Suite 5.5 Now Available
- Critical Flash Vulnerability Heats Up the Web
- More on Nonpersistent Client-Side Remote Sha...
- Nonpersistent Client-Side Remote Shared Obje...
- Using the Decorator Pattern for a Real Web S...
- Using Concrete Decorator Classes
- Delving More Deeply into the Decorator Patte...
- The Decorator Pattern in Action
- A Simple Decorator Pattern Example
- Decorator Pattern

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 

Developer Shed Affiliates


© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials