Mailing List
Home
Forum Home
Flash Pro
Subjects
Firework Effect
setInterval bug identified and fixed
setInterval bug identified and fixed
ScrollPane component doesn 't auto update
Help: MX 2004 How to script a print button to print the entire sli
Event Dispatcher between classes
memory management removeMovieClip /
MX2004 Dataset itemClassName
Order of events per frame
XML to Object help
Textfield prototype question
Flash and QuickTime VR
Reading and displaying RSS feeds in Flash MX
Flash MX 2004 Sucks
AW: [Flashcoders] Switch/Case vs If/else
AW: [Flashcoders] Switch/Case vs If/else
Flash Interface with 10mb xml file
Web Service Results
Listener Object 's best practice
 
AS 2.0: enumerations?

AS 2.0: enumerations?

2004-03-14       - By Metanet Software

 Back
Reply:     1     2     3     4     5  

hi,
i'm just about to take the plunge and start using AS 2.0 for my next
project.

one "trick" i use quite frequently in AS 1 is "enumerations" using
compile-time constants:

OBJTYPE_BOX = 1;
OBJTYPE_DOOR = 2;

this lets me write slightly-more-friendly code such as:
if(obj.type == OBJTYPE_BOX)

instead of
if(obj.type == 1)

and, it runs JUST as fast since the compiler knows the value of OBJTYPE_BOX
at compile-time, and it replaces all instances of OBJTYPE_BOX with the value
1.


now, the real problem with this type of "enumeration" is that it's not
actually supported; in AS 2, if i want a function to take an "OBJTYPE" as a
parameter or return an "OBJTYPE", will i have to just define the
parameter/return type as "Number"? or is there are support for enumerations?

raigan
p.s - i realize that i could define a class OBJTYPE, each instance of the
class having a single .value number, BUT the problem with this is that it's
much slower: i want something that will compile down to a literal value like
"1" and won't involve any slow get-the-valuue-of-this-variable bytecode.

__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ __
MSN Premium includes powerful parental controls and get 2 months FREE*  
http://join.msn.com/?pgmarket=en-ca&page=byoa/prem&xAPID=1994&DI=1034&SU=http:/
/hotmail.com/enca&HL=Market_MSNIS_Taglines


=-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- --
Supported by Fig Leaf Software
=-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- --
Be sure to check the archives and the wiki:
http://chattyfig.figleaf.com/
=-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- --
http://chattyfig.figleaf.com/cgi-bin/ezmlm-cgi?1:mss:106893
=-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- --
To unsubscribe send a blank e-mail to:
Normal Mode: flashcoders-unsubscribe@(protected)
Digest Mode: flashcoders-digest-unsubscrive@(protected)