DictionaryUtil.as 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /*
  2. Copyright (c) 2008, Adobe Systems Incorporated
  3. All rights reserved.
  4. Redistribution and use in source and binary forms, with or without
  5. modification, are permitted provided that the following conditions are
  6. met:
  7. * Redistributions of source code must retain the above copyright notice,
  8. this list of conditions and the following disclaimer.
  9. * Redistributions in binary form must reproduce the above copyright
  10. notice, this list of conditions and the following disclaimer in the
  11. documentation and/or other materials provided with the distribution.
  12. * Neither the name of Adobe Systems Incorporated nor the names of its
  13. contributors may be used to endorse or promote products derived from
  14. this software without specific prior written permission.
  15. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
  16. IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
  17. THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  18. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
  19. CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  20. EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  21. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  22. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  23. LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  24. NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  25. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  26. */
  27. package com.adobe.utils
  28. {
  29. import flash.utils.Dictionary;
  30. public class DictionaryUtil
  31. {
  32. /**
  33. * Returns an Array of all keys within the specified dictionary.
  34. *
  35. * @param d The Dictionary instance whose keys will be returned.
  36. *
  37. * @return Array of keys contained within the Dictionary
  38. *
  39. * @langversion ActionScript 3.0
  40. * @playerversion Flash 9.0
  41. * @tiptext
  42. */
  43. public static function getKeys(d:Dictionary):Array
  44. {
  45. var a:Array = new Array();
  46. for (var key:Object in d)
  47. {
  48. a.push(key);
  49. }
  50. return a;
  51. }
  52. /**
  53. * Returns an Array of all values within the specified dictionary.
  54. *
  55. * @param d The Dictionary instance whose values will be returned.
  56. *
  57. * @return Array of values contained within the Dictionary
  58. *
  59. * @langversion ActionScript 3.0
  60. * @playerversion Flash 9.0
  61. * @tiptext
  62. */
  63. public static function getValues(d:Dictionary):Array
  64. {
  65. var a:Array = new Array();
  66. for each (var value:Object in d)
  67. {
  68. a.push(value);
  69. }
  70. return a;
  71. }
  72. }
  73. }