package org.libspark.utils{ import flash.display.DisplayObjectContainer; import flash.display.MovieClip; import flash.external.ExternalInterface; /* * sanzoku ver0.2 * Sprite/MovieClipのプロパティを一括・指定でトレースするクラス * * @author Kaede[xingxx.com] * */ public class Sanzoku { //参照するプロパティ private var mcProperty:Object = {accessibilityProperties:"",alpha:"",blendMode:"",buttonMode:"",cacheAsBitmap:"",constructor:"",contextMenu:"",currentFrame:"",currentLabel:"",currentLabels:"",currentScene:"",doubleClickEnabled:"",dropTarget:"",enabled:"",filters:"",focusRect:"",framesLoaded:"",graphics:"",height:"",hitArea:"",loaderInfo:"",mask:"",mouseChildren:"",mouseEnabled:"",mouseX:"",mouseY:"",name:"",numChildren:"",opaqueBackground:"",parent:"",prototype:"",root :"",rotation:"",scale9Grid:"",scaleX :"",scaleY:"",scenes:"",scrollRect:"",soundTransform:"",stage:"",tabChildren:"",tabEnabled:"",tabIndex:"",textSnapshot:"",totalFrames:"",trackAsMenu:"",transform:"",useHandCursor:"",visible:"",width:"",x:"",y:"" } private static const br:String = "\n"; private static const hr:String = "/*--------------------------------*/" + br; //コンストラクタ public function Sanzoku():void{} private function parse(target:DisplayObjectContainer = null,propertyFilter:Array = null):Array { var traceTextArr:Array = [] for (var property:String in mcProperty) { try { mcProperty[property] = target[property] }catch (err:Error) { mcProperty[property] = "noExtends" } } for (var propertyName:String in mcProperty) { var isfiltering:Boolean = false if (propertyFilter[0]) { for (var filteringName:String in propertyFilter) { if (propertyName == propertyFilter[filteringName]) isfiltering = true } }else isfiltering = true; if (mcProperty[propertyName] != "noExtends" && isfiltering) { traceTextArr.push(propertyName+"=>"+mcProperty[propertyName]) } } traceTextArr.sort(Array.DESCENDING) traceTextArr.reverse() return traceTextArr } //トレース private function getOutPutString(arr:Array):String { var name:String = "/*$=" + mcProperty.name +mcProperty.constructor+"*/"+br; var _txt:String = name+arr.join(br)+br+hr return _txt } private function outPut(txt:String):Boolean { trace(txt) return true } private function debug(txt:String):Boolean { ExternalInterface.call("console.debug", txt); return true } public static function peep(target:Object = null , propertyFilter:Object=null, usefireBug:Boolean = false):void { var targetArray:Array,propertyArray:Array, _target:DisplayObjectContainer, sanzoku:Sanzoku, parsedArray:Array,outPutTxt:String; targetArray = propertyArray = []; if (target is DisplayObjectContainer) targetArray.push(target); else if (target is Array) targetArray = target as Array; if (propertyFilter is String) propertyArray.push(propertyFilter); else if (propertyFilter is Array) propertyArray = propertyFilter as Array; for each (_target in targetArray) { sanzoku = new Sanzoku(); parsedArray = sanzoku.parse(_target,propertyArray) outPutTxt = sanzoku.getOutPutString(parsedArray) sanzoku.outPut(outPutTxt) if (usefireBug) { sanzoku.debug(outPutTxt) } } } } }