Flash
  Home arrow Flash arrow Page 2 - Using the Decorator Pattern for a Real Web...
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 the Decorator Pattern for a Real Web Site
By: O'Reilly Media
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 3
    2008-12-31

    Table of Contents:
  • Using the Decorator Pattern for a Real Web Site
  • Hybrid car classes concrete component
  • Using Auto Options as Decorators
  • Setting Up the User Interface
  • Creating the document and setting the stage
  • Implementing the concrete components and their decorators

  • 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 the Decorator Pattern for a Real Web Site - Hybrid car classes concrete component


    (Page 2 of 6 )

    The four hybrid autos are placed into separate concrete component classes that are all subclassed from the Auto class. The constructor function assigns a value to the information property, and the price() function returns a value representing the car’s price. In Examples 4-39 to 4-42, the captions are the filenames to use for saving each class.

    Example 4-39. Prius.as

    package
    {
       public class Prius extends Auto
       {
         
    public function Prius()
          {
            
    information = "Toyota Prius Hybrid~\n";
          }
          override public function price():Number
          {
            
    return 21725.00;
          }
       }
    }

    Example 4-40. Mariner.as

    package
    {
       public class Mariner extends Auto
       {
         
    public function Mariner()
          {
            
    information = "Mercury Mariner Hybrid~\n";
          }
          override public function price():Number
          {
            
    return 29225.00;
          }
       }
    }

    Example 4-41. Accord.as

    package
    {
       public class Accord extends Auto
       {
         
    public function Accord()
          {
            
    information = "Accord Hybrid~\n";
          }
          override public function price():Number
          {
            
    return 30990.00;
          }
       }
    }

    Example 4-42. Escape.as

    package
    {
       public class Escape extends Auto
       {
         
    public function Escape()
          {
            
    information = "Ford Escape Hybrid\n~";
          }
          override public function price():Number
          {
            
    return 26240.00;
          }
       }
    }

    The prices here are based on prices found on the Internet, but they may or may not reflect prices at a later date. If you want to update prices or even use different autos, feel free to do so.

    The\nescape character and the tilde (~) characters are used for formatting purposes. The\nis a line break, and the tilde (~) helps in separating out all the different models that become a big string as the decorator merges them altogether. Without these, the output would be a mess.

    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 5 Hosted by Hostway
    Stay green...Green IT