When it boils down to it, there is almost no difference between what you have
just described and creating a class with static vars to hold constants.
The only difference being in the static class situation, the object on _global
will be a Function (the class' constructor), not an Object.
And by using a class, you are provided the benefit of type-checking during
compilation. I'm not sure many people would call this lame or unnecessary.
Scott
-----Original Message-----
From: [EMAIL PROTECTED] on behalf of Steven Sacks
Sent: Tue 1/31/2006 6:08 PM
To: 'Flashcoders mailing list'
Cc:
Subject: RE: [Flashcoders] Tell me more about "_global"
Making a class for globals is lame. I don't get why people do stuff like
that. It's completely unnecessary. Here's how I make a namespace for
globals in one line.
On frame one of the root timeline:
_global.APP = {};
Wow. That was so hard.
APP.someglobal
APP.someotherglobal
APP.etc
> Nathan Derksen nderksen at sfu.ca wrote:
> >I generally keep at least one singleton class which is responsible
> >for storing global properties. I make those properties accessible
> >with getters and setters so that I can allow changes in those
> >properties to trigger events. You can't really do that if you use
> >_global to store your data. Also, there is always a risk in name
> >space collision if you load in other elements that also use global,
> >where one or more variables use the same name and are thus
> >inadvertently shared for different uses. You definitely do not want
> >to use _global within any classes that you create, as that
> can cause
> >entanglement, gives you no private protection, and does not
> properly
> >contain your code into a well-defined unit with a well-defined API.
> >
> >Nathan
> >http://www.nathanderksen.com
>
> _______________________________________________
> Flashcoders mailing list
> [email protected]
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders