FDT Tip: Shortcut In Writing A Class’s Name

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,

    public class Test 
        public static const APP_NAME:String = "fdt-tip";

        public function Test () 
            // Best practice to include class's 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.


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. 😛

About Flashmech

I have too many things in plans for my own good. But well, that's me. :) I love God, praise Him, and trust that He has the best plans in life for me.
This entry was posted in ActionScript, FDT, Tutorials and tagged . Bookmark the permalink.

Comments are closed.