Flash
  Home arrow Flash arrow ActionScript Syntax for Flex Applications
IBM Developerworks
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Dedicated Servers  
Download TestComplete 
IBM® developerWorks 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
FLASH

ActionScript Syntax for Flex Applications
By: O'Reilly Media
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 1
    2008-05-08

    Table of Contents:
  • ActionScript Syntax for Flex Applications
  • Declaring Classes
  • Variables and Properties
  • Variables and Properties continued

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
     
    ADVERTISEMENT

    Free Web 2.0 Code Generator! Generate data entry and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!

    ActionScript Syntax for Flex Applications
    (Page 1 of 4 )

    In this second part of a five-part series that focuses on using ActionScript in Flex applications, you will learn ActionScript's syntax and how to use it with Flex. 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.

    Understanding ActionScript Syntax

    Whether you’re writing ActionScript code inline, in an MXML script, or in a class, you’ll need to understand its basic syntax. The following sections look at the basic elements of ActionScript, such as class syntax, variables, statements, expressions, functions, and objects.

    Understanding Packages

    The majority of classes are organized into structures called packages. To understand most of ActionScript, you must understand what packages are and how you can work with them.

    A package groups together classes so that you can ensure uniqueness of scope. For example, you can have only oneButton class within a scope. If you tried to declare twoButtonclasses in the same scope, there would be a conflict; the compiler wouldn’t know which one to use.

    A package allows you to create several classes with the same name by placing them in different scopes. For example, theButtonclass that’s part of the Flex framework (i.e., the button UI component) exists within a package calledmx.controls. When a class is placed within a package, it has what’s called a fully qualified class name. Therefore, the fully qualified class name forButtonismx.controls.Button. That ensures that if you want to create anotherButtonclass in a different package, you can do so without conflicting withmx.controls.Button. For example,mx.controls.Buttonandcom.example.ui.Button(a fictitious class) could exist within the same application without causing a problem.

    When classes are in packages, it can be quite cumbersome to have to refer to a class by its fully qualified name. For example, if you want to declare aButtonvariable, you have to use the following code if you wish to use the fully qualified class name:

      var button:mx.controls.Button;

    And if you wanted to use the constructor, you’d have to use the following code:

      button = new mx.controls.Button();

    Obviously, it’s much more convenient to use the shorthand form of a class name (i.e.,Button). ActionScript allows you to reference a class by the shorthand notation if you first add animportstatement. Animportstatement tells the compiler that you can refer to the class by its shorthand notation from that point forward. The following is animportstatement for theButton class:

      import mx.controls.Button;

    You can simply refer toButtonas such from that point forward.

    If you import twoButton classes (from different packages) in the same class, you must still refer to them using their fully qualified class names within that class.

    More Flash Articles
    More By O'Reilly Media


       · This article is an excerpt from the book "Programming Flex 2," published by...
     

    Buy this book now. 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). Check it out today at your favorite bookstore. Buy this book now.

    FLASH ARTICLES

    - Manipulating Data with ActionScript in Flex ...
    - ActionScript Syntax for Flex Applications
    - ActionScript in Flex Applications
    - A Closer Look at Apollo`s File System API
    - Using the File System API
    - ActionScript 101
    - Flash Buttons
    - Advanced Flash Animation
    - Creating Your First Animated Movie with Flas...
    - Flash: Building Blocks
    - Building Preloaders
    - Fun Things to Do with Movie Clips in Flash MX
    - Referencing Movie Clips in Flash MX
    - Organizing Movie Clips in Flash MX
    - Making Movie Clips Perform in Flash MX


     
    Accelerating Trading Partner Performance
     
    Competing on Analytics
     
    Cost Effective Scaling with Virtualization and Coyote Point Systems
     
    Five Checkpoints to Implementing IP Telephony
     
    Hosted Email Security: Staying Ahead of New Threats
     





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway