5 Replies Latest reply on Mar 10, 2010 2:27 PM by atrzebunia

    How to attachMovie in a specific frame?

    atrzebunia

      I have 3 pages of a document converted to symbols (i.e. mc_pg1, mc_pg2, mc_pg3), each residing in its own frame (i.e. "pg1", "pg2", "pg3") inside mc_Pages.  Mc_pg1, mc_pg2, and mc_pg3 are inside a movieclip called mc_Pages.  On click of mc_Pages, I am attaching a blinking icon (mc_Target) to a specific page.  The problem I'm having is when I attach mc_Target to a specific mc in its frame, navigate to another frame, and then return to the initial frame, mc_Target is no longer attached.  Yet, I have not clicked anywhere else other than the buttons that allow me to navigate from one frame to another.  So, my code is:

       

      mc_Pages.onPress = function():Void

      {

           if(varPg1 == true) //this checks to see if I'm on "pg1" frame where mc_pg1 is located

           {

                mc_Pages.mc_pg1.attachMovie("mcTarget", "mc_Target", 1); //attaches mc_Target blinking icon in mc_pg1

                mc_Pages.mc_pg1.mc_Target._x = mc_Pages.mc_pg1._xmouse

                mc_Pages.mc_pg1.mc_Target._y = mc_Pages.mc_pg1._ymouse

           }

           else if(varPg2 == true) //this checks to see if I'm on "pg2" frame where mc_pg2 is located

           {

                mc_Pages.mc_pg2.attachMovie("mcTarget", "mc_Target", 1); //attaches mc_Target blinking icon in mc_pg2

                mc_Pages.mc_pg2.mc_Target._x = mc_Pages.mc_pg2._xmouse

                mc_Pages.mc_pg2.mc_Target._y = mc_Pages.mc_pg2._ymouse

           }

           else if(etc.)

      }

       

      Everything is working as it should, i.e. on press of the mouse button, the mc_Target is attached to the frame/mc within mc_Pages that I'm in (I have a btn_Next and btn_Previous on the same timeline as mc_Pages that navigates to the specific frames inside mc_Pages), except that upon returning to a frame/mc which previously had mc_Target attached, mc_Target is no longer there.

       

      I've been struggling with this for some time and can't seem to find a solution.  Any help is greatly appreciated.  Thank you.

      Artur

        • 1. Re: How to attachMovie in a specific frame?
          kglad Adobe Community Professional & MVP

          if the movieclip which you targeted for the attachment does not exist at any point (like when you change frames), the attachment will be removed (along with the target parent).  the fact that you navigate back to a frame where, you think, the parent still exists is irrelevant.  in fact, the parent exists again, not still exists.

          1 person found this helpful
          • 2. Re: How to attachMovie in a specific frame?
            Ned Murphy Adobe Community Professional & MVP

            I'm not entirely clear on what you have, but if you are moving away from a frame to where something doesn't exist any longer, then that something is no longer where you left it dynamically created.  When you return, that piece had already been lost when you left... the frame can only set up with what exists defining it in the frames.  So you need to have some variable that remains active on the timeline such that when you return to the frame you can check that vartiable to see if you need to attach that mc again.  You want an actions layer that extends as far as you might travel along the timeline that holds variables that you assign a value (true or false) to when you attach the object.  THat way, when you return to that frame, you can test that variable and have it re=attach the object if it is supposed to be attached.

            .

            1 person found this helpful
            • 3. Re: How to attachMovie in a specific frame?
              atrzebunia Level 1

              Thanks for such a quick response.  Another user had a similar response and suggested that I use variables and upon returning to a frame in which mc_Target was initially attached, mc_Target would once again be attached based on a value of a variable.  But, using "if" statements and variable values, how do I attachMovie in the same location (i.e. _xmouse, _ymouse) where I last clicked in the frame to which I'm now returning?  I would have to store the last _xmouse and _ymouse coordinates in a variable and then use that variable as the _x and _y position of mc_Target?  How do I do that?

              • 4. Re: How to attachMovie in a specific frame?
                Ned Murphy Adobe Community Professional & MVP

                The same way you will store a variable that indicates if the object was loaded or not.  So you'll need a few variables for each that you assign values to when you first attach the object, ion e that indicates it was attached (true/false) and two that indicate the _X and _y coordinates of the attached object..

                • 5. Re: How to attachMovie in a specific frame?
                  atrzebunia Level 1

                  I think I got it.  Seems to be working for at least one page so far.  Thank you!