Preloader to Game Transition with Stop Propagation

This will be a quick post on some gotcha’s to keep an eye out for when loading your ActionScript 3 game swf from a preloader swf. Nothing revolutionary here, back in mid-December, I had posted a blog on ActionScript 3’s Event Handling and the stopPropagation method and just the other day working on the code for a new game project, I ran into a situation where I should’ve used the method, didn’t, and ran into some issues.

Note: If you’re here looking for code on how to write a flash preloader, Lee Brimlow’s video tutorial on Preloading in AS3 gives a beautiful example. When I was originally learning how to code a preloader, that tutorial, and a couple of other tutorials around the net that escape my memory at the moment, were absolutely perfect.

(more…)

Useful Air Apps, Reviews, Links

For those of you who haven’t seen or come across this yet, I thought I’d pass this along.

AS3 Language Reference Air App

I came across that early last month and it has saved me quite a bit of time. If you have AS3 Livedocs as one of your most visited bookmarks, this app brings livedocs to your desktop so you can load it up when you sit down to work on a project and you don’t have to open browsers and wait for pages to load or even be online at all.

(more…)

AS3 Dictionary Class vs. Array vs. Object!

It’s some sort of crazy nerdtastic Data Structure Deathmatch!

The Adobe Actionscript 3 Dictionary Class Vs Object Vs Array!  Man it’s awesome to have a language to work in, just like a great RPG where everyone’s got their strengths and weaknesses and it all works together to make awesome flashlove all over the web.

“What is a Dictionary Class and Why Should I read this post?”

Here’s the results from my testing right up front and I feel like it’s a good rough estimate of where each excells.

(more…)

AS3 TweenMax-imumLove

So I’ve been working pretty hard on what started as a TowerDefense game for a tutorial here.  It has since become more complex, less tutorialtastic, and awesome.  … sort of.  I’m happy with where it’s going. Now that I’ve stroked my ego, let me stroke a few more.

First off I have to say one of the single-most priceless pieces of code ever is TweenMax.  I know I seem to mention them in every blogpost these days.  When I buy programming books, or browse thru Adobe AS3 Live-Docs , I’m reading to solve a problem.  My brains don’t encyclopedia-ize all of the things I come across.  I don’t need to keep them in my memory, that’s why they’re written elsewhere… in APIs and documentation and stuff that I don’t care about.  …Until I need something.

(more…)

Stop Propagating! Pt. 1 AS3, Event Handling, and Lil Timmy

I’ve periodically run into issues playing around with EventListeners where I want to remove one EL, and add another in the same function, something similar to the following code below.  First, a quick note on what’s going on in the code so we’re all on the same page.  I have a movie clip “defensive structure,” say, a tower for a Tower Defense game.  It has been added to the stage and I attached an EL to this movie clip of the tower when I added it to the stage, listening for a MOUSE_DOWN event on said tower.

Since then, I’ve added a few other movie clips INTO the tower Movie Clip.  The first issue I ran into was that normally I’ll use “e.target” as the “hey what did I click” variable to trace out or find out just what exactly was clicked.  e.target was pointing at a child of my tower movieclip, which gave me a number of errors like, “this function does not belong to this movie clip,” because functions belong to classes, and I’m targeting just a simple sprite or movie clip.

However, e.currentTarget returns the containing DisplayObjectContainer of e.target.  Usually e.currentTarget would trace out to be [object Stage], but since I specifically added e.target as a child of my defense movie clip, e.currentTarget is returning the actual object I need, the Defense object.

So, let’s take a look:

(more…)

Fisheye Menu Using AS3 and TweenLite

A friend of mine that enjoys bitching until I help her with whatever popped into her head that moment messages me tonight.  “Hey for my site [that you’ll make for me for free because i’m a girl and your friend] I want a menu system like that one I showed you [which you’re supposed to magically remember out of all the sites you’ve seen on the whole internet in your life].” After she re-sent me the link, a beautiful site called ilovedust I took a look at the slick little fish-eye style menu and said, “Yeah that’s Animation, I do code.  Not pretty stuff like that.”

After 5 minutes of receiving complaining message (but mostly once my game was finished that I was playing at Kongregate, I actually thought about what was happening in that menu, and after about 20 minutes of coding, had a workable menu.  I thought I’d post the code here and make a little tutorial out of it.

I love TweenLite.  And TweenMax.  And pretty much everything at GreenSock.  Once you learn the class, it makes everything so easy.  For those that are here who are AS2 coders… a) Upgrade!  and b) They also have AS2 versions of all of their code.  There are a number of other Tween libraries to choose from. Some perform better than others.  But TweenLite was the first for me that ‘made sense’ in my budding AS3 days, which still continue.

This is a quick little example of making a 5 menu-item menu that does stuff when you mouse-over.  You could probably think of a million ways to optimize this code; putting the menu items in a loop to initialize and things like that.  I’m just going to lay it out, and you can make your own better.

(more…)