Tuesday, September 27, 2005

Externally Loaded .txt files

First, create your text file. Do this with a basic notepad. I am going to use the variable mymessage, so my .txt file would be formatted like this:

&mymessage= Hi, this is my message
Welcome to my site!
More stuff here and here
-----END&



Make sure to add the &'s at the beginning and end. Now just save your .txt file as text.txt(Also, check the .txt file in the download) Now open up your swishmax. Create a dynamic text file, name it message, click the target button and give it the variable of mymessage(or the same thing in your .txt file)..and add this code to your scene:

onLoad () {
loadVariablesNum("http://yourdomain.com/text.txt",0,'GET');
}


Please change the http://yourdomain.com/text.txt to your file, or you can keep it there, because I have a file that is uploaded there Now we will do the easiest part, the scroll buttons (Too hard to explain scrollbars or anything like that) So make a up button, with the code:

on (press) {
Message.scroll -= 1;
}


and a down button with the code:

on (press) {
Message.scroll += 1;
}


Both these refer to Message, which is what I put in the name of the text, not the variable. Hope this helps... Also, I would like to include this info from John: Also while your at it try altering the TEXT to the HTML format [in the "text" section select "Formatting" and then select " <> " "render text as HTML" ] ( much clearer text and then do things like add colour and links such as Swish Tutorials to the notepad text file..

3 comments:

Anonymous said...

i have checked, and double-checked, a million times, and this just won't work for me.
I'm using SwishMax 2005.8.15.
I've tried a million times, but all I get is an empty page. No text loaded.

I have the txt file in the same directory as the swf (but I even tried it on my server - still didnt work).
Followed each of your steps:
dynamic, named "message", variable name "mymessage", text.txt (containing an exact copy and paste of your sample - including the &'s), included the code:
onLoad () {
loadVariablesNum("text.txt",0,'GET');
}

But it just wont work!!!!!!!
What's wrong?!

All I want is a text box that will display whatever is written in an external txt file. =(

Radu Ciuca said...

for anonymous
at the up and down buttons put

on (press) {
_root.message.scroll += 1;
}

and

on (press) {
_root.message.scroll += 1;
}

"_root."

Anonymous said...

hi., it works well when loaded in the scene. however when i load it to a sprite the text doesn't show.
i have a button that loads a sprite, in the button i entered wn_window.loadVariablesNum("http://absrnd01/test/testload/text.txt",0,'GET')
where: wn_window is the name of the sprite.. please help me.