ActionScript 3.0 :: Format All The Text Using Stylesheets Or Textformat?
Mar 25, 2010I'm not sure if I should format all the text using Stylesheets or Textformat.
View 3 RepliesI'm not sure if I should format all the text using Stylesheets or Textformat.
View 3 RepliesI 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 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 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?
Is there a way to prevent Flash from removing the applied textFormat style whenever a textField.text value is redefined?
View 5 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].....
why I can have multiple css styles when I use an external css file but when I try and create styles in AS I cant seem to get two different stlyes in the same box?
heres my test code...
Code:
this.createTextField("textBox", this.getNextHighestDepth(), 10, 10, 300, 100);
textBox.border = true;
textBox.html = true;
[Code].....
I 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 RepliesI am working on my portfolio website in Flash. I have few text areas where I need to set CSS formatted text. Can someone point me on how to use the style sheets and embed my fonts, so that they show up properly everywhere?
View 2 RepliesI'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].....
I'm trying to figure out htmlText in Flash, and a number of things don't seem to be working:
- The first line of each paragraph is slightly indented. I can't seem to find a setting to remove this.
- There doesn't seem to be any way to control the amount of space before or following a paragraph. Setting "marginBottom" doesn't do anything - and of course it's not defined in the class anyway.
- Can't control how indented <li> elements are, or how much space is before/after them.
Is there any way to get more precise control over formatting of text, using style sheets or some other method?
Flex stylesheets are parsed by the compiler and bundled with their assets (graphics, usually) into a swf file, which can then be loaded at runtime. I've got a project with a fixed number of styles (currently 4: old corporate style, new corporate style, and high contrast versions of both). Using Flash Builder (Eclipse with Flex IDE plugin) I'm able to have all .css files compiled to .swf files alongside the primary project artifact .swf file. This is also possible with ant scripts.
My current understanding is that Maven wants to only create one artifact per project (POM file), but may have some additional ones added (like zip packaging). For scalability reasons - I've got a complex setup of many library and module projects, several of them having their own individual stylesheets - it would be very impractical to split up the projects into the 'main' project and copies for each stylesheet. At least on the Eclipse project side, having some subfolders with POM files in each, all refered by a master pom file and referring the same src/ location (and being inside one Eclipse project) would probably work. Though that's ugly and needs individual artifactIds for each, and still need to be assembled somehow.
The important thing is to be able to have a final assembly which contains the (Eclipse) projects main swf file and each stylesheets swf file (and some static files like localized texts to be loaded at runtime). This will be part of a large assembly of several of those projects which I've described in a separate question.
I'm using Eclipse 3.6.1 (Helios) with Flash Builder Plugin (i.e. Flex4), targetting Flex SDK 3.5 (FlashPlayer 10.0). I've installed Maven 3.0.2, using Sonatypes flexmojos-maven-plugin 3.7.1 (as it seems more active than the one from Servebox). I've manually created pom files for my projects and they work (though only compiling one swf artifact file, depending on whether I specify the main .as or one of the .css files as sourceFile)
I've tried for some days now to understand "The Maven Way" (which seems to be tailored for Java and not fitting perfectly for Flex), but couldn't get this to work so that I have a single project, or at least a single assembly with everything in it.
Trying to format input text fields using format buttons in Actionscript has been challenging. I've been able to put some pieces together, however I am still missing some things. Here's my code:
Code:
function selectText() {
startSelect = Selection.getBeginIndex();[code].........
I need the ability to click the Bold button and it bolds or unbolds at the cursor so if I hit the bold button what I type from that point on will be bold until I hit the button again and then it goes back to regular. I am able to change it to bold or unbold by selecting the text and clicking the button but I also need to do it without selecting.
When applying text formatting to a comboBox, the text formatting appears perfectly on the dropdown menu items but the textField text disappears.Removing the text formatting from the textField makes the textField text reappear but of course there is no text formatting.
Is there a trick to this.
I need application with input text box and a button, user is able to write into the input text box, and when he press button, the written text will save on a text format file on server (like a notepad with .txt extension) and if this file exist before new information will over write!
View 2 RepliesNoob question, I hope. I need to create scrolling text areas with rich text format content. I know I can use the textArea component and set the htmlText property but converting all of my RTF to HTML is gonna be a major pain in the @$$. I keep getting into trouble thinking what's mindlessly easy in Director/Lingo is gonna be reasonably simple in Flash/AS3, I hoping this is just my inexperience with Flash getting in the way. Is there an easier way? I thought of embedding a PDF document but apparently that's not an option in Flash either (note: I know how to link a PDF doc, I need this text to display and scroll within the application, not just pop a new window on top).
View 6 RepliesI have a text field where user can type and few controls to customize the text properties like: font, size, color etc.If a user has typed say "Hello World", the caretindex is next to d of World. I want that if now the user makes some changes to the cusomization properties like: changes font size, then the text appearing next is of the font size set and not that of d. How can I do that?
View 1 RepliesI have one dynamic text field in the instance name my_text. I have set the Embed option in that file. because i need to rotate the text field. Now I need to change the font format of dynamic text field.[code]...
View 1 RepliesI'm reading text from a text file and displaying it into a text field. The problem is when i read it doesn't display the text as it is in a text file. For ex - See below imageNow , as you can see, second line in the text file starts right where first line ends.But flash doesn't display it like that. I have hundreds of lines and in most cases flash spaces consumes less space then a text file. The font in both text field in Flash and notpad is to Arial so the font shouldn't be a problem.
View 8 RepliesI have text that is in a scrollable box using the scroll bar component and I would like to be able to format headlines differently than the main body copy, etc. How do I do this? The text is dynamic, multiple line.Was hoping not to have to use external files.
View 1 RepliesI'm importing text via an XML file that will then be displayed in a dynamic text field. The text is about 1 sentence long but one of the words in the sentence must be bold and a different color. So I've added some HTML tags in the XML node to change the color and format but when I test the file the html tags show in the dynamic text field and the text is NOT formatted.
Here is my code:
I bring in the XML data with this AS3 code:
ActionScript Code:
var _xml:XML;
var _xmlList:XMLList;
var _xmlLoader:URLLoader = new URLLoader();
[Code]....
Am I not using the CDATA tag properly? Or do I need to change something in the way I call up the data in the xml node ?
i have to set the text format for some tokens in a plain text. I'm trying to use the Text Layout Framework to improve the speed of the operation but i've founded that TLF is far slower (10X in my tests) than the old setTextFormat(). For each token i call this function:
public function setTextFormat(format:TextLayoutFormat, begin:int, end:int):void{
var selection:SelectionState = new SelectionState(this._textFlow, begin, end, this._normalFormat);
[code].....
I am presently using the text tool to draw out a text box on stage (classic text, input text - the end user needs to be able to change the text inside the text box). the instance name for the text box will be called borderText. i need to use buttons to change the size of the text, the color of the text and also change the font style. have been playing around with it, but having mixed or no results. i need someone to help me get started.
View 3 Repliesfound that code to display html format text to dynamic textfield in as3:
var url:String = "http://edeejay.dyndns.org:8000/currentsong?sid=1";
var loadit:URLLoader = new URLLoader();
loadit.addEventListener(Event.COMPLETE, completeHandler);
[code].....
I'm using CS4 AS2. Should I just use CDATA tag within the XML is this the easiest way? I have 32 swfs which are each loaded to a holder at different times. Do I use code to format the text? The boxes exist in the swfs already.
View 10 Replies