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

X, Y position of character based on index

Explorer ,
Feb 24, 2012 Feb 24, 2012

Copy link to clipboard

Copied

Hey everyone,

Does anyone know how to get the X and Y coordinates of a character in a string based on index?  I find it odd that I can get the exact letter and index by clicking a character in a text field, but I haven't found anything in code that can get those coordinates without a user click.  Seems like they would have to know the x,y of the individual indexs to be able to tell you what letter you're clicking based on your own mouse coordinates.

TOPICS
ActionScript

Views

2.0K

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 ,
Feb 24, 2012 Feb 24, 2012

Copy link to clipboard

Copied

if you're using a tlftextfield, you can use the getCharAtPoint() method.

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 ,
Feb 24, 2012 Feb 24, 2012

Copy link to clipboard

Copied

That's what I've been using to get characters and indexes.  I'm trying to get the x and y location of a character by simply feeding it the index of the string.

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 ,
Feb 24, 2012 Feb 24, 2012

Copy link to clipboard

Copied

iterate through your textfield indices using that method to find the corresponding x,y

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
New Here ,
Dec 10, 2013 Dec 10, 2013

Copy link to clipboard

Copied

Just try this...

Once you get proper character's index, use the following code,

myTxtFld.getCharBoundaries(index); // this will return a rectangle.

myTxtFld.getCharBoundaries(index).x; // ===========> will provide x coordinate and

myTxtFld.getCharBoundaries(index).y; // ===========> will provide y coordinate.

Good luck !!

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
New Here ,
Nov 15, 2016 Nov 15, 2016

Copy link to clipboard

Copied

LATEST

Does anyone have any ideas how this can be done with createjs?

Need to overlay specific strings within a textfield.

Cheers.

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