Text file var decides which button is correct

Hi,

I was wondering if anybody would have some input on this.

I have three paths in my movie, p0, p1 and p2 (instance names). These paths are buttons and when I click on the right button I will get a message saying congratulations, if I click on the wrong button I will get a message saying wrong path.

The catch is, a text file will contain the info on which button(path) is the correct one.
The text file will contain, p1=true&, nothing else.

This text file will change every time the game is played so I was hoping if some one would be able to help me.

Does anyone know the action script that will check the var in the text file and assign the correct path(button) as the successful outcome???

Hi,
Simply use loadVariables command like this:

loadVariables (“data.txt”, “container”);

where container is an instance of a movieClip symbol.
Providing your buttons are inside the container clip use this code:

on (release){
if (this.p1){
trace(“yes”);
} else{
trace(“no”);
}
}
data.txt is a file that contains this:
p1=1

Note that I use 1 rather than true (1=true , 0=false)

Thanks for your help.

I have a couple of questions. Forgive me as I am new to flash.

How do you mean store the buttons in the movie clip container?

At the moment I just have a Layer called Buttons with the three buttons on it. Do Ihave to change this to a layer called Movie Buttons(for e.g.) and make all three buttons part of a Movie Clip in that layer?

Is that what you mean by saying "Providing your buttons are inside the container clip "?

And finally where should I type the code?
In the Actions layer along with all my other Actions in the main timeline?

Thanks in advance!

Hi,

What you say :

"At the moment I just have a Layer called Buttons with the three buttons on it. Do Ihave to change this to a layer called Movie Buttons(for e.g.) and make all three buttons part of a Movie Clip in that layer?

Is that what you mean by saying "Providing your buttons are inside the container clip “?”

it’s just right.

What I would do is select all three buttons (****-click to select several) that should be in a layer and press F8 (convert to symbol). Finally give it an instance name (‘container’ in this case).

You should put the first part of the code , where you load the variables in the first frame in the main timeline.

The rest of it (on release events) have to be applied to the buttons themselves.

cya

I appreciate that.

Thanks!

Any time!

:slight_smile: