Solved

Importing Text Into A Scrollable Text Field - HELP -

Posted on 2003-11-23
8
482 Views
Last Modified: 2010-04-03
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.
0
Comment
Question by:moe10
  • 5
  • 3
8 Comments
 
LVL 9

Expert Comment

by:OBCT
ID: 9807900
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
0
 
LVL 1

Author Comment

by:moe10
ID: 9808003
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.
0
 
LVL 9

Expert Comment

by:OBCT
ID: 9808086
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
0
 
LVL 9

Expert Comment

by:OBCT
ID: 9808088
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");
     }
};
0
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
LVL 1

Author Comment

by:moe10
ID: 9812728
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?
0
 
LVL 1

Author Comment

by:moe10
ID: 9813005
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
0
 
LVL 9

Accepted Solution

by:
OBCT earned 79 total points
ID: 9816639
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
0
 
LVL 9

Expert Comment

by:OBCT
ID: 9816689
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
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

This is intended to introduce all collision detection principles in flash, their strengths, weaknesses and workarounds. The main method for Collision Detection in flash is using hitTestObject. But unless you'll be pushing rectangular shapes without …
Sometimes you know that one object has a specific child in it, but you can't find the child. This happened to me when I was trying to code some actionScript to make a toolbar work with its embedded buttons.  My partner had created the toolbar usi…
The goal of the tutorial is to teach the user how to how to load their YouTube profile onto Flash Media Live Encoder.
This Micro Tutorial will teach to how to utilize bit rate in Adobe Flash Media Live Encoder.

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now