home *** CD-ROM | disk | FTP | other *** search
/ com!online 2002 July / com!online0702.iso / software / livemotion / DATA1.CAB / Scripting_Resources / Samples / Automation_Scripts / DumpProperties-full.js < prev    next >
Encoding:
Text File  |  2002-05-13  |  2.9 KB  |  118 lines

  1. /***************************************************************
  2. ADOBE SYSTEMS INCORPORATED 
  3. Copyright 2001 Adobe Systems Incorporated 
  4. All Rights Reserved 
  5.  
  6. NOTICE:  Adobe permits you to use, modify, and distribute this 
  7. file in accordance with the terms of the Adobe license agreement 
  8. accompanying it.  If you have received this file from a source 
  9. other than Adobe, then your use, modification, or distribution
  10. of it requires the prior written permission of Adobe. 
  11. ***************************************************************/
  12. /***************************************************************
  13. Author: Mary Obelnicki
  14. ***************************************************************/
  15.  
  16. /***************************************************************
  17. Description goes here
  18.  
  19. ***************************************************************/
  20.  
  21. /***************************************************************
  22. To change the behavior of this script, 
  23. make your changes below
  24. ***************************************************************/
  25.  
  26. DumpProperties(application.currentComposition.objects[0], 3, 
  27.                                 "position", "scale", "name");
  28.  
  29. /***************************************************************
  30. DO NOT EDIT BELOW THIS LINE
  31. ***************************************************************/
  32.  
  33.  
  34.  
  35. function DumpProperties(anObject, depth)
  36. {
  37.     var filters = new Array; 
  38.     var i; 
  39.     for (i = 2; i < arguments.length; i++)
  40.         filters[i-2] = arguments[i];
  41.     
  42.        var ret = "\n";
  43.     ret += "(typeof: " + typeof(anObject) + ") " +anObject +"\n";
  44.     
  45.     if (depth > 0)
  46.         ret += DumpContainedProperties(1, anObject, depth, filters);
  47.  
  48.     return ret;
  49. }
  50.  
  51. function createIndent(indentLevel)
  52. {
  53.     var ret = "";
  54.     var i = 0; 
  55.     while (i < indentLevel)
  56.     {
  57.         ret += "    ";
  58.         ++i;
  59.     }
  60.     return ret; 
  61. }
  62. function filterTest(testString, filters)
  63. {
  64.     if (filters.length == 0)
  65.         return true;
  66.     var i = 0; 
  67.     for (i = 0; i < filters.length; i++)
  68.     {
  69.         if (testString == filters[i])
  70.             return true; 
  71.     } 
  72.     return false; 
  73.      
  74. }
  75.  
  76. function DumpContainedProperties(indentLevel, anObject, depth, filters)
  77. {
  78.     var ret = "";
  79.     var aProperty;
  80.     for (aProperty in anObject)
  81.     {
  82.         if (filterTest(aProperty.toString(), filters))
  83.         {
  84.             ret += createIndent(indentLevel); 
  85.             ret += aProperty;
  86.  
  87.             var    typeName = typeof(anObject[aProperty]);
  88.             ret += " (typeof: " + typeof(anObject[aProperty]) + ")";
  89.  
  90.             if (typeName != "function")
  91.             {
  92.                 ret += ": ";
  93.  
  94.                 try
  95.                 {
  96.                     ret += anObject[aProperty];
  97.                 }
  98.                 catch (theError)
  99.                 {
  100.                     ret += "<no toString defined>";
  101.                 }
  102.             }
  103.  
  104.             ret += "\n";
  105.             if (typeName == "object")
  106.             {
  107.                 if(depth > indentLevel)
  108.                     ret += DumpContainedProperties(indentLevel + 1, anObject[aProperty],depth, new Array);
  109.                 else
  110.                     ret += createIndent(indentLevel+1) + "...details omitted" + "\n";
  111.  
  112.             }
  113.         }
  114.     }
  115.  
  116.     return ret;
  117. }
  118.