Re: [Flashcoders] Object path to string
Nick, I need to convert an Object path, for example data.item[3].description.short To a string: "data.item[3].description.short" Something like the targetpath() MovieClip method, but for a basic Object. I reckon you'd need to loop through the object backwards but was hoping to find a function written for this purpose already. No luck yet though. Anyone? You might find something here: http://proto.layer51.com/default.aspx. If you want to code this yourself, you'd need to start at 'data' and loop recursively through all its properties until you find a reference to the object you're looking for. Having said that, of course objects exist only as references, so there might be more than one 'path' to your object. Cheers, Steve -- Steve Webster Head of Development Featurecreep Ltd. http://www.featurecreep.com 14 Orchard Street, Bristol, BS1 5EH 0117 905 5047 ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
Re: [Flashcoders] Object path to string
Nikolaj Selvik wrote: Hi all, I need to convert an Object path, for example data.item[3].description.short To a string: "data.item[3].description.short" Well, if you copied the object to another variable, what should the toString-method then result in? var foo = data.item[3].description.short; toString(foo); // what should this be? var foo2 = data.item[3].description; toString(foo2.short); // and this? There is no such way, as an object or variable has no knowledge of which references exist to it. MovieClips are hierarchically defined, with no cycles, explicit knowledge of parent and children - normal objects are not, and thus you cannot do this. You would have to manually build this in some way. For instance you could create a method, with took data and data.item[3].description as arguments, and returned the string "item[3].description", as this is where this object is found. But otherwise no. This is a quite commen question and misconception of ActionScript and the "object hierarchy". :) -- Morten Barklund ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
[Flashcoders] Object path to string
Hi all, I need to convert an Object path, for example data.item[3].description.short To a string: "data.item[3].description.short" Something like the targetpath() MovieClip method, but for a basic Object. I reckon you'd need to loop through the object backwards but was hoping to find a function written for this purpose already. No luck yet though. Anyone? BR, Nick ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com