Groups | Blog | Home
all groups > flash actionscript > january 2006 >

flash actionscript : dynamicly loading text into a scroll bar thats within a actionscript loaded movieclip!


IndieMonkey
1/23/2006 8:44:52 PM
Hello,

Im stuck! I used a tutorial on kirupa.com that teaches you how to dynamicly
load text from a notepad file into a scroll box! Heres the tutorial

http://www.kirupa.com/developer/mx/dynamic_scroller.htm

Which is all good, except when I put the scrollbar into a movieclip that was
dynamicly loaded when a button is pressed it didnt work. The movieclip that
gets loaded had the scroller an the following actionscript in it:

loadText = new loadVars();
loadText.load("kirupa.txt");
//creating the loadVarsText function
loadText.onLoad = function() {
scroller.text = this.kirupatext;
};

I think its a path issue but im not entirely sure how it works! :confused; if
anyone could help me out, I'd appreciate it loads!

Thank you if you read this far!

Gavin
TPK
1/23/2006 9:05:23 PM
Hi Gavin,

I had the same problem. Are you using Flash 8? I took a different approach
that seems to work (except now I am trying to cause the scroll bar to hide when
it isn't needed). I got it by looking at the Flash source files that came as
samples with the program.

Here is the code I used as a tutorial. You may be able to adapt it to your
needs.
I tried using loadVars and had limited success. This seems to work better.

var myStyle:TextField.StyleSheet = new TextField.StyleSheet();
myStyle.load(?sample.css?);
content_txt.styleSheet = myStyle;

content_txt.multiline = true;
content_txt.wordWrap = true;
content_txt.html = true;


var story:XML = new XML();
story.ignoreWhite = true;
story.load(?sample.html?);
story.onLoad = function() {
content_txt.htmlText = story;
}

This code grabs text from a HTML file called "sample.html" and applies CSS
styling (from sample.css) to it. The text file can have HTML formatting
embedded in it that will affect the display.

Definitely look at the file samples that came with the program (MX, MX 2004,
or 8). They may shed additional light on the subject.

TPK
AddThis Social Bookmark Button