ActionScript 3.0 :: TextFormat Lost When Redefining TextField.text?
Mar 3, 2009Is there a way to prevent Flash from removing the applied textFormat style whenever a textField.text value is redefined?
View 5 RepliesIs there a way to prevent Flash from removing the applied textFormat style whenever a textField.text value is redefined?
View 5 RepliesI have a TextField that is formatted with bold and blue. However, when I change TextField.text, the formatting of the textfield resets and I have to setTextFormat again. This is the code I use to set my TextField. myText is the variable for my TextField. (This is just part of my code; it is part of a function for my EventListener.)
View 3 Repliesthe example of my problem is:
I have 2 textFiled there are:
1. myTextFied ( to store the original text )
2. displayText ( to show some line of original text )
I try this:
myTextField.htmlText = '<B>THIS IS A TEXT LINE 1</B>
' +
'<I>THIS IS A TEXT LINE 2</I>
' +
[Code]....
I have a problem where i want to remove the last character from a textfield (including linebreaks) that has multiple textformats without removing the formats.[code]...
i guess this doesn't remove linebreaks, and is very slow, seems to destroy my textformats.
or:
textfield.text = textfield.text.slice(0,-1);
this is faster but removes all textformats as well.
I'm trying to put some leading on a body of text, however it doesn't seem to work after a stylesheet has been applied. Without the stylesheet it works..
Here's what im doing:
ActionScript Code:
//CSS
cssStyle = function(my_txt){
[code]...
I'm trying to apply a format (specifically, green-colored text) to specific words in a TextField. I tried the below method, checking for words in an array "commands", and it works fine apart from a few issues below (see pic).
ActionScript Code:
var commands:Array = ["green", "no"] // etc.
function formatGreen(msg:TextField):void {
for (var i in commands) {
[Code].....
I have a set of 5 TextFields that a user enters info into. Each has the same TextFormat applied. If the focus is set by clicking with the mouse, the TextFormat is applied and all is well. If the focus is set by tabbing, the TextFormat is not applied and a default style for the font is seen. Here's my code:
Code:
var input1:TextField = new TextField();
addChild(input1)[code]...................
here is the code:
// Create new textFormat object-----
var myTF:TextFormat = new TextFormat();
myTF.font = "Verdana";
[Code].....
how do I address only the texField named t3 ?
I have very little experience with text in flash. In a dynamic text field I know I can apply a TextFormat to the entire field but can I apply different fromatting to individual workd in the field if for example I wanted to make a word or a few words of text a hyperlink within a textfield. Can I do that or would I need to use html text?
View 3 RepliesProject: Simple Click Counter of two separate buttons.
Problem: Font size of clicks needs to be changed/increased.
link to .fla
Not sure where to place this code in the script below.(inserting it causes font to initially to be correct size of 20 but changes back to default when a mouse click is issued)[code]...
throught code i am trying to read GUI display objects. (don't ask why) My problem is that i can read individual properties of TextField object and TextFormat object, but not traverse those objects to gather all its contents at once.
See my code, individual traces are hapening ok, but those in for cicles are not, i don't get it.
Code:
if (_target.getChildAt(i) is TextField)
{
var currentTextField:TextField = _target.getChildAt(i) as TextField;
trace(currentTextField.embedFonts); //true
[Code]....
How can I apply a TextFormat to a TextField instance in a super class?
Code:
// This doesn't seem to work:
var textFormat:TextFormat = new TextFormat();
textFormat.size = 24;
super.alertText.setTextFormat(textFormat);
I have a movie that has four different input text fields, all in separate movieClips. Inside each movie clip I have code that listens for the 'Enter' key to be pressed, and if it is, it stores the value and turns the focus off of that textField...which works great.
[cODE]...
I have a method/function inside my class called "doSomething()". This function gets called once a frame.
I am trying to figure out if it's possible to redefine that function on the fly with code.
For example, For the first 100 frames of my move I want "doSomething()" to look something like this :
Code:
public function doSelected():void {
trace("hello");
}
and then after 100 frames has passed I'd like "doSomething()" to be redefine to look like this :
Code:
public function doSelected():void {
trace("bye");
}
I have a textfield that is dynamicly created which contains some text and has a textformat applied to it, which works fine, and I have my happy little text field.
the problem comes when I try to change the text and textformat after an event. I am doing it as so:
Code:
targ.getChildAt(2).setTextFormat(WoodTxtFmt.contentTitleSel)
targ.getChildAt(2).text = "back"
then the text becomes invisible. I know it is changed because once I rollover the container movieclip, the text appears.
I tried to dispatch a rollover event after I change the text, but no dice.
Forgive me if this is an obvious one but it has me a bit confused. I have the following sample:
Code:
import flash.display.Sprite;
import flash.text.TextField;
[code].....
I am trying to edit a flash file that was done in MX. I only have CS5. When i open the file, save and export there is a slight problem. Once published and uploaded, a dynamic text box which is meant to load text from the CMS appears blank. Is there something which can be lost in translation when saving from MX to CS5?
View 1 RepliesI want the font size of a dynamic text box to change according to the number of characters of the input text. The user types in whatever (up to 50 characters long), then hits an update button to see it in the dynamic text box. But since the dynamic text can only be a single line within a defined area with no horizontal scrolling.
Here's the code I'm having a problem with:
Code:
updateBtn.addEventListener(MouseEvent.CLICK, updateIt);
inputText.maxChars = 50;
function updateIt(event:MouseEvent):void{
[Code]......
I want the font size of a dynamic text box to change according to the number of characters of the input text. The user types in whatever (up to 50 characters long), then hits an update button to see it in the dynamic text box. But since the dynamic text can only be a single line within a defined area with no horizontal scrolling.
Here's the code I'm having a problem with:
ActionScript Code:
updateBtn.addEventListener(MouseEvent.CLICK, updateIt);
inputText.maxChars = 50;
function updateIt(event:MouseEvent):void{
[Code].....
This is not styling my text. What am I doing wrong?
this.textScroll.createTextField("my_txt", this.getNextHighestDepth(), 0, 0, 255, 200);
textScroll.my_txt.multiline = true;
textScroll.my_txt.html = true;
[code].....
I want to create a draft program for fantasy league football that will be viewed on an external monitor by all of the participants.The program will have all of the "draftable" players.I want to be able to click on the player (or drag) and have that player show up in the participants picked box while deleting (or changing the properties) of the player.
Questions: 1. Should I use variables and arrays for all of the draftable players to accomplish this or would it be easier to just use combo boxes? Mind you that there are about 250 draftable players.
2.Should I have a seperate mc for all of the draftable positions and all of the participants.
3.
Code:
quarterbacks = newArray
line[0] = "1. Donovan Mcnabb";
line[1] = "2. Rich Gannon";
How do I get a hard return in the above sample?
4.How do I dynamically put the picks in the participants draft box?
I am basically creating a new text field for every number, i though 10. And I want to apply Text format to each and every text field so that I can tell it which font I want to use and yada yada.
[Code]...
I am trying to create a TextField, set its type property to "input," set its format via the TextFormat object, and allow the user to add a label to a movieclip.
Assume you have a button named b_add, and you assign it this code on the main timeline:
Code:
_root.b_add.onRelease = function () {_root.createTextField("myLabel", 10, -38, -15, 76, 29.7);
_root.myLabel.type = "input";
_root.myLabel.text = "insert label";
_root.myLabel.wordWrap = true;
[Code]...
The TextField that gets created loses all of its formatting once the user starts typing. It reverts to Time New Roman and doesn't wrap. Do I have something out of order? Should I approach the problem with another solution?
I'm not sure if I should format all the text using Stylesheets or Textformat.
View 3 RepliesWhat does work : I want to put a dynamic textfield on my stage.Then i change the content of this field with AS3.But : when I rate the textfield on my stage, the text disappears.And I have embedded my font (also 'Export for actionscript')...I prefer not to put any textfields on the stage using ASSo the only code I use is : ActionScript Code:this.trial.text = "this is a test";
View 2 RepliesBasically what I have is a dynamic text field that gets text into it from an external file using loadVars(). I have got every single HTML tag to work, except for the one I really need, which is the tabstops attribute of the <textformat> tag.The content I have is like so:
Code:
<textformat tabstops='[50,100]'>Damn stupid tabstops doesn't work.</textformat>
Which displays as:
[code].....
I am making a simple contact form in as3, but I am having problems formating it. As soon as I use a FocusEvent, as below, it completely ignores the formating which I set?
[AS]private function onFocus(evt:FocusEvent):void
{
if(evt.target.text == "Enter here.") {
[code].....
In the Flash IDE, I have made a dynamic text field bold. When the Flash is compiled and run, the bold styling disappears. How do I retain the bold styling?
Top: IDE
Bottom: SWF
I've been struggling with this problem for a while:I have a string containing HTML and I'm using a regular expression to get the characters between the tags. I'm then attempting to apply a TextFormat to those characters.The problem is that I'm using the TextField's "htmlText" property instead of it's "text" property (because I don't want the HTML tags to be visible). So, the character index that's returned from the regular expression is incorrect, when I apply the TextFormat.Here is some sample code which illustrates the problem:
var txt:String = "<b>Sample</b> string with bold text";
var tf:TextField = new TextField();
addChild(tf);
[code].....
how can i make a movieclip and a textfield to resize to the content of the text in the textfield? I mean, if I have a textfield with 3 letters font name XXX and then the content of the field change, how can i resize te textfield so the text dont autoadjust to the 3 letter space?
View 3 Replies