package com.ds.comm{    import flash.utils.Dictionary;    import flash.utils.Proxy;    import flash.utils.flash_proxy;                public dynamic class MyDictionary extends Proxy{        private var $dic : Dictionary;        /**         * @param $weakKeys : Boolean 是不是弱引用         * @author Ainy         * */        public function MyDictionary( $weakKeys : Boolean = false){            super();            this.$dic = new Dictionary($weakKeys);        }        flash_proxy override function setProperty(name:*, value:*):void{            if(name && value){                $dic[name] = value;            }        }        flash_proxy override function deleteProperty(name:*):Boolean{            if($dic.hasOwnProperty(name)){                $dic[name] = null;                delete $dic[name];                return true;            }else{                return false;            }        }        flash_proxy override function getProperty(name:*):*{            if($dic.hasOwnProperty(name)){                return $dic[name];            }else{                return null;            }        }        public function getKeyByValue(value : * ) : *{            for(var $key : * in this.$dic){                if($dic[$key] == value){                    return $key;                }            }            return null;        }    }}

应用:

package{    import com.ds.comm.MyDictionary;          import flash.display.Sprite;    import flash.text.TextField;          public class myTest extends Sprite    {        private var myDictionary : MyDictionary;        public var $myText : TextField;        public function myTest(){//          $myText = new TextField();//          $myText.text = "myTest";//          addChild($myText);//          var bb : Boolean = this.hasOwnProperty("$myText");//          trace(bb);//          var  $myttt : String = String.fromCharCode(10);//          $myText.text = $myttt;            myDictionary = new MyDictionary();            myDictionary["Aony"] = "Ainy";            callBack.apply(null,["KK"]);                      }        private function callBack($c : String = "CC") : void{            trace($c);            trace(myDictionary.getKeyByValue("Ainy"));        }    }}