Skip to main content
June 14, 2006
Answered

Variables

var t3 = "Hello world";
var tn = 't'+_currentframe; //_currentframe now is iqual 3
trace(tn);

tn shoud be "Hello world", but I'm getting that tn is equal to t3.

Thanks in advance
This topic is closed to new replies. Start a new post to keep the conversation going.
Newsgroup_UserCorrect answer
Inspiring
June 14, 2006
"norbit" <cel@web-engineer.co.uk> wrote in message
news:e6p884$ss5$1@forums.macromedia.com...
> var tn - this['t'+this._currentframe]

Apart from the typo (= not -) .. that would fail if inside a function,
because you cannot get to local vars (declared with var) using this[]
notation.

Better is to use

var tn = eval('t'++this._currentframe);
--
Jeckyl


5 replies

June 14, 2006
Thanks

I use the code as:

this.onEnterFrame = function() {
stop();
fondo.tema = eval('t'+this._currentframe);
if (_currentframe == 1) {
nextback(false, true);
} else if ((_currentframe == _totalframes)) {
nextback(true, false);
} else {
nextback(true, true);
}
};
Translate
June 14, 2006
I use the code as:

this.onEnterFrame = function() {
stop();
fondo.tema = eval('t'+this._currentframe);
if (_currentframe == 1) {
nextback(false, true);
} else if ((_currentframe == _totalframes)) {
nextback(true, false);
} else {
nextback(true, true);
}
};
Translate
Newsgroup_UserCorrect answer
Inspiring
June 14, 2006
"norbit" <cel@web-engineer.co.uk> wrote in message
news:e6p884$ss5$1@forums.macromedia.com...
> var tn - this['t'+this._currentframe]

Apart from the typo (= not -) .. that would fail if inside a function,
because you cannot get to local vars (declared with var) using this[]
notation.

Better is to use

var tn = eval('t'++this._currentframe);
--
Jeckyl


Translate
June 14, 2006
Thanks norbit
Translate
Participant
June 14, 2006
this is the right behavior! tn will be equel to the string "t3" in your example

i think what you meant to do was -

var tn - this['t'+this._currentframe]
Translate