开发者

Flash Alchemy built .swc library too small and missing functions

I can modify and compile the SDK's stringecho.c example for AS3 use no problem.

For my own app, I compile with g++ a few dozen files successfully and link:

g++ -swc -o myApp.swc glue.o demo.o obj1.o obj2.o obj3.o

I do get a myApp.swc, but it's erroneously only 80k (same size as the simple stringecho example).

When examined in any flash IDE, unlike the stringecho.swc which has

cmodule.stringecho.AlchemyBlock 
cmodule.stringecho.AlchemyBreakPoint
...

This myApp.swc has

cmodule.AlchemyBlock
cmodule.AlchemyBreakPoint
...

And has no glue function I defined. In essence, I can't use it in an AS3 project.

My glue.c code is be开发者_如何学编程low. Basically, I create a demo object and call its functions. The demo class encapsulates all the other object files.

#include "demo.h"
#include "AS3.h"
    AS3_Val InitSystem(void* self, AS3_Val args)
    {
        demo = new demo9();
        return 0;
    }

    AS3_Val LoadSceneFile( void* self, AS3_Val args )
    {
        demo->loadScene("scene.txt");
        return 0;
    }

...

    int main()
    {
        AS3_Val InitSystemMethod = AS3_Function( NULL, InitSystem );
        AS3_Val LoadSceneFileMethod = AS3_Function( NULL, LoadSceneFile );
        AS3_Val getAlchemyScreenMethod = AS3_Function( NULL, getAlchemyScreen );
        AS3_Val setMouseStateMethod = AS3_Function( NULL, setMouseState );
        AS3_Val rasterizeMethod = AS3_Function( NULL, rasterize );

        AS3_Val result = AS3_Object("InitSystem: AS3ValType,LoadSceneFile: AS3ValType,getAlchemyScreen:AS3ValType,setMouseState:AS3ValType,rasterize:AS3ValType"
                                    ,InitSystemMethod,
                                    LoadSceneFileMethod,
                                    getAlchemyScreenMethod,
                                    setMouseStateMethod,
                                    rasterizeMethod);

        AS3_Release( InitSystemMethod );
        AS3_Release( LoadSceneFileMethod );
        AS3_Release( getAlchemyScreenMethod );
        AS3_Release( setMouseStateMethod );
        AS3_Release( rasterizeMethod );

        AS3_LibInit( result );

        return 0;
    }


Read this blog post.

The short story is that linking lots of .o files won't work. You need to 'ar' them together into a library (.a) file. Then you compile your glue code against that library. Per your example it would be something like this:

ar rc mylib.a demo.o obj1.o obj2.o obj3.o
ranlib mylib.a
g++ -swc -o myApp.swc glue.c mylib.a
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜