0
    //--------------------------------------------test.cpp

// g++ test.cpp -O3 -Wall -swc -o test.swc


#include <iostream>
#include <list>
#include <vector>
#include "AS3.h"
using namespace std;

//vector<float> vf;
list<float> vf;

static AS3_Val getSize(void* self, AS3_Val args)
{
    int num = vf.size();
    return AS3_Int(num);
}

int main()
{
    AS3_Val getSizeMethod = AS3_Function( NULL, getSize);

    AS3_Val result = AS3_Object( "getSize:AS3ValType", getSizeMethod); 

    AS3_Release( getSizeMethod );

    AS3_LibInit( result );

    return 0;
}




    //-------------------------------------------------test.as

// C:\alchemy\flex4\bin\mxmlc -library-path+=./test.swc -static-link-runtime-shared-libraries=true test.as 


package{
    import flash.display.Sprite;
    import flash.text.TextField;
    import flash.text.TextFieldType;

    import cmodule.test.CLibInit

    public class test extends Sprite{
        public function test() {
            var info:TextField = new TextField();
            this.addChild(info);


            var loader:CLibInit = new CLibInit();
            var lib:Object = loader.init();
            info.appendText("size:" + lib.getSize() + "\n");
        }
    }
}

- - - - - - - - - - - - - - - - - - -質問 - - - - - - ------

1.test.swfが動かないけどvectorなら大丈夫!
2.いくつかの要素をリストにプッシュバックすると、実行できますが、取得したサイズが間違っています!

誰でも私を助けることができます!ありがとう!!!

4

1 に答える 1

1

Alchemy では静的イニシャライザが壊れています。これを回避するには、main() でリストを作成する必要があります。例えば、

list<float> vf;

になる

list<float> *vf;

メインでは、それを作成する必要があります:

vf= new list<float>();

getSize メソッドが返されます

int num = vf->size();
于 2012-03-26T21:49:53.353 に答える