记得riacn有一段时间经常有人贴23种gof设计模式的代码,其实在很早以前,偶就已经把这23种基本模式还有其它的模式如MVC等,用Actionscript写了一遍,嘿嘿.还有thor的一些扩展数组类的与数据结构有关的东东,偶去年九月flash2004刚出来的时候,就写过一个Collection Framework了.慢慢放出一些吧.
// "Adaptee" class Adaptee { // Methods public function SpecificRequest():Void { trace("Called SpecificRequest()"); } } // "Adapter" class Adapter extends Target { // Fields private var adaptee:Adaptee; public function Adapter() { adaptee = new Adaptee(); } // Methods public function Request():Void { // Possibly do some data manipulation // and then call SpecificRequest adaptee.SpecificRequest(); } }
class Target { // Methods public function Request():Void { // Normal implementation goes here } }
//client.fla var t:Target = new Adapter(); t.Request();
//output: //Called SpecificRequest()