PDA

View Full Version : scrollable texts in MX



catreya
May 30th, 2003, 05:20 PM
This is regarding the tutorial at Kirupa.
http://www.kirupa.com/developer/mx/dynamic_scroller.htm

For loading the text from a txt document i am using the following code (which is the same as Kirupa's code - except for the names)

/* Load Welcome Message */
loadText = new LoadVars();
loadText.load("welcome.txt");
//creating the loadVarsText function
loadText.onLoad = function() {
scrollableText.text = this.welcometext;
};
/* End of Welcome Messge */


However, only the first three words of the txt doc file is displayed.

I am not using the component scroller but using my own buttons and codes for scrolling vertically. Those codes are:

on (press, release, keyPress "<Up>") {
currentScroll = scrollableText.scroll;
if (Number(currentScroll)>1) {
scrollableText.scroll = currentScroll-1;
}
}

on (press, release, keyPress "<Down>") {
currentScroll = scrollableText.scroll;
if (Number(currentScroll)<Number(scrollableText.maxscroll)) {
scrollableText.scroll = Number(currentScroll)+1;
}
}


If i declare the value of the variable "scrollableText" within the actions panel then it works.

catreya
May 30th, 2003, 05:27 PM
Would you believe it? I close the flash program and restarted it and it worked!

Wonder wat the magic is!!!!

:whistle:

catreya
May 30th, 2003, 05:47 PM
Now me thinks if there is a way to go about unloading the txt file??? I have looked at the functions of flash but could find nothing that could be of help.

Any suggestions???

catreya
May 30th, 2003, 07:26 PM
got it. but i cant unload. just give a null value to the textbox.

catreya
May 30th, 2003, 08:12 PM
now I am stuck. I converted the dynamic text loading into the prototype on the main time line.

MovieClip.prototype.hometext = function() {
loadText = new LoadVars();
loadText.load("a.txt");
//creating the loadVarsText function
loadText.onLoad = function() {
scrollableText.text = this.b;
};
/* End of Welcome Messge */
}


now i goto into a button (which) is not the main time line and give this code

on (release) {
.
_root.hometext();
}


This button in the main time line is a movie clip - but acts as a button once u get into it by pressing CTRL-E. (sorry dont know the terminology yet)

So the on release event is not on the main timeline. The above doesnt work. I have tried variations like:

_parent.hometext();
this._root.hometext();
this._parent.hometext();


dont work. Am i doing the right thing here?