Flash
  Home arrow Flash arrow Page 3 - A Simple Decorator Pattern Example
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

A Simple Decorator Pattern Example
By: O'Reilly Media
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 2
    2008-12-04

    Table of Contents:
  • A Simple Decorator Pattern Example
  • Abstract Decorator Class
  • Concrete Decorations
  • Wrapping Up

  • 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


    A Simple Decorator Pattern Example - Concrete Decorations


    (Page 3 of 4 )

    Now, we’re all set to write the concrete decorator classes. Save Examples 4-4 and 4-5 as DecConA.as and DecConB.as, respectively.

    In several of the decorator classes, you’ll see:

      this.components = components;

    Such code is a non-standard use of thethisidentifier, but it makes sense in this context because it differentiates the variable and parameter. Normally, you wouldn’t use thethisidentifier in this manner. The variable and parameter names are identical to emphasize the use of the abstract class in both cases, with one passing the value to the other.

    Example 4-4. DecConA.as

    package
    {
       //Concrete Decorator "Alpha"
       public class DecConA extends Decorator
       {
         
    private var components:Component;
          public function DecConA(components:Component)
          {
            
    this.components=components;
          }
          override public function getInformation():String
          {
            
    return components.getInformation() + " Decoration Alpha:";
          }
       }
    }

    Example 4-5. DecConB.as

    package
    {
       //Concrete Decorator "Beta"
       public class DecConB extends Decorator
       {
         
    var components:Component;
          public function DecConB(components:Component) {
             
    this.components=components;
          }
          override public function getInformation():String
          { 
             
    return components.getInformation() + " Decoration Beta:";
          }
       }
    }

    More Flash Articles
    More By O'Reilly Media


       · This article is an excerpt from the book "ActionScript 3.0 Design Patterns Object...
     

    Buy this book now. This article is excerpted from chapter four of ActionScript 3.0 Design Patterns Object Oriented Programming Techniques, written by William B. Sanders and Chandima Cumaranatunge (O'Reilly, 2007 ISBN: 0596528469). Check it out today at your favorite bookstore. Buy this book now.

    FLASH ARTICLES

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







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