I forget what MTASC does.... I think it throws a warning too. ----- Original Message ----- From: "JesterXL" <[EMAIL PROTECTED]> To: "Flashcoders mailing list" <flashcoders@chattyfig.figleaf.com> Sent: Friday, December 30, 2005 2:34 PM Subject: Re: [Flashcoders] Singleton as associative array - yucky icky?
Flash won't bitch when you do this: my_xml["owner"] Flex 1 & 1.5 will give you a warning. Flex 2 bitches if owner isn't public. ----- Original Message ----- From: "Nathan Derksen" <[EMAIL PROTECTED]> To: "Flashcoders mailing list" <flashcoders@chattyfig.figleaf.com> Sent: Friday, December 30, 2005 2:24 PM Subject: Re: [Flashcoders] Singleton as associative array - yucky icky? > On 12/30/05, Nathan Derksen <[EMAIL PROTECTED]> wrote: > > while that is true, i thought that was what the "dynamic" keyword was > to allow, and without it, you'd get some sort of error... That's the theory, but as the XML example shows, using the associative array syntax gets around the compile-time checking for that. >> In many respects, LoadVars is doing what you want to do with your >> Session class. > > well, in ways, yes - in ways, no. it's doing the same on-the-fly > variable assignment, but doesn't have any other methods (like > "addItem") that would put keys/values into a specific class member. > > it seems that LoadVars just iterates over the object and outputs any > property it finds (which is why "onLoad=function" used to appear in > LoadVars data). > > i was doing iterations over both the class object and the Items > member. i'd obviously prefer just to have one place for all props. Yah, that's why it is so much cleaner just to have an associative array as a private property within your class, and create addItem(), getItem(), and removeItem() methods to manage that associative array. That way you also don't have to worry about the names of added properties possibly colliding with existing property/method names within the class. Nathan http://www.nathanderksen.com _______________________________________________ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders _______________________________________________ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders _______________________________________________ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders