PDA

View Full Version : AS2 naming conventions: suffix or prefix?


PaulSheffield
09-07-2007, 02:15 PM
I'm just setting out learning actionScript. Wanting to do it by the book like a good boy, I recently attended a Macromedia authorised training course where the materials used prefixes to name new objects/instances:
mcMovie
btnButton
txtTextField
and so on.

However, the Flash8 help files suggest using _suffixes:
movie_mc
button_btn
etc...
:confused:
Does it make any difference (I know that code-hinting in Flash8 is triggered by the suffixes)? Is one method more widely used, or more appropriate for AS3?

TIA

CyanBlue
09-07-2007, 02:23 PM
Howdy and Welcome... :)

I use the suffix only because of the code hinting and funny thing is that I don't use that code hinting at all... I just keep type the function instead of selecting it from that...

I think people from other language background mostly go by the prefix because that's abit more widely used method, but I don't think it really matters as long as you are consistent in your code... Just use something that you are most comfortable with and you should be good... ;)

PaulSheffield
09-07-2007, 02:32 PM
Thanks

In that case, I think I'll go with the first method, simply because I learned not to use the _underscore_ writing html and it feels kinda weird using it in AS2! :)

CyanBlue
09-07-2007, 02:45 PM
Whatever you are most comfortable with... ;)

Can you clarify your reason abit though cuz I don't really understand that...

tg
09-07-2007, 06:32 PM
if you want to force the code hints this will work for some of the items. not sure if it works for all of them:

in your code do:

// got to do this next line to get your code hint
// MovieClip mcMyMovie;


then when you type in mcMyMovie. - at the '.' you will get the code hints pop up for the movie clip.

PaulSheffield
09-07-2007, 09:45 PM
Whatever you are most comfortable with... ;)

Can you clarify your reason abit though cuz I don't really understand that...

I've seen underscores discouraged in folder/file names in html from a usability standpoint: a live link is indicated by default in your browser with an underscore, so a link with its own underscore becomes hard to read by eye and looks like it has a gap in it: underscore_underscore.com becomes:

http://www.underscore_underscore.com

It's a small point, but it got me out of using underscores at all in web design.

Hope that made sense:)

PaulSheffield
09-07-2007, 09:47 PM
Thanks tg, that's gonna be useful! I need all the hints I can get. :)

CyanBlue
09-07-2007, 09:57 PM
Well... That is a valid point, but I don't know how that could be really related to the programming in general... We are talking about something that's only visible to the developers not the end users... ;)

Never tried that nor will I try that, but that's good to know, tg... I always have trouble with the that notation... My brain simply does not work with that somehow... :(

PaulSheffield
09-08-2007, 09:07 PM
Well... That is a valid point, but I don't know how that could be really related to the programming in general... We are talking about something that's only visible to the developers not the end users... ;)
(

Agreed. Just explaining why I have a downer on underscores. It's just a key combination that doesn't feel right to me. ;)

Flash Gordon
09-08-2007, 09:46 PM
just my practice:

Anything built in the GUI gets the appropriate suffix. IE moveclip on the stage gets named myClip_mc.

Anything built with code does NOT get a suffix, but data typed.

This lets me very quickly see if I'm referencing a dynamic object or static.

tg
09-10-2007, 04:43 PM
hrm... i think that would confuse me more....
depending on if a movie clip is placed on the stage, or dynamically coded, you could have mcs with _mc and without.... but then thats just me. :)

for me. i pic one way... and always use that way, i have use both in the past mcMovie, movie_mc.... but all my movieclips have the same suffix or prefix.

consistency in your code will definitely make maintenance easier.

you could solve the whole issue by using mcMovie_mc.
muahahahahaha

Flash Gordon
09-10-2007, 11:32 PM
not to mention all private propeties are preceed with an underscore. :p

PaulSheffield
09-11-2007, 09:55 AM
hrm... i think that would confuse me more....
you could solve the whole issue by using mcMovie_mc.
muahahahahaha
:(Just when it was all starting to make sense! :D