Tom,

First, thanks to you and all(Eric, Doug, Bidhu) who responded with useful 
advice 
to my question.

Yes, unit_dp and division_dp were simply pointers to the same, filtered object.

I used a clone as you suggested and the application works fine now. The 
modified 
code is below. 


import mx.utils.*;

private var cloneDept:ArrayCollection = new ArrayCollection(); 
private var cloneUnit:ArrayCollection = new ArrayCollection(); 

private function initApp():void {
var cloneDept:ArrayCollection = new 
ArrayCollection(ObjectUtil.copy(Application.application.dept_dp.source) as 
Array 
);
                var cloneUnit:ArrayCollection = new 
ArrayCollection(ObjectUtil.copy(Application.application.unit_dp.source) as 
Array 
);
                

dept_dp = cloneDept;

}

I hope the code snippet helps someone else. I had to do some rummaging on the 
Web to understand how cloning works in Actionscript.

I thought I knew enough Flex to decipher code after I completed the Flex 3 
Bible, but I guess I still have to study Actionscript 3 Bible to know the 
subtle 
differences like when pass by reference and pass by value are done. 


Coming from a C/C++ development background it is hard from me to realize that 
division_dp = Application.application.division_dp is pass by reference. Now, I 
wish I knew Java well which is quite similar to Flex. 


Thanks for your advice and time. 






________________________________
From: Tom McNeer <[email protected]>
To: [email protected]
Sent: Wed, August 18, 2010 9:22:07 AM
Subject: Re: [AFFUG Discuss] newbie question: making values persist after 
windows are changed

Chris,

I may not have followed the flow of your application correctly, but if both 
windows use the same dataProvider, then any filtering done in one place will 
show up in another - because it is, after all, the same object. Creating 
another 
object = to the dataProvider will, as Doug notes, involve passing by reference 
and so shouldn't solve your problem.

So unit_dp and division_dp are simply pointers to the same, filtered object.

Perhaps you could consider cloning your data as it arrives from the server (or 
wherever it comes from). A clone of the data will be a completely separate 
object, and thus not affected by the filtering of the first object. So you 
might 
create division_dp as a pointer to Application.application.division_dp, but 
clone the application's dp, and use the clone as unit_dp.

I often do this when I need to use the same basic lookup data in different 
parts 
of my applications, with slight differences. For example, I might retrieve a 
list of departments and use that list within an employee's edit screen. But I 
might clone the list and add an entry for "New Department" to use in a 
drop-down 
choice elsewhere.

-- 
Thanks,

Tom

Tom McNeer
MediumCool
http://www.mediumcool.com
1735 Johnson Road NE
Atlanta, GA 30306
404.589.0560



      


-------------------------------------------------------------
To unsubscribe from this list, simply email the list with unsubscribe in the 
subject line

For more info, see http://www.affug.com
Archive @ http://www.mail-archive.com/discussion%40affug.com/
List hosted by http://www.fusionlink.com
-------------------------------------------------------------

Reply via email to