Home Tutorials Forums Articles Blogs Movies Library Employment Press Buy templates

Go Back   ActionScript.org Forums > General > Best Practices

Reply
 
Thread Tools Rate Thread Display Modes
Old 07-14-2007, 11:37 PM   #1
Flash Gordon
rather be programming
 
Flash Gordon's Avatar
 
Join Date: Feb 2005
Location: City of Angels
Posts: 10,000
Default public static var/const: Name conventions

Hi,

What is the convention for naming public static vars? I know public static conts look like this:
ActionScript Code:
public static const HELLO_WORLD:String = "hello world";

But is the all capital letters because is it static or because it is a constant? So what would be the convention for this:
ActionScript Code:
public static var WIDTH:Number = 300;
where "WIDTH" would actually change? Would it be all upper case or lower case?
__________________
I'm old enough to know better and young enough to do it anyway. -- maskedman
Flash Gordon is offline   Reply With Quote
Old 07-15-2007, 04:54 AM   #2
LOLFlash
Senior Member
 
Join Date: May 2007
Location: Toronto,Canada
Posts: 345
Default Convetion

Good question, as much as a know, you can't declare constant in Flash and they advise to name variables UPPERCASE as reminder: it is variable that you shouldn't change in future.
LOLFlash is offline   Reply With Quote
Old 07-15-2007, 05:20 AM   #3
Flash Gordon
rather be programming
 
Flash Gordon's Avatar
 
Join Date: Feb 2005
Location: City of Angels
Posts: 10,000
Default

AS 3.0 allows contsants just like the first code I posted.

question still out there.......
__________________
I'm old enough to know better and young enough to do it anyway. -- maskedman
Flash Gordon is offline   Reply With Quote
Old 07-15-2007, 08:23 AM   #4
Assertnfailure
as[org].addListener(this)
 
Assertnfailure's Avatar
 
Join Date: Dec 2005
Location: LA, California
Posts: 838
Default

All caps is a convention for constant, not static. Static variables should still follow the same conventions as instance variables.
Assertnfailure is offline   Reply With Quote
Old 07-15-2007, 09:49 AM   #5
Flash Gordon
rather be programming
 
Flash Gordon's Avatar
 
Join Date: Feb 2005
Location: City of Angels
Posts: 10,000
Default

ok....so I take it AS 2.0 use just trying to fake constants.

Thanks
__________________
I'm old enough to know better and young enough to do it anyway. -- maskedman
Flash Gordon is offline   Reply With Quote
Old 07-15-2007, 06:52 PM   #6
Assertnfailure
as[org].addListener(this)
 
Assertnfailure's Avatar
 
Join Date: Dec 2005
Location: LA, California
Posts: 838
Default

Well, in AS 2.0 you'd just caps to differentiate between which values shouldn't be changed.

However I always liked to write my constants in AS 2.0 like this:
ActionScript Code:
public static function get MAX_HEIGHT():Number{ return 500; }
Assertnfailure is offline   Reply With Quote
Old 07-15-2007, 09:32 PM   #7
Flash Gordon
rather be programming
 
Flash Gordon's Avatar
 
Join Date: Feb 2005
Location: City of Angels
Posts: 10,000
Default

yea that makes sense. That's a nice approach for AS 2.0.

Thanks
__________________
I'm old enough to know better and young enough to do it anyway. -- maskedman
Flash Gordon is offline   Reply With Quote
Old 07-16-2007, 01:54 AM   #8
Assertnfailure
as[org].addListener(this)
 
Assertnfailure's Avatar
 
Join Date: Dec 2005
Location: LA, California
Posts: 838
Default

np d0000d
Assertnfailure is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
it creates the dynamic movieclips, problems assigning functions to them Junior84 ActionScript 2.0 7 05-10-2007 02:02 PM
class caching issue possibly? binkyboo ActionScript 2.0 1 01-29-2007 10:47 PM
static properties and methods skjc ActionScript 2.0 7 02-22-2006 04:33 PM
Help with KeyManager class Slowburn ActionScript 2.0 2 01-11-2006 10:39 PM
Getter & setters using AS2.0 Taff ActionScript 2.0 18 05-27-2005 06:45 PM


All times are GMT. The time now is 04:46 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2009 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.