1 Reply Latest reply on Dec 17, 2010 7:03 AM by jomelia

    Clicking animated button goes directly to URL - need to see button animation first.

    ruthgordy Level 1

      I have created a button in Flash CS4 with AS3. It is an invisible button over a test tube illustration. I have created an animation of an empty test tube illustration that fills with liquid when you click on the invisible button. The duration of the movie clip (test tube filling) is 26 frames at 18 frames per second (about 1.5 seconds).

      I have put in action script that sends the viewer to a URL when you click on the (invisible) test tube button and it works as expected.

      My problem is that when I test the button, it goes immediately to the URL without me being able to see the full animation of the test tube filling first.

      My question:

      How can I delay the action of the button linking to the URL to allow the viewer to see the full 26 frames (about 1.5 seconds) of animation and THEN GO TO THE SPECIFIED URL?

      Found lots of stuff about delaying using intervals?? in ActionScript -not making any sense to me. I am a beginner/intermediate in Flash and know very little about AS - i find most of my AS stuff on line on forums etc.

      Would appreciate any help.

       

      Here is my action script 3.0 on the last frame (26) of my animation. teach_btn is the invisible button.

       

      stop();

       

      teach_btn.addEventListener(MouseEvent.CLICK,mouseClick);

      function mouseClick(event:MouseEvent):void

       

        var request = new URLRequest("http://www.webpage.com/")

        navigateToURL(request,"_blank");

      }

       

      Thanks

        • 1. Re: Clicking animated button goes directly to URL - need to see button animation first.
          jomelia

          I'm at about the same level you seem to be at but one thing I've used are TweenEvents. If you have a tween defined you can add a TweenEvent listener that calls a function when the tween is finished. I don't know how your's is laid out but in one of my projects I have a tween that moves an object from one place to another. Once that move is finished I have another function called, like below:

           

          moveTween = new Tween(obj,"x",Strong.easeOut,From,To,15,false);

          moveTween.addEventListener(TweenEvent.MOTION_FINISH, newFunc);

           

          function newFunc(evt:TweenEvent){

               //whatever you want to do here

          }

           

          Hope this helps.

           

          Jack