Flash
  Home arrow Flash arrow Page 2 - Using Concrete Decorator Classes
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

Using Concrete Decorator Classes
By: O'Reilly Media
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 2
    2008-12-24

    Table of Contents:
  • Using Concrete Decorator Classes
  • Deadly sins
  • Implementing the Good and Evil Decorator
  • Charting souls

  • 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


    Using Concrete Decorator Classes - Deadly sins


    (Page 2 of 4 )

    Example 4-29. Rage.as

    package
    {
       public class Rage extends Decorator
       {
         
    private var components:Component;
          public function Rage(components:Component)
          {
            
    this.components=components;
          }
          override public function getSoul():String
          {
            
    return components.getSoul() + "|Rage";
          }
          override public function good():Number
          {
             return -9 + components.good();
          }
          override public function evil():Number
          {
            
    return 8 + components.evil();
          }
       }
    }

    Example 4-30. Malice.as

    package
    {
       public class Malice extends Decorator
       {
         
    private var components:Component;
          public function Malice(components:Component)
          {
            
    this.components=components;
          }
          override public function getSoul():String
          {
            
    return components.getSoul() + "|Malice";
          }
          override public function good():Number
          {
            
    return -14 + components.good();
          }
          override public function evil():Number
          {
            
    return 12 + components.evil();
          }
       }
    }

    Example 4-31. Prejudice.as

    package
    {
       public class Prejudice extends Decorator
       {
         
    private var components:Component;
          public function Prejudice(components:Component)
          {
            
    this.components=components;
          }
          override public function getSoul():String
          {
            
    return components.getSoul() + "|Prejudice";
          }
          override public function good():Number
          {
            
    return -10 + components.good();
          }
          override public function evil():Number
          {
            
    return 15 + components.evil();
          }
       }
    }

    Example 4-32. Obfuscation.as

    package
    {
       public class Obsfuscation extends Decorator
       {
         
    private var components:Component;
          public function Obsfuscation(components:Component)
          {
            
    this.components=components;
          }
          override public function getSoul():String
          {
            
    return components.getSoul() + "|Obsfuscation";
          }
          override public function good():Number
          {
            
    return -12 + components.good();
          }
          override public function evil():Number
          {
            
    return 7 + components.evil();
          }
       }
    }

    Example 4-33. Dogmatisms.as

    package
    {
       public class Dogmatisms extends Decorator
       {
         
    private var components:Component;
          public function Dogmatisms(components:Component)
          {
            
    this.components=components;
          }
          override public function getSoul():String
          {
            
    return components.getSoul() + "|Dogmatisms";
          }
          override public function good():Number
          {
            
    return -12 + components.good();
          }
          override public function evil():Number
          {
            
    return 15 + components.evil();
          }
       }
    }

    Example 4-34. Arrogance.as

    package
    {
       public class Arrogance extends Decorator
       {
         
    private var components:Component;
          public function Arrogance(components:Component)
          {
            
    this.components=components;
          }
          override public function getSoul():String
          {
            
    return components.getSoul() + "|Arrogance";
          }
          override public function good():Number
          {
            
    return -5 + components.good();
          }
          override public function evil():Number
          {
            
    return 5 + components.evil();
          }
       }
    }

    Example 4-35. Indifference.as

     package
    {
       public class Indifference extends Decorator
       {
         
    private var components:Component;
          public function Indifference(components:Component)
          {
            
    this.components=components;
          }
          override public function getSoul():String
          {
            
    return components.getSoul() + "|Indifference";
          }
          override public function good():Number
          {
            
    return -9 + components.good();
          }
          override public function evil():Number
          {
            
    return 10 + components.evil();
          }
       }
    }

    At this point you can add your own concrete decorators. Use the same format as the others. You can also add additional concrete components. So instead of just Dick and Jane, you can add others you’d like to decorate with good and evil.

    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