Page 1 of 1

_global variable in Movie from resource

Posted: Fri Dec 21, 2007 3:41 pm
by seesharp
Hi

I am loading an AS2 .swf from resource into another movie using MovieClipLoader object.

The second movie I load into the first one contains some _global variables.
Now, If I load the second movie from the filesystem, I can access the _global variables correctly but if I load it from resource I always get undefined. Everything else seems to work as expected. Do you have any hint to solve this issue ?

Best regards

Alex

Posted: Fri Dec 21, 2007 4:06 pm
by Softanics
Thank you for your question.

How do you load the first movie?

Posted: Fri Dec 21, 2007 4:40 pm
by seesharp
Hi

from resource as well in both scenarios.

Alex

Posted: Fri Dec 21, 2007 5:12 pm
by Softanics
I can't understand why it doesn't work properly.

If you load from the file system and provide its content using a global handler, does it work well?

Posted: Fri Dec 21, 2007 10:51 pm
by seesharp
Hi

it seems so. If I use an address like 'loaded.swf' pointing to the filesystem as it is resolved as fullpath, it works as expected.
If I use 'http://resource/loaded.swf' as path, as it is needed to load it from resource, it doesn't. _global is broken while everything else works.

I cannot see if there is a security issue as it is loaded from a domain 'http://resource..' But setting allowDomain doesn't solve it.

Alex

Posted: Sat Dec 22, 2007 3:41 pm
by seesharp
Finally I found the source and solution:

_global objects are strictly separated if movies are loaded from different domains even if you set allowDomain.

In my implementation, the first movie has been loeded from resource without invoking LoadMovie hence FlashPlayer didn't actually know the domain of the movie, while the second movie has been loaded from http://resource.

I changed the implementation a bit using FlashMethod_LoadMovie for the initial movie as well and now it works as expected.

Alex

Posted: Sun Dec 23, 2007 12:29 pm
by Softanics
Thank you for the interesting result!

Posted: Wed Dec 26, 2007 8:20 am
by seesharp
Hi

indeed. As a rule, to avoid such problems, always invoke
FlashMethod_LoadMovie to load a movie and then handle the OnLoadExternalResource event to serve the movie to the player.

If you load it directly with LoadFromStream the player doesn't seem to get a usable domain information and subsequently loaded movies (loaded into the first one) are handled as coming from a different domain.

At least according to my tests.

Hope this might help others as well.

Happy New Year

Alex