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

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

Explorer ,
May 29, 2023 May 29, 2023

Copy link to clipboard

Copied

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 )
}

Views

104

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

correct answers 1 Correct answer

Community Expert , May 29, 2023 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.

Votes

Translate

Translate
Community Expert ,
May 29, 2023 May 29, 2023

Copy link to clipboard

Copied

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.

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
Explorer ,
Jun 01, 2023 Jun 01, 2023

Copy link to clipboard

Copied

It will take a lot of time to fix my code, but your advice is correct.
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
Community Expert ,
Jun 01, 2023 Jun 01, 2023

Copy link to clipboard

Copied

LATEST

you're welcome.

 

 

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