Skip to main content
Inspiring
May 29, 2023
Answered

The (x,y) coordinates in the text field are out of range of the field.

  • May 29, 2023
  • 2 replies
  • 280 views

I have a text field with many lines.
While checking the (x,y) coordinates of the field, I came across an incomprehensible problem.
The (x,y) coordinates in the text field are out of range of the field.

Why this problems occurred,
Please let me know if You can solve it.
I want to make the field's base point coordinates be (0,0).
Thank you

// sm => list Array
// There are no blanks before each character in the array.

for (var i: uint = 0; i < sm.length; i++) {
    var tx: String = (i < sm.length - 1) ? "\n" : " ";
    musicList.appendText(sm[i] + tx);
}
DisplayObject(musicList);
musicList.addEventListener(MouseEvent.MOUSE_OUT, mouseOutHandler);

function mouseOutHandler(e: MouseEvent): void {
    var topOut: Number = e.localY;
    var leftOut: Number = e.localX;
    var bottomOut: Number = e.localY;

    // textField.height => 373.95
    // The coordinates fluctuate slightly from time to time... For example

    trace("TopOut    : " + topOut); // 7.999603271484375 ( Top > 0 )
    trace("LeftOut   : " + leftOut); // -2.3534393310546875 ( Left < 0 )
    trace("BottomOut : " + bottomOut); // 382.3807067871094 (Bottom > textField.height )
}
    This topic has been closed for replies.
    Correct answer kglad

    localX and localY is a little funky, but your naming isn't helping things.  ie, there is no left, top, bottom.  it's the x and y, only.

     

    anyway, it's more intuitive to use mouseX and mouseY.  if you want those relative to the object, use the object's corner coordinates.

    2 replies

    Inspiring
    June 1, 2023

    It will take a lot of time to fix my code, but your advice is correct.
    Thank you

    kglad
    Community Expert
    Community Expert
    June 1, 2023

    you're welcome.

     

     

    kglad
    Community Expert
    kgladCommunity ExpertCorrect answer
    Community Expert
    May 29, 2023

    localX and localY is a little funky, but your naming isn't helping things.  ie, there is no left, top, bottom.  it's the x and y, only.

     

    anyway, it's more intuitive to use mouseX and mouseY.  if you want those relative to the object, use the object's corner coordinates.