简体   繁体   中英

In actionscript, why is my static class member variable not the same when accessed from different parts of my app?

I have an actionscript class with a static member variable defined.

public class A
{
     public static var x:int;
}

When I try to access it from different parts in my code I don't get the same value in each spot.

A.x 

I am accessing the variable in different modules that are loaded, so they are all in their own separate .swf file. Could this by why?

Seems like an application domain problem. The main swf and the modules seem to be accessing their own copies of the A class. You should probably change the way you load your modules.

Check this out:

http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/system/LoaderContext.html#applicationDomain http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/system/ApplicationDomain.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM