|
-
Total Universe Mod
use of the "is" operator
I'm trying to see if a passed object is an instance of a specific class.
Code:
function setActiveChild(child:MovieClip):void{
trace(child); //outputs [object MyClass]
trace(child is MyClass); //outputs false
}
Why does (child is MyClass) trace false?
How do I get it to be true?
-
Is the child object loaded from a separate swf?
-
Total Universe Mod
Yes, its the document class of a loaded .swf.
It calls the function in its parent passing itself
parent.setActiveChild(this);
-
When you load a swf into a Loader, you can specify the ApplicationDomain through the LoaderContext. If you do not specify, things in the loaded will be in a child application domain, and you can get weird things where there are two different (but identical) definitions for MyClass.
Code:
loader.load(new URLRequest("something.swf"), new LoaderContext(false, ApplicationDomain.currentDomain, null));
This will import the defined classes into the same application domain. Beware though that if you do actually have two different conflicting classes (such as two swfs built on the same Document Class, but with different graphic assets), you will get an error.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|