Even though commenting is very helpful, and is good coding practice, sometimes you take a variable for granted and think that anyone will be able to tell what that variable is with or without a comment. And that may be true if you practice good naming conventions. When naming variables, instances, functions, methods, and events, it is important to use names that can be easily understood. For instance, if you have a variable that represents the beginning horizontal position of an object on the stage, which of the following would you be more apt to recognize as what it is? var startX = myMovie_mc._x; or var s1 = myMovie_mc._x; Obviously the first variable is named something appropriate to what it is holding, whereas the second variable, even though it is holding the same information, does not give you a clue about what it holds. As its creator, you will remember (at least for a short time) what the variable is, but the next person to look at your code will have no idea what the variable is for. Some rules to follow when naming instances and variables:
Also, when creating instances of objects, there are special suffixes that can be added to the ends of the names to make the code hints pop up. Code hints are used to assist developers when working with objects. When the Actions panel knows what object type you are working with, it can give you a list of all the available methods, properties, and events of that object so that you don't have to remember them all. To see an example of code hints, follow these steps:
If the code hints do not appear, make sure they are turned on by going to the Show Code Hint button in the Actions panel. What controls these code hints? ActionsPanel.xmlThe code hints for objects are controlled in an XML file at C:\Program Files\ Macromedia\Flash 8\en\First Run\ \ActionsPanel\ActionScript_1_2\ ActionsPanel.xml for Windows users and Applications\Macromedia\Flash 8\en\ First Run\ActionsPanel\ActionScript_1_2\ActionsPanel.xml for Mac users. You can view all of the suffixes as well as other hinting tools at the bottom of those files. Or you can use this list to see the available suffixes:
Of course, using suffixes is not the only way to trigger code hints. You can also declare the data type in comments. Triggering Code Hints with CommentsYou do not have to use the suffixes with object names to get code hints to work; you can also declare the object's data type in a commented line. After that, the object's name will pop open the code hints for that object. To declare a data type of an object on a commented line, you first put the two forward slash marks (//), followed by the object class name (i.e., Array, String, Color), then a space followed by the object's instance name, and finally a semicolon to end the line. For example, place this code in the first frame of the main timeline in the Actions panel: //Color myColor; Now whenever myColor is used, it will pop open the code hints for the Color object. There is one final way to trigger the code hints, and we have already used it: strict data typing. Strict Data Typing to Trigger Code HintsYou can trigger code hints by declaring the object's data type in a commented line because you are declaring the object's data type. Strict data typing does the same thing without the commented line. Place this line of code in the first frame of the main timeline in the Actions panel: var myString:String = "test"; Now when you use the myString string, when you place a period after its name in the Actions panel, the code hints for the String object will appear. |