Home arrow Flash arrow Page 4 - ActionScript Syntax for Flex Applications
FLASH

ActionScript Syntax for Flex Applications


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.

Author Info:
By: O'Reilly Media
Rating: 4 stars4 stars4 stars4 stars4 stars / 8
May 08, 2008
TABLE OF CONTENTS:
  1. · ActionScript Syntax for Flex Applications
  2. · Declaring Classes
  3. · Variables and Properties
  4. · Variables and Properties continued

print this article
SEARCH DEVARTICLES

TOOLS YOU CAN USE

advertisement
ActionScript Syntax for Flex Applications - Variables and Properties continued
(Page 4 of 4 )

In addition to thepublic,private,protected, andinternalmodifiers, you can also combine these modifiers with thestaticmodifier. Thestatic modifier says that the property is directly accessible from the class rather than from instances. Static modifiers are used for many purposes, including design patterns such as the Singleton pattern. The following example adds a staticprivateproperty called
_instanceof typeExample:

  package com.example {
    import flash.net.URLLoader;
    import flash.net.URLRequest;
    public class Example {
     
private var _loader:URLLoader;
      static private var _instance:Example;
    }
  }

A concept related to properties is that of the constant. A constant is a container for data, much like a variable/property except that once it has a value, you cannot change the value (hence the name, constant). You’ve likely seen constants in the Flash Player and Flex framework API. A few examples of constants areEvent.COMPLETE,MouseEvent.CLICK,TimerEvent.TIMER, andMath.PI. Although not a requirement, most constants are declared asstatic, and most are also declared aspublic(unlike properties, constants aren’t part of a class’s state and can therefore be declaredpublic). To declare a constant, use theconst keyword rather thanvar. By convention, constant names are all uppercase, as shown here:

  package com.example{
    import flash.net.URLLoader;
    import flash.net.URLRequest;
    public class Example {
     
private var _loader:URLLoader;
      static private var _instance:Example;
      static public const TEST:String = "test constant";
    }
  }

Please check back next week for the continuation of this article.


DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

blog comments powered by Disqus
FLASH ARTICLES

- 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

Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 



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