You're exactly correct. I offered some ASCII-art diagrams of this yesterday, but your explanation in English is better.
Gordon Smith Adobe Flex SDK Team From: flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] On Behalf Of Todd Kerpelman Sent: Monday, July 27, 2009 6:35 PM To: flexcoders@yahoogroups.com Subject: Re: [flexcoders] Who can explain me this: Here's my guess as to what's going on underneath the hood... private var a:Object = {data:String}; "Let's create an object that lives at memory address 123 RAM Lane. This variable 'a' gives me the object that lives at that address." private var b:Object = {data:String}; "Let's create an object that lives at memory address 456 Silicon Drive. This variable 'b' gives me the object that lives at that address." private var testx:Array = [a] "The first entry of this array is this object that the variable 'a' is pointing to. Looks like that's the object at 123 RAM lane. So the first entry of this array is 'The object that lives at 123 RAM Lane'" trace(testx[0].data) // 1st - 100 "According to the first entry of my array, I want to be looking at the object that lives at 123 RAM Lane. That's an object with a 'data' variable of 100" a.data = 1000 "This variable 'a' is looking at an object that lives at 123 RAM Lane. Let's take this object and set it's 'data' variable to 1000" a = b; "You know this variable 'a' that's looking at the object that lives at 123 RAM Lane? Let's have it look at the object that lives at 456 Silicon Drive" trace(testx[0].data) // 3rd - 1000 "According to the first entry of my array, I want to be looking at the object that lives at 123 RAM lane. That's an object with a 'data' variable of 1000" Basically, it's the fact that when you assign objects to variables, you're not assigning the entire object, but a pointer to where that object lives in memory. And then, when you stored that object in an array, I'm guessing that Flex stored "The address of the object that 'a' is pointing to" instead of anything related to the actual variable called 'a'. That's why you can change what a is pointing to without actually changing what the first element in your array is pointing to. At least, I'm pretty sure that's what's going on. Somebody out there feel free to correct me if I'm wrong... --Todd On Mon, Jul 27, 2009 at 6:17 PM, lytvynyuk <lytvyn...@yahoo.com<mailto:lytvyn...@yahoo.com>> wrote: <?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="init()"> <mx:Script> <![CDATA[ import mx.collections.ArrayCollection; private var a:Object = {data:String}; private var b:Object = {data:String}; [Bindable] private var testx:Array = [a] private function init():void { b.data = 200; a.data = 100 trace(testx[0].data) // 1st - 100 a.data = 1000 trace(testx[0].data) // 2nd - 1000 a = b; trace(testx[0].data) // 3rd - 1000 } ]]> </mx:Script> </mx:Application> Why third trace(...) outputs 1000 not 200!? :)