If you have a weakness for kludgy solutions, try the 'getObjNames' function
below.
Otherwise: don't 'forget' the names of the objects: store the name in the
same object, as an additional property.


// 'don't try this at home!'

a = {someProp:'someValue'};
b = {someProp:'someOtherValue'};
c = a;

arr = [a, b];


// later, when we have 'forgotten' the names of the objects

for(var i=0, len=arr.length; i<len; i++){
        trace(getObjNames(arr[i]) + '   - someProp: '+ arr[i].someProp);

        // Output:      c,a   - someProp: someValue
        //                      b   - someProp: someOtherValue

}


// kludgy, poorly tested and a waste of processor cycles
function getObjNames(o:Object, timeline:MovieClip){
        var names:Array;
        var o2 = arguments[1] ? arguments[1] : _level0;
        if(!names){names = []}
        for(var p in o2){
                if(typeof(o2[p]) == 'object'){
                        if(o2[p] != o){
                                 getObjName(o, o2[p]);
                        }else{
                                names.push(p);
                        }
                }
        }
        return names;
}

hth
--------------
Andreas Weber
motiondraw.com



-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf Of Sascha
Balkau
Sent: Monday, January 23, 2006 2:03 PM
To: flashcoders
Subject: [Flashcoders] getting the name of an object


hi,

this might be obvious but how do I get the name of an object? If I got an
object named fooObj how can I get Flash to for example trace out the name of
the object, so that it traces "fooObj"? I know this works with movieclips
but how about objects or arrays?

Sascha

_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to