all groups > flash actionscript > april 2005 >
You're in the

flash actionscript

group:

problem with text length of external text file


problem with text length of external text file zzdobrusky
4/17/2005 12:00:00 AM
flash actionscript:
Hi, I am creating news ticker, text from external txt file is loaded into text
box and then the box as a symbol is moved to the left, everything works great,
except I just cannot get the correct length of the txt string I am loading from
txt file (i need it to start ticker over and over), the actual txt when it
scrolls is correct but when I try to trace it or find its lenght it gives me
very weird : trace(news_content) '<p align='left'></p>' and
news_content.length = 20 The actual content of external text file is :
news_content=This is to show a news ticker, all text is from external text
file, <b>This is bould</b> and <a href='http://www.macromedia.com'>this is
link to Macromedia</a>. and as I said it shows inside my news
ticker!!!!!!!!!!!!!!! So what is happenning? Any help or advice? Search gave me
no ideas so far. :-) Zbynek
Re: problem with text length of external text file kglad
4/17/2005 12:00:00 AM
flash adds tags to the htmlText of textfields. if you were just loading a html
text string, flash wouldn't be adding any tags.

to access the string length of news_content, store that value after loading is
complete and before assigning html-text to your textfield.
Re: problem with text length of external text file zzdobrusky
4/17/2005 12:00:00 AM
Hi, thanks for your answer, I guess that would solve the problem, but I beeing
dumb how to do it, I changed the name of text variable for dynamic txt box to
news and news_content is variable in external txt file, right now it gives me
for trace(news_content): undefined and other traces are: news_content.length =
undefined newsLength = NaN and the code attached to movie clip with dynamic box
looks like this: onClipEvent (load) { //loading external
txt file loadVariables('news.txt', this); trace(this.news_content);
//setting speed of scrolling speed = oldSpeed = 2; // some bumb before
starting over bump = 30; //Courier New 16 monospaced letter charLength =
9.833; // start x position start_x = this._x = 400; //calculating the
length of txt newsLength = news_content.length * charLength;
trace('news_content.length = ' + news_content.length); trace('newsLength = '
+ newsLength); //news is variable attached to dynamic txt box news =
news_content; } on(rollOver) { speed=0; } on (rollOut) { speed = oldSpeed; }
onClipEvent (enterFrame) { this._x -= speed; //when out of txt all over from
the beginning if (this._x < -(newsLength + bump)) { this._x = start_x; } }
external file is news.txt: news_content=This is to show a news ticker, all text
is from external text file, <b>This is bould</b> and <a
href='http://www.macromedia.com'>this is link to Macromedia</a>. Any advice
what's wrong? Thanks
Re: problem with text length of external text file kglad
4/17/2005 12:00:00 AM
you're trying to use that textfile before loading is complete. try:

onClipEvent (load) {
//loading external txt file
loadVariables("news.txt", this);
}
onClipEvent (data) {
trace(this.news_content);
//setting speed of scrolling
speed = oldSpeed=2;
// some bumb before starting over
bump = 30;
//Courier New 16 monospaced letter
charLength = 9.833;
// start x position
start_x = this._x=400;
//calculating the length of txt
newsLength = news_content.length*charLength;
trace("news_content.length = "+news_content.length);
trace("newsLength = "+newsLength);
//news is variable attached to dynamic txt box
news = news_content;
}
Re: problem with text length of external text file zzdobrusky
4/18/2005 12:00:00 AM
Thanks a lot, that was it! That was supposed to be a half an hour project and
it took me half a day :-) ! I guess nothing goes easy, at the same time it
makes me think that Flash actionscript is hard to learn. Have a great day,
Zbynek
Re: problem with text length of external text file kglad
4/18/2005 12:00:00 AM
AddThis Social Bookmark Button