3 Replies Latest reply on Nov 1, 2011 12:34 PM by kglad

    Create two buttons to stop/start an animation (cookies ?)

    Mats16

      Hi,

       

      First I'd like to apologise about by poor english, I'm french so I'll try not to do too much of them.

       

      I'm currently making a little header in flash. I created an animation ( things appearing and such ), and I like the way it is. But I'd like to know if it's possible to create two buttons : "stop animation" and "start animation", allowing people not to see the opening animation even if they reload the page and to skip to the last frame. The thing is it's the header of my forum : so it can be a bit annoying if it loads everytime you click on another page.

       

      I read somewhere it's possible by using the "cookies", and a ... "shared object" ? But it wasn't clear and since I'm fairly new at using flash, I'd like to know if someone could help me about it by explaining with details how I can do it.

       

      Thank you to whoever can help me !

       

      (Ps : I use Flash Cs5 with AS2)

        • 1. Re: Create two buttons to stop/start an animation (cookies ?)
          kglad Adobe Community Professional & MVP

          assign your buttons instance names and use:

           

          var tl:MovieClip=this

          var so:SharedObject=SharedObject.getLocal("banner","/");

          if(so.data.stopVar){

          tl.gotoAndStop(tl._totalframes);

          }

           

          stopBtn.onRelease=function(){

          so.data.stopVar=true;

          tl.gotoAndStop(tl._totalframes);

          }

          startBtn.onRelease=function(){

          so.data.stopVar=false;

          tl.gotoAndPlay(1);

          }

          • 2. Re: Create two buttons to stop/start an animation (cookies ?)
            Mats16 Level 1

            Hi,

             

            Thank you for your quick answer ! I've created my two buttons, named them and put the codes in it but I'm not sure : where do I have to put the

             

            "var tl:MovieClip=this

            var so:SharedObject=SharedObject.getLocal("banner","/");

            if(so.data.stopVar){

            tl.gotoAndStop(tl._totalframes);

            }"

             

            part ? In the first frame ?

            It's what I did, but I have two error messages :

             

            "Scene=scene1, layer="ON", frame=1, line1: Statement must appear within an handler"

            "Scene=scene1, layer="OFF", frame=1, line1: Statement must appear within an handler"

             

            Edit : I changed the code ( by putting on(release) and not ("stopbtn...") ) and now it works ! Thank you very much !

            • 3. Re: Create two buttons to stop/start an animation (cookies ?)
              kglad Adobe Community Professional & MVP

              you're welcome.

               

              but all the code should be attached to the first frame that contains your buttons.  no code should be attached to your buttons.

              1 person found this helpful