10 Replies Latest reply: Aug 13, 2013 10:30 PM by vari25 RSS

    Nested Movieclip problem

    vari25 Community Member

      Hi All,

       

      I have movieclip, inside a movieclip. And Inside that second movieclip I have another mc with buttonmODE enabled.

       

      The target is a mvoieclip and movieclip inside.

       

      If I click in the button then the second movieclip target has to be displayed.

       

      TypeError: Error #1009: Cannot access a property or method of a null object reference.

      at InteractiveHomeDesign_sample3_fla::MainTimeline/frame1()

       

      Please anyone has solution for this?

       

      Thanks in advance.

        • 1. Re: Nested Movieclip problem
          Ned Murphy CommunityMVP

          The 1009 error indicates that one of the objects being targeted by your code is out of scope.  This could mean that the object....

           

          - is declared but not instantiated

          - doesn't have an instance name (or the instance name is mispelled)

          - does not exist in the frame where that code is trying to talk to it

          - is animated into place but is not assigned instance names in every keyframe for it

          - is one of two or more consecutive keyframes of the same objects with no name assigned in the preceding frame(s).

           

          If you go into your Publish Settings Flash section and select the option to Permit debugging, your error message should have a line number following the frame number which will help you isolate which object is involved.

          • 2. Re: Nested Movieclip problem
            vari25 Community Member

            Hi Ned,

             

            Thank You for your help.

             

            But In fact, I have given instance names to all  movieclips.

             

            Even tried giving frame labels to the target movieclips but of no use.

             

            Its not animated instances, only images.

             

            This time it not even giving any error neither does it gives any output.

            • 3. Re: Nested Movieclip problem
              Ned Murphy CommunityMVP

              You have not provided any information beyond saying you have a movieclip in a movieclip, and something about buttonMode being assigned.  If you showed some code and indicated what is not happening that should then you might get some help.

               

              If the inner movieclip is what is supposed to be clicked but you have made it invisible, you cannot click an invisible object.

               

              The 1009 error does not necessarily mean you didn't assign instance names - it means the compiler doesn't see the object your code targets.  Read all the reasons instead of just one.  Frame labels will have nothing to do with instance names.

              • 4. Re: Nested Movieclip problem
                vari25 Community Member

                This is the script assigned in the main timeline.

                 

                import flash.events.MouseEvent;

                 

                garage_mc.garage_heading.garage_myText.text = "Garage Door";
                gutter_mc.gutter_heading.gutter_myText.text = "Gutter";
                contrastbrick_mc.contrastbrick_heading.contrastbrick_myText.text = "Contrast Brick";
                facebrick_mc.facebrick_heading.facebrick_myText.text = "Face Brick";
                roof_mc.roof_heading.roof_myText.text = "Roof";
                windowcolour_mc.windowcolour_heading.windowcolour_myText.text = "Window Color";
                rendercolour_mc.rendercolour_heading.rendercolour_myText.text = "Render Color";
                cladding_mc.cladding_heading.cladding_myText.text = "Cladding";
                trim_mc.trim_heading.trim_myText.text = "Trim";

                 

                garage_mc.garage_horizon_btn.addEventListener(MouseEvent.CLICK, garage)

                function garage(event:MouseEvent):void
                {
                images_all_mc.garage_horizon_mc.gotoAndStop(2);
                }
                garage_mc.garage_moss_btn.addEventListener(MouseEvent.CLICK, garage1)

                function garage1(event:MouseEvent):void
                {
                images_all_mc.garage_moss_mc.gotoAndStop(2);
                }
                garage_mc.garage_ocean_btn.addEventListener(MouseEvent.CLICK, garage2)

                function garage2(event:MouseEvent):void
                {
                images_all_mc.garage_ocean_mc.gotoAndStop(2);
                }

                 

                 

                Although no syntax error. it is showing compiler error:

                 

                TypeError: Error #1009: Cannot access a property or method of a null object reference.

                at InteractiveHomeDesign_sample3_fla::MainTimeline/frame1()[InteractiveHomeDesign_sample3_fl a.MainTimeline::frame1:13]

                 

                 

                Thank u for your help.

                • 5. Re: Nested Movieclip problem
                  Ned Murphy CommunityMVP

                  The error is pointing to line 13.  Whichever line that is is trying to target an object that does not exist as far as the compiler sees it.  You can confirm this by trying to trace the object.

                  • 6. Re: Nested Movieclip problem
                    vari25 Community Member

                    yes. Infact, I have given instance name to the movieclip. but the button enabled mc is in secondframe of the garage_mc.

                     

                    If dat is a problem?

                     

                    Or shud I move the buttons to the main timeline?

                     

                    Thank u.

                    • 7. Re: Nested Movieclip problem
                      Ned Murphy CommunityMVP

                      Reason three that I listed:

                       

                      - does not exist in the frame where that code is trying to talk to it

                       

                      The object has to be present when the frame with the code executes.  If it is somewhere down a timeline, it is not present.

                      • 8. Re: Nested Movieclip problem
                        vari25 Community Member

                        Then shud I move the content whr it can call the function?

                         

                        or is there any other solution like rewriting anthr program etc., ????

                         

                         

                        What is the exact solution for thsi problem?

                         

                        Thank u.

                        • 9. Re: Nested Movieclip problem
                          Ned Murphy CommunityMVP

                          Either move the object to where the code can see it, or move the code to where the object exists.

                          • 10. Re: Nested Movieclip problem
                            vari25 Community Member

                            eitherways its not working also tried with boolean.

                             

                            no solution.

                             

                            Actually, Now that I have moved by target mc to main timeline. and the buttons are inside anthr mc.

                             

                            now shud i add the script to main timline or the button mc??

                             

                            Please help.

                            Thank u.