I am writing an application in Flash CS3 and I thought as a way to learn Flex I would also write the application in tandem in Flex Builder 3 Beta. Being that I’m an experienced AS2 coder I thought it would be interesting to really start getting dirty with AS3 in a big way and this seemed the ideal way to do it. What became interesting to me real fast was the differences in coding for both IDE’s that use the same language….yeah I had to think about it as well ☺
I am finding that it’s the little things that are catching me out and giving me headaches that I later feel rather dumb to admit to not knowing, for example consider this line of code below that refers to a nested movieclip on the root in Flash CS3.
Now this is real simple code that is executed when I choose a value from the combobox component, in this case the value is ‘location1’ so the code actually reads
So when I went over to Flex I was delighted that nearly all the code was the same as expected however it took me a long time to figure out how to reference the nested clip (location1) inside mapClip, I knew I was in for some trouble because the swf file that contains mapClip is loaded using the SWFLoader in Flex. But what I did not expect was to spend hours trying to figure out why I could not drill down to the instance of location1. Then after a lot of searching, reading, trying and failing I then realized the problem was stupidly simple yet not in the AS3 for Flex documentation…
Throws an error everytime and the reason….you need to cast it as a MovieClip even if it appears to already be one inside the SWFLoader so
Will work just fine…don’t you hate it when the simple things are the problem and they just don’t tell you these things 😦