4 Replies Latest reply on Aug 13, 2010 12:49 PM by Ned Murphy

    scroll buttons

    Ron Colmen Level 2

      I'm trying to replce A with B. But I can't figure it out why A is not functioning when I do so.

       

      A (works fine)

      scrollUp_btn.onRelease = function() {

          newszlatest.scroll--;

          scroll_txt.text = newszlatest.scroll+" of "+newszlatest.maxscroll;

      };

      scrollDown_btn.onRelease = function() {

          newszlatest.scroll++;

          scroll_txt.text = newszlatest.scroll+" of "+newszlatest.maxscroll;

      };

       

      B (doesn't work when replaced)

      var dir = 1;

      scrollUp_btn.onPress = function() {

            dir = -1;

            this.onEnterFrame = scrollText;

      }

      scrollDown_btn.onPress = function() {

            dir = 1;

            this.onEnterFrame = scrollText;

      }

      scrollUp_btn.onRelease = scrollDown_btn.onRelease = function(){

            delete this.onEnterFrame;

      }

      function scrollText(){

      newszlatest.scroll += dir;

      scroll_txt.text = newszlatest.scroll+" of "+newszlatest.maxscroll;

      }

       

       

      This code goes just under this (I'm not sure if this is helpful)

      receiveLoad.onData = function(src) {

      }

        • 1. Re: scroll buttons
          kglad Adobe Community Professional & MVP

          you're over-writing the first (A) onRelease methods with the ones that delete this.onEnterFrame.

          1 person found this helpful
          • 2. Re: scroll buttons
            Ned Murphy Adobe Community Professional & MVP

            Here's a link to a working version of the modified help document example.  Maybe you can compare to see how your design differs...

             

            http://www.nedwebs.com/Flash/AS2_Continuous_Scroll.fla

            • 3. Re: scroll buttons
              Ron Colmen Level 2

              Thank you Ned. I can not figure it out....

               

              THis is my full code

               

               

              newszlatest.text="";

              var senderLoad:LoadVars = new LoadVars();

              var receiveLoad:LoadVars = new LoadVars();

              var format1:TextFormat = new TextFormat();

              format1.color = 0xC0C0C0;


              this.createTextField("scroll_txt", this.getNextHighestDepth(), 100, 170, 650, 230);

              this.createTextField("newszlatest", this.getNextHighestDepth(), 100, 170, 650, 230);

              newszlatest.multiline = true;

              newszlatest.wordWrap = true;


              senderLoad.sendAndLoad("http://www.web.com/my.php",receiveLoad,"POST");

              receiveLoad.onData = function(src) {

                   var messageA:Array = src.split(",,,");

                   messageA.pop();

              var charCount = 0;

                   var formatIndices = new Array();

              newszlatest.html=true;

                   for(var i:Number=0; i<messageA.length; i++){

                         var msgA:Array = messageA[i].split(",,");

                         newszlatest.htmlText += msgA[0]+"  | "+msgA[1].split(" ")[0]+"<br>"+msgA[2]+"<br><a href='"+msgA[3]+"'>"+msgA[3]+"<\a><br><br>";

                         formatIndices[i] = {startAt: charCount, endAt: charCount+msgA[0].length};

                         charCount = newszlatest.text.length;

                   }

                   for(var j:Number=0; j<formatIndices.length; j++){

                         newszlatest.setTextFormat(formatIndices[j].startAt, formatIndices[j].endAt, format1);

                   }

              }

               

               

               

              var dir = 1;

              scrollUp_btn.onPress = function() {

                  dir = -1;

              this.onEnterFrame = scrollText;

              };

              scrollDown_btn.onPress = function() {

                  dir = 1;

              this.onEnterFrame = scrollText;

              };

              scrollUp_btn.onRelease = scrollDown_btn.onRelease = function(){

              trace("here");

              delete this.onEnterFrame;

              }

              function scrollText(){

              newszlatest.scroll += dir;

              scroll_txt.text = newszlatest.scroll+" of "+newszlatest.maxscroll;

              }


              • 4. Re: scroll buttons
                Ned Murphy Adobe Community Professional & MVP

                If I substitute a variable in place of loading your data file (and assign it some parse-able values)  and adjust the related code, I can get it working as you have it, so I can't say what might be wrong in your setup...

                 

                var format1:TextFormat = new TextFormat();
                format1.color = 0xC0C0C0;

                 

                this.createTextField("scroll_txt", this.getNextHighestDepth(), 100, 150, 250, 20);
                this.createTextField("newszlatest", this.getNextHighestDepth(), 100, 170, 650, 230);

                 

                newszlatest.multiline = true;
                newszlatest.wordWrap = true;
                newszlatest.text="";

                 

                var src = "some,,stuff,,to start,,to start,,,other,,stuff,,to add,,to start,,,even more,,stuff,,to boot,,to start,,,some,,stuff,,to start,,to start,,,other,,stuff,,to add,,to start,,,even more,,stuff,,to boot,,to start";

                 

                var messageA:Array = src.split(",,,");

                 
                messageA.pop();

                 
                var charCount = 0;
                var formatIndices = new Array();
                newszlatest.html=true;

                 

                for(var i:Number=0; i<messageA.length; i++){
                   var msgA:Array = messageA[i].split(",,");
                   newszlatest.htmlText += msgA[0]+"  | "+msgA[1].split(" ")[0]+"<br>"+msgA[2]+"<br><a href='"+msgA[3]+"'>"+msgA[3]+"<\a><br><br>";
                   formatIndices[i] = {startAt: charCount, endAt: charCount+msgA[0].length};
                   charCount = newszlatest.text.length;
                }

                 

                for(var j:Number=0; j<formatIndices.length; j++){
                   newszlatest.setTextFormat(formatIndices[j].startAt, formatIndices[j].endAt, format1);
                }


                var dir = 1;
                scrollUp_btn.onPress = function() {
                    dir = -1;
                this.onEnterFrame = scrollText;
                };

                scrollDown_btn.onPress = function() {
                    dir = 1;
                this.onEnterFrame = scrollText;
                };

                scrollUp_btn.onRelease = scrollDown_btn.onRelease = function(){
                trace("here");
                delete this.onEnterFrame;
                }

                function scrollText(){
                newszlatest.scroll += dir;
                scroll_txt.text = newszlatest.scroll+" of "+newszlatest.maxscroll;
                }