Skip navigation
Currently Being Moderated

Drag Scrolling Textbox?

Dec 10, 2013 8:17 PM

Tags: #scrolling #drag #textbox #air_for_ios #air_for_android

I am looking for the AS3 code for a textbox that scrolls by dragging similar to that on an iPhone. I DO NOT want a scroll bar. I just want to be able to scroll through the text by dragging it up and down or side to side. I haven't found any complete code for this anywhere online so if someone can give me the complete AS3 code for this, that would be awesome! Thanks!

 
Replies
  • Currently Being Moderated
    Dec 11, 2013 5:33 AM   in reply to xp3tp85

    you can simply turn off the scrollPolicies of a textArea Component:

     

    //with a TextArea Component instance _ta on stage

     

    _ta.verticalScrollPolicy = "off";

    _ta.horizontalScrollPolicy = "off";

     

    this will hide the UIScrollbar and make the dragging you described available by clicking down inside the textarea and moving your mouse accordingly

     
    |
    Mark as:
  • kglad
    72,340 posts
    Jul 21, 2002
    Currently Being Moderated
    Dec 26, 2013 7:01 AM   in reply to xp3tp85

    yes.

     

    right click your textfield>convert to symbol>movieclip.

     

    add a mousedown listener that adds and enterframe loop which calls a function that scrolls your textfield based on mouse position and add a stage mouseup listener to terminate the loop.

     
    |
    Mark as:
  • kglad
    72,340 posts
    Jul 21, 2002
    Currently Being Moderated
    Mar 14, 2014 9:11 PM   in reply to xp3tp85

    var m,b:Number;

    paramF(10,0,tf.height-10,tf.maxScrollV);

     

    tf.addEventListener(MouseEvent.MOUSE_OVER,overF);

    tf.addEventListener(MouseEvent.MOUSE_OUT,outF);

    function overF(e:MouseEvent):void{

        this.addEventListener(Event.ENTER_FRAME,tfF);

    }

    function outF(e:MouseEvent):void{

        this.removeEventListener(Event.ENTER_FRAME,tfF);

    }

    function tfF(e:Event):void{

        tf.scrollV = Math.min(tf.maxScrollV,Math.max(0,Math.round(m*tf.mouseY+b)));

    }

     

    function paramF(x1:Number,y1:Number,x2:Number,y2:Number):void{

        m = (y1-y2)/(x1-x2);

        b = y1-m*x1;

    }

     
    |
    Mark as:
  • kglad
    72,340 posts
    Jul 21, 2002
    Currently Being Moderated
    Mar 15, 2014 6:09 AM   in reply to xp3tp85

    here's code for that but you'll probably need to hire someone to implement it in your project.  i took the code from an ios project i made for a client last year/*

     

     

    code.jpg

     
    |
    Mark as:
  • kglad
    72,340 posts
    Jul 21, 2002
    Currently Being Moderated
    Mar 15, 2014 12:01 PM   in reply to xp3tp85

    no, you have to adapt that to your situation. 

     

    in all cases, you'll need a mask for you movieclip and to use that code there are some paramenters you need to define and a tween class (i used tweenlite) to add.

     
    |
    Mark as:
  • kglad
    72,340 posts
    Jul 21, 2002
    Currently Being Moderated
    Mar 15, 2014 3:12 PM   in reply to xp3tp85

    you're welcome.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points