Ahmed Nuaman


builder of internets ~ developer of dreams ~ tamer of Dachshunds

How every ActionScript base class should start

Regardless of what you think of Flash (you know who you are) ActionScript 3 is by far the most powerful front end language and it teaches the developer something important: class based development. Let’s be honest here, JavaScript is a huge hack of a language and considering it was one of the first languages I ever wrote, I will always prefer ActionScript 3 (but not necessarily Flash) over JavaScript.

Anyway, if you’re still writing ActionScript 3 then you most certainly have a base class and this base class should always (in my opinion) start like this:

package
{
    import flash.display.Sprite;
    import flash.events.Event;
   
    [SWF( backgroundColor=0xffffff, frameRate=30, height=600, width=800 )]
   
    public class App extends Sprite
    {
        public function App()
        {
            loaderInfo.addEventListener( Event.INIT, handleInit, false, 0, true );
        }
       
        private function handleInit(e:Event):void
        {
            loaderInfo.removeEventListener( Event.INIT, handleInit );
        }
    }
}

I’ve come across a lot of code in my time and a lot of problems stem from badly initialisation of the application before it’s embedded or even ready to have stuff drawn. By listening to the ‘loaderInfoINIT event, you know your app’s ready. That is all.

Where have comments gone?

Good question my old fruity. I'm now sticking any post discussions on Google+. Why? Well simply it's better. WordPress's comment system isn't very elegant and nor are ones like Disqus or Livefyre, so to save hassle I've just shipped them off to a social network, like a real boss.

Search

My social skills

Latest blog posts

  • Loading posts...

Subscribe in a reader

Latest tweets

  • Loading tweets...