2 Replies Latest reply on Mar 11, 2009 12:07 PM by injpix

    Mixing AS2 and AS3

    SiHoop Level 1
      I'm working on a project built mainly in as3. Part of the project is written in as2 and works properly when it's imported into as3, but only the first time it is used. The second time, it fails. Has anyone run into this problem and found a work around?
        • 1. Re: Mixing AS2 and AS3
          SiHoop Level 1
          My problem is caused by using two versions of Tweener-- one for as2 the other for as3. Is there a way of dealing with this or am I going to have to re-write the as2 code in as3?
          • 2. Re: Mixing AS2 and AS3
            injpix Level 3
            This is caused by application domains. When importing a SWF into another, Flash Player can handle it in 3 ways:

            -the loaded SWF runs in a new application domain that is completely partitioned from all other applications domains
            -the loaded SWF runs in a new application domain that is a child of an existing application domain.
            -the loaded SWF runs in an existing application domain

            “An application domain ensures that within the domain there is only one definition for each class”. Having this feature prevents duplicate classes from accumulating in memory. So since you may be importing a SWF that contains the same class definition, FP may be purging your AS2.0 Tweener class. It may not be doing this the first time...because it hasn't been recognized yet? I am not sure.

            Anyways, try this, create a partitioned domain from its parent. Below is a snippet on instantiating an ApplicationDomain.

            ref: Programming Flex 2, Chafic Kazoun and Joey Lott