Skip navigation

        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.

this.mapClip[event.currentTarget.value].x

        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

this.mapClip.location1.x

        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…

mapClip.content[event.currentTarget.value].x

        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

MovieClip(mapContent.content[event.currentTarget.value].x

        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 😦

Advertisements

3 Comments

    • Dmitriy
    • Posted January 11, 2008 at 1:23 pm
    • Permalink

    I could totally understand your pain, I’ve gone through a lot things like this even in AS2 when I started learning it about 5 years ago. It looks like it’s gonna happen to me all over in AS3. I don’t understand why in the world they would not have clear explanations or examples for AS3, how the hell would anyone learn it? Guessing, trying and finding random things here and there that others figured out? This could be one of the reasons Silverlight might kill Flash in time. Good-luck with all this.

    • Tranda
    • Posted July 11, 2008 at 4:03 pm
    • Permalink

    hi,

    i was trying to load symbol from library into scrollpane and there is no way you can control timeline of that movieclip
    until i found your advice
    casting instance as a Movieclip gives you control of that movieclip timeline

    thnx a lot

  1. No problem, happy to help. This was driving me crazy for ages 🙂


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: