X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=lib%2Fmodules%2Fswfabc.c;h=8139af8d96dfeec52fa2c321ba653eee6c511dfc;hb=fffa3792bb7fa347161847b51e4782eae16c5de8;hp=7e42951bea4daa5ea546b9d7c70800e542c5eea2;hpb=d597c1a412999e1fc4f6d02028d2887e20fe6544;p=swftools.git diff --git a/lib/modules/swfabc.c b/lib/modules/swfabc.c index 7e42951..8139af8 100644 --- a/lib/modules/swfabc.c +++ b/lib/modules/swfabc.c @@ -535,7 +535,7 @@ static void dump_method(const char*prefix, const char*type, const char*name, int dump_traits(prefix, c->traits, pool); printf("%s{\n", prefix); parse_code(c->tag, c->tag->len, pool,prefix2); - printf("%s}\n", prefix); + printf("%s}\n\n", prefix); } //#define DEBUG @@ -648,7 +648,7 @@ static void dump_traits(const char*prefix, dict_t*traits, abc_file_t*pool) } else if(kind == TRAIT_SLOT || kind == TRAIT_CONST) { // slot, const int slot_id = trait->slot_id; const char*type_name = dict_getstr(pool->multinames, trait->type_index); - printf(" %sslot %s %d %s (vindex=%d)\n", prefix, name, trait->slot_id, type_name, trait->vindex); + printf("%sslot %s %d %s (vindex=%d)\n", prefix, name, trait->slot_id, type_name, trait->vindex); } else { printf(" can't dump trait type %d\n", kind); } @@ -1016,6 +1016,13 @@ void* swf_ReadABC(TAG*tag) cls->ns_index = swf_GetU30(tag); ns = dict_getstr(pool->namespaces, cls->ns_index); } + /* TODO + + flags&01 = sealed + flags&02 = final + flags&04 = interface + flags&08 = protectedNS + */ printf("class %s extends %s, %s, flags=%02x\n", classname, supername, ns, cls->flags); printf("{\n"); @@ -1435,13 +1442,27 @@ void swf_WriteABC(TAG*tag, void*code) #include "swfabc_ops.c" -void swf_AddButtonLinks(TAG*tag) +void swf_AddButtonLinks(SWF*swf, char stop_each_frame) { + int num_frames = 0; + TAG*tag=swf->firstTag; + while(tag) { + if(tag->id == ST_SHOWFRAME) + num_frames++; + tag = tag->next; + } + abc_file_t*file = abc_file_new(); abc_method_body_t*c = 0; - abc_class_t*cls = abc_NewClass(file, "buttonmitlink_fla:MainTimeline", "flash.display:MovieClip"); - + abc_class_t*cls = abc_NewClass(file, "rfx:MainTimeline", "flash.display:MovieClip"); + + TAG*abctag = swf_InsertTagBefore(swf, swf->firstTag, ST_DOABC); + + tag = swf_InsertTag(abctag, ST_SYMBOLCLASS); + swf_SetU16(tag, 1); + swf_SetU16(tag, 0); + swf_SetString(tag, "rfx.MainTimeline"); c = abc_AddStaticConstructor(cls, "void", 0); c->max_stack = 1; @@ -1469,45 +1490,61 @@ void swf_AddButtonLinks(TAG*tag) abc_getlex(c, "[package]flash.system:Security"); abc_pushstring(c, "*"); abc_callpropvoid(c, "[package]:allowDomain", 1); - - //abc_getlocal_0(c); - //abc_constructsuper(c,0); - - abc_findpropstrict(c,":addFrameScript"); - abc_pushbyte(c,0x00); - abc_getlex(c,"[packageinternal]buttonmitlink_fla:frame1"); - abc_callpropvoid(c,":addFrameScript",2); - - abc_getlex(c,":MyButton1"); - abc_getlex(c,"flash.events:MouseEvent"); - abc_getproperty(c, ":CLICK"); - abc_getlex(c, ":gotoPage1"); - abc_callpropvoid(c, ":addEventListener" ,2); - - abc_getlex(c,":MyButton2"); - abc_getlex(c,"flash.events:MouseEvent"); - abc_getproperty(c, ":CLICK"); - abc_getlex(c,":gotoPage2"); - abc_callpropvoid(c,":addEventListener",2); - abc_returnvoid(c); - - c = abc_AddMethod(cls, 0, "[packageinternal]buttonmitlink_fla:frame1", 0); - c->max_stack = 3; - c->local_count = 1; - c->init_scope_depth = 10; - c->max_scope_depth = 11; + if(stop_each_frame) { + int i; + for(i=0;ifirstTag; + while(tag) { + if(tag->id == ST_DEFINEBUTTON || tag->id == ST_DEFINEBUTTON2) { + char buttonname[80]; + char functionname[80]; + sprintf(buttonname, ":button%d", swf_GetDefineID(tag)); + //sprintf(functionname, ":clickLink%d", swf_GetDefineID(t)); + sprintf(functionname, ":clickLink1"); + abc_getlex(c,buttonname); + abc_getlex(c,"flash.events:MouseEvent"); + abc_getproperty(c, ":CLICK"); + abc_getlex(c,functionname); + abc_callpropvoid(c, ":addEventListener" ,2); + } + tag = tag->next; + } - abc_getlocal_0(c); - abc_pushscope(c); abc_returnvoid(c); + if(stop_each_frame) { + c = abc_AddMethod(cls, 0, "[packageinternal]rfx:stopframe", 0); + c->max_stack = 3; + c->local_count = 1; + c->init_scope_depth = 10; + c->max_scope_depth = 11; + + abc_getlocal_0(c); + abc_pushscope(c); + abc_findpropstrict(c, "[package]:stop"); + abc_callpropvoid(c, "[package]:stop", 0); + abc_returnvoid(c); + } - abc_AddSlot(cls, ":MyButton1", 0, "flash.display:SimpleButton"); - abc_AddSlot(cls, ":MyButton2", 0, "flash.display:SimpleButton"); - + tag = swf->firstTag; + while(tag) { + if(tag->id == ST_DEFINEBUTTON || tag->id == ST_DEFINEBUTTON2) { + char buttonname[80]; + sprintf(buttonname, ":button%d", swf_GetDefineID(tag)); + abc_AddSlot(cls, buttonname, 0, "flash.display:SimpleButton"); + } + tag = tag->next; + } - c = abc_AddMethod(cls, ":void", ":gotoPage1", 1, "flash.events:MouseEvent"); + c = abc_AddMethod(cls, ":void", ":clickLink1", 1, "flash.events:MouseEvent"); c->max_stack = 3; c->local_count = 2; c->init_scope_depth = 10; @@ -1516,30 +1553,13 @@ void swf_AddButtonLinks(TAG*tag) abc_pushscope(c); abc_findpropstrict(c,"flash.net:navigateToURL"); abc_findpropstrict(c,"flash.net:URLRequest"); - abc_pushstring(c,"http://www.google.com/"); + abc_pushstring(c,"http://www.quiss.org/"); //abc_pushstring(c,"file:///home/kramm/c/swftools/lib/modules/test2.html"); abc_constructprop(c,"flash.net:URLRequest", 1); abc_callpropvoid(c,"flash.net:navigateToURL", 1); abc_returnvoid(c); - c = abc_AddMethod(cls, ":void", ":gotoPage2", 1, "flash.events:MouseEvent"); - c->max_stack = 3; - c->local_count = 2; - c->init_scope_depth = 10; - c->max_scope_depth = 11; - abc_getlocal_0(c); - abc_pushscope(c); - abc_findpropstrict(c, "flash.net:navigateToURL"); - abc_findpropstrict(c, "flash.net:URLRequest"); - abc_pushstring(c, "http://www.quiss.org"); - //abc_pushstring(c, "file:///home/kramm/c/swftools/lib/modules/test1.html"); - abc_constructprop(c, "flash.net:URLRequest", 1); - abc_callpropvoid(c, "flash.net:navigateToURL", 1); - abc_returnvoid(c); - - - abc_script_t*s = abc_AddInitScript(file, 0, 0); c = (abc_method_body_t*)dict_getdata(file->method_bodies, s->method->method_body_index); c->max_stack = 2; @@ -1572,12 +1592,12 @@ void swf_AddButtonLinks(TAG*tag) abc_popscope(c); abc_popscope(c); abc_popscope(c); - abc_initproperty(c,"buttonmitlink_fla:MainTimeline"); + abc_initproperty(c,"rfx:MainTimeline"); abc_returnvoid(c); - //abc_method_body_addClassTrait(c, "buttonmitlink_fla:MainTimeline", 1, cls); - abc_initscript_addClassTrait(s, "buttonmitlink_fla:MainTimeline", 1, cls); + //abc_method_body_addClassTrait(c, "rfx:MainTimeline", 1, cls); + abc_initscript_addClassTrait(s, "rfx:MainTimeline", 1, cls); - swf_WriteABC(tag, file); + swf_WriteABC(abctag, file); }