A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: use of the "is" operator

  1. #1
    Total Universe Mod jAQUAN's Avatar
    Join Date
    Jul 2000
    Location
    Honolulu
    Posts
    2,429

    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?

  2. #2
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    Is the child object loaded from a separate swf?

  3. #3
    Total Universe Mod jAQUAN's Avatar
    Join Date
    Jul 2000
    Location
    Honolulu
    Posts
    2,429
    Yes, its the document class of a loaded .swf.
    It calls the function in its parent passing itself

    parent.setActiveChild(this);

  4. #4
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    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
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center