I have two classes, call them A and B. They both contain a Loader object. In class A I load content into the Loader object.
public class A {
var loader:Loader;
public function A():void {
loader = new Loader();
this.addChild(loader);
loader.load(...);
}
}
public class B() {
var loader:Loader;
public function B():void {
loader = new Loader();
this.addChild(loader);
}
}
I need to now assign A's Loader to B's Loader (after the load is complete).
In some other class I have an instance of A and B. Doing a direct assignment of the loader values doesn't seem to work (when showing B, A's loader content is not displayed).
var b:B = new B();
var a:A = new A();
// ... I wait for a's loader to be loaded ...
// ... then ...
b.loader = a.loader;
addChild(b);
// A's Loader is not shown ...
If I do the following, it works:
b.addChild(a.loader);
But that's not what I want. I don't want to manage a bunch of children when I know I only have one child but just want to change its content.
Is there a way to copy/assign a Loader directly? I tried assigning to 'content' but that's read-only. Is there another way I can do this? Basically I have an array of Loader objects that all get loaded with images. I then have a single Loader that's on the stage and I want to assign to it images (Loaders) from my array.
Thanks.