Setting variable - help please

I have applied the following code to a button:

on (press, release, keyPress “<Down>”) {
gallerycount = gallerycount+1;
if (gallerycount<2) {
gallery = gallery1;
} else {
gallery = gallery2;
}
}

the variable “Gallery” is a dybamic text field variable. The code loads diffrent text from txt file based on key presses. For some reason (maybe I’m being stupid) the code loads the text then instantly disappears?

Any ideas? more info?

thanks in advance guys!!

I didnt understand what exactly you are tring to do.
Are you loading an external txt file? Which event changes the textfield content? Which vars are on the external txt?
:-\

Yeah sorry, I probably didn’t explain well.

Yeah, I’m loading an external text file.

The vars in text file is:

gallery 1 & gallery2.

I want to change the contents of textfield by the click of the button.

any ideas?

Maybe this helps you.

claudio thanks a lot mate!!

That helped me 120%

I got it working - I learnt some new conepts from that.

Thanks again.

Glad I could help
:slight_smile:

claudio.

1 last thing: in your AS you done this:-

loadText[“text”+count]

cool.

can you do a simular thing to a variable assignment?

e.g. I want to set variable “gallery” to the contents of “gallery1”, “gallery2”, etc…

I did this:

    gallery = "gallery"+gallerycount;

what i get is the litteral string GALLERY2 rather than the contents of “gallery2”. whats the best way forward?

Hmm again i am confused :stuck_out_tongue: :stuck_out_tongue:
Maybe if you explain what you are trying to achieve… :slight_smile:

Ok…

I want to do what you have done in your fla, but slightly different.

When the button is pressed I want the variable “gallery” to equal the contents of “gallery1”, “gallery2”, etc. loaded from text file.

I have done this:-

gallerycount = 1;
loadVariables(“data2.txt”, this);
b1.onPress = function() {
if (gallerycount != 1) {
gallerycount–;
gallery = “gallery”+gallerycount;
}
};
b2.onPress = function() {
if (gallerycount != max) {
gallerycount++;
gallery = “gallery”+count;
}
};

gallerycount, max, gallery1 and gallery2 all loaded from textfile.

when I press the button I get for example: gallery2
as a string literal NOT the text in textfile…

is that clearer? let me know If u want more info?

any ideas?

I have not tested this and dont know what you are trying to acomplish, but try this:[AS]max = 4;
gallerycount = 1;
loadText = new loadVars();
loadText.load(“data2.txt”);
loadText.onLoad = function(OK) {
if (OK) {
mytext.text = this[“gallery”+count];
} else {
trace(“Error”);
}
};
b1.onPress = function() {
if (gallerycount != 1) {
gallerycount–;
gallerycount = loadText[“gallery”+gallerycount];
}
};
b2.onPress = function() {
if (gallerycount != max) {
gallerycount++;
gallerycount = loadText[“gallery”+count];
}
};[/AS]

I am trying to achieve exactly what you have done, but in a Flash 5 way.

I understand ‘loadVars’ is a Flash MX feature. I understand your code, and know it should work (apart from 1 thing), what I want to do is mimic this line (I have amended the line):

gallery = loadText[“gallery”+gallerycount];

in my code: gallery is my textfield variable. In the line above we set the variable gallery to “gallery”+count so if count = 2 gallery will = gallery2 right?

gallery2 is loaded from textfile and will now display gallery2’s text.

In my code I want to do this (lets say gallerycounter is 1):

  1. press button
  2. increment gallerycounter
  3. now gallerycounter is 2
  4. set gallery to the contents of the following:
    gallery1
    gallery2
    gallery3 etc…

to set gallery i’m doing this:

gallery = “gallery”+gallerycount

…it doesn’t work cause gallery now prints “gallery2” in words as apose to the CONTENTS of the variable gallery2.

so my question is, how do I pass the value instead of the words “gallery2”?

A big thanx if u can crack this 1.

Im a litttle bit confused, nut if you use the code i provided, it will load the variables in the txt file. :hangover: