_global variable in Movie from resource

.NET Edition of the F-IN-BOX
seesharp
Posts: 82
Joined: Mon Oct 30, 2006 1:34 pm

_global variable in Movie from resource

Postby seesharp » Fri Dec 21, 2007 3:41 pm

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

Softanics
Site Admin
Posts: 1402
Joined: Sat Sep 18, 2004 3:03 am
Location: Russia, St. Petersburg
Contact:

Postby Softanics » Fri Dec 21, 2007 4:06 pm

Thank you for your question.

How do you load the first movie?
Best regards, Artem A. Razin,
F-IN-BOX support
Ask your question here: http://www.f-in-box.com/support.html

seesharp
Posts: 82
Joined: Mon Oct 30, 2006 1:34 pm

Postby seesharp » Fri Dec 21, 2007 4:40 pm

Hi

from resource as well in both scenarios.

Alex

Softanics
Site Admin
Posts: 1402
Joined: Sat Sep 18, 2004 3:03 am
Location: Russia, St. Petersburg
Contact:

Postby Softanics » Fri Dec 21, 2007 5:12 pm

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?
Best regards, Artem A. Razin,

F-IN-BOX support

Ask your question here: http://www.f-in-box.com/support.html

seesharp
Posts: 82
Joined: Mon Oct 30, 2006 1:34 pm

Postby seesharp » Fri Dec 21, 2007 10:51 pm

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

seesharp
Posts: 82
Joined: Mon Oct 30, 2006 1:34 pm

Postby seesharp » Sat Dec 22, 2007 3:41 pm

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

Softanics
Site Admin
Posts: 1402
Joined: Sat Sep 18, 2004 3:03 am
Location: Russia, St. Petersburg
Contact:

Postby Softanics » Sun Dec 23, 2007 12:29 pm

Thank you for the interesting result!
Best regards, Artem A. Razin,

F-IN-BOX support

Ask your question here: http://www.f-in-box.com/support.html

seesharp
Posts: 82
Joined: Mon Oct 30, 2006 1:34 pm

Postby seesharp » Wed Dec 26, 2007 8:20 am

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


Return to “.NET Edition”

Who is online

Users browsing this forum: No registered users and 19 guests