topical media & game development
actionscript-example-Rectangle.ax
actionscript-example-Rectangle.ax
(swf
)
[ flash
]
flex
package {
// The actionscript-example-Rectangle subclass implements Serializable directly
public class actionscript-example-Rectangle extends Shape implements Serializable {
public var width:Number = 0;
public var height:Number = 0;
private var serializer:Serializer;
public function actionscript-example-Rectangle (fillColor:uint, lineColor:uint) {
super(fillColor, lineColor)
// Here is where the composition takes place
serializer = new 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 actionscript-example-Rectangle class forwards the serialize()
// invocation to the Serializer instance stored in serializer
return serializer.serialize();
}
}
}
(C) Æliens
20/2/2008
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.