View Full Version : Help with dynamic scroller

11-20-2001, 07:15 PM
I have created a scroller that loads the text from the text file dynamically. (flash generates the variable names)

when I try to call the text into the scroll box I have to access another movie to get the name of the variable.


windowtext = _parent._parent._parent.nav.w;

11-20-2001, 07:15 PM
w is the result of a calculation that gives me a random name.
for arguments sake let's say that w=scott1.

Now, scott1 is a variable in my text file and contains the info that I want displayed in my scroll box.

But....and here it comes. when the variable is called into the scroll movie, windowtext sees it as a string not a variable. Thus it dispalys scott1 in the window.

Now at lunch I did some reading. I came accross an article that is about complex paths. It included instructions on how to use [] to convert strings into variables. I have tried to use this info but when i trace(typeof(windowtext)) it comes back undefined.

11-20-2001, 07:17 PM

20 Ton Squirrel
11-20-2001, 07:39 PM
Ooooooooooooh, okay. Gotcha, I understand your question now. Having trouble posting or something?

Ummm, okay, you are on the right track with using the brackets for evaluation. Take this example...

I have an MC on my stage called targetMC1.

whichMC = "targetMC1";

Make sense? The brackets tell Flash to evaluate whatever is in those brackets on the level that was last designated... ummm, that didn't make much sense to me, so I'll show another example...

whichMC = "subMC";
_root["targetMC" + 1][whichMC].play();

See how that works? This would literally evaluate out to:

The use of the brackets for evaluation is ever-so-much better than the actual use of the eval() function. Just experiment and you'll get the hang of it.

11-20-2001, 08:02 PM
Sorry about posting twice I didn't realize I had I thought I deleted that post.

I have been playing around with the [] but haven't been able to get them to work properly.

This is what I have tried:

I need windowtext = scott1
in another movie scott1 is created here (in relation to windowtext)

At first I tried:

windowtext = _parent._parent._parent.nav.w;

that gave me scott1 displaying in the scroll box.
After I read about [] I was hoping to get away with.
windowtext = _parent._parent._parent.nav[w];
so I can acces the info held in the variable in the .txt file and diaplay that in the scroll box.

When I added the [] to windowtext = _parent._parent._parent.nav[w]; and traced windowtext it came back un defined. Am I using the [] wrong? if so how can i make:

windowtext = scott1; (scott1 located (_parent._parent._parent.nav.w;))
by accessing the scott1 from another movie?

20 Ton Squirrel
11-20-2001, 08:18 PM
Yoru first attempt at using the brackets should have worked. Is your [FONT=courier new]scott1[\FONT] variable located three levels back inside a MC called [FONT=courier new]nav[\FONT]?

windowtext = _parent._parent._parent.nav[w];

Check your pathing... could you list out what MCs you have from the root leading all the way to where you are calling this statement from? Something like:

Just so I can visualize what you are doing here....

Do you need to dynamically reference the variables by using _parent or can you do a static reference to it like:


Alternatively, you could post up your FLA and we can vivisect it.

11-20-2001, 08:43 PM
Before I rip into the pathing situation:
I would like to keep the path to w relitive so I can call the scroller from other clips. I'll have to find a away to get w on the the _root of the load movie so the path can be rewritten _parent._parent._parent[w];

Also If i eliminate the [] the current script will write scott1 in the scroll box. So I'm sure it leads to the right path.

I have noticed two things in all of the examples when using [].
One _root is always the path. Is this a design or is it because it is easer?
Two, there is always an action after eg _root["mc"+1].play (); Can I use the [] to re define a variable? eg wer=_root["mc"+1]