Flashmech.net

codes, tips, mac, softwares and deals

Flashmech.net

FDT Tip: Shortcut In Writing A Class’s Name

September 19th, 2009 · No Comments · ActionScript, FDT, Tutorials

I have tried my best to make the title as self-explanatory as possible, but pardon me if you still have no idea what I’m referring to. However, more importantly is that this tip saved me a great deal of time, so I would suggest any FDT user to read this. ;)

When you have a constant declared in a class, it is always considered good practice to refer to it with the class name. Meaning,

1
2
3
4
5
6
7
8
9
10
11
12
13
package
{
    public class Test 
    {
        public static const APP_NAME:String = "fdt-tip";
 
        public function Test () 
        {
            // Best practice to include class's name
            trace(Test.APP_NAME);
        }
    }
}

As you can see from the above example, I referred to the constant using the class’s name. In our above example though, there is no issue since we’re only referring to the constant once.

Things start to worsen if the constant is referred to A LOT OF TIMES. Now it gets even worse if we had named our classes based on the display objects’ hierarchy, with class names looking like WrapperPageContentViewGenericSprite. *loL~* What if you actually have several classes with similar class names, e.g. WrapperPageContentViewUniqueSprite, WrapperPageGenericView, WrapperPage? At this point, even code-hinting will take you some time to filter through to the right class.

Solution

Head right on to Preferences > FDT > Editor > Templates and click on the “New…” button.

Here’s what I recommend to enter in the fields:
Name: tt (your own preference)
Context: AS2/AS3
Automatically Insert: Checked
Description: Fills in the current class (your own preference)
Pattern: ${enclosing_type}

FDT Tip Shortcut In Writing A Class's Name

After you are done creating this template, click the “OK” button. Try it out now! Simply type “tt” (or whatever is your shortcut), and press enter: the class’s name will now be automatically inserted for you. No fuss anymore, and no more excuses for not coding with best practices. :P

DeliciousStumbleUponDiggTwitterMixxTechnoratiFacebookNews VineRedditLinkedInEmail

Tags:

No Comments so far ↓

Like gas stations in rural Texas after 10 pm, comments are closed.