Flash Instance Names - spot the error

Say we have a simple flash file with an instance of a symbol on the stage (like a rectangle). The rectangle has an instance name and we want to change or display it's properties via action script.

Here's a screen shot of the stage and the instance properties.

And here's the code in the actions layer:

view plain print about
1var mcRect:MovieClip;

The output of the code is:

view plain print about

HUH? Shouldn't that be the x coordinate of the mcRect instance?

The issue is that there is an error in the instance name. Can you see what it is? Nope didn't think so.

The issue is there's a space at the end of the instance name it's actually "mcRect " not "mcRect" ie "mcRect"!

How would you find this out if someone gave you the file?

This code might give you a clue to what was going on.

view plain print about
1for varr item:String in this) {
2 trace(":"+item+":");    

But you'd still need to some some inkling to what the issue was.

Action script variables names can't contain spaces (esp at the end) so I've no idea why flash would let you type a space into the instance name field.

Hopefully you'll never run into this sort of error.

Comments (Comment Moderation is enabled. Your comment will not appear until approved.)
I'd like to thank Kristine from http://www.flashclassroom.com/ for pointing this out to me.
# Posted By Justin Mclean | 4/17/07 12:41 PM