2 import flash.sampler.StackFrame;
4 public final class Util {
6 public static function trim(str:String, index:int, array:Array):String {
11 return str.replace(/^\s+|\s+$/g, "");
14 //Might be better making an abstract class with this method and extending my objs
15 //Extend A with Bs properties. Properties in A will be over written with properties
16 //in B if they exist in both.
17 public static function extend(objA:Object, objB:Object):Object {
19 for(var prop:String in objB) {
20 if(typeof(objB[prop]) === "object") {
21 objA[prop] = extend(objA[prop], objB[prop]);
23 objA[prop] = objB[prop];
30 //Might be better making an abstract class with this method and extending my objs
31 public static function resolvePropertyChain(dotDelimited:String, obj:Object):* {
32 var properties:Array = dotDelimited.split('.');
33 //var field:String = properties.pop();
34 for each(var prop:String in properties) {
35 obj = obj.hasOwnProperty(prop) && obj[prop];
41 public static function toPropertyChains(obj:Object):Array {
42 function chainFrom(chain:Array, obj:Object, atEnd:Function) {
43 if(typeof(obj) === "object") {
44 for(var prop:String in obj) {
46 chainFrom(chain, obj[prop], atEnd);
55 chainFrom([], obj, function(chain:Array) {
56 res.push(chain.join("."));
62 //Might be better making an abstract class with this method and extending my objs
63 public static function objectIsEmpty(obj:Object):Boolean {
64 for(var s:String in obj) {
71 public static function arrayConcatUnique(arr1:Array, arr2:Array):Array {
72 for each (var value:* in arr2) {
73 if (arr1.indexOf(value) == -1)