8 Replies Latest reply on Jun 10, 2007 8:03 AM by kglad

    scroll text when button held down

    rockfiend
      Hi all,

      done quite a bit of looking around, and i am sure this is easy... trying to create a button that will scroll a section of text down (and a button to go up). i want it to scroll continuesly and slowly when the mouse button is held down on the button. i can get it to scroll one line when clicked using this script on the button:

      down_btn.onPress = function() {
      mytext.scroll += 1;
      };

      no luck for when the mouse is then continued to be held down on that button. seen some rediculously complex script that i didnt understand and some simple script that looked like it might work, but just didnt for whatever reason. probably me not implimenting it correctly as I am still just stumbling around when it comes to this stuff. any help much appreciated, and very helpful would be the actual script correctly formatted and with instruction on where to put the script.
      thanks
        • 1. Re: scroll text when button held down
          chrebel Level 1
          down_btn.onPress = function()
          {
          this.onEnterFrame = function()
          {
          mytext.scroll += 1;
          }
          }

          down_btn.onRelease = function()
          {
          delete this.onEnterFrame;
          }
          • 2. Re: scroll text when button held down
            kglad Adobe Community Professional & MVP
            you must create a loop when your button is pressed if you want to repeatedly scroll your textfield:

            • 3. Re: scroll text when button held down
              rockfiend Level 1
              thanks for the ideas, and finally had a chance to look at this.

              so far no luck,

              chrebel, tried your script and it did not do anything. no effect at all. not sure why.

              kglad, your script gives me errors, and i do not know enough about it to know what is wrong. errors are :

              **Error** Scene=Scene 1, layer=actions, frame=159:Line 5: Type mismatch in assignment statement: found Number where Function is required.
              scrollI=setInterval(scrollF,100,1); // use -1 for example to scroll up

              **Error** Scene=Scene 1, layer=actions, frame=159:Line 10: Type mismatch.
              clearInterval(scrollI);

              **Error** Scene=Scene 1, layer=actions, frame=159:Line 19: Type mismatch.
              clearInterval(scrollI);

              **Error** Scene=Scene 1, layer=actions, frame=159:Line 27: Type mismatch.
              clearInterval(scrollI);

              Total ActionScript Errors: 4 Reported Errors: 4

              thanks for any additional ideas
              • 4. Re: scroll text when button held down
                kglad Adobe Community Professional & MVP
                function scrollI(dir){

                should be:

                function scrollF(dir){
                • 5. Re: scroll text when button held down
                  rockfiend Level 1
                  ahah! that has worked! excellent, thank you. had a play with making the "UP" button with little success, however. not sure if i copy all the code a second time and change names of variables, or just add a function for up at the top.... a little more help and we have got it, thanks!
                  • 7. Re: scroll text when button held down
                    rockfiend Level 1
                    kglad,
                    you've nailed it! got it working without a hitch now. had to change the += to a -= in your last post to keep it from going down a line before going up and had to change a <maxscroll to a <=maxscroll so that it didnt get stuck at the bottom and not scroll up. and add in the release part of it for the up button as well so it didnt just scroll up endlessly. somehow i managed to understand it enough to do that, so maybe there is hope for me yet.

                    thanks again, wouldnt have got it without ya. attached is final complete code for anyone else trying to do this. paste in your actions layer or whatever for that part of your movie, make a button and name the instance "down_btn" make another button and name the instance "up_btn" and make your text dynamic and scrollable with instance name "mytext". done! brilliant!
                    • 8. Re: scroll text when button held down
                      kglad Adobe Community Professional & MVP
                      you're welcome.