Flash
  Home arrow Flash arrow Interfaces and Events with ActionScript an...
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  
Mobile Linux 
App Generation ROI 
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

Interfaces and Events with ActionScript and Flex
By: O'Reilly Media
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 4
    2008-05-22

    Table of Contents:
  • Interfaces and Events with ActionScript and Flex
  • Handling Events
  • Handling Synchronous Errors
  • Handling Asynchronous Errors

  • 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


    Interfaces and Events with ActionScript and Flex


    (Page 1 of 4 )

    In this fourth part of a five-part series on using ActionScript in Flex applications, you will learn how to define interfaces, and handle events and errors. It 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.

    Interfaces

    ActionScript 3.0 also allows you to define interfaces. Interfaces allow you to separate the interface from the implementation, which enables greater application flexibility.

    Much of what you learned about declaring classes applies to declaring interfaces as well. In fact, it’s easier to list the differences:

    • Interfaces use theinterfacekeyword rather than theclasskeyword.
    • Interfaces cannot declare properties.
    • Interface methods declare the method signature but not the implementation.
    • Interfaces declare only thepublicinterface for implementing classes, and therefore method signature declarations do not allow for modifiers.

    By convention, interface names start with an uppercaseI. The following is an example of an interface:

      package com.example {
       
    public interface IExample {
         
    function a():String;
         
    function b(one:String, two:uint):void;
       
    }
      }

    In the preceding example,interfacesays that any implementing class must declare methodsa()andb()using the specified signatures.

    You can declare a class so that it implements an interface using theimplementskeyword, following the class name or following the superclass name if the class extends a superclass. The following example implementsIExample:

      package com.example {
       
    import com.example.IExample;
       
    public class Example implements IExample {
         
    public function Example() {
         
    }
         
    public function a():String {
           
    return "a";
         
    }
         
    public function b(one:String, two:uint):void {
           
    trace(one + " " + two);
          }
        }
      }

    When a class implements an interface, the compiler verifies that it implements all the required methods. If it doesn’t, the compiler throws an error. A class can implement methods beyond those specified by an interface, but it must always implement at least those methods. A class can also implement more than one interface with a comma-delimited list of interfaces following theimplementskeyword.

    More Flash Articles
    More By O'Reilly Media


     

    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

    - 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
    - Organizing Frames and Layers for Flash Anima...
    - Organizing Frames and Layers
    - Using XML and ActionScript with Flex Applica...
    - Interfaces and Events with ActionScript and ...
    - Manipulating Data with ActionScript in Flex ...
    - ActionScript Syntax for Flex Applications
    - ActionScript in Flex Applications







    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
    Stay green...Green IT