Here's some code!
package { import flash.display.Sprite; public class Main extends Sprite { public function Main() { var p:Person = new Person("Charlie"); var pp:PersonPicture = new PersonPicture("Charlie.jpg"); trace(p); // [Person Charlie] trace(pp); // [PersonPicture Charlie.jpg] }; } } /** * class Person * Even though it's not written, Person extends the "Object" class by default. * Though a toString function exists for Objects, we don't need to override here. Just declaring it is enough. */ final class Person { private var _name:String; public function Person($name:String) { _name = $name; }; public function toString():String { return "[Person "+_name+"]"; }; } /** * class PersonPicture * In the case of Sprites (and most other classes) we actually need to explicitly override the function. */ import flash.display.Sprite; final class PersonPicture extends Sprite { private var _url:String; public function PersonPicture($url:String) { _url = $url; }; override public function toString():String { return "[PersonPicture "+_url+"]"; }; }





