actionscript-3actionscripttweener

How can I isolate the Tweener class so that loaded .swfs are not interfering with my tweens


I am working on a UI that makes heavy use of the Tweener class, and which also loads an external .swf that I believe also uses the Tweener class.

After tracking down all kinds of buggy behavior, I'm thinking that the problem is that the loaded .swf is making calls to Tweener.removeAllTweens() ***(This is just an assumption) and stopping other tweens that are happening in my UI.

Is this possible, and if so, is it possible to isolate the two versions of the Tweener class so that they don't reference the same object?

Thanks :)


Solution

  • You can try to use a LoaderContext with a different ApplicationDomain.

    When loading external SWF you can have the loaded SWFs definitions* be shared with the main SWF, override them or you can have them completely isolated. You put this definitions into something known as the ApplicationDomain.

    **read classes, including graphical assets marked to export in the library.*

    The setup you are interested in is as follows: Your loaded SWF domain is isolated from your main and keeps its own classes definitions.

    var separateDefinitions:LoaderContext = new LoaderContext(); separateDefinitions.applicationDomain = new ApplicationDomain(); var myLoader: Loader = new Loader(); var request:URLRequest = new URLRequest( "OtherSWF.swf" ); myLoader.load(request, separateDefinitions);

    LoaderContext and ApplicationDomain explained by Senocular on kirupa