Dynamic text, on click

Hello, here are the basics of what i am trying to do in flash mx:

have 4 or 5 text links.

have a text “area”

when you click each link you get new text about that subject.

I have been through the tutorial on dynamic text and that works great.

But this is going to be made into a projector and I dont know how those text files will work with a projector.

Also, I need to figure out how to make the text change each time a link is clicked.

Please let me know if you know of a tutorial or something that will help me figure this out.

Thanks for your time,
Kenny

I can help you out with the changing text, and the fact that it’ll be made into a projector (I assume you mean into an exe?) shouldn’t matter cause it should still call those text files, which we’ll be loading. Alright, let’s start this out. We have a text “area” (which is just a <b>dynamic text box</b>) so now we set the variable (you can find it in the properties panel after you click on the text box) to something like <b>_root.currentText</b> (I like that name because I find that going back and looking at my old flas becomes less confusing with names like that). Okay! Now, whenever we change the variable <b>_root.currentText</b> the text box will automatically update it. Nice, right? Next, you’ve got a choice. You can either load <B>4 different text files</B> or you can load <B>1 text file</B>. If you’re still new to stuff, I’d say stick to the four text files. So, we’ll start with that method.

<B>METHOD 1: “simple’s always good”</B>
Let’s click on the <b>first</b> button (with the following code):


on(release)
{
//let's load ALL the variables from
//the text file into the _root
loadVariablesNum("theFirstTextFile.txt", 0);
}

Now, in our text file we have the following variable…


&currentText=Entry number 1. Wow, loading text is fun.&

WAIT! Wasn’t currentText the name of the variable we set for the text box? Yes, it is, since we loaded the variables into the root (so you’d access that one by _root.currentText). So, you clicked the button and the text loaded. Good. So, now we do the same thing for your other four or five other text files. You’ll only be changing the file that’s being loaded (on the different buttons), the file name (of the text file, that is), and that’s it. Great! That was easy.

METHOD 2: “we like complexity”
Well, maybe you just want one text file. So, let’s set that up first. Make a text file (let’s call it entries.txt). Now, let’s put the following stuff in it:


&entry1=First entry!&
&entry2=Second entry!&
&entry3=Third entry!&
&entry4=Fourth entry!&

Good. On the first frame of the entire movie, let’s load the text file.


loadVariablesNum("entries.txt",0);

Now, let’s work on the button code…So, first one…


on(release)
{
_root.currentText=_root.entry1;
}

Then you go on to the second button and just change which entry is loaded, understand? Cool, that was simple.

<B>CONCLUSION</B>
In both methods we are basically telling flash that the dynamic text variable _root.currentText is something, and it updates it for us. That’s it. Now, if you wanted to do something cool with the text box (like a transition effect), I’d find a movieclip prototype function that fades stuff. First, put your text box into a movieclip (if you haven’t already) and give it an instance name. Let’s pretend that it is called “fade();”…On each button, you’d have a call to fade like “instanceNameOfMCWithTextBox.fade();” Cool stuff, right?

Understand everything, okay? Good.

Later,
–Elios

P.S. Don’t double post.

That is awesome! Thank you for taking the time to give me such a long answer. I have it working great with 3 push buttons!

If I wanted to use text links instead of buttons…
All I have to do is create a new symbol… make it a button…
Define the 4 states of the button…
Then drag the new button symbol from the library to the stage.
Then in the actions of that button symbol add the actions in there that I used on the push buttons…

That sound right?

Thanks again for your time.
This helps me a wholeeeeeeee lot!

I just noticed that the scroll bars dont work…
I have plenty of text in there…
It is set to multiline…

Is it because I am using a variable for the text?

I figured out something about the scroll bars…
If I add some static text there that is long enough to make the scroll bars show up… then it works for when I click the buttons and load the text files…

I just need to figure out how to load a text file “onload” and then I will be set… except for figuring out how to use text links to do this…

Thanks again

Oh, I didn’t know you were using push buttons. I generally don’t like Flash MX components, but, you know, whatever floats your boat. As for the scroll bars scrolling your dynamic text, I ran into that problem before, but it kind of fixed itself when I just remade it (i.e. removed the scroll bar, removed the mc, put the mc back, used the scroll bar component again…). Now, make sure you’ve got your text box “Scrollable”, right click on it and if that option is unchecked, you’ll know what the problem is. At any rate, if that doesn’t work, you can try my method.

Later,
–Elios

hehe… well i would rather use text links…
but i used the buttons because I knew I could make it work with those…

I tried it with text links and could not get it to work…

The text box is set to scrollable…

I made another beside it to test it out…
and that one works… scrolls like a charm…

it has something to do with the fact that I have those variables defined on the dynamic text area…