ActionScript 2.0 :: SetTextFormat Not Working In Loop
Dec 21, 2011
I create 30 text fields dynamically on the stage and want to set text format for all text fields. I use 'setTextFormat'. It works fine for single text box. But not working if I give this in loop. See the code below. It creates thirty input text boxes on the stage. But it assigns text format only to the last text box. When code Copied and placed in frame 1. The stage size should be 800 x 600. Execute the program and type in the last text field. I want that to happen for all text boxes.
ActionScript Code:
var xtpos:Number = 10;
var ytpos:Number = 10;
var i,j:Number=0;
var depth:Number = 100
var k:Number=0;
[Code] .....
In the above it traces only the last text field.
I am trying to get setTextFormat working, but I can't seem to get it to work. The textfield appears and has the text I want, however, the font is just not changing.Here is my code:
package { import flash.display.MovieClip;import flash.text.TextField;import flash.text.TextFormat; public class Photograph extends MovieClip {
I'm trying to set only a portion of a string to use a particular text format and it does not seem to be working. I'm calling setTextFormat() after setting the text of the TextField like this:
myTextField.setTextFormat(newFormat, 7);
change the format for the remaining characters after the 6th. The textfield seems to use the default text format for the entire text however.
I have some dynamic text boxes loading text from an array. I initially have the text box aligned "right" but when you put dynamic text it "left" aligns them. Anyway, here is my code:
Code: var format:TextFormat = new TextFormat(); format.align = "right";
i've a text with a very long list of words to highlight and calling setTextFormat() one for each word takes ages. There's some way to speedup this operation ? i've tried with a TextField not instantiate in the DisplayObject's list, to bypass the rendering stage but i've founded that the performance are the sam
I set a textformat and apply it with setTextFormat, this is fine when my movie runs however when I try and change the text (with a mouse over of a button) this formatting disappears and have to set it again after I have changed the value of the text box. Why does it resort back to the original formatting? Is there not a way to set a textfield and keep it set?
function setText(evt:MouseEvent) { clientText.text = "hello2"; clientText.setTextFormat(myFormat); }
I created a text editor in AS3 to administer a site online, but i have a problem when i select a word, put it in bold, save the text and load it, all the text after this word becomes bold too. (to put a word in bold i select that world and use a button that turn this word in bold)Here is my code
Code: var formatGlobal12:TextFormat = new TextFormat ("_serif", 12); txt_references_springbok_fr.setTextFormat (formatGlobal12);
i'm unsuccessfully attempting to assign a textFormat to two different parts of the same string, but the second time it doesn't register and remains the default text format. both styles (regular and bold) of the font are embedded.
I've written some code that uses setTextFormat to apply formatting to textFields. I need to change it now so if a textfield has a particular title it adds to the formatting (capitalizing it). There's several workarounds I could use but ideally I would like to either create an override for the setTextFormat or textFormat classes that checks the name of the textfield and if it's a particular name before applying all the other specified formatting capitalises it. I know how to override a setter such as (width or height) but can't find any info on overriding a specific property.
Is it possible to maintain the style format I've applied to my dynamic textfield when using css?What I'm trying to accomplish: I'm trying to get the url links in my cdata from my xml file ( <a href="">link</a> ) to underline, and if even more so possible, to bold or change font color for that link. And I'd like to avoid just using the <u> tag in the cdata instead.I know you can just use a stylesheet to accomplish that, but I've already set up my script to use the setTextFormat method and when I try to combine the two, it seems that I lose my embedded font.Heres what I have now for my textfield, which is also successfully pulling the style from a xml file.[code]
Is there a way of changing the styles of parts of a text using stylesheets, but without giving each part its own class? (Like you can do with setTextFormat by supplying the start and end character indexes). Or is there just another way of achieving the same result without using setTextFormat because you can't use it on a textfield that has a stylesheet applied to it?
when I parse my input-textfield and setTextFormat, everything works fine, but when I write something between the newly formatted part of the the, suddenly the formatting spreads over the whole texfield.
Is there any way (besides .htmlText="") to get rid of text formatting-tags. (maybe something simpler than a html-parser or so?)
We have a library with a bunch of TextFields inside MovieClips. During runtime, we make an instance of one of these, run getTextFormat on it to get the formatting, then create a bunch of TextFields in code and run setTextFormat on them to give them the same formatting.
I'm trying to do the same thing but with TLFTextFields. I have the following:
var text:TLFTextField = new classFromLib(); text.selectable = true; //required for getTextFormat to work, flash bug textFormat = text.getTextFormat();
[Code]....
If I set textFormat.leading and textFormat.letterSpacing to null before I run setTextFormat, then everything works, but obviously the text fields don't get the leading and letter spacing that the one in the library had.
is there a way i can change the standard setTextFormat() ; function? I found out that after you change the text, the format sets back to default. I want to add a "on text change, settextformat again" bit but im completely lost on how to do this? something to do with prototypes doesnt it?
I have a TLFTextfield, which I've applied a TextFormat to, using a start and end index so it only applies to a range of text.Something similar to this:
var textfield:TLFTextField = new TLFTextField(); textfield.text = "Some Text"; textfield.textColor = 0x0000FF;
I created a text editor in AS3 to administer a site online, but i have a problem when i select a word, put it in bold, save the text and load it, all the text after this word becomes bold too. Here is my code
i am trying to apply setTextFormat function for my dynamic text filed in as 3, but its not taking. look at my code and suggest me where i am going wrong.
I have a project I am working on in Flash CS3 using AS3.I have a drag and drop quiz that contains 8 boxes. 4 of the boxes contain dynamic text boxes with the vocabulary words. 4 of the boxes contain the definitions to the vocab words. The students drag and drop the vocab words onto the definitions. My issue is that hitTestObject is only working on the first box everytime. I have a for loop in my endDrag code that should loop through each object and test against it to see if there is a hit. Can anyone see anything wrong with my loop?
I am having some trouble with some code. buttons are not working. Code: menuLoc = new Array("menu_main", "menu_philosophy", "menu_portfolio", "menu_resume", "menu_contact"); for(i=0; i < menuLoc.length; ++i){ _level0.navMenu.menuLoc[i].onRelease = function() { trace("hit"); }} The array has the instance names of the movieclips which are located in navMenu.
I'm trying to create a "for" loop to load thumbs into existing movie clips using the following code:[code]This should load thumbs 9-17. The trace shows the variable is incrementing but I'm not getting the thumbs to load.
I'm loading a variable from a .txt file into flash (per client request).The variable is as follows &ClientNumberOf=4 so the variable = 4, this works on trace, happy, joy When I try and add the variable to my for loop..[code]I've tried a slew of different options...(for example)var newVariable: Number = ClientNumberOf; Nothing works, again, trace works, but script fails to work when I try and dynamically set the loop?!
I'm very new to Adobe Flash CS5.5. Can you create a common instance EG: "Enemy" and then control it like so: Enemy.x += 1; So that all instances of Enemy will move forward one pixel each frame? Instead of just one enemy? If this is not possible could I set up some sort of array of enemies like you can in C and try something like: int EnemyNo = 1; for(EnemyNo = 1; EnemyNo < 5; EnemyNo++) { Enemy[EnemyNo].x += 1; } Does Flash even support "for" loops?