Flash Stylesheet Question
Hey all,
I've been exploring using the Stylesheet object to styles my dynamic textfields, and am wondering if there is a default selector I can use to style the entire textfield without encasing the text in HTML tags... similar to using the 'body' selector in standard website CSS (although technically whatever it's styling is within <body> tags).
if not, is there another way to do so? I tried setting the style using TextFormat, but when CSS is applied the text format of any text not encapsulated in HTML tags get overridden
thanks for any help! Jay
FlashKit > Flash Help > Actionscript 3.0
Posted on: 05-04-2008, 04:02 AM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
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 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 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
Flash Stylesheet Method
I'm actually glad this IE "click to activate" problem happened, because it unexpectedly caused me to come up with a way of embedding Flash that works like a CSS stylesheet, in a way. With the help of developer Karlene at the office, we were able to figure out how to make it work. It took about fifteen minutes to figure out once we had the idea, and now this is a speedy way to integrate Flash!
Step 1
To avoid the IE problem and also lay the foundation for deeplinking (if you're so inclined), set up your site with the Flash Object method.
http://blog.deconcept.com/flashobject/
Step 2
Then create a JavaScript file (we call it flashembed.js) which will list all Flash objects for embedding. Notice how a DIV tag is specified. Instead of putting your Flash on the page directly, you're putting them here. You will need to add an IF statement so this file doesn't stop if it can't find a needed DIV tag on a certain page in your site. The IF statement will make it skip over that Flash object if it is not to be put on a specific page.
Step 3
We include this file into our site pages (in the footer, right before the Body tag closes so all DIV tags load by the time it gets to flashembed.js code). In your body of your site pages, you will create DIV tags with an ID that corresponds to the Flash file you want to put in that location.
Step 4
Enjoy. You now have a CSS-like method for integrating Flash into your site that is compliant with IE's recently ActiveX update and lays the foundation for deeplinking!
---------------
Here is an example of using this for a Flash hybrid site I'm currently working on:
http://stage.endresultinc.com
PHP Code:
// All Flash Objects
if(document.getElementById("flashHome")!= undefined){
var fo = new FlashObject("/media/home.swf", "home", "762", "460", "7.0.00", "#000000", true);
fo.addParam("allowScriptAccess", "sameDomain");
fo.addParam("quality", "high");
fo.write("flashHome");
}
if(document.getElementById("spinweblogo")!= undefined){
var fo = new FlashObject("/media/spinweb-logo.swf", "spinweblogo", "93", "23", "7.0.00", "#000000", true);
fo.addParam("allowScriptAccess", "sameDomain");
fo.addParam("wmode", "transparent");
fo.addParam("quality", "high");
fo.write("spinweblogo");
}
Advantages of this method seem to be:
*Cleaner Pages
*Flash is separated from HTML
*All flash files are now found in one location, like a CSS stylesheet
*Assigns Flash to DIV tag IDs, replacing alternate HMTL content in the DIV that exists if Flash version is not installed.
*AJAX friendly!
Run with it if you like this!
Cheers,
-Alex
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.
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!
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?
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?
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?
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 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>
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
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
Stylesheet With Loaded Txt Files
MX04 publishing for Flash 7, AS 2:
My main movie loads a content movie, which in turn loads variables from a text file with the following:
code:
loadVariablesNum("contHome_en.txt", 0);
globalStyle = new TextField.StyleSheet();
globalStyle.load("global.css");
hdrHome00_txt.styleSheet = globalStyle;
contHome00_txt.styleSheet = globalStyle;
Everything works, but I'd like to have the variables loaded from the main movie so I don't have to load it with each new content movie. Also I'd like to call the stylesheet from the main movie so I don't have to call it each time either. I tried to accomplish both with the following:
code:
//Main Movie
loadVariablesNum("contHome_en.txt", 0);
_global.globalStyle = new TextField.StyleSheet();
globalStyle.load("global.css"); //tried with and without _global. here
//Loaded content movie
hdrHome00_txt.styleSheet = globalStyle;
contHome00_txt.styleSheet = globalStyle;
Text and variables load fine, but no stylesheet. Can't figure out why.
Retrieving A StyleSheet Value Using GetStyle?
since i am a complete retard when it comes to as2, i was hoping someone might be able to help me with this. i have a simple styleSheet object set up thus:
code:
var styles = new TextField.StyleSheet();
styles.setStyle("body",
{color: '#000000',
fontFamily: 'Trebuchet MS',
fontSize: '12'
}
);
but i have another function that would need to retrieve the value of fontSize. when i traced styles.getStyle("body"), it just returned the object type.
so, does anyone know how i can retrieve the value of fontSize dynamically?
thanks for your time
lawrie
Stylesheet Not Loading Quick Enough
I have a movie that loads a stylesheet that formats a text field upon opening.
The problem I am having is the stylesheet evidently isn't loading quick enough to format the text. When I double click on the link the stylesheet loads and formats my text. Is there a way to load the stylesheet before the text is called up into the dynamic text field?
Below is the code:
var format = new TextField.StyleSheet();
var path = "../styles/emails.css";
format.load(path);
;
format.onLoad = function(loaded) {
if (loaded) {
ContentText.styleSheet = format;
} else {
trace("it's not working");
ContentText.text = "Error loading CSS file!";
}
}
this.loadVariables(_root.theFileToLoad);
this.onData = function ()
{
ContentText.htmlText = this.scrollText;
}
The address where the working file can be seen is at:
http://www.heartlandcommunitychurch....aff/staff.html
I have attached two files, pastors.swf that calls up the movie called peeps.swf
Again, how can I load the stylesheet in advance? Originally the stylesheet and the dynamic text loaded on the first frame. The intent was to have text field behind a mask that opened to reveal the text. However, the dynamic field would not display the text behind a mask. When I would go under Debug and list my variables the text and stylesheet was loaded, but not in the text filed. So, I placed the dynamic text field on a layer above the mask so the text was viewable once the mask had completely opened. Then the text would display properly.
Any way to preload the stylesheet or put the dynamic text field back behind the mask and load it on the first frame?
TextField.StyleSheet() And Fonts
Is it possible to use embedded fonts with CSS formatted text?... For example, if i am using pixel fonts, and have font symbols in the library for each font/style (i.e. bold, extended) I just want to be able to apply styles to links, headings, etc Can i/how would I reference those fonts in my .css file?? I obviously have given all my font symbols linkage id's, but i don't know how to reference them in CSS... or if it's even possible.
Any help would be appreciated. thanks in advance!!
[F8] LoadVars And Stylesheet Problem
Hi there all, I am having trouble with CSS formated HTML in Flash 8. Specifically, with LoadVars() and TextField.StyleSheet(). The problem I am having is that the CSS formatting only works intermitently.
To see the effect go to http://www.mellowdrama.com
Click movies>411>then click around in any of the right menu links (apart from preview) you'll see that the css styles apply intermitently.
I have the following code on frame one of the timeline for each movieclip where I am loading an HTML and CSS file:
var flash_css = new TextField.StyleSheet();
flash_css.load("styles.css");
flash_css.onLoad = function(success:Boolean) {
if (success) {
my_txt.styleSheet = flash_css;
lv.load("theHTMLfile.htm");
} else {
trace("Could not load CSS file.");
}
};
var lv:LoadVars = new LoadVars();
lv.onData = function (src:String):Void {
if (src != undefined) {
my_txt.html=true;
my_txt.htmlText = src;
this.setDepthTo(DepthManager.kBottom);
} else {
my_txt.text = "Unable to load external file.";
}
}
On frame 2 I have a stop();
Any help is greatly appreciated.
Stylesheet/TextFormat Incompatible?
Ok, so:
I have a text field that is pulling dynamic text out from a database, and some of that text is wrapped in different classes. The classes are reading from an external stylesheet. However, the main text field has to change its formatting on button clicks, and I'd like the whole thing to change fonts (barring the text blocked out by my class), so the easiest thing I thought was to change the textFormat onRelease.
The problem:
my textFormat won't work when I enable my external stylesheet. It just goes away, but works (mostly) fine when I comment out that stylesheet line. Are the two formatters incompatible?
Code example:
Code:
var mainFormat:TextFormat = new TextFormat();
mainFormat.leading = 10;
mainFormat.font= WhitneyLight;
mainFormat.color = 0xFFFFFF;
var quoteFormat:TextFormat = new TextFormat();
quoteFormat.align = "center";
quoteFormat.font = Granjon;
mainText = contBox.centerText;
mainText.condenseWhite= true;
mainText.html = true;
mainText.embedFonts = true;
//mainText.styleSheet = styles;
mainText.htmlText = "<textformat leading='10'>" +introText+ "</textFormat>";
mainText.setTextFormat(mainFormat);
function
showQuote() {
mainText.htmlText = this["section"];
mainText.setTextFormat(quoteFormat);
}
var getQuote = new LoadVars();
getQuote.onLoad = showQuote;
A More Comprehensive Stylesheet For Text?
In my flash application I create a lot of dynamic text on the fly. While I've been using TextFormat to handle the embedded font, colour and style, is there a better way to compress all the other attributes into some sort of style sheet system?
Code:
var MyDynamiclyMadeText:TextField = new TextField();
MyDynamiclyMadeText.autoSize = TextFieldAutoSize.LEFT;
MyDynamiclyMadeText.embedFonts = true;
MyDynamiclyMadeText.multiline = true;
MyDynamiclyMadeText.wordWrap = true;
MyDynamiclyMadeText.defaultTextFormat = StylinStyleSheety;
MyDynamiclyMadeText.htmlText = "TheText.";
MyDynamiclyMadeText.width = 200;
addChild(MyDynamiclyMadeText);
MyDynamiclyMadeText.x = 25;
MyDynamiclyMadeText.y = 60;
Adding Stylesheet To TextArea
Pretty simple question here:
How can I add a stylesheet to a TextArea?
I've tried it with two scenarios. One where I had drawn the TextArea right on the stage and another when I added the TextArea using AS.
Using this code:
Code:
var chatarea:TextArea = new TextArea();
chatarea.x = 156.3;
chatarea.y = 12.4;
chatarea.width = 725.9;
chatarea.height = 316.0;
var style:StyleSheet = new StyleSheet();
style.setStyle("html", {fontFamily:"Arial,Helvetica,sans-serif", fontSize:"12px", color:"#0000FF"});
style.setStyle("body", {color:"#00CCFF", textDecoration:"underline"});
chatarea.styleSheet = style;
I get the following error:
Code:
1119: Access of possibly undefined property styleSheet through a reference with static type fl.controls:TextArea.ea
Can anyone shed some light on what's wrong here and how I can add a simple stylesheet to a TextArea?
Thanks in advance.
Embedding Fonts + Using CSS Stylesheet
Is there a way to embedd a font and also use an external stylesheet for the same text field.
I have a dynamic textfield that I am pulling the text in via xml. The text field has to be masked, so I have embedded the font in it, but I also want to format the text with an external stylesheet.
I was trying to do something like this, but it only works with the css or if I embedded it, not both.
PHP Code:
import fonts.FontLoader
var content_css:StyleSheet = new StyleSheet();
var arialFont:FontLoader = new FontLoader();
addChild(arialFont);
var paragraph:Object = new Object();
paragraph.color = "#FF0000";
//auto size the textfield
content_main.defaultTextFormat = new TextFormat("_Arial", 12, 0);
content_main.autoSize = TextFieldAutoSize.LEFT;
content_main.embedFonts = true;
content_main.antiAliasType = AntiAliasType.ADVANCED;
content_css.setStyle(".paragraph", paragraph);
Thanks for the help.
OnClick: Change Stylesheet?
I've got a small Flash based AS3 MP3 jukebox on a webpage and I'm wondering if I can assign an onClick behavior in my .fla that besides playing the MP3 it assigns Javascript to switch to a different stylesheet for my webpage layout?
Help With StyleSheet() And Text Bgcolors
I am trying to display an html text string that has multiple background colors inside a dynamic textField object. I have the stylesheet loading properly and it is being applied to my textField just fine. The problem is that properties that set the background color of the text, such as background or background-color, are being ignored.
Here is my ActionScript:
Code:
import TextField.StyleSheet;
var sSheet:StyleSheet = new StyleSheet();
sSheet.load("styles.css");
this.createTextField("test_css", 1, 10, 10, 300, 100);
test_css.html = true;
test_css.styleSheet = sSheet;
test_css.htmlText = "<span class="bgRed">Red</span> " +
"<span class="bgGreen">Green</span> " +
"<span class="bgBlue">Blue</span>";
styles.css contains:
Code:
.bgRed {
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
background: #FF0000;
}
.bgGreen {
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
background: #00FF00;
}
.bgBlue {
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
background: #0000FF;
}
I know that the textField object has a background color attribute, but that sets one color for the whole textField and I need multiple colors within the same textField. I have looked into using styleSheet.transform() to extend styleSheet, but it looks like it is limited to the attributes of the textFormat object, which has no attributes for background color. Is there any way to get this to work the way I want it to, or am I running into a limitation of Flash?
Thank you for your time,
Jon
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.
Stylesheet With InputText Issue
hi,
Does anybody know why when setting stylesheet on an input texfield it is no loger editable?
example: http://www.videodrome.hr/podly/fffstyle.swf
Any help with this would be appreciated
cheers
Stylesheet On Individual Button
I have a movie which has buttons in it using the Button component included with Flash 8. In the actionscript, I'm using lines of code like this to format them:
Code:
_global.style.setStyle("themeColor", "haloOrange");
There is one individual button I want to use a different font (webdings), however I just can't get it to work. How could I do this?
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.
StyleSheet And TextField.embedFonts
Hi,
I'm on a problem since two days and no solution in sight.
I try to use an external StyleSheet with an embedFont. But as soon as I switch embedFonts to true, nothing happens anymore.
The font is embedded in an dynamic TextField on the library (so I can embed parts of the font and doen't have to import the whole font), it's definitively there, I can find it width enumerateFonts and use it with TextFormat. But if you click here, you see the un-embedded TextFields most likely in an alternative Font (wich both are shown correctly on my system), the correct embedded-font TextField with TextFormat but nothing on StyleSheet with embedded font.
Does anyone sees the error?
Here's the code and the files are attached.
thanks.
PHP Code:
import flash.display.Sprite;
import flash.text.StyleSheet;
import flash.text.TextFormat;
import flash.text.TextField;
import flash.text.TextFieldAutoSize;
var cssLoader:URLLoader = new URLLoader();
var myStyleSheet:StyleSheet;
var myTextFormat:TextFormat;
var text1:TextField;
var text2:TextField;
var text3:TextField;
var text4:TextField;
function init() {
traceFonts();
initTextFormat();
cssLoader.addEventListener(Event.COMPLETE, completeHandler);
cssLoader.load(new URLRequest("css/textfeld.css"));
}
function initTextFormat():void {
myTextFormat = new TextFormat();
myTextFormat.font = "Christopherhand";
myTextFormat.size = 40;
myTextFormat.color = 0xFFFFFF;
}
function initStyleSheet(cssString:String):void {
myStyleSheet = new StyleSheet();
myStyleSheet.parseCSS(cssString);
traceStyles(myStyleSheet);
}
function initTextFields():void {
text1 = setTextfield(myStyleSheet, "StyleSheet", false, 0,0);
text2 = setTextfield(myStyleSheet, "StyleSheet", true, 0,188);
text3 = setTextfield(myTextFormat, "TextFormat", false, 250,0);
text4 = setTextfield(myTextFormat, "TextFormat", true, 250,188);
for (var i:int = 1; i<=4; i++) {
addChild(this["text"+i]);
}
}
function completeHandler(event:Event):void {
var cssString:String = event.currentTarget.data;
initStyleSheet(cssString);
initTextFields();
for (var i:int = 1; i<=4; i++) {
TextField(this["text"+i]).htmlText = "<span class='header'>| Dorem ipsum |</span>";
}
trace("******** TextField-Content:String *********");
for (var i:int = 1; i<=4; i++) {
trace(TextField(this["text"+i]).htmlText);
}
trace("******************************************");
trace("");
}
function setTextfield(defaultFormat:*, type:String = "TextFormat", embed:Boolean = true, x:int = 0, y:int = 0 ):TextField {
var t:TextField = new TextField();
t.x = x;
t.y = y;
t.width = 250;
if (embed) {
t.embedFonts = true;
} else {
t.embedFonts = false;
}
if (type == "TextFormat") {
t.defaultTextFormat = TextFormat(defaultFormat);
//trace(t.getStyle);
} else {
t.styleSheet = StyleSheet(defaultFormat);
//trace(t.styleSheet.getStyle("text1"));
}
t.antiAliasType = AntiAliasType.NORMAL;
t.wordWrap = true;
t.autoSize = TextFieldAutoSize.LEFT;
t.multiline = true;
return t;
}
function traceStyles(style:StyleSheet):void {
trace("****** CSS Data Content ********");
var styleNames_array:Array = style.styleNames;
for (var i = 0; i<styleNames_array.length; i++) {
var styleName_str:String = styleNames_array[i];
var styleObject:Object = style.getStyle(styleName_str);
trace(styleName_str);
for (var prop in styleObject) {
trace(" "+prop+": "+styleObject[prop]);
}
trace("");
}
trace("************************************");
trace("");
}
function traceFonts():void {
var embeddedFontsArray:Array = Font.enumerateFonts(false);
trace("****** Show embedded Fonts ********");
for (var i:uint = 0; i < embeddedFontsArray.length; i++) {
trace((i+1)+".) fontName: " + embeddedFontsArray[i].fontName);
}
trace("***************************************************");
trace("");
}
init();
|