September 19, 2009
Import the correct package for Actionscript 3 functions
Warning: geeky rant follows. If you don’t care about Flash and Actionscript, don’t bother reading. Go and play in the sunlight, or whatever you people do for fun.
Dear Adobe
Your actionscript 2 migration documentation sucks. It’s written for people who already know what to do and so therefore wouldn’t make mistakes in the first place. For the rest of us, it’s kinda hard (and incredibly unintuitive) to follow. Since I’ve had to upgrade an Actionscript 2 project to Actionscript 3, I’ve been drinking your “Actionscript 3 is so much easier to use – fast and powerful too!” koolaid. Page 19 of your Actionscript migration cookbook helpfully shows how to do button clicks in Actionscript 3, which are a little different from Actionscript 2. Here we go:
function onButtonClick(event:MouseEvent):void
{
trace("button was clicked");
}
my_button.addEventListener(MouseEvent.CLICK, onButtonClick);
Easy enough, yes? Listen for a click on the button my_button. When the button is clicked, execute the function onButtonClick which traces out “button was clicked”.
Except it doesn’t work. At all. Luckily your migration guide tells me, on page 9, that I can “Troubleshoot code more easily” with Actionscript 3. Fantastic – I can’t wait for a meaningful error message – let’s take a look.
Running that code in Flash gives the following error:
1046: Type was not found or was not a compile-time constant: MouseEvent
WTF?!?! What kind of error message is that?!
It’s because everything in Actionscript 3 is now done in classes, and we haven’t imported the correct class.
Simple. Load up the built-in Flash help (don’t even think of using the online Adobe help – it’s so slooooow) and search for “MouseEvent”. This renders a page which helpfully tells me that MouseEvent is part of the package flash.events
Therefore, all I need to do is put the following before my above code:
import flash.events.MouseEvent;
A wonderful place to put something like the above line of code would be, well I don’t know, how about page 19 of your Actionscript migration cookbook just above your button documentation?!?! Since that cookbook is written for newbies like me (and thank goodness I know what Object Oriented Programming is – can you imagine someone who doesn’t have a clue about that trying to figure out how to get button clicks working?!) why not include the correct classes to import before all of the sample code?
Otherwise it just makes your users feel stupid. I hate feeling stupid while using Flash – but I do all the time.
Regards
A frustrated Flash user
Comments(1)
Roger Saner is a web platform developer (using 

Percocet dosages….
Canadian prescritions and percocet. Percocet addiction. Percocet. Percocet 93-490 10 mg. Buy percocet online without office visit. How do i get off percocet….