How do I tell an MC to read a variable from another MC?!?

Hi everybody,

Let’s see (this is somehow complex to explain :wink:
I have 5 buttons (English, Spanish, French…) in frame 2 which call different dynamic text files with different content according to the chosen languaje. Each button contains the following AS:

on (release)
{
loadVariablesNum (“tab_english.txt”, 0);
idioma=“tab_english.txt”
gotoAndStop(2);
}

(“tab_english.txt” for english, “tab_french.txt” for french and so on.)

In frame 1, I have the following AS:

idioma = “tab_spanish.txt”;

This way, default is Spanish.

In frame 2, I have this AS:

loadVariablesNum (idioma, 0);

Flash loads the text in the chosen language, and places a piece of this text in a dynamic text box that I’ve made for this purpose.
So, as an example, the bit of text corresponding to “Credits”: In every text file it can be found the following:

&credits=Made by Pete (for the English one)
&credits=Hecho por Pete (for the Spanish one, an so on for the rest of the languages).
Obviously, in the dynamic text box, the variable is called “Credits”.

So far, everything’s ok and it works properly. The problem comes when I try to load another MC (MC-2) inside the main MC-1:
This MC-2 has a text box which calls another variable “Services” from "tab_xxxxxx.txt. What I want is that this MC-2 loads the content of “Services” in the language that it was chosen in MC-1

Now, how should I do to transfer the “idioma” variable value from MC-1 to MC-2? Or, what it’d be quite the same: How do I tell MC-2 to read a variable from MC-1?

Something funny ¿?: MC-2, if loaded into MC-1 with static text property (not dynamic), then it’s loaded properly. What’s more, just to test this, I added a green background color to MC-2 and efectively, this color can be seen when using an static text but it doesn’t when switched to a dynamic text (so text won’t turn up either) ¿…?!?
The only piece of AS in this MC-2 is the following (in frame 1) Perhaps the mistake is here?:

stop ();
loadVariablesNum (/:idioma, 0);

Tha call from MC-1, it’s done from a button:

on (release) {
loadMovie (“MC-2.swf”,“MC-import”);
}

where MC-Import, is the name I’ve given to the instance where MC-2 is loaded.

I don’t know if I explained myself clearly enough. If not, somebody tell me and I’ll try to clarify it.
Thanks very much in advance.

Manare

intead of your on (release) {
idioma=“tab_english.txt”
}
try:
on (release) {
_root.idioma=“tab_english.txt”
}
then, include the _root. whenever you refer to your variable.

Thanks for your answer Mr.X.

However, by doing what you’ve recommended, now I get a “string” value/error in the output window.
I’ve been struggling my brains for a month or so with this topic and I can’t find a logic mistake in this AS coding. Sometimes AS in Flash really gets on my nerves!!..:q:

If I add this AS sentence in MC-2:
trace(typeof(_root.idioma));
It returns me “undefined” ???!?!?

Please heeeeelppp! :*(

you can create (simulate) a global variabel by doing this:

[COLOR=blue]Object[/COLOR].[COLOR=blue]prototype[/COLOR].your_variable= value;

[SIZE=1]this method is kindaof complicated, you cannot have any variables with the same name, and it could be changed any time any where. So, be carefull with that![/SIZE]

or:

you can refer to a variable in a relative position:

movieClipInstanceName.variableName

[SIZE=1]easy way[/SIZE]

=)

what do you get when you do just trace(_root.idioma); ?
also, I’m not familiar w/ loadVariablesNum. I think it’s deprecated after Flash 4, but you shouldn’t put the _root. thing there: loadVariablesNum (“tab_english.txt”, 0) cause it’s a string, you could probably just put that though: loadVariablesNum (_root.idioma, 0) once you find out if that variable’s value (w/ trace) is right.
Don’'t know if I’m really clear on that one… Sorry, just woke up and didn’t get my coffee yet! :wink:

Hi!
Thanks for your answers, unfortunately the problem persists.
Guig0: By changing these parameters you suggest I still don’t obtain the desirable effect.
Mr.X: No, the loadVariablesNum (“tab_english.txt”, 0) seems to be correct. The buttons load the proper language when clicked. What it does not work is when calling the language from another movie clip (here MC-2): The text is not displayed and it is not switched to the chosen language.
If I do a trace(_root.idioma) from MC-2, I get nothing.
Pitty I can’t test if variables are loaded in MC-2 by doing the typical ALT-CTRL-V, as the result I get belongs to MC-2.

Please, help again!..I’m already desperate with thisss
Manare

If nothing that I or Mr.X told you helped, maybe it is another problem…

post your fla here, and we see what we can do.

=)