Snippet Template (imports)

  1. package {
  2.     import adobe.utils.*;
  3.     import flash.accessibility.*;
  4.     import flash.display.*;
  5.     import flash.errors.*;
  6.     import*;
  7.     import flash.external.*;
  8.     import flash.filters.*;
  9.     import flash.geom.*;
  10.     import*;
  11.     import*;
  12.     import flash.printing.*;
  13.     import flash.profiler.*;
  14.     import flash.sampler.*;
  15.     import flash.system.*;
  16.     import flash.text.*;
  17.     import flash.ui.*;
  18.     import flash.utils.*;
  19.     import flash.xml.*;
  21.     dynamic public class Snippet extends MovieClip {
  22.         public function Snippet() {
  23.              // paste your snippet here (functions and all)
  24.         }
  25.     }
  26. }

This snippet imports all flash packages and is dynamic... you can copy actionsnippet code into the constructor of this file if you use Flex, FlashDevelop, TextMate etc... I tested it with a bunch of snippets and it seems to work nicely.

When I first teach classes in AS3 this is the template I use:

  1. package{
  2.     import flash.display.*;
  3.     import*;
  5.     public class Main extends Sprite{
  6.         // etc...
  7.     }
  8. }

Display and events cover a lot of ground..... next one I find myself adding is flash.geom, followed by I'd say those are my top 4 most frequently used packages.... I do lots of text layout in the Flash IDE, otherwise flash.text would be in there....

This entry was posted in OOP, dynamic, misc, timeline and tagged , . Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.


  1. Philippe
    Posted February 2, 2009 at 11:11 am | Permalink

    This is silly - FlexBuilder or FlashDevelop will add the imports automatically for as you need them.


  2. Posted February 2, 2009 at 12:09 pm | Permalink

    Thanks for the comment Philippe, but I’m pretty sure your wrong… at least about Flex. Flex is smart enough to add some import statements, but it’s not perfect…. and it only does this as you write them… simply try to copy and paste any of the larger sized posts on this site into a new actionscript flex project and you’ll see that flex won’t add any import statements…

    Flex also wouldn’t and shouldn’t add the dynamic keyword automatically… I only used FlashDevelop when I used to have a PC…. so it’s possible that it is smart enough to read through code copy and pasted into the constructor….

    If there is a way to get Flex to automatically add all required import statements to a chunk of copy and pasted code I’d love to know about it….

  3. Philippe
    Posted February 3, 2009 at 2:02 am | Permalink

    Sorry, please disregard my comment - to try random snippets you still have to go through some manual operations.

  4. Posted February 3, 2009 at 7:57 am | Permalink

    No worries Philippe…

Post a Comment

Your email is never published nor shared. Required fields are marked *