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

I believe you would have to load the text in via the LoadVars object and then assign it to the ‘text’ property of your text field… a little tricky in your case because now you would have 2 data files being loaded simultaneously (css and text files) and you need to make sure both are loaded before setting the text. (Unless the text is automatically reformatted after CSS is loaded which I don’t think it is).

Let me know if you’d like to see some sample code…

Yes I would love to see some sample code. Anything that would help I am open arms to.

Thank You!

Flash_Boi

i reposted the fla doc up above…please take a look at it…Thanks!

Ok- I didn’t test this or anything, but here’s the basic idea:

import TextField.StyleSheet;

var myStyle:StyleSheet = new StyleSheet();
var myStyle_loaded:Boolean = false; // new code here !
myStyle.load(“mystyles.css”);
myStyle.onLoad = function(success:Boolean) {
newsLetterTop_txt.styleSheet = myStyle;
newsLetterTop_txt.html = true;
myStyle_loaded = true;
setNewsText();
};

var myText:LoadVars = new LoadVars();
myText.load(“dpmoreinfo.txt”);
myText.onLoad = function(s:Boolean)
{
setNewsText();
}

function setNewsText()
{
if (myStyle_loaded && myText.loaded)
{
newsLetterTop_txt.text = myText.dpmoreinfopage;
}
}

Hi,

I have this file which I created from http://www.tutorialized.com/tutorial/Tab-menu-design-and-implementation/11499 where the actionscript works in Flash Player 6 but when I publish into Flash player 7 or 8 it does not seem to want to play.

It gets a pop up message stating:
“A script in this movie is causing Flash Player to run slowly. If it continues to run, your computer may become unresponsive. Do you want to abort?”

My purpose to get this working in Flash 8 is because I need to incorporate CSS Stylesheets externally.

Here is the following actionscript:

stop();
numberOfTabs = 3;
for (i=1; i<=numberOfTabs; i++) {
line = eval(“tab”+i);
line.onRelease = function() {
for (i=1; i<=numberofTabs; i++) {
otherTabs =
eval(“this._parent.tab”+i);
otherTabs.bottomLine._visible =
true;
}
this.bottomLine._visible = false;
contentFrame = Number (this._name.substr(3,
1));
this._parent.contents.gotoAndStop(contentFrame);
}
}
tab1.bottomLine._visible = false;

tab1.onPress = function() {
gotoAndStop(“tab1”);
};

tab2.onPress = function() {
gotoAndStop(“tab2”);
};

tab3.onPress = function() {
gotoAndStop(“tab3”);
};

How does it need to be changed?