void add_text_field(SWFMovie mo, const char* name, const char* varname, const char* initial_label, int depth, int x, int y) { SWFDisplayItem it; SWFTextField tf = newSWFTextField(); SWFTextField_setFont(tf, (void*)font); SWFTextField_addChars(tf, " abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ012345689:.,/\\#@?!"); SWFTextField_setVariableName(tf, varname); SWFTextField_addString(tf, "Idle"); SWFTextField_setBounds(tf, 120, 12); SWFTextField_setFlags(tf, SWFTEXTFIELD_DRAWBOX|SWFTEXTFIELD_NOEDIT); it = SWFMovie_add(mo, (SWFBlock)tf); SWFDisplayItem_moveTo(it, x, y+2); SWFDisplayItem_setDepth(it, depth); SWFDisplayItem_setName(it, name); // "textfield"); // Label tf = newSWFTextField(); SWFTextField_setFont(tf, (void*)font); SWFTextField_addString(tf, initial_label); SWFTextField_setFlags(tf, SWFTEXTFIELD_DRAWBOX|SWFTEXTFIELD_NOEDIT); it = SWFMovie_add(mo, (SWFBlock)tf); SWFDisplayItem_scale(it, 0.3, 0.3); SWFDisplayItem_setDepth(it, depth*10); SWFDisplayItem_moveTo(it, x, y); }
static void ming_ellipse(GVJ_t * job, pointf * A, int filled) { SWFMovie movie = (SWFMovie)(job->context); SWFShape shape; SWFFill fill; SWFDisplayItem item; obj_state_t *obj = job->obj; gvcolor_t pencolor = obj->pencolor; gvcolor_t fillcolor = obj->fillcolor; double rx, ry; shape = newSWFShape(); SWFShape_setLine(shape, obj->penwidth, pencolor.u.rgba[0], pencolor.u.rgba[1], pencolor.u.rgba[2], pencolor.u.rgba[3]); if (filled) { fill = SWFShape_addSolidFill(shape, fillcolor.u.rgba[0], fillcolor.u.rgba[1], fillcolor.u.rgba[2], fillcolor.u.rgba[3]); SWFShape_setRightFill(shape, fill); } SWFShape_movePenTo(shape, 0, 0); rx = A[1].x - A[0].x; ry = A[1].y - A[0].y; SWFShape_drawCircle(shape, rx); item = SWFMovie_add(movie, (SWFBlock)shape); SWFDisplayItem_scale(item, 1., ry/rx); SWFDisplayItem_moveTo(item, A[0].x, A[0].y); }
int main(int argc, char** argv) { SWFMovie mo; SWFMovieClip mc1, mc2, dejagnuclip; SWFDisplayItem it; SWFShape sh1,sh2; SWFAction ac1, ac2; int i; const char *srcdir="."; if ( argc>1 ) srcdir=argv[1]; else { //fprintf(stderr, "Usage: %s <mediadir>\n", argv[0]); //return 1; } Ming_init(); mo = newSWFMovie(); SWFMovie_setDimension(mo, 800, 600); //SWFMovie_setRate (mo, 1.0); dejagnuclip = get_dejagnu_clip((SWFBlock)get_default_font(srcdir), 10, 0, 0, 800, 600); SWFMovie_add(mo, (SWFBlock)dejagnuclip); SWFMovie_nextFrame(mo); sh1 = make_fill_square (100, 300, 60, 60, 255, 0, 0, 255, 0, 0); sh2 = make_fill_square (300, 300, 60, 60, 255, 0, 0, 0, 0, 0); it = SWFMovie_add(mo, (SWFBlock)sh1); SWFDisplayItem_setName(it, "sh1"); SWFDisplayItem_setDepth(it, 3); //place the sh1 DisplayObject at depth 3; it = SWFMovie_add(mo, (SWFBlock)sh2); SWFDisplayItem_setName(it, "sh2"); SWFDisplayItem_setDepth(it, 4); //place the sh2 DisplayObject at depth 4; check(mo, "sh1 != undefined"); check(mo, "sh2 != undefined"); // Do these checks mean that shapes are movieclips? // seems not. check_equals(mo, "typeof(sh1)", "'movieclip'"); check_equals(mo, "typeof(sh2)", "'movieclip'"); check_equals(mo, "typeof(_root)", "'movieclip'"); add_actions(mo, "sh1.var1 = 10;" "sh2.var2 = 20;" ); // Do these checks mean that we can add variables to shapes? // seems not, variable are added to the _root, interesting. check_equals(mo, "sh1.var1", "10"); check_equals(mo, "sh2.var2", "20"); check_equals(mo, "_root.var1", "10"); check_equals(mo, "_root.var2", "20"); check_equals(mo, "sh1._x", "0"); check_equals(mo, "sh2._x", "0"); add_actions(mo, "sh1._x = 0;" "sh2._x = 400;" ); check_equals(mo, "sh1._x", "400"); check_equals(mo, "sh2._x", "400"); check_equals(mo, "_root._x", "400"); add_actions(mo, "_root._x = 0;" ); /* cleanup */ // Do these checks mean that shapes are *not* movieclips? check_equals(mo, "typeof(sh1.getDepth())", "'undefined'"); check_equals(mo, "typeof(sh2.getDepth())", "'undefined'"); // Do these checks mean that shapes are *not* movieclips? check_equals(mo, "typeof(getInstanceAtDepth(-16381))", "'undefined'"); check_equals(mo, "typeof(getInstanceAtDepth(-16380))", "'undefined'"); SWFMovie_nextFrame(mo); /* * UdoG's drawing * * See DrawingApiTest.as (inv8) * */ { /* using left fill, non-closed paths */ SWFDisplayItem it1, it2; SWFShape sh = newSWFShape(); SWFMovieClip mc = newSWFMovieClip(); SWFShape_setLineStyle(sh, 1, 0, 0, 0, 255); SWFShape_setLeftFillStyle(sh, SWFShape_addSolidFillStyle(sh, 0, 255, 0, 255)); SWFShape_movePenTo(sh, 20, 10); /* 0 */ SWFShape_drawLineTo(sh, 40, 10); /* 1 */ SWFShape_drawLineTo(sh, 40, 40); /* 2 */ SWFShape_drawLineTo(sh, 20, 40); /* 3 */ SWFShape_drawLineTo(sh, 20, 10); /* 4 */ SWFShape_drawLineTo(sh, 10, 10); /* 5 */ SWFShape_drawLineTo(sh, 10, 20); /* 6 */ SWFShape_drawLineTo(sh, 30, 20); /* 7 */ SWFShape_drawLineTo(sh, 30, 30); /* 8 */ SWFShape_drawLineTo(sh, 20, 30); /* 9 */ it1 = SWFMovieClip_add(mc, (SWFBlock)sh); // Test that clip events are not invoked for shapes #if 0 // current Ming HEAD chokes if we add an onClipConstruct event... SWFDisplayItem_addAction(it1, newSWFAction( "_root.check(false && 'clip event for shape should not be executed');" SWFACTION_CONSTRUCT); #endif SWFDisplayItem_addAction(it1, newSWFAction( "_root.check(false && 'clip event for shape should not be executed');" ), SWFACTION_ENTERFRAME); SWFDisplayItem_addAction(it1, newSWFAction( "_root.check(false && 'clip event for shape should not be executed');" ), SWFACTION_ONLOAD); SWFDisplayItem_addAction(it1, newSWFAction( "_root.check(false && 'clip event for shape should not be executed');" ), SWFACTION_UNLOAD); SWFDisplayItem_addAction(it1, newSWFAction( "_root.check(false && 'clip event for shape should not be executed');" ), SWFACTION_MOUSEMOVE); SWFDisplayItem_addAction(it1, newSWFAction( "_root.check(false && 'clip event for shape should not be executed');" ), SWFACTION_MOUSEDOWN); // None of these should be executed SWFDisplayItem_addAction(it1, newSWFAction( "_root.check(false && 'clip event for shape should not be executed');" ), SWFACTION_ONLOAD); SWFDisplayItem_moveTo(it1, 80, 120); SWFDisplayItem_scale(it1, 2, 2); SWFMovieClip_nextFrame(mc); it2 = SWFMovie_add(mo, (SWFBlock)mc); } { /* using right fill, non-closed paths */ SWFDisplayItem it; SWFShape sh = newSWFShape(); SWFMovieClip mc = newSWFMovieClip(); SWFShape_setLineStyle(sh, 1, 0, 0, 0, 255); SWFShape_setLeftFillStyle(sh, SWFShape_addSolidFillStyle(sh, 0, 255, 0, 255)); SWFShape_movePenTo(sh, 20, 10); /* 0 */ SWFShape_drawLineTo(sh, 40, 10); /* 1 */ SWFShape_drawLineTo(sh, 40, 40); /* 2 */ SWFShape_drawLineTo(sh, 20, 40); /* 3 */ SWFShape_drawLineTo(sh, 20, 10); /* 4 */ SWFShape_drawLineTo(sh, 10, 10); /* 5 */ SWFShape_drawLineTo(sh, 10, 20); /* 6 */ SWFShape_drawLineTo(sh, 30, 20); /* 7 */ SWFShape_drawLineTo(sh, 30, 30); /* 8 */ SWFShape_drawLineTo(sh, 20, 30); /* 9 */ it = SWFMovieClip_add(mc, (SWFBlock)sh); SWFDisplayItem_moveTo(it, 200, 120); SWFDisplayItem_scale(it, 2, 2); SWFMovieClip_nextFrame(mc); it = SWFMovie_add(mo, (SWFBlock)mc); } { /* using left fill, closed paths */ SWFDisplayItem it; SWFShape sh = newSWFShape(); SWFMovieClip mc = newSWFMovieClip(); SWFShape_setLineStyle(sh, 1, 0, 0, 0, 255); SWFShape_setLeftFillStyle(sh, SWFShape_addSolidFillStyle(sh, 255, 0, 0, 255)); SWFShape_movePenTo(sh, 20, 10); /* 0 */ SWFShape_drawLineTo(sh, 40, 10); /* 1 */ SWFShape_drawLineTo(sh, 40, 40); /* 2 */ SWFShape_drawLineTo(sh, 20, 40); /* 3 */ SWFShape_drawLineTo(sh, 20, 10); /* 4 */ SWFShape_drawLineTo(sh, 10, 10); /* 5 */ SWFShape_drawLineTo(sh, 10, 20); /* 6 */ SWFShape_drawLineTo(sh, 30, 20); /* 7 */ SWFShape_drawLineTo(sh, 30, 30); /* 8 */ SWFShape_drawLineTo(sh, 20, 30); /* 9 */ SWFShape_drawLineTo(sh, 20, 10); /* 0 */ it = SWFMovieClip_add(mc, (SWFBlock)sh); SWFDisplayItem_moveTo(it, 80, 200); SWFDisplayItem_scale(it, 2, 2); SWFMovieClip_nextFrame(mc); it = SWFMovie_add(mo, (SWFBlock)mc); } { /* using right fill, closed paths */ SWFDisplayItem it; SWFShape sh = newSWFShape(); SWFMovieClip mc = newSWFMovieClip(); SWFShape_setLineStyle(sh, 1, 0, 0, 0, 255); SWFShape_setRightFillStyle(sh, SWFShape_addSolidFillStyle(sh, 255, 0, 0, 255)); SWFShape_movePenTo(sh, 20, 10); /* 0 */ SWFShape_drawLineTo(sh, 40, 10); /* 1 */ SWFShape_drawLineTo(sh, 40, 40); /* 2 */ SWFShape_drawLineTo(sh, 20, 40); /* 3 */ SWFShape_drawLineTo(sh, 20, 10); /* 4 */ SWFShape_drawLineTo(sh, 10, 10); /* 5 */ SWFShape_drawLineTo(sh, 10, 20); /* 6 */ SWFShape_drawLineTo(sh, 30, 20); /* 7 */ SWFShape_drawLineTo(sh, 30, 30); /* 8 */ SWFShape_drawLineTo(sh, 20, 30); /* 9 */ SWFShape_drawLineTo(sh, 20, 10); /* 0 */ it = SWFMovieClip_add(mc, (SWFBlock)sh); SWFDisplayItem_moveTo(it, 200, 200); SWFDisplayItem_scale(it, 2, 2); SWFMovieClip_nextFrame(mc); it = SWFMovie_add(mo, (SWFBlock)mc); } add_actions(mo, "_root.totals(); stop();"); SWFMovie_nextFrame(mo); //Output movie puts("Saving " OUTPUT_FILENAME ); SWFMovie_save(mo, OUTPUT_FILENAME); return 0; }
EXPORT BOOL WINAPI i_scale(float xScale, float yScale, int p3, int p4) { lstrcpy(funcname, "i_scale"); SWFDisplayItem_scale(mhsp_item, xScale, yScale); return 0; }
int main(int argc, char** argv) { SWFMovie mo; const char *srcdir="."; char fdefont[256]; SWFMovieClip dejagnuclip; SWFDisplayItem it; /********************************************* * * Initialization * *********************************************/ if ( argc>1 ) srcdir=argv[1]; else { fprintf(stderr, "Usage: %s <mediadir>\n", argv[0]); return 1; } sprintf(fdefont, "%s/Bitstream-Vera-Sans.fdb", srcdir); FILE *font_file = fopen(fdefont, "r"); if ( font_file == NULL ) { perror(fdefont); exit(1); } SWFFont efont = loadSWFFontFromFile(font_file); puts("Setting things up"); Ming_init(); Ming_useSWFVersion (OUTPUT_VERSION); mo = newSWFMovie(); SWFMovie_setRate(mo, 1.0); SWFMovie_setDimension(mo, 800, 600); dejagnuclip = get_dejagnu_clip((SWFBlock)get_default_font(srcdir), 10, 0, 0, 800, 600); SWFMovie_add(mo, (SWFBlock)dejagnuclip); SWFMovie_nextFrame(mo); // 1st frame /********************************************* * * Add some textfields * *********************************************/ int y = 30; int inc = 30; it = add_text_field(mo, (SWFBlock)efont, "Normal", 1, 2, 3, SWFTEXTFIELD_ALIGN_LEFT, 10, 0, 0, 0, 255); SWFDisplayItem_moveTo(it, 50, y); SWFDisplayItem_setName(it, "tf1"); y += inc; it = add_text_field(mo, (SWFBlock)efont, "Transparent", 1, 2, 3, SWFTEXTFIELD_ALIGN_LEFT, 10, 0, 0, 0, 0); SWFDisplayItem_moveTo(it, 50, y); SWFDisplayItem_setName(it, "tf2"); y += inc; it = add_text_field(mo, (SWFBlock)efont, "X scaled by 16, no indent or " "margin", 0, 0, 0, SWFTEXTFIELD_ALIGN_LEFT, 10, 0, 0, 0, 255); SWFDisplayItem_moveTo(it, 50, y); SWFDisplayItem_scale(it, 16, 1); SWFDisplayItem_setName(it, "tf3"); y += inc; it = add_text_field(mo, (SWFBlock)efont, "X scaled by 16, indent 4", 4, 0, 0, SWFTEXTFIELD_ALIGN_LEFT, 10, 0, 0, 0, 255); SWFDisplayItem_moveTo(it, 50, y); SWFDisplayItem_scale(it, 16, 1); SWFDisplayItem_setName(it, "tf4"); y += inc; it = add_text_field(mo, (SWFBlock)efont, "X scaled by 16, left margin 4", 0, 4, 0, SWFTEXTFIELD_ALIGN_LEFT, 10, 0, 0, 0, 255); SWFDisplayItem_moveTo(it, 50, y); SWFDisplayItem_scale(it, 16, 1); SWFDisplayItem_setName(it, "tf5"); y += inc; it = add_text_field(mo, (SWFBlock)efont, "X scaled by 16, right margin 4", 0, 0, 4, SWFTEXTFIELD_ALIGN_LEFT, 10, 0, 0, 0, 255); SWFDisplayItem_moveTo(it, 50, y); SWFDisplayItem_scale(it, 16, 1); SWFDisplayItem_setName(it, "tf6"); y += inc; it = add_text_field(mo, (SWFBlock)efont, "X scaled by 16, left margin 4, " "indent 4", 4, 4, 0, SWFTEXTFIELD_ALIGN_LEFT, 10, 0, 0, 0, 255); SWFDisplayItem_moveTo(it, 50, y); SWFDisplayItem_scale(it, 16, 1); SWFDisplayItem_setName(it, "tf7"); y += inc; it = add_text_field(mo, (SWFBlock)efont, "X scaled by 8, no indent or margin", 0, 0, 0, SWFTEXTFIELD_ALIGN_LEFT, 10, 0, 0, 0, 255); SWFDisplayItem_moveTo(it, 50, y); SWFDisplayItem_scale(it, 8, 1); SWFDisplayItem_setName(it, "tf8"); y += inc; it = add_text_field(mo, (SWFBlock)efont, "X scaled by 8, indent 4", 4, 0, 0, SWFTEXTFIELD_ALIGN_LEFT, 10, 0, 0, 0, 255); SWFDisplayItem_moveTo(it, 50, y); SWFDisplayItem_scale(it, 8, 1); SWFDisplayItem_setName(it, "tf9"); y += inc; it = add_text_field(mo, (SWFBlock)efont, "X scaled by 0.2", 8, 8, 8, SWFTEXTFIELD_ALIGN_LEFT, 10, 0, 0, 0, 255); SWFDisplayItem_moveTo(it, 50, y); SWFDisplayItem_scale(it, 0.2, 1); SWFDisplayItem_setName(it, "tf10"); y += inc; it = add_text_field(mo, (SWFBlock)efont, "Y scaled by 4", 4, 4, 0, SWFTEXTFIELD_ALIGN_LEFT, 10, 0, 0, 0, 255); SWFDisplayItem_moveTo(it, 50, y); SWFDisplayItem_scale(it, 1, 4); SWFDisplayItem_setName(it, "tf11"); y += inc * 3; it = add_text_field(mo, (SWFBlock)efont, "Y scaled by 8", 4, 4, 0, SWFTEXTFIELD_ALIGN_LEFT, 10, 0, 0, 0, 255); SWFDisplayItem_moveTo(it, 50, y); SWFDisplayItem_scale(it, 1, 8); SWFDisplayItem_setName(it, "tf12"); // It's not clear how consistent the textWidth or textHeight // values are. As they are embedded, it may be possible to reproduce // exactly, in which case the test can be made more precise. check_equals(mo, "tf1._width", "84"); check_equals(mo, "tf1._height", "20"); xcheck_equals(mo, "tf1._x", "48"); xcheck_equals(mo, "tf1._y", "28"); xcheck_equals(mo, "tf1.textHeight", "23"); // Approx 46 add_actions(mo, "trace(tf1.textWidth);"); xcheck(mo, "tf1.textWidth >= 44 && tf1.textWidth <= 48"); check_equals(mo, "tf2._width", "84"); check_equals(mo, "tf2._height", "20"); xcheck_equals(mo, "tf2._x", "48"); xcheck_equals(mo, "tf2._y", "58"); xcheck_equals(mo, "tf2.textHeight", "23"); // Approx 78 add_actions(mo, "trace(tf2.textWidth);"); xcheck(mo, "tf2.textWidth >= 76 && tf2.textWidth <= 80"); check_equals(mo, "tf3._width", "1344"); check_equals(mo, "tf3._height", "20"); xcheck_equals(mo, "tf3._x", "18"); xcheck_equals(mo, "tf3._y", "88"); xcheck_equals(mo, "tf3.textHeight", "23"); // Approx 230 add_actions(mo, "trace(tf3.textWidth);"); xcheck(mo, "tf3.textWidth >= 225 && tf3.textWidth <= 235"); check_equals(mo, "tf4._width", "1344"); check_equals(mo, "tf4._height", "20"); xcheck_equals(mo, "tf4._x", "18"); xcheck_equals(mo, "tf4._y", "118"); xcheck_equals(mo, "tf4.textHeight", "23"); // Approx 156 add_actions(mo, "trace(tf4.textWidth);"); xcheck(mo, "tf4.textWidth >= 153 && tf4.textWidth <= 159"); check_equals(mo, "tf5._width", "1344"); check_equals(mo, "tf5._height", "20"); xcheck_equals(mo, "tf5._x", "18"); xcheck_equals(mo, "tf5._y", "148"); xcheck_equals(mo, "tf5.textHeight", "23"); // Approx 186 add_actions(mo, "trace(tf5.textWidth);"); xcheck(mo, "tf5.textWidth >= 183 && tf5.textWidth <= 189"); check_equals(mo, "tf6._width", "1344"); check_equals(mo, "tf6._height", "20"); xcheck_equals(mo, "tf6._x", "18"); xcheck_equals(mo, "tf6._y", "178"); xcheck_equals(mo, "tf6.textHeight", "23"); // Approx 194 add_actions(mo, "trace(tf6.textWidth);"); xcheck(mo, "tf6.textWidth >= 189 && tf6.textWidth <= 199"); check_equals(mo, "tf7._width", "1344"); check_equals(mo, "tf7._height", "20"); xcheck_equals(mo, "tf7._x", "18"); xcheck_equals(mo, "tf7._y", "208"); xcheck_equals(mo, "tf7.textHeight", "23"); // Approx 247 add_actions(mo, "trace(tf7.textWidth);"); xcheck(mo, "tf7.textWidth >= 240 && tf7.textWidth <= 254"); check_equals(mo, "tf8._width", "672"); check_equals(mo, "tf8._height", "20"); xcheck_equals(mo, "tf8._x", "34"); xcheck_equals(mo, "tf8._y", "238"); xcheck_equals(mo, "tf8.textHeight", "23"); // Approx 222 add_actions(mo, "trace(tf8.textWidth);"); xcheck(mo, "tf8.textWidth >= 217 && tf8.textWidth <= 227"); check_equals(mo, "tf9._width", "672"); check_equals(mo, "tf9._height", "20"); xcheck_equals(mo, "tf9._x", "34"); xcheck_equals(mo, "tf9._y", "268"); xcheck_equals(mo, "tf9.textHeight", "23"); // Approx 148 add_actions(mo, "trace(tf9.textWidth);"); xcheck(mo, "tf9.textWidth >= 144 && tf9.textWidth <= 152"); check_equals(mo, "tf10._width", "16.8"); check_equals(mo, "tf10._height", "20"); xcheck_equals(mo, "tf10._x", "49.6"); xcheck_equals(mo, "tf10._y", "298"); xcheck_equals(mo, "tf10.textHeight", "23"); // Approx 99 add_actions(mo, "trace(tf10.textWidth);"); xcheck(mo, "tf10.textWidth >= 95 && tf10.textWidth <= 103"); // The textHeight for the following two fields varies. check_equals(mo, "tf11._width", "84"); check_equals(mo, "tf11._height", "80"); xcheck_equals(mo, "tf11._x", "48"); xcheck_equals(mo, "tf11._y", "322"); xcheck_equals(mo, "tf11.textHeight", "23"); // Approx 86 add_actions(mo, "trace(tf11.textWidth);"); xcheck(mo, "tf11.textWidth >= 84 && tf11.textWidth <= 88"); check_equals(mo, "tf12._width", "84"); check_equals(mo, "tf12._height", "160"); xcheck_equals(mo, "tf12._x", "48"); xcheck_equals(mo, "tf12._y", "404"); xcheck_equals(mo, "tf12.textHeight", "23"); // Approx 86 add_actions(mo, "trace(tf12.textWidth);"); xcheck(mo, "tf12.textWidth >= 84 && tf12.textWidth <= 88"); add_actions(mo, "totals(); stop();"); SWFMovie_nextFrame(mo); /***************************************************** * * Output movie * *****************************************************/ puts("Saving " OUTPUT_FILENAME ); SWFMovie_save(mo, OUTPUT_FILENAME); return 0; }
int main(int argc, char** argv) { SWFMovie mo; const char *srcdir="."; char fdbfont[256]; SWFMovieClip dejagnuclip; SWFDisplayItem it; /********************************************* * * Initialization * *********************************************/ if ( argc>1 ) srcdir=argv[1]; else { fprintf(stderr, "Usage: %s <mediadir>\n", argv[0]); return 1; } sprintf(fdbfont, "%s/Bitstream-Vera-Sans.fdb", srcdir); puts("Setting things up"); Ming_init(); Ming_useSWFVersion (OUTPUT_VERSION); mo = newSWFMovie(); SWFMovie_setRate(mo, 1.0); SWFMovie_setDimension(mo, 800, 600); dejagnuclip = get_dejagnu_clip((SWFBlock)get_default_font(srcdir), 10, 0, 0, 800, 600); SWFMovie_add(mo, (SWFBlock)dejagnuclip); SWFMovie_nextFrame(mo); // 1st frame /********************************************* * * Add some textfields * *********************************************/ SWFBrowserFont bfont = newSWFBrowserFont("_sans"); int y = 30; int inc = 30; it = add_text_field(mo, (SWFBlock)bfont, "Normal", 1, 2, 3, SWFTEXTFIELD_ALIGN_LEFT, 10, 0, 0, 0, 255); SWFDisplayItem_moveTo(it, 50, y); SWFDisplayItem_setName(it, "tf1"); y += inc; it = add_text_field(mo, (SWFBlock)bfont, "Transparent", 1, 2, 3, SWFTEXTFIELD_ALIGN_LEFT, 10, 0, 0, 0, 0); SWFDisplayItem_moveTo(it, 50, y); SWFDisplayItem_setName(it, "tf2"); y += inc; it = add_text_field(mo, (SWFBlock)bfont, "X scaled by 16, no indent or " "margin", 0, 0, 0, SWFTEXTFIELD_ALIGN_LEFT, 10, 0, 0, 0, 255); SWFDisplayItem_moveTo(it, 50, y); SWFDisplayItem_scale(it, 16, 1); SWFDisplayItem_setName(it, "tf3"); y += inc; it = add_text_field(mo, (SWFBlock)bfont, "X scaled by 16, indent 4", 4, 0, 0, SWFTEXTFIELD_ALIGN_LEFT, 10, 0, 0, 0, 255); SWFDisplayItem_moveTo(it, 50, y); SWFDisplayItem_scale(it, 16, 1); SWFDisplayItem_setName(it, "tf4"); y += inc; it = add_text_field(mo, (SWFBlock)bfont, "X scaled by 16, left margin 4", 0, 4, 0, SWFTEXTFIELD_ALIGN_LEFT, 10, 0, 0, 0, 255); SWFDisplayItem_moveTo(it, 50, y); SWFDisplayItem_scale(it, 16, 1); SWFDisplayItem_setName(it, "tf5"); y += inc; it = add_text_field(mo, (SWFBlock)bfont, "X scaled by 16, right margin 4", 0, 0, 4, SWFTEXTFIELD_ALIGN_LEFT, 10, 0, 0, 0, 255); SWFDisplayItem_moveTo(it, 50, y); SWFDisplayItem_scale(it, 16, 1); SWFDisplayItem_setName(it, "tf6"); y += inc; it = add_text_field(mo, (SWFBlock)bfont, "X scaled by 16, left margin 4, " "indent 4", 4, 4, 0, SWFTEXTFIELD_ALIGN_LEFT, 10, 0, 0, 0, 255); SWFDisplayItem_moveTo(it, 50, y); SWFDisplayItem_scale(it, 16, 1); SWFDisplayItem_setName(it, "tf7"); y += inc; it = add_text_field(mo, (SWFBlock)bfont, "X scaled by 8, no indent or margin", 0, 0, 0, SWFTEXTFIELD_ALIGN_LEFT, 10, 0, 0, 0, 255); SWFDisplayItem_moveTo(it, 50, y); SWFDisplayItem_scale(it, 8, 1); SWFDisplayItem_setName(it, "tf8"); y += inc; it = add_text_field(mo, (SWFBlock)bfont, "X scaled by 8, indent 4", 4, 0, 0, SWFTEXTFIELD_ALIGN_LEFT, 10, 0, 0, 0, 255); SWFDisplayItem_moveTo(it, 50, y); SWFDisplayItem_scale(it, 8, 1); SWFDisplayItem_setName(it, "tf9"); y += inc; it = add_text_field(mo, (SWFBlock)bfont, "X scaled by 0.2", 8, 8, 8, SWFTEXTFIELD_ALIGN_LEFT, 10, 0, 0, 0, 255); SWFDisplayItem_moveTo(it, 50, y); SWFDisplayItem_scale(it, 0.2, 1); SWFDisplayItem_setName(it, "tf10"); y += inc; it = add_text_field(mo, (SWFBlock)bfont, "Y scaled by 4", 4, 4, 0, SWFTEXTFIELD_ALIGN_LEFT, 10, 0, 0, 0, 255); SWFDisplayItem_moveTo(it, 50, y); SWFDisplayItem_scale(it, 1, 4); SWFDisplayItem_setName(it, "tf11"); y += inc * 3; it = add_text_field(mo, (SWFBlock)bfont, "Y scaled by 8", 4, 4, 0, SWFTEXTFIELD_ALIGN_LEFT, 10, 0, 0, 0, 255); SWFDisplayItem_moveTo(it, 50, y); SWFDisplayItem_scale(it, 1, 8); SWFDisplayItem_setName(it, "tf12"); // As these are device fonts, it's not clear how consistent the textWidth // value will be. It's not even clear that it's worth testing it. check_equals(mo, "tf1._width", "84"); check_equals(mo, "tf1._height", "20"); xcheck_equals(mo, "tf1._x", "48"); xcheck_equals(mo, "tf1._y", "28"); xcheck_equals(mo, "tf1.textHeight", "24"); // Approx 42 xcheck(mo, "tf1.textWidth >= 40 && tf1.textWidth <= 45"); check_equals(mo, "tf2._width", "84"); check_equals(mo, "tf2._height", "20"); xcheck_equals(mo, "tf2._x", "48"); xcheck_equals(mo, "tf2._y", "58"); xcheck_equals(mo, "tf2.textHeight", "24"); // Approx 69 xcheck(mo, "tf2.textWidth >= 66 && tf2.textWidth <= 72"); check_equals(mo, "tf3._width", "1344"); check_equals(mo, "tf3._height", "20"); xcheck_equals(mo, "tf3._x", "18"); xcheck_equals(mo, "tf3._y", "88"); xcheck_equals(mo, "tf3.textHeight", "24"); // Approx 13 xcheck(mo, "tf3.textWidth >= 11 && tf3.textWidth <= 15"); check_equals(mo, "tf4._width", "1344"); check_equals(mo, "tf4._height", "20"); xcheck_equals(mo, "tf4._x", "18"); xcheck_equals(mo, "tf4._y", "118"); xcheck_equals(mo, "tf4.textHeight", "24"); // Approx 9 xcheck(mo, "tf4.textWidth >= 7 && tf4.textWidth <= 11"); check_equals(mo, "tf5._width", "1344"); check_equals(mo, "tf5._height", "20"); xcheck_equals(mo, "tf5._x", "18"); xcheck_equals(mo, "tf5._y", "148"); xcheck_equals(mo, "tf5.textHeight", "24"); // Approx 10 xcheck(mo, "tf5.textWidth >= 8 && tf5.textWidth <= 12"); check_equals(mo, "tf6._width", "1344"); check_equals(mo, "tf6._height", "20"); xcheck_equals(mo, "tf6._x", "18"); xcheck_equals(mo, "tf6._y", "178"); xcheck_equals(mo, "tf6.textHeight", "24"); // Approx 11 xcheck(mo, "tf6.textWidth >= 9 && tf6.textWidth <= 13"); check_equals(mo, "tf7._width", "1344"); check_equals(mo, "tf7._height", "20"); xcheck_equals(mo, "tf7._x", "18"); xcheck_equals(mo, "tf7._y", "208"); xcheck_equals(mo, "tf7.textHeight", "24"); // Approx 14 xcheck(mo, "tf7.textWidth >= 14 && tf7.textWidth <= 16"); check_equals(mo, "tf8._width", "672"); check_equals(mo, "tf8._height", "20"); xcheck_equals(mo, "tf8._x", "34"); xcheck_equals(mo, "tf8._y", "238"); xcheck_equals(mo, "tf8.textHeight", "24"); // Approx 25 xcheck(mo, "tf8.textWidth >= 21 && tf8.textWidth <= 27"); check_equals(mo, "tf9._width", "672"); check_equals(mo, "tf9._height", "20"); xcheck_equals(mo, "tf9._x", "34"); xcheck_equals(mo, "tf9._y", "268"); xcheck_equals(mo, "tf9.textHeight", "24"); // Approx 16 xcheck(mo, "tf9.textWidth >= 14 && tf9.textWidth <= 18"); check_equals(mo, "tf10._width", "16.8"); check_equals(mo, "tf10._height", "20"); xcheck_equals(mo, "tf10._x", "49.6"); xcheck_equals(mo, "tf10._y", "298"); xcheck_equals(mo, "tf10.textHeight", "24"); // Approx 452 xcheck(mo, "tf10.textWidth >= 440 && tf10.textWidth <= 460"); // The textHeight for the following two fields varies. check_equals(mo, "tf11._width", "84"); check_equals(mo, "tf11._height", "80"); xcheck_equals(mo, "tf11._x", "48"); xcheck_equals(mo, "tf11._y", "322"); add_actions(mo, "trace(tf11.textWidth);"); xcheck(mo, "tf11.textHeight >= 23 && tf11.textHeight <= 24"); // Approx 315 xcheck(mo, "tf11.textWidth >= 305 && tf11.textWidth <= 325"); check_equals(mo, "tf12._width", "84"); check_equals(mo, "tf12._height", "160"); xcheck_equals(mo, "tf12._x", "48"); xcheck_equals(mo, "tf12._y", "404"); add_actions(mo, "trace(tf12.textWidth);"); xcheck(mo, "tf12.textHeight >= 23 && tf12.textHeight <= 24"); // Approx 640 xcheck(mo, "tf12.textWidth >= 625 && tf12.textWidth <= 655"); add_actions(mo, "totals(); stop();"); SWFMovie_nextFrame(mo); /***************************************************** * * Output movie * *****************************************************/ puts("Saving " OUTPUT_FILENAME ); SWFMovie_save(mo, OUTPUT_FILENAME); return 0; }