X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=src%2Fswfc.c;h=f07d424159de493702a2e8d4b3c6d9e372f4ba57;hb=aab59bee1b79b487e2a15ec57a80a857ffd623a5;hp=19a53c7b38c83344c4183855f29a8836687e004c;hpb=4ffab196c117e0f85e7c8764edb5cede894975f6;p=swftools.git diff --git a/src/swfc.c b/src/swfc.c index 19a53c7..f07d424 100644 --- a/src/swfc.c +++ b/src/swfc.c @@ -177,6 +177,7 @@ static struct level /* for swf (0): */ SWF*swf; char*filename; + char as3; /* for sprites (1): */ TAG*tag; @@ -340,22 +341,22 @@ static void free_outline(void* o) static void freeDictionaries() { - dict_free_all(&instances, free_instance); - dict_free_all(&characters, free); - dict_free_all(&images, free); - dict_free_all(&textures, free); - dict_free_all(&outlines, free_outline); - dict_free_all(&gradients, free_gradient); - dict_free_all(&filters, free); - dict_free_all(&fonts, free_font); - dict_free_all(&sounds, free); - dict_free_all(&interpolations, free); + dict_free_all(&instances, 1, free_instance); + dict_free_all(&characters, 1, free); + dict_free_all(&images, 1, free); + dict_free_all(&textures, 1, free); + dict_free_all(&outlines, 1, free_outline); + dict_free_all(&gradients, 1, free_gradient); + dict_free_all(&filters, 1, free); + dict_free_all(&fonts, 1, free_font); + dict_free_all(&sounds, 1, free); + dict_free_all(&interpolations, 1, free); cleanUp = 0; } static void freeFontDictionary() { - dict_free_all(&fonts, free_font); + dict_free_all(&fonts, 1, free_font); } static void incrementid() @@ -993,7 +994,7 @@ static void s_endSprite() syntaxerror("internal error(7)"); /* TODO: before clearing, prepend "." to names and copy into old instances dict */ - dict_free_all(&instances, free_instance); + dict_free_all(&instances, 1, free_instance); currentframe = stack[stackpos].oldframe; currentrect = stack[stackpos].oldrect; @@ -1029,6 +1030,22 @@ static void s_endSWF() // tag = swf_InsertTag(tag, ST_SHOWFRAME); tag = swf_InsertTag(tag, ST_SHOWFRAME); + if(stack[0].as3) { + TAG*tag = swf->firstTag; + tag = swf_InsertTag(tag, ST_DOABC); + void*code = as3_getcode(); + swf_WriteABC(tag, code); + if(as3_getglobalclass()) { + tag = swf_InsertTag(tag, ST_SYMBOLCLASS); + swf_SetU16(tag, 1); + swf_SetU16(tag, 0); + swf_SetString(tag, as3_getglobalclass()); + } else { + warning("no global public MovieClip subclass"); + } + as3_destroy(); + } + tag = swf_InsertTag(tag, ST_END); swf_OptimizeTagOrder(swf); @@ -1864,19 +1881,20 @@ void s_blur(const char*name, double blurx, double blury, int passes) void s_action(const char*text) { - ActionTAG* a = 0; - a = swf_ActionCompile(text, stack[0].swf->fileVersion); - if(!a) - { + if(stack[0].swf->fileVersion < 9) { + ActionTAG* a = 0; + a = swf_ActionCompile(text, stack[0].swf->fileVersion); + if(!a) { + swf_ActionFree(a); + syntaxerror("Couldn't compile ActionScript"); + } + tag = swf_InsertTag(tag, ST_DOACTION); + swf_ActionSet(tag, a); swf_ActionFree(a); - syntaxerror("Couldn't compile ActionScript"); + } else { + as3_parse_bytearray(stack[0].filename, text, strlen(text)); + stack[0].as3 = 1; } - - tag = swf_InsertTag(tag, ST_DOACTION); - - swf_ActionSet(tag, a); - - swf_ActionFree(a); } void s_initaction(const char*character, const char*text) @@ -2696,7 +2714,7 @@ float parsePercent(const char*str) if(!l) return 1.0; if(str[l-1]=='%') { - return atoi(str)/100.0; + return atof(str)/100.0; } syntaxerror("Expression '%s' is not a percentage", str); return 0;