Copying an Array 2004-03-17 - By Merrill, Jason
Back Easy enough to test:
myArray1 = [] myArray1 = [1,2,3,4,5] myArray2 = myArray1 myArray1.pop(); trace(myArray1) trace(myArray2)
This shows that myArray2 is a reference to myArray1, not a duplicate of myArray1 since the 5 is missing from both. Change one, and you change the other. i.e. even works the other way around:
myArray2.pop(); trace(myArray1) trace(myArray2)
Only way I know how to make a "clone" copy of the entire array that could be different from the original, would be by looping through and grabbing values, and inserting them into the new array you create. Someone else might know. I remember this came up before on one of the chattyfig lists.
Jason Merrill ICF Consulting Government e-Learning Solutions icfconsulting.com
:::>-- --Original Message-- -- :::>From: Brook Davies [mailto:blists@(protected)] :::>Sent: Wednesday, March 17, 2004 4:13 PM :::>To: flashnewbie@(protected) :::>Subject: [Flashnewbie] Copying an Array :::> :::> :::>I am wondering what is the best way to make a duplicate :::>copy of an array or :::>a position in an array. The array contains nested arrays :::>and structures. If :::>I was to say: :::> :::>myDuplicateArray = myArray[4] :::> :::>Would myDuplicateArray be a reference to the original data? :::>I need a :::>duplicate. What if myArray[4] contains a nested array and :::>structures? Would :::>it be duplicated or referenced? :::> :::>Brook :::> :::> :::> :::>-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- -- :::>-- ------ :::>Supported by Fig Leaf Software :::>-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- -- :::>-- ------ :::>Lower Prices for Certified Training! Check out new lower prices for :::>Certified Macromedia Training from Fig Leaf Software. Expand your :::>skill set with courses in ColdFusion, Flash, Rich Internet :::>Applications and .NET in the new year. Fig Leaf Software provides :::>the highest caliber instruction at our training centers in :::>Washington :::>D.C., Atlanta, Chicago, Baltimore, Northern Virginia, or on-site at :::>your location. :::> :::>Get the details at http://training.figleaf.com/ :::>-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- -- :::>-- ---- -- :::>To unsubscribe, e-mail: :::>flashnewbie-unsubscribe@(protected) :::>For additional commands, e-mail: :::>flashnewbie-help@(protected) :::> :::> :::> NOTICE: This message is for the designated recipient only and may contain privileged or confidential information. If you have received it in error, please notify the sender immediately and delete the original. Any other use of this e-mail by you is prohibited.
-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ------ Supported by Fig Leaf Software -- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ------ Lower Prices for Certified Training! Check out new lower prices for Certified Macromedia Training from Fig Leaf Software. Expand your skill set with courses in ColdFusion, Flash, Rich Internet Applications and .NET in the new year. Fig Leaf Software provides the highest caliber instruction at our training centers in Washington D.C., Atlanta, Chicago, Baltimore, Northern Virginia, or on-site at your location.
Get the details at http://training.figleaf.com/ -- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- -- To unsubscribe, e-mail: flashnewbie-unsubscribe@(protected) For additional commands, e-mail: flashnewbie-help@(protected)
|
|