_global isn't global

Can anyone tell me if I have to use _root instead of _global?
I am loading a movie into an empty movie clip,
but when it is loaded it seems to have it’s own _global object!

Like maybe all the core objects are the same,
but anything I put in there isn’t.
The loaded movie sees objects it has created in _global,
but not the objects that were already created in _global
before it was loaded.
And vice-versa for the _root movie.

Anil

Here is some code from the movie that is loaded:
_global.hello=“hello”;
_global.another=“whatdyanow”;
for(one in _global){
this.status+="
"+one;
}
It displays ‘hello’ and ‘another’ in the ‘status’ textfield.
But nothing else.

Here is some code from the existing _root movie:
for(one in _global){
Y.Log(one);
}
The Y.Log code displays all the properties and sub-objects
(including the Y object which it is a sub-object of, in _global)
that are placed in _global by the _root movie,
but not “hello” and “another”.

Just use _root, unless you really need the scope of the variable to be available in all areas of your movie. As it is, all objects in Flash MX have _global properties, that is why you see them as such. It is much simpler to simply use your variables with _root. That should simplify matters.

Wow! That is the quickest reply!
Thanks for your help IAmMontoya…

Actually, yes, I did rather want the object to be totally global.
That’s why I used _global!
It is crucial that it is global, I have to find a way round this.

I guess using _root will work,
I am about to try it out right now.
But I find _global simpler (when it works),
because the target path is cleaner.
I like shorter identifiers,
especially when the code gets complex,
which it will.

I guess I’d just like to know whether _global is actually global,
if I’m just using it in the wrong way…
Or whether when Macromedia say _global is global they are lieing.

At least then I can happily go on my way to make a kludge,
without thinking I am missing out on it being better.

Thanks for your time and consideration.
Anil

_global is global… which really means that once you do

_global.myvar=100;

you can reference myvar by itself, and it should recognize it anywhere in any movie clip. You do not have to use _global.myvar to reference it again.

Now it’s really getting tough.

Yes, _global SHOULD be _global.
I SHOULD be able to access any _global subobject,
without using any target path.
I can do this:
_global.Y = {};
Y.Log=function(msg){somecode=inhere;};
And then access the Log function anywhere,
just by using:
Y.Log(“Log this message”);

And it does work,
but only inside the main (’_root’) movie.

When I download another movie like this:
var mc;
_root.createEmptyMovieClip(Q.q[2],Q.depth);
mc=_root[Q.q[2]];
mc._visible=true;
mc._x=Q.q[4];
mc._y=Q.q[5];
mc.loadMovie(Q.liburl+Q.q[3]);
The new movie CAN’T SEE the _global environment.
ALSO I just discovered, it CAN’T SEE the _root environment!
It actually has a totally empty _global and _root.

In fact, even though a targetPath(this) statement
inside the downloaded movie returns ‘_level0.menu’
(Q.q[2] = ‘menu’)
A 'for(varname in _level0){} statement doesn’t find ANYTHING.

To make it worse, using the debugger DOES reveal
ALL the _global objects for BOTH movies, side by side,
just the way they SHOULD be.

Aaaaaarrrrrrrgggggghhhhhh!!!
Anil

functions are different and can only be called by addressing them properly.

Woo that’s strange. I’ll test this… when my computer starts functionning normally.

I made a very simple test, it works for me. You must be doing something wrong… but what :q:

pom :cyclops:

ilyaslamasse/pom

i am so glad to here that this works for you!
i need it to work for me too!

could you post your test fla for me please?

i am about to back out on the flas that i have got
and start all over again with a very simple test fla
that only tackles this problem and nothing else
then i can double prove it

but if you can send me your fla
then things could be happening for me a whole lot quicker

thanks for your post
anil

now i have created two VERY simple flas and they work
they do everything they are supposed to do
none of the problems that i had before are present!

thankyou Lord JESUS !

now i guess i only have to work out the differences
between these ones and what i had before

if i come up with anything interesting i will post here

thanks for all your help and encouragement

anil

well well very strange
seems like i have found some ‘undocumented behaviour’
how’s this:
the following _global is visible using for (i in _global) {}:
_global.Q = “hello my name is Q”;
but this one just doesn’t appear at all using the same code:
_global.O = “hello my name is the big letter O”;
so maybe macromedia have secretly reserved _global identifiers whose name begins with ‘O’?

i have brought my new code up to do exactly what it did before,
i went step by step only adding code to the simple fla
that i knew already worked, and testing it every time

so now i have two fla’s
they both do the same thing
but only one of them works
while the other one has all the problems mentioned before

i wouldn’t believe it myself if i didn’t run the swfs 100 times each
and watch the same thing happen over and over again

at least my problem is fixed

thankyou everyone
thankyou jesus

anil