You have to initialize (create) the array. Same as in AS 1.0. myArray = new Array();
This: >> public var items_arr:Array; Doesn't create the array, it only typecasts the variable. Jason Merrill Bank of America Learning & Organization Effectiveness - Technology Solutions >>-----Original Message----- >>From: [EMAIL PROTECTED] [mailto:flashcoders- >>[EMAIL PROTECTED] On Behalf Of Jon Bennett >>Sent: Tuesday, October 10, 2006 1:06 PM >>To: [email protected] >>Subject: [Flashcoders] Moving to AS2, array always undefined >> >>Hi, >> >>got a AS NooB Q. >> >>I'm working on a project and have decided to finally jump ship to AS2, >>but I've run into a (probably obvious) problem which has me a bit >>stumped. >> >>I've written a class, in which I have an array, but the array always >>traces 'undefined' and I can't work out why. >> >>right, so example code: >> >>// ArrayTest.as >> >>class ArrayTest { >> >> public var items_arr:Array; >> >> public function ArrayTest () >> { >> } >> >> public function test (str:String) >> { >> this.items_arr.push (str); >> trace (this.items_arr); >> } >>} >> >>// Timeline >> >>// import class >>import ArrayTest.as; >>// create instance >>var Test:ArrayTest = new ArrayTest(); >>// add some values to the array >>Test.test ('foo'); >>Test.test ('bar'); >> >>I'm pretty sure this is just me not grasping something bleedin' obvious! >> >>tia, >> >>jon >> >>-- >> >> >>jon bennett >>t: +44 (0) 1225 341 039 w: http://www.jben.net/ >>iChat (AIM): jbendotnet Skype: jon-bennett >>_______________________________________________ >>[email protected] >>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 _______________________________________________ [email protected] 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

