X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=src%2Fswfc.c;h=26e46cdd57c6688b8583fa48c2b84e444bbd087e;hb=d37a4db40333c68f0b764e1aef6f784887429151;hp=2cc9887d61cf5a657a6a85d51a7a8672f3af2973;hpb=9d42dd912d2cb790518837bd2a6ce7097a8e6fa0;p=swftools.git diff --git a/src/swfc.c b/src/swfc.c index 2cc9887..26e46cd 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; @@ -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); @@ -1364,6 +1381,24 @@ void s_quicktime(const char*name, const char*url) incrementid(); } +void s_video(const char *name, int width, int height) +{ + SRECT r; + + memset(&r, 0, sizeof(r)); + + tag = swf_InsertTag(tag, ST_DEFINEVIDEOSTREAM); + swf_SetU16(tag, id); + swf_SetU16(tag, 0); // numframes + swf_SetU16(tag, width); + swf_SetU16(tag, height); + swf_SetU8(tag, 0); // videoflags + swf_SetU8(tag, 0); // codecid + + s_addcharacter(name, id, tag, r); + incrementid(); +} + void s_edittext(const char*name, const char*fontname, int size, int width, int height, const char*text, RGBA*color, int maxlength, const char*variable, int flags, int align) { SWFFONT*font = 0; @@ -1864,19 +1899,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 +2732,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; @@ -3804,6 +3840,15 @@ static int c_quicktime(map_t*args) return 0; } +static int c_video(map_t*args) +{ + const char*name = lu(args, "name"); + int width = parseInt(lu(args, "width")); + int height = parseInt(lu(args, "height")); + s_video(name, width, height); + return 0; +} + static int c_image(map_t*args) { const char*command = lu(args, "commandname"); @@ -4073,6 +4118,7 @@ static struct { {"font", c_font, "name filename glyphs="}, {"soundtrack", c_soundtrack, "filename"}, {"quicktime", c_quicktime, "url"}, + {"video", c_video, "name width= height="}, // generators of primitives