Flash Foibles

Here's just a few of the things bugging me at the moment. If you're new to ActionScript keep an eye out for these nuggets...

 

Run-time/Compile-time errors (or lack of)

Did you know that you can completely mis-spell a function call and the code will happily compile, and execute too for that matter, without even batting an eye. You can also set MovieClip attributes which don't exist, and Flash is quite happy. One way around this second problem is to declare your variables correctly. E.g:

var myBananas;
myBananas = _root.attachMovieClip("bananas", "myBananas", 1);
myBananas._scale = 110; // error! should be xscale!

 

...does not work, but silently fails, however the following code at least generates a warning:

var myBananas:MovieClip;
myBananas = _root.attachMovieClip("bananas", "myBananas", 1);
myBananas._scale = 110; // error! should be xscale!

 

Case-sensitivity

Generally, I have no problem with case-sensitivity in programming languages. I get along just fine with Java and VB alike, in fact if I were to choose one or the other, case-sensitive would win. If you declare a variable with caps you better use the same name in the code, or you deserve shooting. So why do I have a gripe with ActionScript, which is itself case-sensitive? Well...combine this with the problem above (no compiler warnings) and you have a deadly combination. I was trying to figure out why my text box wasn't working...until I noticed I was setting it with messageTxt.Text and not messageTxt.text. I guess if I had declared the variable properly it would have been OK, but it's the same with function calls.

Dynamically attached buttons can't be removed

This is a good one. There's no need to elaborate too much, but if you attach a button using startButton = _root.attachMovieClip(...) you can't remove it using startButton.removeMovie(). You can use a get-around which is set the x/y co-ordinates off the screen, which is messy. Maybe there's some other way to remove it I don't know about?

 

Buttons with dynamic text aren't buttons anymore!

This took a while to figure out as well. When you change the text in a button from Static to Dynamic, the button can't be clicked anymore. There's probably an easy get-around, not had time to look myself.

 

The 'Export for ActionScript' tick box!

Damn you, Export for ActionScript tick box, you are my mortal enemy! I've lost count of the number of times I forgot to tick the box and spent god-knows how long trying to figure out why I see nothing on the Stage. Why doesn't the compiler tell me that the object needs exporting?

 

MovieClips at the same level cancel each other out

If you were wondering where your MovieClip has gone, and you didn't forget to click Export for ActionScript, check the depths you assigned them. Two at the same depth kills them both! It's perfectly understandable why this is necessary, however without any run-time errors it can be frustrating tracking this little monkey down.

 

hitTest?

What's the deal with hitTest? Either I have misunderstood the
documentation, or it's buggy. In some situations it seems to work OK,
mostly it doesn't. In Flasteroids I had to resort to x/y coordinate
comparision to detect if the ship was hitting the asteroids, because
hitTest just didn't work (it detected the first collision, thereafter it always returned false).

 

 

 

( categories: )