Skip navigation
cconcannon
Currently Being Moderated

How to create a draggable text box with a scroll bar?

Nov 16, 2012 9:46 AM

I am trying to create a dynamic textbox that can be dragged around the screen using AS3.  The problem is that I need a scroll bar on the text box because of the amount of text.  I can build the text box and have attached the scrollbar component and turned it all into a movieclip.  However, when I make the movieclip draggable, he scrollbar becomes inoperable.  If I just make the text box draggable inside the movieclip, then the scroll bar works, but not draggable and I get an error "Error #1069: Property stopDrag not found on flash.text.TextField and there is no default value."

How do I create a draggable text box that has a scroll bar attached?

 
Replies
  • kglad
    72,212 posts
    Jul 21, 2002
    Currently Being Moderated
    Nov 16, 2012 10:03 AM   in reply to cconcannon

    build the text box and attach the scrollbar component and turned it all into a movieclip.

     

    but don't assign mouse listeners to the movieclip.  create a child movieclip that has a dragbar or titlebar or something else that looks draggable (like a windows or mac application window).  assign your mouse listeners to that titlebar.

     
    |
    Mark as:
  • kglad
    72,212 posts
    Jul 21, 2002
    Currently Being Moderated
    Nov 16, 2012 12:23 PM   in reply to cconcannon

    :

     

    Transcript_mc.fontBar.addEventListener(MouseEvent.MOUSE_DOWN,downF);

    Transcript_mc.fontBar.addEventListener(MouseEvent.MOUSE_UP,upF);

     

    function downF(e:MouseEvent):void{

    Transcript_mc.startDrag();

    }

    function upF(e:MouseEvent):void{

    Transcript_mc.stopDrag();

    }

     
    |
    Mark as:
  • kglad
    72,212 posts
    Jul 21, 2002
    Currently Being Moderated
    Nov 16, 2012 2:53 PM   in reply to cconcannon

    correct you want the child to listen for mouse events.  if you assign mouse events to the parent that will prevent the children from detecting mouse events (unless you enable the capture parameter of the listener).

     
    |
    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