RE: [Flashcoders] clone object
That's true - it happens to me all the time when I use _global(tt) with Xray and have a circular reference (such as two classes that hold eachother as listeners). This was why John had to change his original treeview parser to a non-recursive method. But it still happens with the trace function. So I'd say that some kind of check would be useful. Karina -Original Message- From: Scott Hyndman [mailto:[EMAIL PROTECTED] Sent: 25 August 2006 02:59 To: Flashcoders mailing list Subject: Re: [Flashcoders] clone object If you had one circular reference, you'd hit the recursion limit. On 24/08/06, Steven Sacks | BLITZ [EMAIL PROTECTED] wrote: If you're not willing to code a solution, then why are you bothering to write out an explanation? I have yet to encounter a recursion limit and I've parsed some deep object models. ___ 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@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@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] clone object
you'd need some way of checking for circular references like Scott pointed out. Believe me when I say - i've been down that road several times with Xray. var obj = new Object(); obj.prop1 = new Object(); obj.prop1.prop2 = new Object(); obj.prop1.prop2.ref = obj.prop1; bingo, you'e into 256 levels of recursion error. And no, it's not far fetched ;) alternative: Keith Peters Debug: http://mirror1.cvsdude.com/trac/osflash/xray/browser/DEV_Source/xray/classes/com/bit101/Debug.as I switched out xray's trace for Keiths just a couple of weeks ago because it worked on a per level basis for dispatching traces (rather than on big bulk of data) and it's really clean/readable code. You could alter it in no time to clone and object. However, mx.utils.ObjectCopy would work just fine ;) On 8/24/06, Steven Sacks | BLITZ [EMAIL PROTECTED] wrote: Careful with circular references. Pretty easy to get that one in to exceed the 256 recursion limit. Feel free to post an alternative. :) ___ 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 -- [ JPG ] ___ 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] clone object
Guess there's a first time for everything, eh? var obj = new Object(); obj.prop1 = new Object(); obj.prop1.prop2 = new Object(); obj.prop1.prop2.ref = obj.prop1; function clone(obj:Object):Object { var o = (null != obj.length) ? [] : {}; for (var i in obj) { o [i] = (typeof obj[i] == object) ? clone(obj[i]) : obj[i]; } return o; } 256 levels of recursion were exceeded in one action list. This is probably an infinite loop. Further execution of actions has been disabled in this movie. ;) On 8/24/06, Steven Sacks | BLITZ [EMAIL PROTECTED] wrote: If you're not willing to code a solution, then why are you bothering to write out an explanation? I have yet to encounter a recursion limit and I've parsed some deep object models. ___ 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 -- [ JPG ] ___ 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] clone object
I'm using this to clone data objects. If you put circular references in your data models that's not my problem. :) -Original Message- From: [EMAIL PROTECTED] [mailto:flashcoders- [EMAIL PROTECTED] On Behalf Of John Grden Sent: Friday, August 25, 2006 6:37 AM To: Flashcoders mailing list Subject: Re: [Flashcoders] clone object Guess there's a first time for everything, eh? var obj = new Object(); obj.prop1 = new Object(); obj.prop1.prop2 = new Object(); obj.prop1.prop2.ref = obj.prop1; function clone(obj:Object):Object { var o = (null != obj.length) ? [] : {}; for (var i in obj) { o [i] = (typeof obj[i] == object) ? clone(obj[i]) : obj[i]; } return o; } 256 levels of recursion were exceeded in one action list. This is probably an infinite loop. Further execution of actions has been disabled in this movie. ;) On 8/24/06, Steven Sacks | BLITZ [EMAIL PROTECTED] wrote: If you're not willing to code a solution, then why are you bothering to write out an explanation? I have yet to encounter a recursion limit and I've parsed some deep object models. ___ 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 -- [ JPG ] ___ 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@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] clone object
I'm using this to clone data objects. If you put circular references in your data models that's not my problem. :) Then you might consider renaming the method 'cloneDataObject' or 'cloneDataObjectThatDoesntContainCircularReference' :-) Jim Kremens On 8/25/06, Steven Sacks | BLITZ [EMAIL PROTECTED] wrote: I'm using this to clone data objects. If you put circular references in your data models that's not my problem. :) -Original Message- From: [EMAIL PROTECTED] [mailto:flashcoders- [EMAIL PROTECTED] On Behalf Of John Grden Sent: Friday, August 25, 2006 6:37 AM To: Flashcoders mailing list Subject: Re: [Flashcoders] clone object Guess there's a first time for everything, eh? var obj = new Object(); obj.prop1 = new Object(); obj.prop1.prop2 = new Object(); obj.prop1.prop2.ref = obj.prop1; function clone(obj:Object):Object { var o = (null != obj.length) ? [] : {}; for (var i in obj) { o [i] = (typeof obj[i] == object) ? clone(obj[i]) : obj[i]; } return o; } 256 levels of recursion were exceeded in one action list. This is probably an infinite loop. Further execution of actions has been disabled in this movie. ;) On 8/24/06, Steven Sacks | BLITZ [EMAIL PROTECTED] wrote: If you're not willing to code a solution, then why are you bothering to write out an explanation? I have yet to encounter a recursion limit and I've parsed some deep object models. ___ 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 -- [ JPG ] ___ 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@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 -- Jim Kremens ___ 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] clone object
I guess you'd be right about that. It'd be my problem - good point. while I'm at it: 1. I use block comments all the time - but if you think it's janky, more power to you. 2. I prefer people to drop the curly brace down to the next line, not left up on the method declaration line. But I don't give a rats ass if they don't. 3. I think WWF wrestling is fake - but it's cool if others don't. 4. Drew Bledsoe will be out by the 3rd game of the regular season - well, that's just a fact. 5. Your mom. and as we all know, the conversation always ends when someone pulls the your mom card. ;) On 8/25/06, Steven Sacks | BLITZ [EMAIL PROTECTED] wrote: I'm using this to clone data objects. If you put circular references in your data models that's not my problem. :) -Original Message- From: [EMAIL PROTECTED] [mailto:flashcoders- [EMAIL PROTECTED] On Behalf Of John Grden Sent: Friday, August 25, 2006 6:37 AM To: Flashcoders mailing list Subject: Re: [Flashcoders] clone object Guess there's a first time for everything, eh? var obj = new Object(); obj.prop1 = new Object(); obj.prop1.prop2 = new Object(); obj.prop1.prop2.ref = obj.prop1; function clone(obj:Object):Object { var o = (null != obj.length) ? [] : {}; for (var i in obj) { o [i] = (typeof obj[i] == object) ? clone(obj[i]) : obj[i]; } return o; } 256 levels of recursion were exceeded in one action list. This is probably an infinite loop. Further execution of actions has been disabled in this movie. ;) On 8/24/06, Steven Sacks | BLITZ [EMAIL PROTECTED] wrote: If you're not willing to code a solution, then why are you bothering to write out an explanation? I have yet to encounter a recursion limit and I've parsed some deep object models. ___ 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 -- [ JPG ] ___ 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@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 -- [ JPG ] ___ 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] clone object
-Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of John Grden Sent: Friday, August 25, 2006 3:06 PM To: Flashcoders mailing list Subject: Re: [Flashcoders] clone object I guess you'd be right about that. It'd be my problem - good point. while I'm at it: 1. I use block comments all the time - but if you think it's janky, more power to you. 2. I prefer people to drop the curly brace down to the next line, not left up on the method declaration line. But I don't give a rats ass if they don't. 3. I think WWF wrestling is fake - but it's cool if others don't. 4. Drew Bledsoe will be out by the 3rd game of the regular season - well, that's just a fact. 5. Your mom. and as we all know, the conversation always ends when someone pulls the your mom card. ;) On 8/25/06, Steven Sacks | BLITZ [EMAIL PROTECTED] wrote: I'm using this to clone data objects. If you put circular references in your data models that's not my problem. :) -Original Message- From: [EMAIL PROTECTED] [mailto:flashcoders- [EMAIL PROTECTED] On Behalf Of John Grden Sent: Friday, August 25, 2006 6:37 AM To: Flashcoders mailing list Subject: Re: [Flashcoders] clone object Guess there's a first time for everything, eh? var obj = new Object(); obj.prop1 = new Object(); obj.prop1.prop2 = new Object(); obj.prop1.prop2.ref = obj.prop1; function clone(obj:Object):Object { var o = (null != obj.length) ? [] : {}; for (var i in obj) { o [i] = (typeof obj[i] == object) ? clone(obj[i]) : obj[i]; } return o; } 256 levels of recursion were exceeded in one action list. This is probably an infinite loop. Further execution of actions has been disabled in this movie. ;) On 8/24/06, Steven Sacks | BLITZ [EMAIL PROTECTED] wrote: If you're not willing to code a solution, then why are you bothering to write out an explanation? I have yet to encounter a recursion limit and I've parsed some deep object models. ___ 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 -- [ JPG ] ___ 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@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 -- [ JPG ] ___ 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@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] clone object
Are you stalking me, Grden? :) 1. I use block comments all the time - but if you think it's janky, more power to you. I have the power of Greyskull. Block comments are for commenting out *gasp* blocks of code. I use block comments all the time for that very purpose. I use line comments to write internal commentary on my code, though, so that anyone can comment out blocks without issue. 2. I prefer people to drop the curly brace down to the next line, not left up on the method declaration line. But I don't give a rats ass if they don't. That's a tomayto tomahto thing. I can read code just fine either way. 3. I think WWF wrestling is fake - but it's cool if others don't. It's never cool to be willfully ignorant. And while it is all fake, it's not like it doesn't hurt getting slammed to the floor or doesn't require a level of athleticism and endurance. It might be a show, but it takes a lot of work to put on that show and I'm sure there are real injuries. 4. Drew Bledsoe will be out by the 3rd game of the regular season - well, that's just a fact. Baseball is boring. Are you cool with me saying that? ;) 5. Your mom. Has a broken heart thanks to you. Nice going, John, you tease. ___ 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] clone object
shouldn't you boys be going out and getting a drink on blitz's account instead of teasing each other like this? On 8/25/06, Steven Sacks | BLITZ [EMAIL PROTECTED] wrote: Are you stalking me, Grden? :) 1. I use block comments all the time - but if you think it's janky, more power to you. I have the power of Greyskull. Block comments are for commenting out *gasp* blocks of code. I use block comments all the time for that very purpose. I use line comments to write internal commentary on my code, though, so that anyone can comment out blocks without issue. 2. I prefer people to drop the curly brace down to the next line, not left up on the method declaration line. But I don't give a rats ass if they don't. That's a tomayto tomahto thing. I can read code just fine either way. 3. I think WWF wrestling is fake - but it's cool if others don't. It's never cool to be willfully ignorant. And while it is all fake, it's not like it doesn't hurt getting slammed to the floor or doesn't require a level of athleticism and endurance. It might be a show, but it takes a lot of work to put on that show and I'm sure there are real injuries. 4. Drew Bledsoe will be out by the 3rd game of the regular season - well, that's just a fact. Baseball is boring. Are you cool with me saying that? ;) 5. Your mom. Has a broken heart thanks to you. Nice going, John, you tease. ___ 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 -- j:pn http://www.lennel.org ___ 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] clone object
LOL I seriously think you may end up in a padded room with a box of crayons ;) OK, we're officiall OT - sorry mods! we're ending it here. ___ 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] clone object
I'm not working for blitz at the moment ;) On 8/25/06, Johannes Nel [EMAIL PROTECTED] wrote: shouldn't you boys be going out and getting a drink on blitz's account instead of teasing each other like this? ___ 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] clone object
I'm not working for blitz at the moment ;) Me neither while this keeps up! ;) ___ 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] clone object
Careful with circular references. Pretty easy to get that one in to exceed the 256 recursion limit. Scott On 23/08/06, Steven Sacks | BLITZ [EMAIL PROTECTED] wrote: static function clone(obj:Object):Object { var o = (null != obj.length) ? [] : {}; for (var i in obj) { o [i] = (typeof obj[i] == object) ? clone(obj[i]) : obj[i]; } return o; } ___ 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@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] clone object
Careful with circular references. Pretty easy to get that one in to exceed the 256 recursion limit. Feel free to post an alternative. :) ___ 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] clone object
I would mark each object (by actually assigning the cloned object as a property of the original) as I go through each individual clone operation, and keep a running array of what is being marked. If I hit something that is already marked, I will use the clone instead of copying the same object again (because it's hanging off the original). When I'm finished, I'd remove all the temporary properties from the originals. This requires two method instead of one, and is a bit more CPU intensive, but it won't break. I'd also be sure to special case the handling of date objects. The alternative is to shallow clone, which does not recursively copy object properties, and instead assigns the reference held by the original to the clone. Scott On 24/08/06, Steven Sacks | BLITZ [EMAIL PROTECTED] wrote: Careful with circular references. Pretty easy to get that one in to exceed the 256 recursion limit. Feel free to post an alternative. :) ___ 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@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] clone object
If you're not willing to code a solution, then why are you bothering to write out an explanation? I have yet to encounter a recursion limit and I've parsed some deep object models. ___ 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] clone object
If you had one circular reference, you'd hit the recursion limit. On 24/08/06, Steven Sacks | BLITZ [EMAIL PROTECTED] wrote: If you're not willing to code a solution, then why are you bothering to write out an explanation? I have yet to encounter a recursion limit and I've parsed some deep object models. ___ 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@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] clone object
I have a style that I need to duplicate for several buttons. The style is declared once and then I want to duplicate the object and add a specific style element and then apply it to the button. However when I duplicate the object I get a reference to the original object, as expected. I tried to fake out a clone method in order to get this to work but it does not seem to properly duplicate the object. I am sure that this question has been asked a million times on this list but I can't seem to googlize the correct answer. Can someone point me in the right direction to properly clone an object and keep all the right castings. Ahh to just have all the Flex classes in flash. private function cloneObject(object){ var iterate; var clone = {}; for(iterate in object){ clone [iterate] = object[iterate]; } return clone; } Thanks! Wade ___ 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] clone object
You know about mx.utils.ObjectCopy, right? Be sure to change the following lines to read accordingly: // var result:Object = new Function( refObj.__proto__.constructor)(); //change to: var result:Object = new (Function( refObj.__proto__.constructor))(); and // p[j]= q[j]; //change to: p[j]= copy(q[j]); Jim Kremens On 8/23/06, Wade Arnold [EMAIL PROTECTED] wrote: I have a style that I need to duplicate for several buttons. The style is declared once and then I want to duplicate the object and add a specific style element and then apply it to the button. However when I duplicate the object I get a reference to the original object, as expected. I tried to fake out a clone method in order to get this to work but it does not seem to properly duplicate the object. I am sure that this question has been asked a million times on this list but I can't seem to googlize the correct answer. Can someone point me in the right direction to properly clone an object and keep all the right castings. Ahh to just have all the Flex classes in flash. private function cloneObject(object){ var iterate; var clone = {}; for(iterate in object){ clone [iterate] = object[iterate]; } return clone; } Thanks! Wade ___ 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 -- Jim Kremens ___ 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] clone object
static function clone(obj:Object):Object { var o = (null != obj.length) ? [] : {}; for (var i in obj) { o [i] = (typeof obj[i] == object) ? clone(obj[i]) : obj[i]; } return o; } ___ 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