1

I've got some old code I'm trying to clean up on a project that uses Adobe Crossbridge to manage a C++ backend and an AS3 frontend. The code hasn't made full use of the interop capabilities, and I'm trying to work toward that end, but all of the docs seem outdated, there don't seem to be any active forums, and whenever I try most of the examples, they don't seem to work, so I'm starting with some simpler conversions to get more comfortable with it.

Right now I'm running into issues using package_as3 to import AS3 classes. Here's an overly simplistic example of some namespaces we have:

namespace A
{
    inline void func1(int a, int b)
    {
        inline_nonreentrant_as3("import MyAS3Class;");
        inline_nonreentrant_as3("MyAS3Class.func1(%0, %1);" :: "r"(a), "r"(b));
    }
    inline void func2(int x, int y)
    {
        inline_nonreentrant_as3("import MyAS3Class;");
        inline_nonreentrant_as3("MyAS3Class.func2(%0, %1);" :: "r"(x), "r"(y));
    }
}

namespace B
{
    inline void func1(int a, int b)
    {
        inline_nonreentrant_as3("import com.packagename.MyOtherAS3Class;");
        inline_nonreentrant_as3("MyOtherAS3Class.func1(%0, %1);" :: "r"(a), "r"(b));
    }
    inline void func2(int x, int y)
    {
        inline_nonreentrant_as3("import com.packagename.MyOtherAS3Class;");
        inline_nonreentrant_as3("MyOtherAS3Class.func2(%0, %1);" :: "r"(x), "r"(y));
    }
}

This code works, but I'm not sure if the compiler can optimize out the repetitive import, especially on subsequent calls to the same function, but it seems reasonable to pull out the import if for no other reason than readability. So I tried doing so, using package_as3, like so:

namespace A
{
    package_as3("import MyAS3Class;");

    inline void func1(int a, int b)
    {
        inline_nonreentrant_as3("MyAS3Class.func1(%0, %1);" :: "r"(a), "r"(b));
    }
    inline void func2(int x, int y)
    {
        inline_nonreentrant_as3("MyAS3Class.func2(%0, %1);" :: "r"(x), "r"(y));
    }
}

namespace B
{
    package_as3("import com.packagename.MyOtherAS3Class;");

    inline void func1(int a, int b)
    {
        inline_nonreentrant_as3("MyOtherAS3Class.func1(%0, %1);" :: "r"(a), "r"(b));
    }
    inline void func2(int x, int y)
    {
        inline_nonreentrant_as3("MyOtherAS3Class.func2(%0, %1);" :: "r"(x), "r"(y));
    }
}

Interestingly, calling functions in namespace A works fine, but calling functions in namespace B causes a ReferenceError at runtime.

[Fault] exception, information=ReferenceError: Error #1065: Variable MyOtherAS3Class is not defined.

Like I said, the example is extremely simplified, but as far as I can tell, the only real difference between the two is that one of the AS3 classes (MyAS3Class) is at the root of the project's source code, and the other (MyOtherAS3Class) is not. I've tried using the fully-qualified name (i.e. com.packagename.MyOtherAS3Class.func1(...)), among other things, but then I got the same ReferenceError, saying "Variable com is not defined". Does anyone know what's happening here?

DevDaddyNick
  • 101
  • 2
  • 5

0 Answers0