topical media & game development

talk show tell print

actionscript-misc-Rectangle.ax

actionscript-misc-Rectangle.ax [swf] flex


  package {
    // The @ax-actionscript-misc-Rectangle subclass implements Serializable directly
    public class @ax-actionscript-misc-Rectangle extends Shape implements Serializable {
      public var width:Number = 0;
      public var height:Number = 0;
      private var serializer:actionscript_misc_Serializer;
    
      public function @ax-actionscript-misc-Rectangle (fillColor:uint, lineColor:uint) {
        super(fillColor, lineColor)
  
        // Here is where the composition takes place
        serializer = new actionscript_misc_Serializer();
        serializer.setRecordSeparator("|");
        serializer.setSerializationVars(["height", "width", 
                                         "fillColor", "lineColor"]);
        serializer.setSerializationObj(this);
      }
    
      public function setSize (w:Number, h:Number):void {
        width = w;
        height = h;
      }
    
      public function getArea ():Number {
        return width * height;
      }
    
      public function serialize ():String {
        // Here is where the @ax-actionscript-misc-Rectangle class forwards the serialize()
        // invocation to the Serializer instance stored in serializer
        return serializer.serialize();
      }
    }
  }
  


(C) Æliens 27/08/2009

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.