使用fireBug输出以及自定义MetaData

firebug输出

http://www.adobe.com/cfusion/communityengine/index.cfm?event=showdetails&postId=15506&productId=2&loc=en_US

自定义元数据标签 http://bbs.airia.cn/ActionScript/thread-2898-1-1.aspx

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
         layout="vertical" creationComplete="init()">
        
        <mx:Metadata>
                [MyEvent(target="button",type="click",eventHandle="clickHandle")]
        </mx:Metadata>
        <mx:Script>
                <![CDATA[
                        import mx.controls.Alert;
                        import mx.core.mx_internal;
                        use namespace mx_internal;
                        import flash.utils.describeType;
                        import flash.external.ExternalInterface;
                        //-keep-as3-metadata+=MyEvent
                        
                        private function init():void{
                                
                                var xml:XML=describeType(this);
                                var meta:XML=XML(xml.metadata);
                                this.callFireBug(meta);
                                /*<metadata name="MyEvent"> 
                                 <arg key="name" value="click"/> 
                                  <arg key="target" value="button"/>  
                                 <arg key="eventHandle" value="clickHandle"/> </metadata>
                                 * 
                                 */
                                var xmlList:XMLList=meta.arg;
                                var target:String=xmlList[0].@value;
                                var eventType:String=xmlList[1].@value;
                                var handle:String=xmlList[2].@value;
                                this.callFireBug("target"+target);
                                this.callFireBug("eventType"+eventType);
                                this.callFireBug("handle"+handle);
                                
                                this[target].addEventListener(eventType,this[handle]);
                        
                                
                        }
                        private function clickHandle(event:Event):void{
                                mx.controls.Alert.show("click");
                        }
                        private function callFireBug(value:String):void{
                                ExternalInterface.call("console.log",value);//使用fireBug输出控制台信息
                        }
                ]]>
        </mx:Script>
        <mx:Button label="button" id="button"/>
        
</mx:Application>
 

你可能感兴趣的:(xml,Firebug,Flash,Adobe,actionscript)