Importing Text Into A Scrollable Text Field - HELP -

i am following the instructions on the page:

http://www.macromedia.com/support/flash/ts/documents/scrolling_text_mx.htm

and i am able to load the text properly, but my question is how do i load another text file into the same text box? i want the previous text to be erased and be replaced by the new text from the new text file.

i am useing the following code to load the first text file into the text box:

LoadVarsText = new LoadVars();
LoadVarsText.load("test.txt");
LoadVarsText.onLoad = function(success) {
      if (success) {
            scroller.html=true
            scroller.htmlText = this.var1;
      } else {
            trace("not loaded");
      }
};

this works properly, but what code would i need to load another text file? i tried useing the same code but just changing

LoadVarsText.load("test.txt");

to

LoadVarsText.load("secondtest.txt");

but it does not seem to work. for some reason i am not able to change what appreas in the text box after i have loaded the first file into place.

could someone please advise me?

thx.
LVL 1
moe10Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

OBCTCommented:
I don't totally understand...do you want to load the second txt file straight after the first has loaded?
The easiest way to erase the first file and load the second would be by having two key frames, both with buttons to get from one to the other and have both frames consist of the same code except with different txt file names.
If you could explain in a bit more detail what you are trying to achieve, I could help alot more.

Cheers

-OBCT
moe10Author Commented:
sorry about not being clear, i will try to explain myself better.

at the begining of the movie a text file is loaded into a texbox with the code i posted above.

there is a button in the movie to go to a later frame that is suppose to load a different text file into the same text box as in the first frame

my problem is when i try to load the second file nothing happens. the text from the first file remains in the text box.

the code i use to load the second text file is the exact same as the first code that i used, just the text file name is changed, but for some reason it will not work.

i hope i have made my problem more clear.
OBCTCommented:
Try this on the second frame that you want your text on:

LoadVarsText2 = new LoadVars();
LoadVarsText2.load("test.txt");
LoadVarsText2.onLoad = function(success) {
     if (success) {
          scroller.html=true
          scroller.htmlText = this.var1;
     } else {
          trace("not loaded");
     }
};

If that doesn't work, check your secondtest.txt to see if there is a variable for flash to read. e.g. &news=This is my news    -In that example flash would print out "This is my news" in the dynamic text box with the var name of "news". So just check to see if that's set up right.

If that doesn't work then try duplicating the scrolling movie clip or add a new dynamic text box etc. Because I can't see the .fla, it makes it hard to know exactly how to fix it.
I hope this has helped.

Cheers

-OBCT
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

OBCTCommented:
Sorry, the code I was meant to post was this:

LoadVarsText2 = new LoadVars();
LoadVarsText2.load("secondtest.txt");
LoadVarsText2.onLoad = function(success) {
     if (success) {
          scroller.html=true
          scroller.htmlText = this.var1;
     } else {
          trace("not loaded");
     }
};
moe10Author Commented:
thank you that does work.

but does that mean i have to create a new var every time i want to load in a different text file?

i have many different text files that i would like to load so could you suggest a different method?
moe10Author Commented:
ok i think i found out what my problem was before, and it is still a problem.

if you use a button to call the second script to load the text file it works fine. and you can just update the text field by changing the text file name.

but if that you edit that button and there is a button within that button. and that sub-button has the script to load the second text file it will not work for some reason.

i will upload an example of what i'm talking about. please take a look at it if you have time.

http://www.angelfire.com/d20/johnjohnjohn/text_scrollMX.ace

thx
OBCTCommented:
If you use a button in a button it will not work because flash needs to detect the mouse down, eg. on (release) {
When you put a button in a button, the script will not work. If you have actions on a button in a button, flash will want you to click the button at exacltly the same time it's being clicked, which is physically impossible. If that makes any sense....
I can't open the file on my computer for some reason, I don't think I have any programs that support .ace

I've been trying out a few different methods of loading new text files by clicking a button and there's two simple and logical ways you can this.

The first one would be by having a button to cater for each text file you want loaded.
So you would have exactly the same code for all of them except the name of the text file would be different.

The second way you could do this would be by having you load vars code in each keyframe. So if you want the next text file to load...you click the button which takes you to the next frame, and in that frame has the code to load up your new text file. You could have just one button for this that just goes to the next frame once it's clicked.

If you give me 5 minutes I'll quickly make an example. I'll make it in Flash Mx, so it works if you have just Mx or Mx 2004.

Cheers

-OBCT

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
OBCTCommented:
Well it looks like my server isn't working so I'm happy to email it to you.
My email address is wrenasourus@hotmail.com

Cheers

-OBCT
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Adobe Flash

From novice to tech pro — start learning today.