3 Replies Latest reply on Jul 16, 2008 1:39 PM by kglad

    Movieclip - Button - Location on stage

    Bill H.


      Fellow Gurus!

      I am using Flash 8.

      I rendered some boxes on the stage. One is for a menu and another is for graphics. The idea is to have a picture pop-up in the graphic box whenever one passes a mouse over a button in the menu (which is in the menu box).

      I have added movie clips to each button’s mouse-over. The movie clips contain a picture (at least for now). Thus when you pass a mouse over the button, a picture pops up. That is the easy part.

      Now, I could simply reposition the movie clip until it appears within the graphic box. My problem is – I have a bunch of buttons and they may or may not be placed in the menu in exact positions. If I were to change a button’s position, the movie clip’s position is relative to the button and not the stage thus it would have to be repositioned as well.

      Therefore, the pop-up pictures within the movie clips which are within the buttons must all pop-up in the graphic box regardless of where I place or reposition the buttons.

      Let’s say I have the graphic box located at x=500 and y = 120.
      Let’s say the button’s name is First_btn.
      Let’s say the movie clip’s name is OneTest_mc.
      And, I can bring it on stage in order to add an instance name of perhaps TestOne.

      Now, I have looked at localToGlobal and globalToLocal. I am not sure which one work for my situation.

      I am assuming that I can add AS2 to the movie clip’s (OneTest_mc) timeline – if that is not where it goes - let me know.

      I have looked at the various scripts on the Internet and all they do is confuse me, namely because they are rotating graphics, etc. In another words, they complicate the examples. What I need is a script to add to each button/movie clip to make them all place the pop-up graphic in the box regardless of where the button is located.

      However, I do not just want a piece of script. I would appreciate some explanation of the code so I can learn from it – not just giving me a fish but teaching me how to fish.

      Thanks in advance,

      Bill
        • 1. Re: Movieclip - Button - Location on stage
          kglad Adobe Community Professional & MVP
          the sum of your button's _x property and the _x property of your graphic relative to your button) is the _x property you want to assign your movieclip if you want it to appear on the same timeline as your button and overlap your graphic (assuming your reg points are comparable). likewise for the _y property.
          • 2. Re: Movieclip - Button - Location on stage
            Bill H. Level 1
            I am not sure if I get this.

            First of all, I am no sure if it is globalToLocal or localToGlobal that I need to use – or maybe you are discussing something else entirely.

            You said: “… the sum of your button's _x property and the _x property of your graphic relative to your button) is the _x property you want to assign your movieclip if you want it to appear on the same timeline as your button and overlap your graphic (assuming your reg points are comparable). likewise for the _y property.”

            I read and reread the above answer. However, I do not have enough of a handle on Action Script to see the logic.

            “I am illuminated with darkness,” as Tennyson might have said. I am assuming that I should figure out how to get the button’s x & y no matter where it is placed – and not by reading them as numbers. I guess I need a hint – how do I capture the button’s x & y coordinates if they are changeable?

            I think this captures the x & y for the button – have I got it right?

            Var point = new Object ();
            point.x = First_btn.x; // First_btn is the name of the button
            point.y = First_btn.y; // First_btn is the name of the button
            OneTest_mc.globalToLocal (point); // OneTest_mc is the name of the movie clip

            If the above script is valid, and it most likely is not since I haven’t a clue what I am doing, then the movie clip would end up located where the button is located on the stage.

            Thanks for your help past and future as well as anyone else’s help.
            • 3. Re: Movieclip - Button - Location on stage
              kglad Adobe Community Professional & MVP
              if First_btn is the instance name of your button (ie, the name in the properties panel clicking on your on-stage button), then: