I believe that using singletons is the traditional design pattern way
to do this although I have seen some people arguing that singletons
conflict with unit testing. I don't know enough to comment on that debate.

I would suggest using a getter for your instance so that, at least,
your call could be SingletonClass.instance.myConstant which, at least
to my eye, is a bit easier to read.

Sorry not to be more helpful, but hope that helps somewhat.

Sid

--- In flexcoders@yahoogroups.com, "Alex Harui" <[EMAIL PROTECTED]> wrote:
>
> I would advise against one big global constants file.  Generally not an
> OOP thing to do.
> 
>  
> 
> I would use static consts on classes.  Look at any mx.events.* class to
> see
> 
>  
> 
> ________________________________
> 
> From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
> Behalf Of edlueze
> Sent: Wednesday, July 09, 2008 4:42 PM
> To: flexcoders@yahoogroups.com
> Subject: [flexcoders] Setting Up a Global Constants File
> 
>  
> 
> I'm trying to fill a file full of global constants that will be used
> by all the other ActionScript files in my project. If I create an
> ActionScript file and start filling it with constants then when I try
> and reference that file from several others I run into the error "A
> file found in a source-path can not have more than one externally
> visible definition". On the other hand, I could create a singleton
> class but then a reference to a simple global constant becomes long
> and unreadable: for example "SingletonClass.getInstance().myConstant".
> 
> What's the best practice in this situation?
> 
> Thanks!
>


Reply via email to