Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Depends on what your object is, or rather what you expect it to have. For example if your object is supposed to contain some property called name that you are looking for, you might do</p> <pre><code>if(objSomeItem == null || objSomeItem.name == null || objSomeItem.name.length == 0) { trace("object is empty"); } </code></pre> <p>or if your object is actually supposed to be something else, like an array you could do</p> <pre><code>var arySomeItems = objSomeItem as Array; if(objSomeItem == null || arySomeItems == null || arySomeItems.length == 0) { trace("object is empty"); } </code></pre> <p>You could also use other ways through reflection, such as ObjectUtil.getClassInfo, then enumerate through the properties to check for set values.... this class help:</p> <pre><code>import flash.utils.describeType; import flash.utils.getDefinitionByName; public class ReflectionUtils { /** Returns an Array of All Properties of the supplied object */ public static function GetVariableNames(objItem:Object):Array { var xmlPropsList:XMLList = describeType(objItem)..variable; var aryVariables:Array = new Array(); if (xmlPropsList != null) { for (var i:int; i &lt; xmlPropsList.length(); i++) { aryVariables.push(xmlPropsList[i].@name); } } return aryVariables; } /** Returns the Strongly Typed class of the specified library item */ public static function GetClassByName($sLinkageName:String):Class { var tObject:Class = getDefinitionByName($sLinkageName) as Class; return tObject; } /** Constructs an instance of the speicified library item */ public static function ConstructClassByName($sLinkageName:String):Object { var tObject:Class = GetClassByName($sLinkageName); //trace("Found Class: " + tMCDefinition); var objItem:* = new tObject(); return objItem; } public static function DumpObject(sItemName:String, objItem:Object):void { trace("*********** Object Dump: " + sItemName + " ***************"); for (var sKey:String in objItem) { trace(" " + sKey +": " + objItem[sKey]); } } //} } </code></pre> <p>Another thing to note is you can use a simple for loop to check through an objects properties, thats what this dumpobject function is doing.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload