Reputation: 5328
I am noticing some strange behaviour with AS2 and using fonts in a textField that is added to the stage using createTextField(). This is for a textField which originally says Year - and user can enter a year, click ok and the year is accepted then the textField reverts back to saying Year. I want this to always be a sans serif font, such as Arial (surely this cant be difficult!)
Here is what I want to achieve -
1) When user clicks on textField, the word "Year" is cleared and flashing cursor indicates that text can be entered. 2) When user clicks ok (and provided year is a four digit number) the textField goes back to saying "Year" (in Arial)
My code -
this.createTextField("uiYear", 99, 0, 0, 65, 20);
uiYear.type = "input";
uiYear.antiAliasType="advanced";
uiYear.restrict = "0-9";
//
var my_fmt:TextFormat = new TextFormat();
my_fmt.font = "Arial";
my_fmt.size = 12;
my_fmt.align = "left";
//
uiYear.embedFonts = true;
uiYear.setTextFormat(my_fmt);
uiYear.text = "Year";
//
uiYear.onSetFocus = function() {
if(uiYear.text == "Year") {
uiYear.text = "";
}
}
//
button_ok.onRelease = function() {
uiYear.text = "Year";
}
Looks ok right?
What i'm noticing is this -
When I click on the textField the word "Year" disappears but the flashing cursor doesnt show and I cant enter text into the textField. If I remove the line -
uiYear.embedFonts = true;
...then it works ok, the word "Year" disappears and I can type number into the textField when I click the textField. So embedding the fonts seems to prevent focus being set on the textField after the onSetFocus function is triggered. However the text i now enter is not Arial, when I click the ok button and the word "Year" is replaced it is in a serif font - like Times or something. I dont want that!
Similarly if I try to embed a font from my library - eg I have a new Font in my library that I export to actionscript with the linkage identifier year_font and change the my_fmt.font=my_font and click Export for actionscript in the linkage dialog. Then when I click the textField, the word Year disappears but the textField cannot be edited.
If I just accept that the onSetFocus is causing the problem and go with keeping the embedded fonts which looks much better I have more probs -
Any ideas?
thanks
Upvotes: 0
Views: 1577
Reputation: 323
I can't answer on your complete request, but I have too experienced the TextField that kills itself when you hit backspace, and does NOT kill itself if you mark text / do stuff differently.
This has to be a bug, since we solved it by changed target player from FP8 to FP9. This was for a banner and naturally we produce them with the lowest common denominator, but this time we gave that up in favor of having something that actually works! :)
Upvotes: 1