RE: [flexcoders] problem with arrays
Title: problem with arrays When I replied to the list, I didn’t realize it was flexcoders – thought it was another Flash list, didn’t realize they were updating a component. Still, the rest of my post holds true. Jason Merrill | E-Learning Solutions | icfconsulting.com From: flexcoders@yahoogroups.com [mailto:flexcoders@yahoogroups.com] On Behalf Of Tracy Spratt Sent: Wednesday, November 23, 2005 5:41 PM To: flexcoders@yahoogroups.com Subject: RE: [flexcoders] problem with arrays But if your array is a dataProvider and you WANT to update the control as you go, do use additem() or addItemAt(). Though usually, if you are building an entire dataProvider, you want to wait until you are done, then re-assign the array to the dataProvider. Tracy From: flexcoders@yahoogroups.com [mailto:flexcoders@yahoogroups.com] On Behalf Of Merrill, Jason Sent: Wednesday, November 23, 2005 4:25 PM To: flexcoders@yahoogroups.com Subject: RE: [flexcoders] problem with arrays Doing this: testArray[0] within the loop will always insert the value in the 0 slot of the array, so your loop is pointless. Use the num variable to increase the array postion targeted. Also, addItem is not necessary. To get the expected results, do this: var testArray:Array = new Array(); var temp_arr:Array = new Array(); for(var num:Number = 0; num < 3; num++) { temp_arr[num] = num; testArray[num] = num+5; } trace(temp_arr) trace(testArray) Jason Merrill | E-Learning Solutions | icfconsulting.com From: flexcoders@yahoogroups.com [mailto:flexcoders@yahoogroups.com] On Behalf Of Parekh, Shweta - BLS CTR Sent: Wednesday, November 23, 2005 4:07 PM To: flexcoders@yahoogroups.com Subject: [flexcoders] problem with arrays Hi, I have a piece of code like the following: var testArray:Array = new Array(); var temp_arr:Array = new Array(2); for(var num:Number = 0; num < 3; num++) { temp_arr[0] = num; temp_arr[1] = num+5; testArray.addItemAt(num, temp_arr); } trace("testArray ***"); for(var i:Number = 0; i < testArray.length; i++) { trace(testArray[i]); } I am expecting it to print 0 5 1 6 2 7 instead the it prints out 2 7 2 7 2 7 Can anybody tell me why??? How can I fix it? Thanks, Shweta 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. -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com SPONSORED LINKS Web site design development Computer software development Software design and development Macromedia flex Software development best practice YAHOO! GROUPS LINKS Visit your group "flexcoders" on the web. To unsubscribe from this group, send an email to: [EMAIL PROTECTED] Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
RE: [flexcoders] problem with arrays
Title: problem with arrays But if your array is a dataProvider and you WANT to update the control as you go, do use additem() or addItemAt(). Though usually, if you are building an entire dataProvider, you want to wait until you are done, then re-assign the array to the dataProvider. Tracy From: flexcoders@yahoogroups.com [mailto:flexcoders@yahoogroups.com] On Behalf Of Merrill, Jason Sent: Wednesday, November 23, 2005 4:25 PM To: flexcoders@yahoogroups.com Subject: RE: [flexcoders] problem with arrays Doing this: testArray[0] within the loop will always insert the value in the 0 slot of the array, so your loop is pointless. Use the num variable to increase the array postion targeted. Also, addItem is not necessary. To get the expected results, do this: var testArray:Array = new Array(); var temp_arr:Array = new Array(); for(var num:Number = 0; num < 3; num++) { temp_arr[num] = num; testArray[num] = num+5; } trace(temp_arr) trace(testArray) Jason Merrill | E-Learning Solutions | icfconsulting.com From: flexcoders@yahoogroups.com [mailto:flexcoders@yahoogroups.com] On Behalf Of Parekh, Shweta - BLS CTR Sent: Wednesday, November 23, 2005 4:07 PM To: flexcoders@yahoogroups.com Subject: [flexcoders] problem with arrays Hi, I have a piece of code like the following: var testArray:Array = new Array(); var temp_arr:Array = new Array(2); for(var num:Number = 0; num < 3; num++) { temp_arr[0] = num; temp_arr[1] = num+5; testArray.addItemAt(num, temp_arr); } trace("testArray ***"); for(var i:Number = 0; i < testArray.length; i++) { trace(testArray[i]); } I am expecting it to print 0 5 1 6 2 7 instead the it prints out 2 7 2 7 2 7 Can anybody tell me why??? How can I fix it? Thanks, Shweta 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. -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com YAHOO! GROUPS LINKS Visit your group "flexcoders" on the web. To unsubscribe from this group, send an email to: [EMAIL PROTECTED] Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
RE: [flexcoders] problem with arrays
Title: problem with arrays temp_arr is a pointer so all you're doing is assigning the same pointer to every index in testArray and simply incrementing the values with each iteration of the first look. Try declaring temp_arr within the loop. Carson Carson HagerCynergy Systems, Inc.http://www.cynergysystems.com Email: [EMAIL PROTECTED]Office: 866-CYNERGYMobile: 1.703.489.6466 From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Parekh, Shweta - BLS CTRSent: Wednesday, November 23, 2005 1:07 PMTo: flexcoders@yahoogroups.comSubject: [flexcoders] problem with arrays Hi, I have a piece of code like the following: var testArray:Array = new Array(); var temp_arr:Array = new Array(2); for(var num:Number = 0; num < 3; num++) { temp_arr[0] = num; temp_arr[1] = num+5; testArray.addItemAt(num, temp_arr); } trace("testArray ***"); for(var i:Number = 0; i < testArray.length; i++) { trace(testArray[i]); } I am expecting it to print 0 5 1 6 2 7 instead the it prints out 2 7 2 7 2 7 Can anybody tell me why??? How can I fix it? Thanks, Shweta -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com YAHOO! GROUPS LINKS Visit your group "flexcoders" on the web. To unsubscribe from this group, send an email to: [EMAIL PROTECTED] Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
RE: [flexcoders] problem with arrays
Title: problem with arrays Doing this: testArray[0] within the loop will always insert the value in the 0 slot of the array, so your loop is pointless. Use the num variable to increase the array postion targeted. Also, addItem is not necessary. To get the expected results, do this: var testArray:Array = new Array(); var temp_arr:Array = new Array(); for(var num:Number = 0; num < 3; num++) { temp_arr[num] = num; testArray[num] = num+5; } trace(temp_arr) trace(testArray) Jason Merrill | E-Learning Solutions | icfconsulting.com From: flexcoders@yahoogroups.com [mailto:flexcoders@yahoogroups.com] On Behalf Of Parekh, Shweta - BLS CTR Sent: Wednesday, November 23, 2005 4:07 PM To: flexcoders@yahoogroups.com Subject: [flexcoders] problem with arrays Hi, I have a piece of code like the following: var testArray:Array = new Array(); var temp_arr:Array = new Array(2); for(var num:Number = 0; num < 3; num++) { temp_arr[0] = num; temp_arr[1] = num+5; testArray.addItemAt(num, temp_arr); } trace("testArray ***"); for(var i:Number = 0; i < testArray.length; i++) { trace(testArray[i]); } I am expecting it to print 0 5 1 6 2 7 instead the it prints out 2 7 2 7 2 7 Can anybody tell me why??? How can I fix it? Thanks, Shweta 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. -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com SPONSORED LINKS Web site design development Computer software development Software design and development Macromedia flex Software development best practice YAHOO! GROUPS LINKS Visit your group "flexcoders" on the web. To unsubscribe from this group, send an email to: [EMAIL PROTECTED] Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
RE: [flexcoders] problem with arrays
Title: problem with arrays It looks like you are just putting a reference to temp_arr instead of it actually creating a new array for the new value in testArray. testArray.addItemAt(num, temp_arr); What you probably want to do is this instead is use concat() to create a duplicate of temp_arr instead of passing a reference. testArray.addItemAt(num, temp_arr.concat()); Hope this helps, Greg From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Parekh, Shweta - BLS CTRSent: Wednesday, November 23, 2005 1:07 PMTo: flexcoders@yahoogroups.comSubject: [flexcoders] problem with arrays Hi, I have a piece of code like the following: var testArray:Array = new Array(); var temp_arr:Array = new Array(2); for(var num:Number = 0; num < 3; num++) { temp_arr[0] = num; temp_arr[1] = num+5; testArray.addItemAt(num, temp_arr); } trace("testArray ***"); for(var i:Number = 0; i < testArray.length; i++) { trace(testArray[i]); } I am expecting it to print 0 5 1 6 2 7 instead the it prints out 2 7 2 7 2 7 Can anybody tell me why??? How can I fix it? Thanks, Shweta -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com SPONSORED LINKS Web site design development Computer software development Software design and development Macromedia flex Software development best practice YAHOO! GROUPS LINKS Visit your group "flexcoders" on the web. To unsubscribe from this group, send an email to: [EMAIL PROTECTED] Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service. To ensure compliance with requirements imposed by the IRS, we inform you that any U.S. federal tax advice contained in this document (including any attachments) is not intended or written to be used, and cannot be used, for the purpose of (i) avoiding penalties under the Internal Revenue Code or (ii) promoting, marketing or recommending to another party any transaction or matter addressed herein. This email may contain confidential and privileged material for the sole use of the intended recipient(s). Any review, use, distribution or disclosure by others is strictly prohibited. If you are not the intended recipient (or authorized to receive for the recipient), please contact the sender by reply email and delete all copies of this message. To reply to our email administrator directly, send an email to [EMAIL PROTECTED] Littler Mendelson, P.C. http://www.littler.com
[flexcoders] problem with arrays
Title: problem with arrays Hi, I have a piece of code like the following: var testArray:Array = new Array(); var temp_arr:Array = new Array(2); for(var num:Number = 0; num < 3; num++) { temp_arr[0] = num; temp_arr[1] = num+5; testArray.addItemAt(num, temp_arr); } trace("testArray ***"); for(var i:Number = 0; i < testArray.length; i++) { trace(testArray[i]); } I am expecting it to print 0 5 1 6 2 7 instead the it prints out 2 7 2 7 2 7 Can anybody tell me why??? How can I fix it? Thanks, Shweta -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com SPONSORED LINKS Web site design development Computer software development Software design and development Macromedia flex Software development best practice YAHOO! GROUPS LINKS Visit your group "flexcoders" on the web. To unsubscribe from this group, send an email to: [EMAIL PROTECTED] Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.