forked from: プロトタイプ継承(?)
Prototype
@author paq89
/**
* Copyright paq ( http://wonderfl.net/user/paq )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/cZDJ
*/
// forked from Nicolas's プロトタイプ継承(?)
// forked from paq's new function
package
{
import flash.display.Sprite;
import flash.events.Event;
import flash.text.TextField;
/**
* Prototype
* @author paq89
*/
public class Main extends Sprite
{
public function Main():void
{
function Dog():void { this.initialize(); }
Dog.prototype = {
initialize: function():void {
this.className = "Dog";
this.name = "Pochi";
},
separator: function():void {
tf.appendText("-----" + this.className + "(" + this.name + ")-----\n");
},
sayHello: function():void {
tf.appendText("Hello, I'm " + this.name + "\n");
},
bark: function():void {
tf.appendText("won wonderfl!\n");
}
};
function Shiba():void { this.initialize(); }
Shiba.prototype = new Dog();
(function():void {
this.initialize = function():void {
this.className = "Shiba";
this.name = "Taro";
};
this.sayHello = function():void {
tf.appendText("こんにちは、私は" + this.name + "です\n");
};
this.bark = function():void {
tf.appendText("just jsdo.it!\n");
};
}).call(Shiba.prototype);
var tf:TextField = new TextField();
tf.width = 465;
addChild(tf);
var dog:Object = new Dog();
dog.separator();
dog.sayHello();
dog.bark();
var shiba:Object = new Shiba();
shiba.separator();
shiba.sayHello();
shiba.bark();
}
}
}