Home Tutorials Forums Articles Blogs Movies Library Employment Press

Go Back   ActionScript.org Forums > Flex > Flex 2, 3 & 4

Reply
 
Thread Tools Rate Thread Display Modes
Old 06-11-2008, 06:50 AM   #1
amarghosh
unRegistered User
 
amarghosh's Avatar
 
Join Date: Feb 2008
Location: Bangalore
Posts: 817
Question Flex: accessing internal TextField methods of TextInput/TextArea

i am using a TextInput control in Flex. i want to get the x-y positions of the individual characters in the text field (making a text editor kinda thing with auto complete: i wanna place the drop down list at correct positions);

using the native flash.text.TextField, i can use getCharBoundaries method. But i am now trying to get hands on Flex and i would like to use mx.controls.TextInput/TextArea. Both of these controls don't have any of the native TextField methods [except getLineMetrics]. And the textField property that returns the internal TextField is protected (i can't see why Adobe is so 'protected' about internal text fields in Flex; in fl.controls.TextArea/TextInput, its available as public property; why would they make it protected in Flex?)

The question is, does anyone know of any way to get those x-y values without extending TextInput/TextArea classes?
writing a class [extending one of those] just to write a getter that returns textField instance seems.... i don't know; i feel like there may be an easier way to do it.
__________________
Blog
amarghosh is offline   Reply With Quote
Old 06-13-2008, 12:01 PM   #2
amarghosh
unRegistered User
 
amarghosh's Avatar
 
Join Date: Feb 2008
Location: Bangalore
Posts: 817
Default

okay... i take it as a no. or is there anything i am missing?

Forget about getCharBoundaries, even caretIndex is not available in these classes. You have to extend TextInput class to get its caretIndex? it doesn't make sense to me. What is so dangerous about making a caretIndex public property in TextInput/TextArea?

why would they do that only in Flex? i mean fl.controls counterparts of these classes have a public textField property.
__________________
Blog
amarghosh is offline   Reply With Quote
Old 06-17-2008, 08:52 PM   #3
ryang
Registered User
 
Join Date: Jun 2008
Posts: 7
Default Use the mx_internal namespace to access the internal textField

You don't have to subclass the TextArea/TextInput class if your parent class/mxml makes use of the mx_internal namespace.

You'll notice in the TextArea class that the getTextField() method is scoped to mx_internal. To access this put the following code in your parent class:

import mx.core.mx_internal;
use namespace mx_internal;


now you should be able to access the TextField class in your TextArea via the following code:

(textAreaId.getTextField() as TextField)

Hope that helps, it is helping me!

Ryan
ryang is offline   Reply With Quote
Old 06-18-2008, 04:24 AM   #4
amarghosh
unRegistered User
 
amarghosh's Avatar
 
Join Date: Feb 2008
Location: Bangalore
Posts: 817
Default

that really helps
i ended up extending TextInput, but now i am gonna change it.
i wasn't aware there was a getTextField() method.
mx_internal methods don't show up in the content assist also, making it difficult to find.
thanks a lot
__________________
Blog
amarghosh is offline   Reply With Quote
Old 11-17-2008, 05:47 AM   #5
crunch
Registered User
 
Join Date: Nov 2008
Posts: 1
Default

Really great thing. Thank you both for this hint. It works great.
crunch is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Accessing methods of external classes peter.vullings ActionScript 3.0 5 03-06-2008 05:34 AM
Overriding methods while accessing original methods sneakyimp ActionScript 3.0 2 02-27-2008 06:05 AM
Accessing a Models methods from a Controller DrGoomba Flex 2, 3 & 4 3 04-05-2007 06:17 PM
Accessing methods from onEnterFrame unkulunkulu ActionScript 2.0 3 10-11-2004 09:18 AM
Controlling TextField Events and Methods Sameal ActionScript 1.0 (and below) 1 06-21-2002 06:09 AM


All times are GMT. The time now is 03:17 AM.


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2010 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.