int main(int argc, char** argv) { SWFMovie mo; SWFMovieClip mc1, mc2, dejagnuclip; SWFDisplayItem it1, it2; SWFShape sh1,sh2; const char *srcdir="."; if ( argc>1 ) srcdir=argv[1]; else { //fprintf(stderr, "Usage: %s <mediadir>\n", argv[0]); //return 1; } Ming_init(); Ming_useSWFVersion (OUTPUT_VERSION); mo = newSWFMovie(); SWFMovie_setDimension(mo, 800, 600); SWFMovie_setRate(mo, 6); // Frame 1: Place dejagnu clip dejagnuclip = get_dejagnu_clip((SWFBlock)get_default_font(srcdir), 10, 0, 0, 800, 600); SWFMovie_add(mo, (SWFBlock)dejagnuclip); add_actions(mo, "mc1Constructed=0; mc2Constructed=0; mc3Constructed=0; mc4Constructed=0;"); SWFMovie_nextFrame(mo); // // Frame 2: // Place red static movieClip1 DisplayObject at depth 3 (-16381) // Place black static movieClip1 DisplayObject at depth 4 (-16380) // sh1 = make_fill_square (300, 300, 60, 60, 255, 0, 0, 255, 0, 0); mc1 = newSWFMovieClip(); SWFMovieClip_add(mc1, (SWFBlock)sh1); SWFMovieClip_nextFrame(mc1); it1 = SWFMovie_add(mo, (SWFBlock)mc1); //add movieClip1 to the _root SWFDisplayItem_setDepth(it1, 3); SWFDisplayItem_setName(it1, "movieClip1"); //name movieClip1 SWFDisplayItem_addAction(it1, newSWFAction( "_root.note(this+' constructed');" "_root.mc1Constructed++;" ), SWFACTION_CONSTRUCT); sh2 = make_fill_square (330, 270, 120, 120, 0, 0, 0, 0, 0, 0); mc2 = newSWFMovieClip(); SWFMovieClip_add(mc2, (SWFBlock)sh2); SWFMovieClip_nextFrame(mc2); it2 = SWFMovie_add(mo, (SWFBlock)mc2); //add movieClip2 to the _root SWFDisplayItem_setDepth(it2, 4); SWFDisplayItem_setName(it2, "movieClip2"); //name movieClip2 SWFDisplayItem_addAction(it2, newSWFAction( "_root.note(this+' constructed');" "_root.mc2Constructed++;"), SWFACTION_CONSTRUCT); SWFMovie_nextFrame(mo); // Frame3: nothing new SWFMovie_nextFrame(mo); // Frame4: remove "movieClip1" and "movieClip2" SWFDisplayItem_remove(it1); SWFDisplayItem_remove(it2); SWFMovie_nextFrame(mo); // // Frame5: // Place red static movieClip3 DisplayObject at depth 3 (-16381) with ratio set to 2.0 // Place black static movieClip4 DisplayObject at depth4 (-16380) with ratio set to 0.0 // it1 = SWFMovie_add(mo, (SWFBlock)mc1); //add movieClip3 to the _root SWFDisplayItem_setDepth(it1, 3); SWFDisplayItem_setName(it1, "movieClip3"); //name movieClip3 SWFDisplayItem_setRatio(it1, 2.0); // It's important to set this, don't why yet. SWFDisplayItem_addAction(it1, newSWFAction( "_root.note(this+' constructed');" "_root.mc3Constructed++;" ), SWFACTION_CONSTRUCT); it2 = SWFMovie_add(mo, (SWFBlock)mc2); //add movieClip4 to the _root SWFDisplayItem_setDepth(it2, 4); SWFDisplayItem_setName(it2, "movieClip4"); //name movieClip4 SWFDisplayItem_setRatio(it2, 0.0); // It's important to set this, don't why yet. SWFDisplayItem_addAction(it2, newSWFAction( "_root.note(this+' constructed');" "_root.mc4Constructed++;" ), SWFACTION_CONSTRUCT); SWFMovie_nextFrame(mo); // // Frame4: check, gotoAndStop(3), check.. // check_equals(mo, "typeof(movieClip1)", "'undefined'"); check_equals(mo, "typeof(movieClip2)", "'undefined'"); check_equals(mo, "typeof(movieClip3)", "'movieclip'"); check_equals(mo, "typeof(movieClip4)", "'movieclip'"); check_equals(mo, "_root.mc1Constructed", "1"); check_equals(mo, "_root.mc2Constructed", "1"); check_equals(mo, "_root.mc3Constructed", "1"); check_equals(mo, "_root.mc4Constructed", "1"); SWFMovie_add(mo, (SWFBlock)newSWFAction( "gotoAndStop(3);")); check_equals(mo, "typeof(movieClip1)", "'movieclip'"); check_equals(mo, "typeof(movieClip2)", "'undefined'"); // the difference of movieClip3 and movieClip4 was caused by the ratio value check_equals(mo, "typeof(movieClip3)", "'undefined'"); check_equals(mo, "typeof(movieClip4)", "'movieclip'"); check_equals(mo, "_root.mc1Constructed", "2"); check_equals(mo, "_root.mc2Constructed", "1"); check_equals(mo, "_root.mc3Constructed", "1"); check_equals(mo, "_root.mc4Constructed", "1"); SWFMovie_add(mo, (SWFBlock)newSWFAction( "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; SWFMovieClip dejagnuclip; SWFMorph morph; SWFShape startShape, endShape; SWFDisplayItem it; float ratio; const char *srcdir="."; if ( argc>1 ) srcdir=argv[1]; else { fprintf(stderr, "Usage: %s <mediadir>\n", argv[0]); return 1; } Ming_init(); mo = newSWFMovieWithVersion(OUTPUT_VERSION); SWFMovie_setDimension(mo, 800, 600); SWFMovie_setRate (mo, 1.0); // _root.frame1 dejagnuclip = get_dejagnu_clip((SWFBlock)get_default_font(srcdir), 10, 0, 0, 800, 600); SWFMovie_add(mo, (SWFBlock)dejagnuclip); SWFMovie_nextFrame(mo); // _root.frame2, define and place a morph morph = newSWFMorphShape(); startShape = SWFMorph_getShape1(morph); make_shape(startShape, 0, 0, 100, 100, 255, 0 ,0); endShape = SWFMorph_getShape2(morph); make_shape(endShape, 700, 500, 100, 100, 0, 255 ,0); it = SWFMovie_add(mo, (SWFBlock)morph); SWFMovie_nextFrame(mo); // update the morph with different ratios for(ratio=0.2; ratio<1.01; ratio+=0.2) { SWFDisplayItem_remove(it); it = SWFMovie_add(mo, (SWFBlock)morph); SWFDisplayItem_setRatio(it, ratio); SWFMovie_nextFrame(mo); } /* Test for #39989 by adding an empty morph shape. */ morph = newSWFMorphShape(); startShape = SWFMorph_getShape1(morph); endShape = SWFMorph_getShape2(morph); it = SWFMovie_add(mo, (SWFBlock)morph); SWFMovie_nextFrame(mo); //Output movie puts("Saving " OUTPUT_FILENAME ); SWFMovie_save(mo, OUTPUT_FILENAME); return 0; }
EXPORT BOOL WINAPI i_setRatio(float ratio, int p2, int p3, int p4) { lstrcpy(funcname, "i_setRatio"); SWFDisplayItem_setRatio(mhsp_item, ratio); return 0; }
int main(int argc, char** argv) { SWFMovie mo; SWFMovieClip mc1, mc2, dejagnuclip; SWFShape sh1, sh2; SWFDisplayItem it1, it2; const char *srcdir="."; if ( argc>1 ) srcdir=argv[1]; else { fprintf(stderr, "Usage: %s <mediadir>\n", argv[0]); return 1; } Ming_init(); mo = newSWFMovieWithVersion(OUTPUT_VERSION); SWFMovie_setDimension(mo, 800, 600); SWFMovie_setRate (mo, 12.0); dejagnuclip = get_dejagnu_clip((SWFBlock)get_default_font(srcdir), 10, 0, 0, 800, 600); SWFMovie_add(mo, (SWFBlock)dejagnuclip); add_actions(mo, "testvar1 = 0; testvar2 = 0;"); SWFMovie_nextFrame(mo); // frame1 // // Define movieClips // mc1 = newSWFMovieClip(); sh1 = make_fill_square (100, 100, 60, 60, 255, 0, 0, 255, 0, 0); SWFMovieClip_add(mc1, (SWFBlock)sh1); SWFMovieClip_nextFrame(mc1); mc2 = newSWFMovieClip(); sh2 = make_fill_square (300, 100, 60, 60, 255, 0, 0, 0, 255, 0); SWFMovieClip_add(mc2, (SWFBlock)sh2); SWFMovieClip_nextFrame(mc2); SWFMovie_nextFrame(mo); // frame2 // // Place mc1 at depth 3, place mc1 at depth3 again with a different name; // Observed behaviour: later place does not create a new DisplayObject // it1 = SWFMovie_add(mo, (SWFBlock)mc1); SWFDisplayItem_setDepth(it1, 3); SWFDisplayItem_setName(it1, "static_mc1"); SWFDisplayItem_addAction(it1, newSWFAction(" _root.testvar1++; trace(this); trace(_root.testvar1); "), SWFACTION_INIT | SWFACTION_CONSTRUCT | SWFACTION_ONLOAD); it2 = SWFMovie_add(mo, (SWFBlock)mc2); SWFDisplayItem_setDepth(it2, 3); SWFDisplayItem_setName(it2, "static_mc2"); SWFDisplayItem_addAction(it2, newSWFAction(" _root.testvar2++; trace(this); trace(_root.testvar2); "), SWFACTION_INIT | SWFACTION_CONSTRUCT | SWFACTION_ONLOAD); check_equals(mo, "typeof(static_mc1)", "'movieclip'"); if(OUTPUT_VERSION > 5) { // check that "static_mc2" doesn't get placed check_equals(mo, "typeof(static_mc2)", "'undefined'"); } else { // check that "static_mc2" does get placed check_equals(mo, "typeof(static_mc2)", "'movieclip'"); } SWFMovie_nextFrame(mo); // frame3 if(OUTPUT_VERSION > 5) { check_equals(mo, "testvar1", "3"); check_equals(mo, "testvar2", "0"); } else { // swf5 does not support CONSTRUCT event check_equals(mo, "testvar1", "2"); check_equals(mo, "testvar2", "2"); } // // Place mc2 at depth 3 again. // Observed behaviour: no new DisplayObject gets created // it2 = SWFMovie_add(mo, (SWFBlock)mc2); SWFDisplayItem_setDepth(it2, 3); SWFDisplayItem_setName(it2, "static_mc3"); check_equals(mo, "typeof(static_mc1)", "'movieclip'"); if(OUTPUT_VERSION > 5) { // check that "static_mc3" doesn't get placed check_equals(mo, "typeof(static_mc3)", "'undefined'"); } else { // check that "static_mc3" does get placed check_equals(mo, "typeof(static_mc3)", "'movieclip'"); } SWFMovie_nextFrame(mo); // frame4 // // Place mc1 at depth 3 again with ratio set to 0.2 // Observed behaviour: no new DisplayObject get placed(created). // it2 = SWFMovie_add(mo, (SWFBlock)mc1); SWFDisplayItem_setDepth(it2, 3); SWFDisplayItem_setName(it2, "static_mc4"); SWFDisplayItem_setRatio(it2, 0.2); check_equals(mo, "typeof(static_mc1)", "'movieclip'"); if(OUTPUT_VERSION > 5) { // check that "static_mc4" doesn't get placed. check_equals(mo, "typeof(static_mc4)", "'undefined'"); } else { // check that "static_mc4" does get placed. check_equals(mo, "typeof(static_mc4)", "'movieclip'"); } SWFMovie_nextFrame(mo); // frame5 // // Place mc2 at depth 3 again with ratio set to 0.2 // Observed behaviour: no new DisplayObject get placed(created). // it2 = SWFMovie_add(mo, (SWFBlock)mc2); SWFDisplayItem_setDepth(it2, 3); SWFDisplayItem_setName(it2, "static_mc5"); SWFDisplayItem_setRatio(it2, 0.2); check_equals(mo, "typeof(static_mc1)", "'movieclip'"); if(OUTPUT_VERSION > 5) { // check that "static_mc5" doesn't get placed. check_equals(mo, "typeof(static_mc5)", "'undefined'"); } else { // check that "static_mc5" does get placed. check_equals(mo, "typeof(static_mc5)", "'movieclip'"); } SWFMovie_nextFrame(mo); // frame6 // // Odd, where are the movieclips now? // Note that all those movieclips are defined above but not now. // if(OUTPUT_VERSION <= 5) { add_actions(mo, "check_equals(typeof(static_m1), 'undefined');" "check_equals(typeof(static_m2), 'undefined');" "check_equals(typeof(static_m3), 'undefined');" "check_equals(typeof(static_m4), 'undefined');" "check_equals(typeof(static_m5), 'undefined');" ); } add_actions(mo, " _root.totals(); stop(); "); SWFMovie_nextFrame(mo); // frame7 //Output movie puts("Saving " OUTPUT_FILENAME ); SWFMovie_save(mo, OUTPUT_FILENAME); return 0; }
int main(int argc, char** argv) { SWFMovie mo; SWFDisplayItem it1, it2, it3; SWFDisplayItem it41; SWFDisplayItem it51; SWFMovieClip mc1, mc2, mc3, dejagnuclip; SWFMovieClip mc4, mc41; SWFMovieClip mc5, mc51; SWFShape sh1, sh2, sh3; const char *srcdir="."; if ( argc>1 ) srcdir=argv[1]; else { //fprintf(stderr, "Usage: %s <mediadir>\n", argv[0]); //return 1; } Ming_init(); Ming_useSWFVersion (OUTPUT_VERSION); mo = newSWFMovie(); SWFMovie_setDimension(mo, 800, 600); SWFMovie_setRate(mo, 12); dejagnuclip = get_dejagnu_clip((SWFBlock)get_default_font(srcdir), 10, 0, 0, 800, 600); SWFMovie_add(mo, (SWFBlock)dejagnuclip); add_actions(mo, " haslooped1=false; haslooped2=false; haslooped3=false;" " mc1Initialized=0; mc1Unloaded=0;" " mc2Initialized=0; mc2Unloaded=0;" " mc3Initialized=0; mc3Unloaded=0;" " asOrder='0+';"); SWFMovie_nextFrame(mo); // frame1 sh1 = make_fill_square (100, 100, 60, 60, 255, 0, 0, 255, 0, 0); mc1 = newSWFMovieClip(); SWFMovieClip_add(mc1, (SWFBlock)sh1); SWFMovieClip_nextFrame(mc1); sh2 = make_fill_square (200, 200, 60, 60, 0, 0, 0, 0, 0, 0); mc2 = newSWFMovieClip(); SWFMovieClip_add(mc2, (SWFBlock)sh2); SWFMovieClip_nextFrame(mc2); sh3 = make_fill_square (300, 300, 60, 60, 0, 0, 0, 0, 0, 0); mc3 = newSWFMovieClip(); SWFMovieClip_add(mc3, (SWFBlock)sh3); SWFMovieClip_nextFrame(mc3); it1 = SWFMovie_add(mo, (SWFBlock)mc1); SWFDisplayItem_setName(it1, "mc1"); SWFDisplayItem_setDepth(it1, 100); SWFDisplayItem_addAction(it1, newSWFAction( "_root.note(this+' initialized');" "_root.mc1Initialized++;" "_root.asOrder += '1+';" ), SWFACTION_INIT); SWFDisplayItem_addAction(it1, newSWFAction( "_root.note(this+' unloaded');" "_root.mc1Unloaded++;" "_root.asOrder += '3+';" ), SWFACTION_UNLOAD); SWFMovie_nextFrame(mo); // frame2 SWFDisplayItem_remove(it1); it2 = SWFMovie_add(mo, (SWFBlock)mc2); SWFDisplayItem_setName(it2, "mc2"); SWFDisplayItem_setRatio(it2, 0.1); SWFDisplayItem_setDepth(it2, 100); SWFDisplayItem_addAction(it2, newSWFAction( "_root.note(this+' initialized');" "_root.mc2Initialized++;" "_root.asOrder += '2+';" ), SWFACTION_INIT); SWFDisplayItem_addAction(it2, newSWFAction( "_root.note(this+' unloaded');" "_root.mc2Unloaded++;" "_root.asOrder += '5+';" ), SWFACTION_UNLOAD); SWFMovie_nextFrame(mo); // frame3 SWFDisplayItem_remove(it2); it3 = SWFMovie_add(mo, (SWFBlock)mc3); SWFDisplayItem_setName(it3, "mc3"); SWFDisplayItem_setRatio(it3, 0.2); SWFDisplayItem_setDepth(it3, 100); SWFDisplayItem_addAction(it3, newSWFAction( "_root.note(this+' initialized');" "_root.mc3Initialized++;" "_root.asOrder += '4+';" ), SWFACTION_INIT); SWFDisplayItem_addAction(it3, newSWFAction( "_root.note(this+' unloaded');" "_root.mc3Unloaded++;" ), SWFACTION_UNLOAD); SWFMovie_nextFrame(mo); // frame4 SWFMovie_nextFrame(mo); // frame 5 add_actions(mo, "if(! haslooped1) {" " gotoAndPlay(5);" " haslooped1 = true;" "}" ); SWFMovie_nextFrame(mo); // frame 6 check_equals(mo, "mc1Initialized", "2"); check_equals(mo, "mc2Initialized", "2"); check_equals(mo, "mc3Initialized", "1"); check_equals(mo, "mc1Unloaded", "2"); check_equals(mo, "mc2Unloaded", "2"); check_equals(mo, "mc3Unloaded", "0"); xcheck_equals(mo, "asOrder", "'0+1+2+3+4+5+1+2+3+5+'"); SWFMovie_nextFrame(mo); // frame 7 // // ==case 2== // mc4 = newSWFMovieClip(); mc41 = newSWFMovieClip(); SWFMovieClip_nextFrame(mc41); it41 = SWFMovieClip_add(mc4, (SWFBlock)mc41); add_clip_actions(mc4, "_root.check_equals(this._target, '/instance3');" "inst = this.getInstanceAtDepth(-16383);" "if(! haslooped2) {" " haslooped2 = true;" " _root.check_equals(inst._target, '/instance3/instance4');" "} else {" " _root.check_equals(inst._target, '/instance3/instance5');" " stop();" "}" ); SWFMovieClip_nextFrame(mc4); SWFDisplayItem_remove(it41); SWFMovieClip_nextFrame(mc4); SWFMovie_add(mo, mc4); SWFMovie_nextFrame(mo); // frame 9 SWFMovie_nextFrame(mo); // frame 10 // // ==case 3== // mc5 = newSWFMovieClip(); mc51 = newSWFMovieClip(); SWFMovieClip_nextFrame(mc51); it51 = SWFMovieClip_add(mc5, (SWFBlock)mc51); add_clip_actions(mc5, "_root.check_equals(this._target, '/instance6');" "inst = this.getInstanceAtDepth(-16383);" "if(! haslooped3) {" " haslooped3 = true;" " _root.check_equals(inst._target, '/instance6/instance7');" "} else {" " _root.check_equals(inst._target, '/instance6/instance7');" " stop();" "}" ); SWFMovieClip_nextFrame(mc5); SWFMovieClip_nextFrame(mc5); SWFMovie_add(mo, mc5); SWFMovie_nextFrame(mo); // frame 11 SWFMovie_nextFrame(mo); // frame 12 SWFMovie_nextFrame(mo); // frame 13 mc5 = newSWFMovieClip(); add_clip_actions(mc5, "_root.check_equals(this._target, '/instance9');"); SWFMovieClip_nextFrame(mc5); SWFMovie_add(mo, mc5); SWFMovie_nextFrame(mo); // frame 14 add_actions(mo, "totals(16); stop();"); SWFMovie_nextFrame(mo); // frame 15 //Output movie puts("Saving " OUTPUT_FILENAME ); SWFMovie_save(mo, OUTPUT_FILENAME); return 0; }
int main(int argc, char *argv[]) { SWFMovie movie; SWFMorph p; SWFShape shape_1; SWFGradient grad_1; SWFFill fill1; SWFShape shape_2; SWFGradient grad_2; SWFFill fill2; SWFDisplayItem timeline; float n; Ming_init(argc, argv); Ming_useSWFVersion(5); movie= newSWFMovie(); SWFMovie_setDimension(movie, 320, 240); p= newSWFMorphShape(); grad_1= newSWFGradient(); SWFGradient_addEntry(grad_1, 0, 0x00, 0x00, 0x00, 0xFF); SWFGradient_addEntry(grad_1, 0.16, 0xFF, 0xFF, 0xFF, 0xFF); SWFGradient_addEntry(grad_1, 0.32, 0x00, 0x00, 0x00, 0xFF); SWFGradient_addEntry(grad_1, 0.48, 0xFF, 0xFF, 0xFF, 0xFF); SWFGradient_addEntry(grad_1, 0.64, 0x00, 0x00, 0x00, 0xFF); SWFGradient_addEntry(grad_1, 0.8, 0xFF, 0xFF, 0xFF, 0xFF); SWFGradient_addEntry(grad_1, 1, 0x00, 0x00, 0x00, 0xFF); shape_1= SWFMorph_getShape1(p); fill1= SWFShape_addGradientFill(shape_1,grad_1, SWFFILL_RADIAL_GRADIENT); SWFFill_scaleTo(fill1, 0.100, 0.100); SWFShape_setLeftFill(shape_1, fill1); SWFShape_movePenTo(shape_1, -160.00, -120.00); SWFShape_drawLineTo(shape_1, 160.00, -120.00); SWFShape_drawLineTo(shape_1, 160.00, 120.00); SWFShape_drawLineTo(shape_1, -160.00, 120.00); SWFShape_drawLineTo(shape_1, -160.00, -120.00); grad_2= newSWFGradient(); SWFGradient_addEntry(grad_2, 0, 0x00, 0x00, 0x00, 0xFF); SWFGradient_addEntry(grad_2, 0.16, 0xFF, 0x00, 0x00, 0xFF); SWFGradient_addEntry(grad_2, 0.32, 0x00, 0x00, 0x00, 0xFF); SWFGradient_addEntry(grad_2, 0.48, 0x00, 0xFF, 0x00, 0xFF); SWFGradient_addEntry(grad_2, 0.64, 0x00, 0x00, 0x00, 0xFF); SWFGradient_addEntry(grad_2, 0.8, 0x00, 0x00, 0xFF, 0xFF); SWFGradient_addEntry(grad_2, 1, 0x00, 0x00, 0x00, 0xFF); shape_2= SWFMorph_getShape2(p); fill2= SWFShape_addGradientFill(shape_2,grad_2, SWFFILL_RADIAL_GRADIENT); SWFFill_scaleTo(fill2, 0.16, 0.16); SWFFill_skewXTo(fill2, -0.50); //SWFFill_rotateTo(fill2, -26.57); SWFShape_setLeftFill(shape_2, fill2); SWFShape_movePenTo(shape_2, -160.00, -120.00); SWFShape_drawLineTo(shape_2, 160.00, -120.00); SWFShape_drawLineTo(shape_2, 160.00, 120.00); SWFShape_drawLineTo(shape_2, -160.00, 120.00); SWFShape_drawLineTo(shape_2, -160.00, -120.00); timeline= SWFMovie_add(movie,(SWFBlock) p); SWFDisplayItem_moveTo(timeline, 160.00, 120.00); for(n=0; n<=1.001; n+=0.01) { SWFDisplayItem_setRatio(timeline, n); SWFMovie_nextFrame(movie); } SWFMovie_save(movie, "gradientxform.swf"); return 0; }