Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    Flash




Dynamic External Stylesheet Fun



Hello-

I'm relatively new to Flex and AS3. Well, in fact, completely new. I'm a .NET programmer, and I've been thrust into the world through a project I'm working on.

I've got a bit of a handle on how to get around, but I'm stuck on one thing- getting dynamic themes to work, depending on the ASP.NET theme I'm on. I can pass the theme name through a parameter, and have that all working; I'm at the point where I can get the Flex app to read the right CSS file through URLLoader. Where it gets stuck, I think, is in applying the CSS.

What I need this to be able to do is change the background color of two elements. I tried putting the same css classes that are in the 'default' style that always gets loaded, and overwriting that in the onload by loading the CSS, but apparently I'm missing a step somewhere. I tried adding in a parseCSS, and still nothing. I'll paste in my code, and perhaps someone can point me in the right direction?

Thanks,
Jack


Code:
private function initApp():void {
if(Application.application.parameters.Theme != undefined) {
CSSFormat();
}
}

public function CSSFormat():void
{
var css_url:String = "App_Themes/" + Application.application.parameters.Theme + "/" + Application.application.parameters.Theme + ".css";
var req:URLRequest = new URLRequest(css_url);

loader = new URLLoader();
loader.addEventListener(Event.COMPLETE, onCSSFileLoaded);
loader.load(req);
}


public function onCSSFileLoaded(event:Event):void
{
var sheet:StyleSheet = new StyleSheet();
sheet.parseCSS(loader.data);

}
I then, in another file, have the actual canvases. The first is the parent element, with a class that I need to change (and since it's a parent, no ID. Not sure how to access it.) The second is another mx:canvas inside of there.



ActionScript.org Forums > ActionScript Forums Group > ActionScript 3.0
Posted on: 03-21-2008, 04:48 PM


View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread

External Stylesheet Css
Hi All,

I am loading text that I will update regularly from a .txt file into my .swf, however, it doesnt seem to be applying the stylesheet.

I'm using this code to get it working

var style_sheet = new TextField.StyleSheet();
var css_url = "../css/styles.css";
style_sheet.load(css_url);
learnText.StyleSheet = style_sheet;

But it's not applying all of it... I have heard on the grapevine that there are some problems with flash and css, so can anyone tell me how I fix it?

External Stylesheet Loading
Hi all,
My 1st post on this board, so please be gentle with me

I've searched other threads for my problem, but none of the solutions offered seemed to work. My Actionscript creates an array from a parsed XML document. One of the XML nodes is HTML in CDATA that I want to output in a text field and style using an external CSS stylesheet. Trouble is that I can't get it to work - I get the 'stylesheet not loaded' message in my textfield.
Code is:

Code:
var flashStyles = new TextField.StyleSheet();
var cssURL = "flashStyles.css";

flashStyles.load(cssURL);
flashStyles.onLoad = function(success)
{
if(success)
{
Nav.info.description_txt.html = true;
Nav.info.description_txt.styleSheet = flashStyles;
Nav.info.description_txt.htmlText = description[currImage];
}
else {
Nav.info.description_txt.htmlText = "Stylesheet not loaded";
}
}
Any help would be appreciated.

Loading An External CSS Stylesheet
I am new to Flash and trying to get an external CSS stylesheet to work correctly. I loaded the following sample code from the Adobe help files but the html text does not format correctly? If I add a StyleSheet object , then it will format just fine. The external CSS file is in the same directory as the SWF file and I'm not getting any error messages. Using IE7 and Flash Player 9.0.115....Any help would be much appreciated.







Attach Code

@charset "utf-8";
/* CSS Document */

p {
font-family: Times New Roman, Times, _serif;
font-size: 14;
}

h1 {
font-family: Arial, Helvetica, _sans;
font-size: 20;
font-weight: bold;
}

.bluetext {
color: #0000CC;
}


package
{
import flash.display.Sprite;
import flash.events.Event;
import flash.net.URLLoader;
import flash.net.URLRequest;
import flash.text.StyleSheet;
import flash.text.TextField;
import flash.text.TextFieldAutoSize;

public class ExternalCSS extends Sprite
{
var loader:URLLoader;
var field:TextField;
var exampleText:String = "<h1>This is a headline</h1>" +
"<p>This is a line of text. <span class='bluetext'>" +
"This line of text is colored blue.</span></p>";

public function ExternalCSS():void
{
field = new TextField();
field.width = 300;
field.autoSize = TextFieldAutoSize.LEFT;
field.wordWrap = true;
addChild(field);

var req:URLRequest = new URLRequest("example.css");

loader = new URLLoader();
loader.addEventListener(Event.COMPLETE, onCSSFileLoaded);
loader.load(req);
}

public function onCSSFileLoaded(event:Event):void
{
var sheet:StyleSheet = new StyleSheet();
sheet.parseCSS(loader.data);
field.styleSheet = sheet;
field.htmlText = exampleText;
}
}
}

Textfield, CSS Stylesheet External Loading
Hi Everyone,

I got this tutorial from the Macromedia FLASH 8 Advanced book at a local library. It has helped me through some stuff. The example of loading external CSS stylesheet into a textfield works lovely, but they don't have an example of loading an external css and external text file into a dynamic text field. I have read numerous tutorials from macromedia's site and a quite a few others from users posting in forums. I seem to still not understand it.

With this actionscript code to load an external css stylesheet. How can I make it so it also loads the external text file dpmoreinfo.txt into the dynamic text field that I render as HTML?

Please incorporate the following ActionScript. Keep in mind to use the dpmoreinfo.txt file in this code.

import TextField.StyleSheet;
var myStyle:StyleSheet = new StyleSheet();
myStyle.load("mystyles.css");
myStyle.onLoad = function(success:Boolean) {
newsLetterTop_txt.styleSheet = myStyle;
newsLetterTop_txt.html = true;
newsLetterTop_txt.text = "<heading>I would like to display my external text file here! How would I do that?</heading>";
};


Thanks for your support!

Flash_Boi

Using Stylesheet In Dynamix Text From External .txt
Hello everybody! Thanx alot for all your tips. I have a problem that i cant find in tutorial or forum.

I am loading external textfiles into my *.swf in a dynamic-textfield and want to use CCS to shape them up. Can anyone please help where to put in the stylesheet code to get this working?

var thumb_spacing = 110;
var columns = 5;
// load variables object to handle loading of text
var description_lv = new LoadVars();
description_lv.onData = function(raw_text) {
description_txt.text = raw_text
};
function GeneratePortfolio(portfolio_xml) {
var portfolioPictures = portfolio_xml.firstChild.childNodes;
for (var i = 0; i<portfolioPictures.length; i++) {
var currentPicture = portfolioPictures[i];
var currentThumb_mc = menu_mc.createEmptyMovieClip("thumbnail_mc"+i, i);
currentThumb_mc._x = (i%columns)*thumb_spacing;
currentThumb_mc._y = Math.floor(i/columns)*thumb_spacing;
currentThumb_mc.createEmptyMovieClip("thumb_contai ner", 0);
currentThumb_mc.thumb_container.loadMovie(currentP icture.attributes.thumb);
currentThumb_mc.title = currentPicture.attributes.title;
currentThumb_mc.image = currentPicture.attributes.image;
currentThumb_mc.description = currentPicture.attributes.description;
currentThumb_mc.onRollOver = currentThumb_mc.onDragOver=function () {
info_txt.text = this.title;
};
currentThumb_mc.onRollOut = currentThumb_mc.onDragOut=function () {
info_txt.text = "";
};
currentThumb_mc.onRelease = function() {
image_mc.loadMovie(this.image);
description_lv.load(this.description);
timeline.loadVariables(baseurl + this.TEXT);

};
}
}
// xml object for xml content (defines sources for selections)
var portfolio_xml = new XML();
portfolio_xml.ignoreWhite = true;
portfolio_xml.onLoad = function(success) {
if (success) {
GeneratePortfolio(this);
} else {
trace("Error loading XML file");
}
// no success? trace error (wont be seen on web)
};
// load
portfolio_xml.load("portfolio.xml");

StyleSheet And Dynamic Text
I wonder if it is possible to link a Style Sheet to a .txt file that is going to be displayed in a dynamic text field in my flash movie

External Stylesheet Font Linkage Question
hi...i am trying to embed a font that will be coming from and external stylesheet. I have to embed this font because i have never seen it until i received this project, and thus, it has to be exactly this font that loads into the movie. I read this from the help:

Quote:




If using CSS styles to set fonts for TextFields or components, set the font-family CSS property to the name of the embedded font. The font-family property must contain a single name and not a list of names if you want to specify an embedded font.




I understand the above to mean, the font in my css must be called the same name as the font's linkage name in the library. My question is, in the stylesheet, must the font contain quotes, or can it go in without.


Code:
.norm{
font-family:WhackyFont;
/*or font-family:"WhackyFont"; */
font-size:10px;
color:#FFFFFF;
}

Loading An External StyleSheet Into A Custom Class
Help! I am trying to load an external stylesheet into a class I have created. This is my first attempt at writing a class and so far so good on loading the xml and other items needed. However, I have spent hours trying to solve this problem, referenced several threads (even on here) and haven't found a solid solution. Below is my code. I am passing variables into it. The xml portion is perfectly fine and loading the string location of the stylesheet. its when I hit here that it won't load. It continues to throw the false message.


Code:
/***Variables declared in header area: ***/
public var myStyle:TextField.StyleSheet():
public var containerClip_mc:MovieClip();
public var styleLocation_str:String();
/*** container clip is referenced in order to view the test text **/

private function loadMyStylesheet(myStyle_css:TextField.StyleSheet, styleLocation_str:String, containerClip_mc:MovieClip):Void {
var loadStyle_css:TextField.StyleSheet = new TextField.StyleSheet();
loadStyle_css = myStyle_css;
/* loads external CSS document */
loadStyle_css.load(styleLocation_str);
loadStyle_css.onLoad = function(success:Boolean) {
if (success) {
trace("loaded CSS successfully");
containerClip_mc.test_txt.text.styleSheet = loadStyle_css;
containerClip_mc.test_txt.text = "<so_boldedText>loaded stylesheet successfully!</so_boldedText>"+" "+success;
checkWhichSectionIsBeingCalled();
} else {
trace("NOT loaded CSS");
containerClip_mc.test_txt.text = "not loading css at all!";
}
}
}
Any help or samples would be wonderful. Thank you for your time!

External Text File In Flash Can't Use Css Stylesheet
I am having trouble attaching an external stylesheet to a dynamic text file in flash.

Details:
Instance name: my_txt
Variable name: storyText
Flash 8 | ActionScript 2.0
inside the text file: storyText=This is my is my text here....

Latest code that I am using:
.................................................. .........
function textLoader() {
myData = new LoadVars();
myData.onLoad = function() {
my_txt.html = true;
my_txt.htmlText = storyText;
};
myData.load("about2.txt");
}

var myCSS = new TextField.StyleSheet();
myCSS.load("style_t.css");
myCSS.onLoad = function() {
my_txt.styleSheet = myCSS;
textLoader();
};
.................................................. .........

anyone know what the problem is?
thanks,
mark.

Applying Stylesheet To Dynamic Textfield
hey ho

i've been working on a fiel for a friend, and have taken his flash mx file into mx 2004. i've been trying to apply a stylesheet to a dynamic textfield inside a movieclip, but it's just not happening. here's the code i've got:

code:
loaderate = new LoadVars();
loaderate.load("info.html");
loaderate.onLoad = function(success) {
if (success) {
container.styleSheet = _root.styles;
container.htmlText = this.recepticle;
container.scroll = 0;
} else {
trace("not loaded");
}
};


and the stylesheet code on the root is this:

code:
var styles = new TextField.StyleSheet();
styles.setStyle("body",
{color: '#000000',
fontFamily: 'Trebuchet MS'
}
);
styles.setStyle("a",
{textDecoration: 'underline'}
);


the file is being exported as a flash 7 with actionscript 2, and i've tried applying the style globally, but it's just not happening. i've gotten a stylesheet working before in other files using a textarea with exactly the same code.

the text in the html file begins 'recepticle=', and all the text is encapsulated inside p="body" tags. any ideas gratefully accepted.

Problem In Loading External Stylesheet In Flash Player 6
Hi,
Does anyone know how to apply external css for flash player 6.

I have an application which has an external stylesheet which is used for formatting the text content.

The screens update and display well in flash player 7 and above but doesnot work when published in player 6.

I know the flash 6 does'nt support stylesheet object. but is there a work around it.


Help needed ASAP.

Flash MX - Apply External Stylesheet To Multiple Frames
I am new to Flash. I spent an entire day today trying to figure this out, but so far I have not been successful.

I have a .fla that rotates ten different quotes. The quotes are kept in an external .txt file.

I want to style this content using an external stylesheet. I created some actionscript in the first frame of the movie that loads the external stylesheet. It successfully styles the first quote. But the second through tenth quotes revert to the style applied during creation from within Flash MX.

And, when the movie loops, the style on the first quote takes a moment to display. Very odd.

The attached .zip has all the needed files: the .fla, .txt, and .css. Can someone take a look at this and let me know if it is possible to do what I am wanting to do?

Thanks ever so much!

Flash MX - Apply External Stylesheet To Multiple Frames
I am new to Flash. I spent an entire day today trying to figure this out, but so far I have not been successful.

I have a .fla that rotates ten different quotes. The quotes are kept in an external .txt file.

I want to style this content using an external stylesheet. I created some actionscript in the first frame of the movie that loads the external stylesheet. It successfully styles the first quote. But the second through tenth quotes revert to the style applied during creation from within Flash MX.

And, when the movie loops, the style on the first quote takes a moment to display. Very odd.

The attached .zip has all the needed files: the .fla, .txt, and .css. Can someone take a look at this and let me know if it is possible to do what I am wanting to do?

Thanks ever so much!

Apply Stylesheet On Dynamic Text Loaded From XML
Hi,

I tried to apply a stylesheet on a textArea where text loaded from XML but its not working. It back to default text style. //solved - thanks jason !!


Problem 2 - is it possible to attach a movieclip or image inside textArea component?


Thanks!

Dynamic Text Stylesheet Issue (Links Shift When Hovered)
Hello everyone,

I'm having an issue with text shifting slightly any time a link is moused over (a:hover). I've been banging my head against this for weeks and haven't been able to figure it out. I searched the forums extensively and haven't found any mention of this issue, so I'm hoping someone can shed some light on it for me.

I'm creating a completely database-powered Flash site, so all text will be loaded into dynamic text boxes. The text boxes will have stylesheets applied to control the standard things like text size, font, and stylize links. Everything is working fine except for the a:hover portion. The link shows up in the text box with the correct properties, and when I mouse over the link it updates with the a:hover properties.

The problem I'm having is whenever I mouse over a link, all of the text around it shifts slightly. When I move my mouse off of the link, the text shifts back to it's original position. I'm not changing anything on a:hover except for font color, but even when I don't change anything the same shifting problem occurs. A few important things I've noticed:

1) This issue only occurs when the dynamic text box is "Anti-alias for readability" AND the text box's autoSize property is set to true.

2) If I do not set the autoSize property but leave "Anti-alias for readability" it works fine. If I set the autoSize property to true, but change the dynamic text box to either "Anti-alias for animation" or "Use device fonts" it works correctly, with no shifting of text when links are hovered.

3) Oddly, if the link appears on the first line of the text box, no shifting occurs, regardless of the autosize and anti-alias settings.

As I mentioned, I've been banging my head against this for weeks and searching everywhere I can think of, but haven't been able to find a solution. If anyone has any ideas, I'd greatly appreciate the input.

I've attached an example .fla file that illustrates the issue I'm having. Although I'm using an external stylesheet, I've placed an inline stylesheet in this file to keep everything in one file. The issue I'm describing is happening with both an external and inline stylesheet.

Again, thanks for any ideas. I'm totally stumped!

Propery Way To Load Dynamic Text Which Uses Stylesheet And Embedded Fonts
I have a dynamic text field with an instance name of txtFilmNews. I am loading some external HTML and an external stylesheet. I am also embedding fonts (Orator, regular and bold) for this text field. Everything seems to load properly -- html and stylesheets both -- however, the text shifts a tiny bit when I mouseover the hyperlinks in my text field.

I'm wondering if this has something to do with how I've embedded my fonts. I created two new font objects in my library:
DynamicFont1 - Orator 12 pt with linkage ID of DynamicFont1, exported for actionscript in first frame.
DynamicFont1Bold - Orator 12 pt *bold* with linkage ID of DynamicFont1Bold, exported for actionscript in first frame.

The stylesheet is here, NOTE that I refer to 'Orator' and not DynamicFont1 or whatever:
http://merminfilm.com/styles.css

The HTML is here:
http://merminfilm.com/getHTML.php?q=filmNews

The text does seem to appear with its regular and bold variants in various sizes and colors HOWEVER the text around the hyperlinks appears to jump when I mouseover the hyperlinks in the text. Interestingly, the jump only happens on the first mouseover and then the text is stable. What the heck? Is there some way to prevent this?

Also, am I properly embedding my fonts and assiging stylesheets? I haven't been able to locate any authoritative adobe documentation on how to use stylesheets with embedded fonts in AS2. I have CS3 but am working on an older file.

My code is below.







Attach Code

stop();

import TextField.StyleSheet;
var myStyleSheet:StyleSheet = new StyleSheet();
myStyleSheet.onLoad = function(success:Boolean) {
if (success) {
var stylesArray:Array = myStyleSheet.getStyleNames();
} else {
}
};
myStyleSheet.load("styles.css");
txtFilmNews.html = true;
txtFilmNews.styleSheet = myStyleSheet;
txtFilmNews.width = 295;
txtFilmNews.autoSize = true;
txtFilmNews.selectable = false;
txtFilmNews.condenseWhite = false;
txtFilmNews.embedFonts = true;


var lvFilmNews:LoadVars = new LoadVars();
lvFilmNews.onLoad = function(success) {
if (success) {
txtFilmNews.htmlText = lvFilmNews.html;

} else {
trace('load failure!');
}
}
lvFilmNews.load('getHTML.php?q=filmNews');

Stylesheet Applying To A Tags, But Not B Tags In Dynamic Text Box
Hello, I have a dynamic text box that pulls HTML-formatted content from a PHP script and everything is working, including getting it formatted with a stylesheet, except the stylesheet seems to be ignored for <B> tags. This is the code I tried:

b,B { font-weight:bold; color:#6600FF; font-family:Baskerville; }
a:link { text-decoration:none; font-family:Baskerville; font-weight:bold; }
a:hover { text-decoration:underline; }
a:active { text-decoration:none; }

This is just for texting. I have a simple textbox with plain text, part of it in bold, part of it as a link, and the link gets the Baskerville font, but the bold tag doesn't. When I set a color for the link, the link gets a color but the bold tag doesn't. I'm stumped. Any ideas?

Masking Dynamic Textfield When The Textfield Has A Stylesheet
ok... i have a movieClip containing dynamic textfields, which i'm trying to mask. the textfields are linked to a stylesheet. i understand that, for the masking to work, i have to embed the font. so i've placed the font in the library, given it a linkage name and set embedFonts = true for the dynamic textfields.

what do i do next? and does the fact that i'm embeding the font override the effect of the stylesheet?

(sorry if i sound confused over this. that's because i am.)

thanks in advance for any help

Masking Dynamic Textfield When The Textfield Has A Stylesheet
ok... i have a movieClip containing dynamic textfields, which i'm trying to mask. the textfields are linked to a stylesheet. i understand that, for the masking to work, i have to embed the font. so i've placed the font in the library, given it a linkage name and set embedFonts = true for the dynamic textfields.

what do i do next? and does the fact that i'm embeding the font override the effect of the stylesheet?

(sorry if i sound confused over this. that's because i am.)

thanks in advance for any help


||| O ^ | + O ¬

Masking Dynamic Textfield When The Textfield Has A Stylesheet
ok... i have a movieClip containing dynamic textfields, which i'm trying to mask. the textfields are linked to a stylesheet. i understand that, for the masking to work, i have to embed the font. so i've placed the font in the library, given it a linkage name and set embedFonts = true for the dynamic textfields.

what do i do next? and does the fact that i'm embeding the font override the effect of the stylesheet?

(sorry if i sound confused over this. that's because i am.)

thanks in advance for any help


||| O ^ | + O ¬

Masking Dynamic Textfield When The Textfield Has A Stylesheet
ok... i have a movieClip containing dynamic textfields, which i'm trying to mask. the textfields are linked to a stylesheet. i understand that, for the masking to work, i have to embed the font. so i've placed the font in the library, given it a linkage name and set embedFonts = true for the dynamic textfields.

what do i do next? and does the fact that i'm embeding the font override the effect of the stylesheet?

(sorry if i sound confused over this. that's because i am.)

thanks in advance for any help


||| O ^ | + O ¬

Help With StyleSheet Bug
I have a textArea with a styleSheet applied to it. This is a simple example of the problem.

this:
<p><head>hello</head> <b>world</b> <i>how are you today</i>?</p>
does not write out correctly. the space characters between the tags do not write out correctly.

helloworldhow are you today?


this is the code for the textArea.

Code:
_root.createClassObject(TextArea, "content_txta", 130, {text:"blank", _width:400, _height:415, _x:400, _y:115, html:true, embedFonts:true, borderStyle:"none", wordWrap:true, vScrollPolicy:"on", styleSheet:contentStyles});



I think it has something to do with the space character loosing it's style-type. It is in <p></p>, but it does not write out like that ... it write nothing ... almost like text with no style does. I think it is a bug, i can't find a work around.

Obviously this works:
<p><head>hello </head> <b>world </b> <i>how are you today</i>?</p>
But, that simple fix will not work for the real program ...

thanks for your input on how to make the space show up!

--mm

As3 Stylesheet
Hello,

Why will flash cs3 with actionscript 3 make a new line when I use a stylesheet css argument <v> using the following code (which should only change the color to black):


Code:
_styleSheet = new StyleSheet();
_styleSheet.setStyle("v",
{color: '#000000'}
);

_textField = new TextField();
//...
_textField.multiline = true;
_textField.embedFonts = true;
_textField.htmlText = "this is <v>some</v> test text <v>black</v>color"
The color is being changed but it also makes a new line after the colored word. Why is that happening?

Thanks a lot for help!

[FMX] - Stylesheet
This is weird... I red the stylesheet tutorial in kirupa and in macromedia site but it doesnt work for me. I dont undestand why...

This code should work fine but it doesnt!!!

Code:
var css_styles = new TextField.StyleSheet();
css_styles.load("styles.css");
css_styles.onLoad = function(ok) {
if(ok) {
// display style names
trace(this.getStyleNames());
} else {
trace("Error loading CSS file.");
}
}
I have the .css file in same directory and its rights are all allowed. I dont get why its not working... I tried some trace inside the function but it doesnt even do that. whats wrong with this? Does anyone have any idea?

Cheers
MZA

Mac Stylesheet Bug?
I have attached a stylesheet to a dynamic textbox, and it runs perfectly on pc, but on mac it seems that it cant find the "font-family" specification. The text looks like crap, with different letter spacing etc... I have the same flashplayer installed on both systems, winxp, osx.
Im loading different .swf:s into a empty movieclip from a parent swf with a menu.
the css looks like this:
.one {
font-family: Verdana, Tahoma, Helvetica, Arial, Geneva, sans-serif;
font-size: 10px;
color: #3F4B5F;
}
a:link { text-decoration: none; color: #666666}
a:visited { text-decoration: none; color: #666666}
a:hover { text-decoration:none; color: #FF0000}
a:active { text-decoration: none; color: #666666}
h2 {
color: #ff0000;
}
em {
color: #DE383D;
}
And the file containing the external text, loaded into the textbox looks like this:
name=<p class='one'>lorem ipsum<br />lorem ipsum<br /><h2>lorem ipsum</h2></p>
help me please `

[FMX] - Stylesheet
This is weird... I red the stylesheet tutorial in kirupa and in macromedia site but it doesnt work for me. I dont undestand why...

This code should work fine but it doesnt!!!

Code:
var css_styles = new TextField.StyleSheet();
css_styles.load("styles.css");
css_styles.onLoad = function(ok) {
if(ok) {
// display style names
trace(this.getStyleNames());
} else {
trace("Error loading CSS file.");
}
}
I have the .css file in same directory and its rights are all allowed. I dont get why its not working... I tried some trace inside the function but it doesnt even do that. whats wrong with this? Does anyone have any idea?

Cheers
MZA

Mac Stylesheet Bug?
I have attached a stylesheet to a dynamic textbox, and it runs perfectly on pc, but on mac it seems that it cant find the "font-family" specification. The text looks like crap, with different letter spacing etc... I have the same flashplayer installed on both systems, winxp, osx.
Im loading different .swf:s into a empty movieclip from a parent swf with a menu.
the css looks like this:
.one {
font-family: Verdana, Tahoma, Helvetica, Arial, Geneva, sans-serif;
font-size: 10px;
color: #3F4B5F;
}
a:link { text-decoration: none; color: #666666}
a:visited { text-decoration: none; color: #666666}
a:hover { text-decoration:none; color: #FF0000}
a:active { text-decoration: none; color: #666666}
h2 {
color: #ff0000;
}
em {
color: #DE383D;
}
And the file containing the external text, loaded into the textbox looks like this:
name=<p class='one'>lorem ipsum<br />lorem ipsum<br /><h2>lorem ipsum</h2></p>
help me please `

Kind Of Stylesheet
i presume this is possible but don't know where to start.

i want to be able to easily change the colour of elements with in a site in one go rather than having to open up every MC or button. ie. type colour ,background colou,r box colour that kinda thing - i can go every month/week/day change some code and all colour way for the site is completely different (like CSS). If anyone knows any good tutorials or source files they'd be much appreciated.

cheers

J

CreateTextField And StyleSheet
Problem to create a text field with html and css


Code:
_root.createTextField("mytext",150,150,200,300,100);
mytext.multiline = true;
mytext.wordWrap = true;
mytext.border = true;
mytext.html = true;
mytext.text = "<span class=headline> Titolo </span> <br />testo testo testo testo";
var css_styles = new TextField.StyleSheet();
css_styles =" headline { font-family: Arial,Helvetica,sans-serif; font-size: 16px; font-weight: bold; display: block; color: #C29D3F; text-decoration:underline; }";
mytext.styleSheet = css_styles
i try also with "mytext.htmlText" but don't change
any idea?
thanks

TextField.StyleSheet
I am trying to set the styles for an external text file that is loaded as a variable into a dynamic text field.

Rather than using an external CSS, I want to modify the text styles within ActionScript.

I have set the following at the onset of the movie, but it is not working:

var styles = new TextField.StyleSheet();
styles.setStyle("heder",{fontSize: '32px'});
learnText.styleSheet=styles;

loadVariables("textFileLearning.txt", this);

learnText is the instance name of the dynamic text field.
textFileLearning.txt is the name of the external text file.
"heder" is embedded in the text file in the form:

<span class = "heder"> text sample </span>

ideas?

Stylesheet Not Working
Hi,

I am loading content into my .swf from an external file. Some of the stylesheet seems to work but not all of it. Here's the code I have:

loadtextContent = new LoadVars();
// Load the text file into my movie
loadtextContent.load("content.txt");
// Start a new function to load the text file
loadtextContent.onLoad = function(success) {
if (success) {
// loads the file into mytextbox
_root.content = this.content;
}
if (!success) {
_root.content = "Error loading content";
}
};

var style_sheet = new TextField.StyleSheet();
var css_url = "../css/styles.css";
style_sheet.load(css_url)
myText.styleSheet = style_sheet;
loadVariables("content.txt",this);

Any ideas why it's not picking up properly?

List StyleSheet
Hello,

How do i create a bulleted list in dynamic field using external css?

I tried the code below with no effect...
xbullet {
color: #0033FF;
list-style: outside; //OR list-style-image: url(bullet.jpg);
}

Currently I use this code successfully to format my textfields.
content4 {
color: #ff0000;
font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;
font-size: 36px;
font-weight: bold;
textDecoration: underline;
display: inline;
}

Thank You

Stylesheet Problem
hi,
i'm using css for a textfield and it works fine, but when i load the swf into another, the stylesheet doesnt work anymore.
can anybody help me? i cant find a solution.

attachment

HtmlText And StyleSheet
Pretty simple code here, works just fine.


Code:
var myStyles:TextField.StyleSheet = new TextField.StyleSheet();
myStyles.setStyle("p", {color:'#808080'});
myStyles.setStyle("h1", {color:'#84ABDB'});
this.createTextField("my_txt",this.getNextHighestDepth(),20,20,260,50);
my_txt.styleSheet = myStyles;
my_txt.html = true;
my_txt.htmlText = "<p>Name: </p>";
my_txt.htmlText += "<h1>Lorem ipsum dolor sit amet, consectetuer adipiscing elit.</h1>";
Here is my problem - want to make a variable and put it between the style tags.

For instance:

Code:
var blah:String = "Hello there";
my_txt.htmlText = "<p>blah</p>";
Without it just writing "blah" I need it to get the string from the variable. How would I accomplish this?

Flash + XML + Stylesheet
I thought I solved the problem with xml + css with the stylesheet class.
But I can apply the style fom the stylesheet to the xml-file.

Please, is there anyone out there who can guide me what´s wrong?












Attach Code

[b]CODE FROM THE CSS-FILE::[/b]

@charset "utf-8";
/* CSS Document */
.test{
font: Helvetica, Arial, sans-serifleft;
font-size:32px;
}

[b]CODE FROM THE .FLA-FILE:[/b]

function contents () {
var cont:XML = new XML ();
cont.ignoreWhite = true;
cont.onLoad = function (success) {
if (success) {
var root:XMLNode = this.firstChild;
if (_root.commingContent == "menu") {
var titleItem:String = root.childNodes[_root.contentInstance].childNodes[0].childNodes[0].nodeValue;
var textItem:String = root.childNodes[_root.contentInstance].childNodes[1].childNodes[0].nodeValue;
}
if (_root.commingContent == "submenu") {
var titleItem:String = root.childNodes[_root.contentInstance].childNodes[2].childNodes[_root.contentSubInstance].childNodes[0].childNodes[0].nodeValue;
var textItem:String = root.childNodes[_root.contentInstance].childNodes[2].childNodes[_root.contentSubInstance].childNodes[1].childNodes[0].nodeValue;
}
//
var myContentText:String = new String (textItem);
var mySubContentText:String = new String ();
mySubContentText = myContentText.substr (-4, 4);
if (mySubContentText == ".swf") {
text._visible = false;
loadMovie (textItem, mcAttach);
}
else {
//Stylesheet
text._visible = true;
var format = new TextField.Stylesheet();
var path ="style.css";
format.load(path);
text.texto.text.styleSheet = format;
text.title.title.styleSheet = format;
text.title.title.htmlText = titleItem;
text.texto.text.htmlText = textItem;
text.texto.text.autoSize = true;
text.top._y = text.texto._y;
text.down._y = text.texto._height + 100;
text._y = Stage.height / 2 - text._height / 2;
if (text._height > Stage.height) {
startGG ();
}
}
}
};
cont.load ("xml/mycontent.xml");
}






[b]CODE FROM THE XML-FILE:[/b]

<mainmenu>
<title><![CDATA[<span class="test">ABOUT US</span>]]></title>
<content_menu><![CDATA[<font color="#ffffff" size="14">Yesterday We where in Stockholm.<br>We did not see anything because we where at Gröna at Lund<br> there we saw Inflames.<br>Trigger was the best tune of all.<br></font><font color="#909090" size="15"><a href="http://www.myhomesite.se" target="_blank"><U>Click here to wiew som more stuff</U></a><br><font color="#FFFFFF" size="15">Have fun!</font>]]></content_menu>
</mainmenu>

StyleSheet Problem
Hi,

I have this code here in Flash where I am dynamically populating a text component...


Code:
var styles = new TextField.StyleSheet();
var css_url="efarmasi.css";
styles.load(css_url);
styles.onLoad = function(ok) {
if (ok) {
// If the style sheet loaded without error,
// then assign it to the text object,
// and assign the HTML text to the text field.
disptext.styleSheet = styles;
disptext.text = storyText;
}
};
Now, in the actual text is in a <li></li> form. But the problem is that Flash displays the text with a lot of line space in between. Is there a way to control this ?


This is the code for the CSS


Code:

ul {
list-style-type: none;
padding-left:0px;
margin-left:0px;
}

li {
padding-left:0px;
margin-bottom:0px;
margin-left:0px;
}
and the text I display is just this


Code:
<ul>
<li>This is my first line</li>
<li>This is my second line</li>
</ul>
But this displays as

Code:
This is my first line

This is my second line
I don't know how the space comes in. Does Flash have a default.css that I must disable ?

StyleSheet V. DefaultTextFormat: Why Can't We All Just Get Along?
Here's my dilemma: I have a few fonts embedded in my FLA; these fonts are linked and exported on frame 1. Within a pile of generated symbols, I have a textfield that uses (among other things, this:


Code:
var cssString:String="p {font-family:"+(new HNC().fontName)+"; font-size: 24px; color:#1A1A1A} b {font-family:"+(new HNMC().fontName)+"; font-size:48px; color:#FF0000}";
tabStyle=new StyleSheet();
tabStyle.parseCSS(cssString);

...

tabInstr=new TextField();

tabInstr.styleSheet=tabStyle;
tabInstr.embedFonts=true;
tabInstr.selectable=false;
tabInstr.multiline=true;
tabInstr.wordWrap=true;
tabInstr.htmlText=String(tabXML.instr);
tabInstr.antiAliasType=AntiAliasType.ADVANCED;
tabInstr.autoSize=TextFieldAutoSize.LEFT;
It displays all of the relevant text:


Code:
<p><b>Point of origin</b><br />Touch one of the available points of origin or touch "Other" to enter your own.</p>
but it only applies the <p> style: the bold text is painted with the same attributes as everything else. I tried ditching the <p> style altogether, but that just made the text fail to show up at all...What am I doing wrong?! Gah?!!?!

Edit: the thread title was from before I realized that stylesheets and textformats are sworn blood-enemies who hate each other a lot.

StyleSheet For Textfield
Hey all,

quick question about actionscript stylesheets. I understand that you can define styles for specific selectors like 'a' or '.myCustomSelector', but is there a default selector for the entire textfield? Or would I have to face my fear that I'd have to encapsulate all the text in the textfield with a <body> tag of some sort? (this is not ideal since the textfield in question is dynamic and is updated pretty regularly)

Thanks for any pointers!
Jay

StyleSheet Problem
Hi,

I have the code below in a Flash movie, but the <small> tag breaks the line of text. Could you please give me any advice on this?

Thanks,
CH


Code:
var styles:TextField.StyleSheet = new TextField.StyleSheet();
styles.setStyle("bodyText", {fontFamily: 'Arial,Helvetica,sans-serif', fontSize: '13px'});
styles.setStyle("small", {fontFamily: 'Arial,Helvetica,sans-serif', fontSize: '9px'});
this.createTextField("caption_txt", 3, 0, 0, 400, 55);
this.caption_txt.html=true;
this.caption_txt.multiline=true;
this.caption_txt.selectable=false;
this.caption_txt.wordWrap=true;
this.caption_txt.autoSize=true;
this.caption_txt.styleSheet = styles;
this.caption_txt.htmlText="<bodyText>Civilians <small>are</small> increasingly becoming the victims of Mexican soldiers waging a bloody campaign against narcotics cartels, TIME.com reports. In one instance, troops shot dead two women and three children traveling to a funeral. It's a drug war that the U.S. Congress is looking at </bodyText>"

HtmlText And StyleSheet
Pretty simple code here, works just fine.


Code:
var myStyles:TextField.StyleSheet = new TextField.StyleSheet();
myStyles.setStyle("p", {color:'#808080'});
myStyles.setStyle("h1", {color:'#84ABDB'});
this.createTextField("my_txt",this.getNextHighestDepth(),20,20,260,50);
my_txt.styleSheet = myStyles;
my_txt.html = true;
my_txt.htmlText = "<p>Name: </p>";
my_txt.htmlText += "<h1>Lorem ipsum dolor sit amet, consectetuer adipiscing elit.</h1>";

Here is my problem - want to make a variable and put it between the style tags.

For instance:

Code:
var blah:String = "Hello there";
my_txt.htmlText = "<p>blah</p>";
Without it just writing "blah" I need it to get the string from the variable. How would I accomplish this?

Stylesheet In Flash MX
Can sombody please tell why the stylesheet is not working properly?
Is there anything wrong with my script. I am sure that i am linking right to my stylesheet.
I don´t get an error and the text is loaded fine but the defined stylesheet is ignored - WHY ?????


HTML Code:

//flash actionscript

var strLg = "EN";
var noPage = 1;

TextField01.html = true;
mStyle = new TextField.StyleSheet();
mStyle.onLoad = function(done) {
if(done) {
TextField01.styleSheet = mStyle;
}
else {
trace("Der skete en fejl");
}
}
mStyle.load("body.css");

xml1 = new XML();
xml1.onLoad = myOnLoad;
xml1.load("TxtBox.xml");
xml1.ignoreWhite = true;

function myOnLoad (success) {
if (success) {
TextField01.htmlText = "";
loadTxtBox(strLg, noPage);
}
}

function loadTxtBox(lg, no) {
var i = 0;
var j = 0;

while (i < xml1.firstChild.childNodes.length) {

if (((xml1.firstChild.childNodes[i].attributes.lg) == lg) && ((xml1.firstChild.childNodes[i].attributes.no) == no)) {
j = 0;
while (j < xml1.firstChild.childNodes[i].childNodes.length) {
if (xml1.firstChild.childNodes[i].childNodes[j].nodeName != null) {
TextField01.htmlText += xml1.firstChild.childNodes[i].childNodes[j].toString();
}
j ++;
}
break;
}
i ++;

}

news_sb._visible = TextField01.maxscroll > 1;

}

Flash In A CSS Stylesheet?
Can Flash be embedded in a CSS style sheet as a background? Anyone have any ideas as to how to code this if it was possible?

StyleSheet And EmbedFonts
Hi,

is it possible to use them both together?
I use a partly embedded font, wich is in an dynamic TextField in the library, exported for ActionScript.
I can see it with enumerateFonts and use with TextFormat, but no chance with StyleSheet, which shows nothing as soon as I set TextField.embedFonts to true.
Here is what it looks like.

I've attached the files, if anyone may want to have a look on it.

Apply Stylesheet
Can anyone help me apply stylesheets to this XML? How do I load my external css-file in flash and how do I write in my XML file to set the styles?

Code in Flash:
Code:

//loading pics and text:
var gallery_xml = new XML();
gallery_xml.ignoreWhite = true;
gallery_xml.onLoad = function(success) {
   if (success) {
      var gallery = this.firstChild;
      for (var i = 0; i<gallery.childNodes.length; i++) {
         tArray.push(gallery.childNodes[i].attributes.title);
         pArray.push(gallery.childNodes[i].attributes.source);
      }
      containerMC.loadPic(0);
   } else {
      title_txt.text = "Error!";
   }
}
gallery_xml.load("main"+main+"/sub"+sub+"/gallery.xml");


My XML file
Code:

<?xml version="1.0" encoding="UTF-8"?>
<portfolio info ="GREGORY">
      <image title="Some text here" source="main1/sub1/pic1.jpg"/>
      <image title="" source="main1/sub1/pic2.jpg"/>
      <image title="" source="main1/sub1/pic3.jpg"/>
      <image title="" source="main1/sub1/pic4.jpg"/>
      <image title="" source="main1/sub1/pic5.jpg"/>
      <image title="" source="main1/sub1/pic6.jpg"/>
</portfolio>

Global Stylesheet?
can i attach globally a stylesheet toall the textarea's at once?

Preloaded External Swf Do Not Show External Dynamic File...?
okeli... I am posting because I am totally stuck... my xp regarding coding and stuff is absolutely crap (although I do understand most logic to the scripts u all write out), so I have followed most of ur tutorials on the site.

The problem:

I have made a main file and used primarily two of ur tutorials together. The first one is Claudio's Preloader and transition tutorial, http://www.kirupa.com/developer/mx/p...transition.htm, but also kirupa's Scrolling dynamically loaded text, http://www.kirupa.com/developer/mx/dynamic_scroller.htm.

The file main.swf should load, with transition and loading, the file members.swf - which it does. However when members.swf should load currentmembers.asp as a scrolling text the text do not show up. When I however view members seperately the scrolling text DO SHOW up! I am all confused at this and the only thing I can imagine being wrong is somewhere in the coding of main.fla file... :/ Perhaps I am wrong (which would not be a surprise) so if someone kind enough can have a look through at the coding of the main.fla and/or members.fla I would be sinceraly grateful... thanks...

The files:
http://www.sebszhost.com/~leete/FftC/currentmembers.asp
http://www.sebszhost.com/~leete/FftC/main.fla
http://www.sebszhost.com/~leete/FftC/members.fla

Dynamic Vars, Dynamic Paths Using Variables And External Text Files
Hi there,

first off, apologies for the long post, but its a tricky problem to explain... and on my first post too! (sorry )
Im have a bit of bother with flash calling variables from a text file, and using them to make paths to other variables, and to control the amount of time a duplicate clip occurs. The first of these 2 problems is this:

Im loading a text file "content.txt" into _root. (this works fine)
it contains the variables:

webclipcount=2
&webhenry=hello hello
&webbutton01=henry

on the main timeline I have this button

on(press){
sectiontitle="web"
clipcount=webclipcount
}

there is a text box on the main timeline with variable name of bodycopy.

on a clip on the main timeline I have this;

onClipEvent (enterFrame) {
if (num< _parent.clipcount) {
duplicateMovieClip(thebutton, "button"+depth, depth);
this["button"+depth].name = _parent[_parent.sectiontitle+"button"+num];

this gives button01 the name henry- this works.

on the duplicated clip I have these actions:

on(mouseDown){
_parent._parent.bodycopy=_parent._parent[_parent._parent.sectiontitle+this.name]
}

so we end up with a path like:

_parent._parent.bodycopy=_parent._parent.webhenry

and it in turn should make the textbox on the main timeline contain "hello hello"

but it doesnt.

also for the duplicating clip, unless i use:

onClipEvent (enterFrame) {
if (num< 2) {.....
<snip>

it wont work either. it seems neither can be dynamic/ pulled from the text file. (well, i can get them to work!)

If I use direct paths like:

on(mouseDown){
_parent._parent.bodycopy="bloody hell it works!"
}

and

onClipEvent (enterFrame) {
if (num< 2) {.....
<snip>

it works, but not if they are dynamicly set from the txt file...
Anyone care to shed some light onto this? its doing my head in!
thanks in advance or the help.

cheers,

chris

Stylesheet For Flash Symbols
hi there,
i am working on a new site and would like to program it in such a way that i would be ablet to change the main colors of all the symbols easily by making changes to something like a stylesheet equivalent.
any ideas anyone?
thank you.

-jo

Image Stylesheet Select Bug
Hello,

I am having a problem with an apparent bug in Flash. The problem has to do with selectable text. I have built a highlighter feature for an application, but an having problems making all of the text in my TextArea Component (AS 2.0) selectable.

There is a bug that appears when all of these are true:
1)image is mixed in with the text via <img> tag
2)html=true
3)embedFonts=true
4)stylesheet is set

The exact problem is that when the text is moused over the “T-bar” does not appear, it stays as the “white arrow” cursor. It appears that the textArea is confused about what is text and what is an image. (b/c the “T-bar” does not appear over images in TextAreas)

What is comes down to is a major problem: many portions of text in the program are unselectable (it appears on about 1100 out of the 9000 pages).

Also, if you scroll so that the image is “cut-off” i.e. 1/2 is visible in the scroll 1/2 is not, nothing is selectable at all. This poses a huge problem for my highlighter tool ... the user cannot highlight if they cannot select!

The problem only occurs on pages that have images on them.

I created a simplified version of this portion of my application. I can be viewed here:
http://www.touchwood.net/temp/imageHighlightIssue.html
or downloaded here:
http://www.touchwood.net/temp/image_select_test.zip

I have tried updating to the 7.2 version but it did not seem to help. (since then I have gone back to 7.01 for other reasons)

So, is this a bug? Is there a workaround? When might we expect a fix from MM?

thanks a ton for you help with this matter.

-mm

Copyright © 2005-08 www.BigResource.com, All rights reserved