# AS 2.0 Variable naming hints \[Coding efficiency\]

**URL:** <https://forum.kirupa.com/t/as-2-0-variable-naming-hints-coding-efficiency/39419>\
**Category:** flash\
**Created:** [January 7, 2004, 4:24am UTC](https://forum.kirupa.com/t/as-2-0-variable-naming-hints-coding-efficiency/39419 "2004-01-07T04:24:10Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![thoriphes](https://avatars.discourse-cdn.com/v4/letter/t/9fc348/32.png) [@thoriphes](https://forum.kirupa.com/u/thoriphes)\
**Post date:** [January 7, 2004, 4:24am UTC](https://forum.kirupa.com/t/as-2-0-variable-naming-hints-coding-efficiency/39419/1 "2004-01-07T04:24:10Z")

</div>

This short article is on variable naming in the new Actionscript 2.0 (and 1.0, I guess).

I like to bring some light to a little known fact about naming variables in 1.0:  
You know how some variables will bring up a list of available functions and properties when you type a dot at the end of it?

For example:

```auto
//syntactically wrong, but for the sake of example
my_mc. // will bring up a list of functions available to that variable
// whereas...
myMC. // won't display anything

```

What triggered the list of available functions for the first command was actually the suffix “\_mc”. The variable types in AS x.0 (for both versions 1 and 2) each has its own suffix to enable what is called _ **Automatic Code Hinting** _. If you’re anything like me, I don’t like typing out some of Flash’s really long function names like

```auto
_mc.createEmptyMovieClip(...); //also case-sensitive, no less

```

so this is where suffix-ing your variables comes in handy.

Like I mentioned, each data type (Array, Color, MovieClip, etc) has its own little tag along suffix that will enable the code hinting. They are as follows: (available for both AS 1.0 and 2.0, incomplete)[list][_]Array: \_array  
[_]Button: \_btn  
[_]Color: \_color  
[_]Date: \_date  
[_]MovieClip: \_mc  
[_]Sound: \_sound  
[_]String: \_str  
[_]TextField: \_txt  
[_]TextFormat: \_fmt  
[_]XML: \_xml  
[\*]XMLSocket: \_xmlsocket[/list]As you can see, the suffix for any given type is pretty obvious.  
So how do we apply this? Well, given that list, you can now add those suffixes to your variable names (like my\_array, preload\_sound, etc) and a menu with every available function for that type will appear. So now you can see why, in the code above, my\_mc triggers a menu and myMC does not. Use these suffixes to your advantage, whether for speed or reliability, it is your friend.

Now on to AS 2.0…  
2.0 also offers those suffixes that were listed above as well as some new ones: (AS 2.0 only):[list][_]Camera: \_cam  
[_]ContextMenu: \_cm (my next tutorial will be on this)  
[_]ContextMenuItem: \_cmi  
[_]Error: \_err  
[_]LoadVars: \_lv  
[_]LocalConnection: \_lc  
[_]Microphone: \_mic  
[_]PrintJob: \_pj  
[_]NetConnection: \_nc  
[_]NetStream: \_ns  
[_]SharedObject: \_so  
[_]Video: \_video  
[\*]XMLNode: \_xmlnode[/list]  
Now there is another way to display code hints without the use of suffixes. It is implemented in AS2.0’s new style of variable declaration:

```auto
//Now instead of using _str to display the menu like:
my_str.
//You can have the same menu appear but name the variable whatever you like:
var myString:String;
myString. // pops-up menu with string functions

```

Now if you haven’t seen this syntax for variable declaration, don’t

fear. It’s quite simple, really:

[font=courier new]var _variable\_name_:_ **Data Type** _[/font]

It’s up to you whether you want to use var or not, it doesn’t make a difference. But if you do, a menu of available data types appears when you type that colon used in the syntax (how nice of them :love:\*\*).

Well that’s all I have for now. If you have any questions/corrections to this article, let me know.

Update

> [@lostchild](#):
>
> (on a standard windows installation) look for the file :“c:\program files\Macromedia\Flash MX 2004\en\First Run\ActionsPanel\AsCodeHints.xml”
> 
> in this xml file u can change the suffixes as u like. other stuff can be set with other xml files also. like u can add ur custom methods to appear in actions panel etc…  
> cheers …

–thor
