Skip to main content
May 22, 2006
Answered

Using Variable Name problem with this_x

Hello to all (on a Sunday afternoon),

Briefly: Trying to load 32 movie clips (via the script below) onto the stage (dynamically). In theory, each clip (or box) will load through a For Loop and each name of the clip is loaded through the number created by the loop. The problem is the x and y position is ignored ONLY when I insert a variable name instead of "this" in f "this._x" or "this._y". (The variable I am using is _global.cl_Name) The clips load fine but all in the upper left hand corner of the stage.

Any help or variation on this theme would be appreciated.
Thanks
D.
This topic is closed to new replies. Start a new post to keep the conversation going.
2m91_2
2m91_2Correct answer
Inspiring
May 22, 2006
Hi,

try:

for (var initCounter:Number=1;initCounter<32;initCounter++) {
_global.cl_Name = (_global.cl_Prefix + initCounter);
if (xValue > 600) {
xValue = 30;
yValue = yValue + 90;
}
_root.attachMovie(_global.cl_Name,_global.cl_Name,(_global.clipHeight++));
//Trouble Area
_root[_global.cl_Name]._y = xValue
_root[_global.cl_Name]._y = yValue;
xValue = xValue + 80;
trace (initCounter);
}

2 replies

2m91_2
2m91_2Correct answer
Inspiring
May 22, 2006
Hi,

try:

for (var initCounter:Number=1;initCounter<32;initCounter++) {
_global.cl_Name = (_global.cl_Prefix + initCounter);
if (xValue > 600) {
xValue = 30;
yValue = yValue + 90;
}
_root.attachMovie(_global.cl_Name,_global.cl_Name,(_global.clipHeight++));
//Trouble Area
_root[_global.cl_Name]._y = xValue
_root[_global.cl_Name]._y = yValue;
xValue = xValue + 80;
trace (initCounter);
}
Translate
May 22, 2006
Hi 2m,

Excellent! You are the coder.

I can not fully understand that sqare bracket thing, but seem to overlook it all the time.
D
Translate