9 Replies Latest reply: Aug 9, 2010 2:07 PM by Ned Murphy RSS

    Complex nested MovieClips

    Shed Simas Community Member

      Hi evereyone.

       

      I'm building an event calendar as part of a website I'm designing, and I need a little help.

       

      The calendar is divided into two sections, "calendar" on the right with the actual calendar displayed, and "calendarContent" on the left, where information about the evnts is supposed to show up. The different frames in "calendarContent" are all labeled. Within "calendar" I have different movieclips for each month, and inside each month I put the buttons that open the event descriptions in "calendarContent."

       

      Now, for some reason it's not working. The function I'm trying is the following:

      MovieClip(root).pages.calendarContent.gotoAndStop("artsundays");

      where "pages" is the name of the parent movieclip that "calendar" and "calendarContent" are both inside, and "artsundays" is the label for the frame in "calendarContent" I want to go to. The function is placed within one of the month movieclips. I get the following error:

      TypeError: Error #1010: A term is undefined and has no properties.

       

      I've also tried usng MovieClip(parent) instead of MovieClip(root).pages (since "pages" is the parent), as well as a few other variations, but the problem remained.

       

      Any help is appreciated! I'm counting on a similar system for other sections of the website as well.

        • 1. Re: Complex nested MovieClips
          Ned Murphy CommunityMVP

          Are you sure that line is the one with the error?  If you go into your Flash Publish Settings and enable the option to Permit Debugging,  the error message should include a line number after the first frame number listed.

          • 2. Re: Complex nested MovieClips
            Shed Simas Community Member

            Hi Ned,

             

            Thank you for replying. Flash actually crashed on me yesterday when I tried using Permit Debugging, and when I got to re-coding that specific section today it worked out just fine. Not sure what the problem was!

            However, I'm still having issues. I'm trying to use the same code on another date on the calendar, and I'm now getting the following error:

            1119: Access of possibly undefined property july17th through a reference with static type flash.display:SimpleButton.
            • 3. Re: Complex nested MovieClips
              Ned Murphy CommunityMVP

              What code do you have that involves something to do with july17th?

              • 4. Re: Complex nested MovieClips
                Shed Simas Community Member

                That's strange. I was sure I'd posted the code! My bad. Here it is:

                 

                july.july17th.addEventListener(MouseEvent.CLICK, showSummerOpenHouse);
                

                 

                That's one of the lines that's giving me trouble. "july" is the name of the MovieClip that contains the month of July, and "july17" is the name of the button that links to the event descriptions for that date. The error message only refers to this line, so I'm assuming there are no problems with the function.

                 

                I went ahead and coded the rest of the calendar, and the months of May, June and July don't work, while April, August and October do (there are no events during the other months, yet). The EventListener code follows the same format on all months, as do the structures of the months.

                 

                Thanks.

                • 5. Re: Complex nested MovieClips
                  Ned Murphy CommunityMVP

                  Check the instance name of the button on the stage.  You just mentioned its name is " july17 " but your code targets " july17th "

                   

                  I'm curious.... do you have 365 manually planted/coded buttons in this calendar?

                  • 6. Re: Complex nested MovieClips
                    Shed Simas Community Member

                    Sorry, I had it named "july17" before, and changed it to "july17th" because "july17" is already the name of the target frame in calendarContent. I wasn't sure whether it would make a difference. The code and instance both say "july17th"; the problem must be somewhere else...

                     

                    I do have all the events manually coded, but it's actually only about 15 events. There's only 2-3 events per month, and only for the months of April to October. I'm fairly new to Flash and didn't know how else to do it.

                    • 7. Re: Complex nested MovieClips
                      Ned Murphy CommunityMVP

                      I can duplicate that error if I create if I take july and turn it into a button symbol.  I suspect that you have somehow done that.

                       

                      If you made july as a button symbol, button symbols are limited to the properties Flash provides for them and you cannot add others and target them with code, such as objects inside with instance names, ...  only MovieClip symbols can have dynamic/targetable content/properties added to them.

                       

                      I won't criticize your design approach... devising a solution that you can understand is good stuff, and with the limited number of events you need to deal with, it isn't a bad choice.  As you learn more Actionscript, you will discover other ways to approach a design that can make for less work and more dynamic functionality.

                      • 8. Re: Complex nested MovieClips
                        Shed Simas Community Member

                        Hi Ned,

                         

                        Unfortunately, the months that are not working were all created as MovieClip symbols, just like the ones that work. I even went into the months and converted the contents into a new symbol and substituted the original; still nothing. Finally, I duplicated one of the working months, substituted the content, and it still gave me the same error.

                         


                        EDIT: So over the weekend I learned how to use event.target functions, and today after trying the solutions above I went through my calendar code and simplified it with those functions. In the process, I also had to change some frame labels and instance names. Just to see if it made a difference, I substituted the faulty functions with the event.target ones, and somehow they are now all working perfectly. Thank you for all your help.

                         

                        Message was edited by: Shed Simas

                        • 9. Re: Complex nested MovieClips
                          Ned Murphy CommunityMVP

                          You're welcome.  Too often, when it comes to Flash, persistence is the key to solving most anything.  It's good that you stuck to your guns and kept up the battle.