View Full Version : fl.TextInput and square symbol
Stratboy
December 21st, 2009, 05:08 AM
Hi! I've got a simple TextInput component. I try to write a square (√) inside, but it doesn't let me do it. I search in the docs and googled for it but found nothing.
Can you help me please?
creatify
December 21st, 2009, 02:41 PM
My guess is that the default font (probably a device font, but I'm not used to using the TextInput component), doesn't contain that glyph. You should be able to find a font on your machine that does contain that font, embed that font, then style the component to utilize that font. Hope this helps.
Stratboy
December 21st, 2009, 02:58 PM
Mmm, I thought that too, but not now: I found that if I write something with AS, ex ti_instance.text = '2*√3', it gets written. What it's not possible is that text to be written by a user. Quite strange to me. :(
My guess is that the default font (probably a device font, but I'm not used to using the TextInput component), doesn't contain that glyph. You should be able to find a font on your machine that does contain that font, embed that font, then style the component to utilize that font. Hope this helps.
creatify
December 21st, 2009, 04:00 PM
I just tried a regular text input field, tried device fonts and a number of embedded fonts - I can't produce that glyph either. So, I'm not sure I can help on this one. There are probably hacky was to account for this, but I don't know that I'd recommend them - ok, well one, but hopefully someone with have a better solution. I believe there is a CHANGE event that you can listen for via the TextField - upon change you could read whatever text code was just input - if the square root symbol is producing at least a unique glyph, you could store the square root symbol (possibly) into a variable and upon change replace the user input glyph with:
var sroot:String = "√";
yourTextField.text = yourTextField.text.substr(0, String(yourTextField.text).length-1)+sroot;
but again, that's a tremendous hack and I'm not even sure the change event would work fast enough whilst someone was typing (I only offer because in AS2 I had to do something similar with a corporate font that didn't support the ° degree symbol, so this may give you some other ideas if no one else here posts a solution)
Stratboy
December 22nd, 2009, 01:43 AM
Ok, thank you very much for your interest anyway :)
I just tried a regular text input field, tried device fonts and a number of embedded fonts - I can't produce that glyph either. So, I'm not sure I can help on this one. There are probably hacky was to account for this, but I don't know that I'd recommend them - ok, well one, but hopefully someone with have a better solution. I believe there is a CHANGE event that you can listen for via the TextField - upon change you could read whatever text code was just input - if the square root symbol is producing at least a unique glyph, you could store the square root symbol (possibly) into a variable and upon change replace the user input glyph with:
var sroot:String = "√";
yourTextField.text = yourTextField.text.substr(0, String(yourTextField.text).length-1)+sroot;
but again, that's a tremendous hack and I'm not even sure the change event would work fast enough whilst someone was typing (I only offer because in AS2 I had to do something similar with a corporate font that didn't support the ° degree symbol, so this may give you some other ideas if no one else here posts a solution)
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.