ActionScript 3.0 :: Odd Behavior With HtmlText, StyleSheet, And <a>?
Sep 26, 2008
I have a programmatically-generated text field that looks like this:
Code:
var tf:TextField=new TextField();
tf.styleSheet=styles;
tf.embedFonts=true;
tf.antiAliasType="advanced";
tf.selectable=false;
[Code]...
Has anyone else noticed this odd behavior? It's too distracting and unprofessional-looking to leave the way it is, but I'm not sure what my alternatives are if I want to include links in the text (which is imported from an XML file).
this is in Flash CS3. EDIT: If I don't embed the fonts, the "problem" goes away; however, I'm left with non-embedded fonts.
I'm having this problem of adding an image to the textArea in RichTextEditor (RTE) on the fly and this image seems to "reset" the html properties of the textArea. Better explained:
The user starts writing something in the TextArea (with Verdana in size:12 font settings). When he adds an image to the text area, the cursor right after the image gets very small and the font settings are reset to HUM777B in size:2.
How could I avoid this behavior?
It seems Flex adds additional HTML code before the image tag. If there was any way to avoid this I would be able to add my own settings to the tags.
I am working on a large project that displays a fair amount of text.how to best handle the formatting of the text globally? what is the best way to handle the text formatting on a global level ? Through the TextFormat class, through style sheets, a combination of these two depending on the specific situation ?
Is it a best practice for large projects to use style sheets for all of the texts ? Implying that all texts must be written with tags.Using only style sheets seems like the best approach at this time to me but before going into coding this approach on a large scale in my project,
I don't know how to test this and I think I'm over thinking it, but here is the situation:Let's say I have a styleSheet that is assigned as a public static var of a Class.Then, in various other Classes, I'm dynamically creating TextFields and assigning their styleSheet property to the static styleSheet varI eventually remove those said TextFields from the DisplayObject they're on and delete all references. Even though they've been removed/cleared, are they retained in memory because they still contain reference to the static var styleSheet? i.e. should I be setting textField.styleSheet=null; before removing?
When I add a style to some text it seems to changed the textHeight even though there is not any extra characters in my text. When I do a test before adding the style its 16.9 height then after the style is added it goes to 31.9. why this is happening and if there is a way to stop this from happening.
Code:
label.fld.styleSheet = setCSS(); private function setCSS():StyleSheet { var bold:Object = new Object();
I have a TextField which styleSheet i want to change at runtime.For testing I created a new .FLA put a Textfield on stage, set it to dynamic, named it mytxt and added some AS3:[code]Well nothing changed I still have a default black text when I publish the swf.My goals:
I was wondering if this can be done? I want to format my content that's in an XML file, being loaded to a dynamic text box using AS3? I've been trying to do this and find any information on the this task. When I put everything together the XML file shows up in the dynamic text box without any styles being applied to it. (As if its ignoring it.)
Code: var cssLoader:URLLoader = new URLLoader(); var cssRequest:URLRequest = new URLRequest("content.css");
I have some text fields which have to be displayed with a style I have previously loaded from a CSS document. There are two choices to choose from, but both have some hitch I cannot resolve by myself:
- If I decide to embed a font and use it along with the other CSS properties, I don't know how to associate this font to the text field, because if I do this: myTextField.embedFonts = true, no text is displayed.
- If I decide not to embed fonts, so that I use the CSS font-family property, I've checked that the text is not displayed the same way in different monitors: while in my PC it is displayed smooth and sharp, in another appears kind of jagged. Moreover the animations of non-embedded fonts are not the best option (the text must have an animation which includes a mix of fading and scale).
i have problem in my flash styleSheet. i add this script,
import TextField.StyleSheet; var myStylesheet:TextField.StyleSheet = new TextField.StyleSheet(); myStylesheet.setStyle("a:link",{color:"#990000", fontSize:"12px", textDecoration:"underline"});[code]....
I am trying to attach a styleSheet to a textField. If I have a tag defined in the css file it will not show in the textField. all the other text is there just not the link (a {font-weight: bold;} is the only thing in my css file).
I tried adding a <p> tag to the text and the css - then all my text disappeared.I deleted everything out of the css file (while still attaching it to the textField in flash). and all my text showed including the link, which worked. But it naturally had no style.
I have a text area, content_txt, that I load html with a stylesheet into using this code:
Code: //code for loading CSS and text into swf; function getRotatorStyles() {[code]....
The problem is that content_txt.maxscroll always returns 1, but I know from testing that the actual value is 121. content_txt.htmlText .maxscroll, content_txt.text.maxscroll, content_txt._text.maxscroll, all return undefined. How can I get an accurate value of maxscroll for this text area? I need it to get a custom scroll bar to work correctly.
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?
How can I refresh the textfield to effect stylesheet on it. My problem is, I have to assign a StyleSheet after assigned a htmlText assignment. I mean, if you set a stylesheet after htmlText assignment it is work, but if you assign stylesheet before assignment a html text it is not effect.
HTML Code: import flash.text.TextField; import flash.text.StyleSheet; var myLabel:TextField = new TextField(); var labelText:String="<span class='defStyle'>Hello world.</span>"; var newStyle:StyleSheet = new StyleSheet(); [Code] .....
i have problem in my flash styleSheet. i add this script,
[Code]...
field1.htmlText = "<a href=[URL]>This is a link with a hover state!</a> This is some more text, just to see how it looks."; but its not display(output). what can i do for solve this problem.....
I found this tutorial online to load a external stylesheet to then load some text content in your box. [URL]. I applied it to my site but its not working! My settings are as follows: stylesheet = saved under styles/flashStyles.css text = saved under text/aboutus.txt Dynamic box = named aboutUs_text
Here is my code. The only thing I keep seeing is 'Could not load CSS stylesheet' when I preview my .swf or when I upload it to my server. function getNewsStyles() { aboutUs_text.text = "Getting news..."; // load stylesheet first, then get content (separate function) var flash_css = new TextField.StyleSheet(); flash_css.onLoad = function(success:Boolean) { if (success) { [Code] .....
var styles:String = ".keyword{color: #ff0000;} .comment{color: #00ff00;}"; var myStyleSheet:StyleSheet = new StyleSheet(); myStyleSheet.parseCSS(styles); myTextArea.htmlText = '<span class = "keyword"> red </span> uncolored <span class = "comment"> green text</span>';
Everything is fine till this point, i can edit my text, of course everything is showed in black, and the html-tags are ignored. But when I put this code in myTextArea.styleSheet = myStyleSheet; my text will be colored as i want it to be, but the textArea will become uneditable (no blinking pointer, no reaction on keyboard press).
After each keyboard-press (or if the time between two key-presses is bigger than x milliseconds ) i will re-render the textArea.text and append the <span class = "keyword"> where needed </span> tags and put it into the textArea.htmlText, but can't seem to figure it out how to do it when style is applied.
Instead of doing it this way I want to define all the styles in a style sheet. I then want to define my slider in a .as file (not an mxml file) and apply the stylesheet to it. Something like the following is what I'm after
levelSlider= new VSlider() levelSlider.minimum=0; levelSlider.maximum=1; levelSlider.value=1; levelSlider.y=150 levelSlider.styleName="sliderStyle.css" this.addChild(levelSlider)
I want to customize the images on increment and decrement buttons in spark numericstepper and I trying the following in my css file. But it doesnot work for spark numericstepper.
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..
I'm trying to implement way so that stylesheets can be loaded on demand: Either the default stylesheet is used, which is compiled into the application file, or a remote stylesheet (.swf) is loaded if the default styles should not be used. (each stylesheet has embedded images)
So what I would like to do is: 1) Embed the stylesheet but not load it right away. Instead, store a reference to it inside a variable. (or simply a path string?) 2) Load the requested stylesheet, for example using StyleManager
My way of tackling the problem was like this: 1) Embed the default stylesheet as Code: [Embed(source="assets/themes/default.theme.swf")] _defaultThemeClass:Class; and turn it into a StyleSheet object
2) Have a separate class decide which stylesheet to use and call StyleManager.loadStyleDeclaration(myStyle), where myStyle can either be the remote or local stylesheet. As it seems, the StyleManager cannot load a local stylesheet. So I'm looking for a way to "activate" the style I have embedded.
I've just discovered that using a stylesheet on an input textfield renders it uneditable. Does anyone one know of a work-around? Trying to build a text editor for a backend project, but it seems to have crashed before takeoff.