Text not appearing on textfield - actionscript-3

To appear softkeyboard for android app i written textfield.needsSoftKeyboard = true and onclick on textfield call textfield.requestSoftKeyboard() method. keyboard is appearing..but the problem is text is not appearing on textfield...

It would make sense if you could post the code snippet here for further investigation. Other than that, it might be that your textfield loses focus for some reason so you may get your issue resolved by calling "stage.focus = textfield;". It could also be the case that there is a problem with font embedding or styles (e.g. white text on white background). Make sure the textfield shows text at all by passing a prefilled text to it. There is currently also a bug, where Chinese and Japanese chars cannot be displayed on some Android devices (https://bugbase.adobe.com/index.cfm?event=bug&id=3839647).

Problem is textfield loses focus.Finally I got solution.We have to set Focus for that tlf textfield like this.txtField.textFlow.interactionManager = new EditManager();
txtField.textFlow.interactionManager.selectRange(0, 0);
txtField.textFlow.interactionManager.setFocus();

Related

Actionscript: input text on iOS working differently than in the simulator

I have an input box created in Flash Professional 500px x 500px, set as Classic Text > Input Text > Singleline.
I import this into my Actionscript project and set to
wordWrap = true;
In the simulator this works great.
However on iOS wordwrap does not occur during input. Everything appears on a single line which is in the center of the textbox height, when focus returns to the app the text is then correctly wrapped.
How can I make it work like it does in the simulator.
As a fix I tried using multiline text box.
This does not have the issue above, however it introduces a new issue, on selection of the textbox the cursor appears one line below the top, I have to press backspace to move to the top of the textbox, interestingly the text box has size 0 despite some sort of new line existing. This occurs in the simulator as well as on the device.

TextField input not working

I am working on a class similar to the standard text field. I actually use the default TextField inside it. My only problem is that the textField does not work correctly. If I set it to textField.type = TextFieldType.INPUT, I can delete the text, but I can't enter new text. Also, the cursor is not being displayed. This is my Class (part of it): http://pastebin.com/LsgQjxpa
The skin is like this: http://pastebin.com/yDhEGHLm
I can't figure out what exactly I am doing wrong. I also have to mention that I am compiling for AIR Mobile and testing directly from Flash Builder
One problem appears to be that you have set the selectable property to false. This makes sense when type is TextFieldType.DYNAMIC. However, it's problematic when the type is TextFieldType.INPUT.
When you disable selection of the text, no cursor is displayed. I am able to still edit the text. However, since the cursor is not visible I cannot change it's position and the text gets added in front of any existing text.

How to make part of a text in a dynamic text field link to another frame just like hyperlinking to an html page?

I have a quite long classic text in a dynamic text field, with an UIScrollBar to scroll it. It has many references inside, part to sites in the web, part to other texts that I distributed in different frames of a movieclip with the text field inside. I have no problem linking to external websites from inside the text using the link and target fields in the properties panel. I have no problem using buttons to link to specific frames using functions with the gotoAndStop method. But I can't navigate to specific frames from selected words inside the text. Actually, I can't even navigate to files inside my computer using the link and target fields in the properties panel. Html tags are not being rendered, even with the "Render text as html" button clicked. I can't change the text to static because of the scroll bar. I can't also use invisible buttons behind the words because the scrolling would make them out of place. I don't see how a var could help me, cause it makes the text field show only the selected words. Anchors seem not to help also, since I can't target a file, but only http. Any ideas will be very welcome.
What you want is possible. But it comes with a little drawback thanks to a flash textfield bug. First your textfield text needs to be html text and also selectable. Then look here:
Textfield link event
public function TextField_event_link() {
myMP3 = new Sound();
var text:TextField = new TextField();
text.autoSize = TextFieldAutoSize.LEFT;
text.multiline = true;
text.htmlText = "Hello this is my little site. Click herefor the imprint. And here for the about page. And if you're coming so far, also here for the exit";
list.addEventListener(TextEvent.LINK, linkHandler);
addChild(list);
}
private function linkHandler(linkEvent:TextEvent):void {
switch(linkEvent.text)
{
case "imprint":
//display imprint
break;
case "about":
//display about
break;
case "exit":
//exit
break;
}
}
You can compare the event name in the handler and do your magic. If your text is not selectable this will not work. Dono if Adobe has fixed that issue with the latest player but this bugged me for years!

TextField autoSize+italics cuts of last character

In actionscript 3, my TextField has :
CSS styling
embedded fonts
textAlign : CENTER
autoSize : CENTER
... when italics are used the very right character gets slightly cut off (specially caps).
It basically seems that it fails detecting the right size.
I've had this problem before but just wondered is there a nice workaround (instead of checking textWidth or offsetting text etc.)?
Initialize your textField as you always do, using multiline, autosize, htmlText...
Then do this little trick :
// saving wanted width and height plus 1px to get some space for last char
var savedWidth = myTextField.width + 1;
var savedHeight = myTextField.height + 1;
// removing autoSize, wich is the origin of the problem i think
myTextField.autoSize = "none";
// now manually autoSizing the textField with saved values
myTextField.width = savedWidth;
myTextField.height = savedHeight;
Not that it is much comfort to you, but Flash sometimes has trouble with this seemingly simple task. CSS styling of html TextField was a nice addition but it has caused headaches for text-rendering. In fact I very rarely use CSS for styling text for that reason. I can only imagine that combining bold, italic and normal type faces within the HTML causes Flash to get some of the width calculations wrong which causes autoSize to set the mask a tiny bit short. I hope very much that the new text rendering engine in Flash Player 10 will finally fix these issues (it certainly looks better in theory).
So my solution is never to use HTML with the exception being when I require <a> links in my text ... and there are even some tricky text shifting issues there. In those cases I avoid mixing different font weights and font styles within the same text field. All other cases I use TextFormat directly on TextField.
I suppose if you can't get out of your current architecture (for some reason) you could try adding to the end of your html encoded strings. Or you could manually set the width of the field and not rely on autoSize (as you have mentioned). But if you keep on the CSS/HTML route you may find another new and painful limitation just when you don't want it.
I've had issues with TextField masks behaving differently in the Flash preview, and in the actual browser plugin. Usually, and this is strange to me, it would appear more correctly in the browser. Have you tried running the swf in a browser to see if the problem is actually an annoyance rather than a permanent problem?
I had said this:
My in-ideal approach to solving this is to attach a change event to the TextField which always adds a space after the last character of the field. And then to remember to trim this space off when using the value.
But that didn't take into account that this probably doesn't have a change event and that it's an HTML rendered text field. To add a trailing space in the HTML text field throw in an again, that's not really fixing the problem.

AS3 AutoSize Textfield

in AS3, I'm making this dynamic textfield that is populated from an XML file based on where the user clicks.
The dynamic textfield has a custom scrollbar to it. My problem is that if the text inserted into the textfield is less than the previously displayed text, you can still scroll the dynamic textfield as far as the previous one.
Is there a way to reset the textfield autoSize?
Many thanks,
If you are talking about Flash ( I have very little experience in Flex ) then the textField.autosize property would probably get you in the right direction.
I think this link will tell you exactly what to do.
Are you using any of the standard flex controls? Or, is this flash?
You can set the width of the field to the string length + some space (by binding the width to the string's length/event handling etc). This may be of interest. Of course,
Try this, wrap the xml elements text in
<text><![CDATA[<span class="someClass">Some Text Here</span>]]></text>
If the prior wasn't wrapped in CDATA, flash would have taken the <span class="someClass"> and attempted to drop it down a line and indent it as you would with XML hierarchy; CDATA tells flash to ignore those characters and literally treat them as a string. The result of not using this process is that there are many odd spacings in your textfield.
Also be sure that your TextField is set to Multiline and wordwrap, as well as autoSize such as TextFieldAutoSize.LEFT;