7 Replies Latest reply: Sep 29, 2011 4:09 PM by kglad RSS

    AS2 Clicktag and Rollover questions

    LuisRM Community Member

      I'm creating a banner ad for Yahoo.com and am running into a conflict with the Rollover replay and Clicktag. Both are buttons on separate layers with the ClickTag on top. If the Clicktag button is on, the rollover (replay) button is ignored.

       

      I'm wondering what changes I need to make, but I need to keep the AS2 out of the Clicktag button. Also, if I rollover and out quickly, the animation replays, when it should stop. Thanks for any help. I've attached my .fla CS4 for analyzing.

       

      Yahoo specs of note:

      • Animation can begin again on mouse over, but must stop immediately on mouse off.
      • When building flash creative, please note that the expression box must be checked and the URL should say clickTag.

       

      If you would like to see the CS4 file, which may explain a lot more, please visit this link.

      http://board.flashkit.com/board/showthread.php?p=4291469#post4291469

       

      Thanks again!

       

      Rollover/replay AS2 code

      on (rollOver) {

          this.play(2)

      }

      on (rollOut) {

          this.gotoAndStop(33)

      }

       

      Clicktag

      on (release) {

      getURL(clickTag, "_blank");

      }

        • 1. Re: AS2 Clicktag and Rollover questions
          kglad MVP

          remove all code from objects.  give both objects instance names (eg, clickTag_btn and replay_btn).  you can then use:

           

          clickTag_btn.onRelease=function(){

          getURL(clickTag,"_blank");

          }

          clickTag_btn.onRollOver=function(){

          this._parent.play(2);

          }

          clickTag_btn.onRollOut=function(){

          this._parent.gotoAndStop(33);

          }

          • 2. Re: AS2 Clicktag and Rollover questions
            LuisRM Community Member

            Thanks for the quick response. So here is exactly what I did.

             

            • Removed the codes from both button objects.
            • Renamed both button objects (clickTag_btn and replay_btn).
            • Removed Var loop code from Actions layer frame 1
            • Added following code to Actions layer, frame 1.

             

            clickTag_btn.onRelease=function(){

            getURL(clickTag,"_blank");

            }

             

            replay_btn.onRollOver=function(){

            this._parent.play(2);

            }

             

            replay_btn.onRollOut=function(){

            this._parent.gotoAndStop(33);

            }

             

            I changed the second and third actions to replay_btn, rather than clickTag as you noted. Otherwise it wouldn't call for replay, and why rename it correct? In any case, the file doesn't click through or rotate with this code. The hand appears, when I hover over it, but no frame 1 actions are executed.

             

            Layer 1 - Clickthrough button (no code)

            Layer 2 - Rotate button (no code)

            Layer 3 - Actions (see above for code)

             

            What am I missing that is not allowing both buttons to be recognized by the actionscript? Thanks again!

            • 3. Re: AS2 Clicktag and Rollover questions
              kglad MVP

              both buttons are attached to a timeline.  is that the timeline that you want to play(2) and gotoAndStop(33)?

               

              if yes, use the code i suggested.  if no, explain the relationship between the timeline that contains your code and the one you want to play(2).

              • 4. Re: AS2 Clicktag and Rollover questions
                Cartomatics Community Member

                Hello LuisRM & kglad,

                 

                Any luck yet? I'm having the same problem but I must use the code bellow for the clickTAG. The ad server that I'm dealing with states the code must not be altered for it to work. Would using the solution above affect the outcome by assigning instances to the buttons? Sorry for any unintentional Flash/AS ignorance. Thanks.

                 

                on (release) {

                    if (clickTAG.substr(0,5)=="http:") {

                        getURL (clickTAG, "_blank");

                        }

                }

                • 6. Re: AS2 Clicktag and Rollover questions
                  LuisRM Community Member

                  I had the buttons named as you suggested an "Instance of" Instead of "Instance Name." Once I put the names in the correct area, the code worked great. I tested it out and notice that if you scroll on and off quickly it will play an extra time, but I think that is due to the quick on/off movement and not allowing the code to properly reset. Does that sound correct to you? Thanks again for your great help!

                  • 7. Re: AS2 Clicktag and Rollover questions
                    kglad MVP

                    if the frame rate is low or the rollover is fast (or some combo of the two), the rollover can be missed by the flash player.  if the frame rate is low or the rollout from the button to off-stage is fast (or some combo of the two), the rollout can be missed by the flash player.

                     

                    you can often remedy any practical problems by increasing the frame rate to 24 or 30 fps.  it will still be possible to screw things up with fast movement, but that's not something that you need to worry about.  it's either you testing causing the problem or somebody screwing around with your swf.  anybody that wants to really use your flash app will less chaotic in their mouse movements.