PDA

View Full Version : Dynamic Variables?


Selinium
03-03-2004, 05:06 PM
I am trying to pas a variable $pageVar_str; to the centre_Txt.htmlText in a seperate movieclip.

Here is the code in frame one of the main time line.


stop();
var $pageVar_str; // Variable to display Page content
_global.$pageVar_str = "home";

Here is the code for the movie clip.

//this.createTextField("centre_Txt",0,250,20,300,560);
// Variable to display Page content
trace ($pageVar_str);
centre_Txt.border = false;
centre_Txt.wordWrap = true;
centre_Txt.borderColor = 0xcccccc;
centre_Txt.html = true;
_global.textVars = new LoadVars();
textVars.load("textVars.txt");
textVars.onLoad = function() {
centre_Txt.htmlText = textVars.$pageVar_str;
};
trace (textVars.$pageVar_str);

I have traced the value of $pageVar_str; and at this point it is equal to "home" as i want it.

what I am trying to acheive is the line 'in red' to dynamically read as :
centre_Txt.htmlText = textVars.home;

Where am I going wrong?

Any help gratefully received!

Cheers

James

nthpixel
03-03-2004, 06:55 PM
Did you try

centre_Txt.htmlText = textVars[pageVar_str];

Selinium
03-03-2004, 07:20 PM
I will give it a go, heading to bed (00:20 GMT) so I will post if it works tomorrow.

Thanks again.

James

Selinium
03-04-2004, 05:09 AM
Cheers, the code I used in the end was,

textVars.onLoad = function() {
centre_Txt.htmlText = textVars[$pageVar_str];
};


Works a treat!!

Thanks again, your a star!


James