在舞台上我有一个文本字段,我的目标是能够在不使用UIScroller的情况下滚动文本字段,我想通过向上或向下拖动鼠标来滚动文本字段。它不起作用......
textfield.addEventListener(MouseEvent.MOUSE_DOWN, fl_MouseClickHandler);
function fl_MouseClickHandler(event:MouseEvent):void
{
textfield.addEventListener(MouseEvent.MOUSE_MOVE, fl_MouseClickHandler3);
}
function fl_MouseClickHandler3(e:MouseEvent):void
{
if(stage.mouseY+1){ //when the cursorY goes down the text goes down too
textfield.scrollV++;
}
if(stage.mouseY-1){ //when the cursorY goes up the text goes up too
textfield.scrollV--;
}
}
答案 0 :(得分:0)
我得到了这段代码,但是您还需要解决其他问题:
试试这段代码:
textfield.addEventListener(MouseEvent.MOUSE_DOWN, fl_MouseClickHandler);
function fl_MouseClickHandler(event:MouseEvent):void
{
textfield.addEventListener(MouseEvent.MOUSE_MOVE, fl_MouseClickHandler3);
}
function fl_MouseClickHandler3(e:MouseEvent):void
{
if( stage.mouseY > e.target.y + e.target.height / 2){ //when the cursorY goes down the text goes down too
textfield.scrollV++;
} else {
textfield.scrollV--;
}
}