5 Replies Latest reply on Jan 27, 2011 10:28 AM by Ned Murphy

    Animate hotspot position in Flash

    Andy Bay Level 2

      Hi!

       

      I'm creating sort of a game in Flash, which requires invisible hotspots changing their position in time, relative to the stage. The question is: can I simply keyframe the hotspot position and have it work, or is there something that I should consider?

        • 1. Re: Animate hotspot position in Flash
          Ned Murphy Adobe Community Professional & MVP

          What do you mean when you say "keyframe the hotspot position"?  You can use actionscript to move things around  (allows for more random positioning) or you can build the changes in position into the timeline (no random positioning).

          • 2. Re: Animate hotspot position in Flash
            Andy Bay Level 2

            Sorry not to make myself clear in the beginning. Im pretty new to Flash so I might be asking a stupid question.

             

            What I mean is that if I animate the position of an invisible button with keyframes, will the mouseover events that I need to attach to it still work normally? Or will animating the hotspot position with keyframes require complex actionscript to be written in order for the button functionality to remain?

            • 3. Re: Animate hotspot position in Flash
              Ned Murphy Adobe Community Professional & MVP

              If you create new keyframe instances, you need to add event listener code for each keyframe instance in the frame where the new instance exists.  They can share the same event handler function (put it on a separate layer that extends the length of the timeline).  So...

               

              insisbleBtn.addEventListener(MouseEvent.CLICK, clickFunction)

               

              needs to accompany each new instance, but...

               

              function clickFunction(evt....  ){

                   // do stuff

              }

               

              can be shared as long as it is accessible along the timeline, which you can achieve by placing it in the first frame of an actions layer that extends the full length of the timeline.

              1 person found this helpful
              • 4. Re: Animate hotspot position in Flash
                Andy Bay Level 2

                Thanks for clearing that out!

                 

                So is it correct to summarize: for each new keyframe, I need a separate listener. But the "in between" states (between the different x and y positions of two keyframes) will be handled correctly. In other words flash is checking the keyframed position of the hotspot layer first before determining if a mouseover event should take place?

                • 5. Re: Animate hotspot position in Flash
                  Ned Murphy Adobe Community Professional & MVP

                  I think you are summarizing the idea fine, though I don't have a clue what flash is doing/checking.  If you have an instance with a listener assigned, that listener will stick along the timeline until a new keyframe interupts it.

                  1 person found this helpful