• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

AS3, text auto-scrolling problem when textfield "MOUSE_OVER"

Explorer ,
May 18, 2023 May 18, 2023

Copy link to clipboard

Copied

Sorry if this is a duplicate question.
No matter how much I try, I can't find a solution, so I'm asking for help.
When "index == -1" at the first execution, the textlist automatically scrolls to the bottom,
When I move the scroll bar (UIScrollBar) and then move the mouse pointer into the textfield, the textlist is not fixed and jumps to the wrong place.

Is there a way to completely freeze the textlist on "MOUSE_OVER" without using "scrollV"?

Thanks in advance.

// tf => textField

lineHighlight(tf);

function lineHighlight(tf):void {
	tf.addEventListener(MouseEvent.MOUSE_OVER, mouseOverHandler);
	tf.addEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler);
}

function mouseOverHandler(e:MouseEvent):void {
	stage.focus = e.currentTarget as InteractiveObject;
}

var fsCount:Number = 0;
function mouseMoveHandler(e:MouseEvent):void {
	++fsCount;
	var index:int = e.currentTarget.getLineIndexAtPoint(e.localX, e.localY);
	
	var sPos:Number = e.currentTarget.scrollV; 
	if ((index == -1) || (index >= e.currentTarget.bottomScrollV)) {
		if (fsCount < 30) {
			e.currentTarget.scrollV = e.currentTarget.getCharBoundaries(0);
			//Prevent moving to the bottom if "index == -1" at first run
		} else {
			e.currentTarget.scrollV = sPos;
		}
		return ; 
	}
}

Views

101

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
May 24, 2023 May 24, 2023

Copy link to clipboard

Copied

LATEST

It's resolved. thank you

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines