/* The file doaction-after-placeobject.swf was created from * doaction-before-placeobject.swf by manually swapping the DoAction and * PlaceObject2 tags in the file with a hex editor */ int main (int argc, char **argv) { SWFMovie movie; SWFMovieClip clip; SWFDisplayItem item; if (Ming_init ()) return 1; Ming_useSWFVersion (7); movie = newSWFMovie(); SWFMovie_setRate (movie, 1); SWFMovie_setDimension (movie, 200, 150); clip = newSWFMovieClip (); item = SWFMovie_add (movie, (SWFBlock) clip); SWFDisplayItem_setName (item, "m"); SWFDisplayItem_addAction (item, compileSWFActionCode ("" " trace (\"clipEvent (load)\");" " trace (this);" ""), SWFACTION_ONLOAD); SWFMovie_add (movie, (SWFBlock) compileSWFActionCode ("" "trace (\"Frame 0\");" "")); SWFMovie_save (movie, "doaction-before-placeobject.swf"); return 0; }
int output_swf_writer(FILE* file, at_string name, int llx, int lly, int urx, int ury, at_output_opts_type * opts, spline_list_array_type shape, at_msg_func msg_func, at_address msg_data, at_address user_data) { int width = urx - llx; int height = ury - lly; SWFMovie m; #ifdef _WINDOWS if(file == stdout) { fprintf(stderr, "This driver couldn't write to stdout!\n"); return -1; } #endif Ming_init(); Ming_setCubicThreshold(20000); m = newSWFMovie(); out_splines(m, shape, height); SWFMovie_setDimension(m, SWFSCALE*(float)width, SWFSCALE*(float)height); SWFMovie_setRate(m, FPS); SWFMovie_nextFrame(m); SWFMovie_output(m, fileOutputMethod, file); return 0; }
int main() { SWFMovie *m; SWFShape *shape; SWFButton *b; SWFDisplayItem *item; SWFBlur *blur; SWFFilter *f; try { Ming_init(); m = new SWFMovie(7); shape = new SWFShape(); shape->setLine(4, 25, 0, 0, 128); shape->movePenTo(5, 5); shape->drawLineTo( 0, 10); blur = new SWFBlur(5,5,2); f = SWFFilter::BlurFilter(blur); b = new SWFButton(); b->addShape(shape, SWFBUTTON_UP | SWFBUTTON_HIT | SWFBUTTON_OVER | SWFBUTTON_DOWN); item = m->add(b); item->addFilter(f); m->save("test01.swf"); } catch (SWFException &e) { std::cerr << "SWFException: " << e.what() << std::endl << std::endl; return EXIT_FAILURE; } return 0; }
int main (int argc, char **argv) { SWFMovie movie; SWFVideoStream video; SWFDisplayItem item; SWFAction action; if (Ming_init ()) return 1; Ming_useSWFVersion (7); movie = newSWFMovie(); SWFMovie_setRate (movie, 1); SWFMovie_setDimension (movie, 200, 150); video = newSWFVideoStream (); SWFVideoStream_setDimension (video, 200, 150); item = SWFMovie_add (movie, (SWFBlock) video); SWFDisplayItem_setName (item, "video"); action = compileSWFActionCode ("" "trace (\"Test parsing of onMetaData\");" "nc = new NetConnection ();" "nc.connect (null);" "ns = new NetStream (nc);" "ns.onMetaData = function (info)" "{" " trace ('onMetaData');" " var props = [];" " for (var prop in info) {" " props.push (prop);" " }" " props.sort ();" " for (var i = 0; i < props.length; i++) {" " if (typeof (info[props[i]]) == 'object') {" " var keys = [];" " for (var key in info[props[i]]) {" " keys.push (key);" " }" " keys.sort ();" " trace (props[i] + ' = ');" " for (var j = 0; j < keys.length; j++) {" " trace (' ' + keys[j] + ' = ' + typeof (info[props[i]][keys[j]]) + ': ' + info[props[i]][keys[j]]);" " }" " } else {" " trace (props[i] + ' = ' + typeof (info[props[i]]) + ': ' + info[props[i]]);" " }" " }" " loadMovie ('FSCommand:quit', '');" "};" "video.attachVideo (ns);" "ns.setBufferTime (5);" "trace (\"Calling play\");" "ns.play (\"video.flv\");" "trace (\"done calling play\");" ""); SWFMovie_add (movie, (SWFBlock) action); SWFMovie_save (movie, "netstream-onmetadata.swf"); return 0; }
int main(int argc, char *argv[]) { SWFMovie movie; SWFShape shape1; SWFGradient grad_1; SWFFill fill1; SWFDisplayItem timeline; SWFShape shape2; SWFGradient grad_2; SWFFill fill2; Ming_init(argc, argv); Ming_useSWFVersion(5); movie= newSWFMovie(); SWFMovie_setDimension(movie, 320, 240); shape1= newSWFShape(); /* first gradient- black to white */ grad_1= newSWFGradient(); SWFGradient_addEntry(grad_1, 0, 0x00, 0x00, 0x00, 0xFF); SWFGradient_addEntry(grad_1, 1, 0xFF, 0xFF, 0xFF, 0xFF); fill1= SWFShape_addGradientFill(shape1, grad_1, SWFFILL_LINEAR_GRADIENT); SWFFill_scaleTo(fill1, 0.170, 0.170); SWFFill_moveTo(fill1, 160.00, 120.00); SWFShape_setRightFill(shape1, fill1); SWFShape_drawLineTo(shape1, 320.00, 0.00); SWFShape_drawLineTo(shape1, 320.00, 240.00); SWFShape_drawLineTo(shape1, 0.00, 240.00); SWFShape_drawLineTo(shape1, 0.00, 0.00); timeline= SWFMovie_add(movie, (SWFBlock) shape1); /* SWFDisplayItem_moveTo(timeline, 0.00, 0.00);*/ shape2= newSWFShape(); /* second gradient- radial gradient from white to red to transparent */ grad_2= newSWFGradient(); SWFGradient_addEntry(grad_2, 0, 0xFF, 0x00, 0x00, 0xFF); SWFGradient_addEntry(grad_2, 1, 0xFF, 0x00, 0x00, 0x00); fill2= SWFShape_addGradientFill(shape2, grad_2, SWFFILL_RADIAL_GRADIENT); SWFFill_scaleTo(fill2, 0.120, 0.120); SWFFill_moveTo(fill2, 160.00, 120.00); SWFShape_setRightFill(shape2, fill2); SWFShape_drawLineTo(shape2, 320.00, 0.00); SWFShape_drawLineTo(shape2, 320.00, 240.00); SWFShape_drawLineTo(shape2, 0.00, 240.00); SWFShape_drawLineTo(shape2, 0.00, 0.00); timeline= SWFMovie_add(movie, (SWFBlock) shape2); SWFMovie_nextFrame(movie); SWFMovie_save(movie, "gradient.swf"); return 0; }
int main(int argc, char** argv) { SWFMovie mo; SWFMovieClip mc, dejagnuclip; 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); SWFMovie_nextFrame(mo); /* 1st frame */ mc = newSWFMovieClip(); add_clip_actions(mc, "_root.x = 1;" "_root.check_equals(_root.x, 1);"); SWFMovieClip_nextFrame(mc); add_actions(mo, " gotoAndPlay(4); "); SWFMovie_nextFrame(mo); /* 2nd frame */ SWFMovie_nextFrame(mo); /* 3rd frame */ /* add mc to _root and name it as "mc" */ SWFDisplayItem it; it = SWFMovie_add(mo, (SWFBlock)mc); SWFDisplayItem_setDepth(it, 3); SWFDisplayItem_setName(it, "mc"); add_actions(mo, " _root.x = 2; " " _root.check_equals(_root.x, 2); "); SWFMovie_nextFrame(mo); /* 4th frame */ SWFDisplayItem_remove(it); check_equals(mo, "_root.x", "1"); check_equals(mo, "typeof(mc)", "'undefined'"); add_actions(mo, " _root.totals(); stop(); "); SWFMovie_nextFrame(mo); /* 5th frame */ //Output movie puts("Saving " OUTPUT_FILENAME ); SWFMovie_save(mo, OUTPUT_FILENAME); return 0; }
int main(int argc, char** argv) { SWFMovie mo; SWFMovieClip dejagnuclip; 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); dejagnuclip = get_dejagnu_clip((SWFBlock)get_default_font(srcdir), 10, 0, 0, 800, 600); SWFMovie_add(mo, (SWFBlock)dejagnuclip); SWFMovie_nextFrame(mo); // frame1 // get current time in frame2 add_actions(mo, "x1 = getTimer();"); SWFMovie_nextFrame(mo); // frame2 // just delay some time here add_actions(mo, " for(i=0; i<1000; i++) {} "); // get current time in frame3 add_actions(mo, "x2 = getTimer();"); SWFMovie_nextFrame(mo); // frame3 // check that the timer is working check(mo, "x1 > 0"); check(mo, "x2 > x1" ); // this is dependent on frame rate(current setting is 1 second per frame) // check(mo, "x2 > 1000"); check(mo, "x2 < 6000"); // check that "getTimer" return a intergral number check(mo, "x2 == Math.ceil(x2)"); check(mo, "x2 == Math.floor(x2)"); SWFMovie_nextFrame(mo); // frame4 add_actions(mo, "_root.totals(); stop();"); SWFMovie_nextFrame(mo); // frame5 //Output movie puts("Saving " OUTPUT_FILENAME ); SWFMovie_save(mo, OUTPUT_FILENAME); return 0; }
int main (int argc, char **argv) { if (Ming_init ()) return 1; Ming_setSWFCompression (-1); do_movie (1); do_movie (2); return 0; }
EXPORT BOOL WINAPI mhsp_init(int p1, int p2, int p3, int p4) { Ming_init(); #ifdef JAMING Ming_setErrorFunction((void (*)(char *msg, ...))mhsp_error); Ming_setWarnFunction((void (*)(char *msg, ...))mhsp_warn); #else Ming_setErrorFunction(mhsp_error); Ming_setWarnFunction(mhsp_warn); #endif return 0; }
int main (int argc, char **argv) { int i; if (Ming_init ()) return 1; for (i = 5; i < 8; i++) do_movie (i); return 0; }
int main (int argc, char **argv) { int i; if (Ming_init ()) return 1; for (i = 8; i >= 5; i--) { do_movie (i); } return 0; }
int main() { SWFMovie m; SWFShape shape; SWFButton b; SWFDisplayItem item; SWFBlur blur; SWFFilter f; SWFShadow shadow; SWFColor c1, c2; Ming_init(); m = newSWFMovieWithVersion(7); if(m == NULL) return EXIT_FAILURE; shape = newSWFShape(); SWFShape_setLine(shape, 4, 25, 0, 0, 128); SWFShape_movePenTo(shape, 5, 5); SWFShape_drawLineTo(shape, 0, 10); blur = newSWFBlur(5,5,2); shadow = newSWFShadow(0.79, 5, 1.0); c1.red = 0; c1.green = 0; c1.blue = 0; c1.alpha = 0xff; c2.red = 0xff; c2.green = 0xff; c2.blue = 0xff; c2.alpha = 0xff; f = newBevelFilter(c1, c2, blur, shadow, FILTER_MODE_INNER | FILTER_MODE_KO); b = newSWFButton(); SWFButton_addCharacter(b, (SWFCharacter)shape, SWFBUTTON_UP | SWFBUTTON_HIT | SWFBUTTON_OVER | SWFBUTTON_DOWN); item = SWFMovie_add(m, (SWFBlock)b); SWFDisplayItem_addFilter(item, f); SWFMovie_save(m, "test04.swf"); return 0; }
static void ming_begin_job(GVJ_t * job) { SWFMovie movie; SWFAction action; Ming_init(); Ming_useSWFVersion(SWFVERSION); Ming_setSWFCompression(SWFCOMPRESSION); movie = newSWFMovie(); SWFMovie_setRate(movie, SWFFRAMERATE); SWFMovie_setDimension(movie, job->width, job->height); // Works, but why is it here? // action = newSWFAction(script); // SWFMovie_add(movie, (SWFBlock)action); job->context = (void*) movie; }
int main() { int swfcompression=-1; // be fast, we don't care // about compression, do we ? if ( Ming_init() ) { fprintf(stderr, "Ming initialization error\n"); exit(EXIT_FAILURE); } // TODO: use multiple SWF target versions ! Ming_setSWFCompression(swfcompression); return do_tests(); }
int main(int argc, char** argv) { SWFMovie movie; SWFMovieClip dejagnuclip; SWFAction ac[FRAME_COUNT]; int i; const char *srcdir="."; if ( argc>1 ) srcdir=argv[1]; else { fprintf(stderr, "Usage: %s <mediadir>\n", argv[0]); return 1; } Ming_init(); movie = newSWFMovie(); SWFMovie_setDimension(movie, 800, 600); dejagnuclip = get_dejagnu_clip((SWFBlock)get_default_font(srcdir), 10, 0, 0, 800, 600); SWFMovie_add(movie, (SWFBlock)dejagnuclip); // Add frame ActionScipts to frames ac[0] = action_in_frame1(); ac[1] = action_in_frame2(); ac[2] = action_in_frame3(); ac[3] = action_in_frame4(); for(i=0; i<FRAME_COUNT; i++) { SWFMovie_add(movie, (SWFBlock)ac[i]); SWFMovie_nextFrame(movie); } // save files puts("Saving " OUTPUT_FILENAME ); SWFMovie_save(movie, OUTPUT_FILENAME); return 0; }
int main(int argc, char* argv[]) { SWFMovie mo; SWFMovieClip mc1, mc2, mc3, mc4, dejagnuclip; SWFDisplayItem it; SWFAction ac; SWFInitAction initac; 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); add_actions(mo, "if (!_global.hasOwnProperty('arr')) { _global.arr = []; };" "_global.ch = function(a, b) {" " trace(a);" " if (typeof(b)=='undefined' || (typeof(b)=='boolean' && b)) {" " _global.arr.push(a);" " };" "};" "this.onEnterFrame = function() { " " _global.ch('onEnterFrame', false);" "};" ); SWFMovie_nextFrame(mo); // MovieClip 1 mc1 = newSWFMovieClip(); // 1 frames // SWF_EXPORTASSETS SWFMovie_addExport(mo, (SWFBlock)mc1, "Segments_Name"); SWFMovie_writeExports(mo); // MovieClip mc3 has two frames. In each frame a different MovieClip // is placed with the name Segments. mc3 = newSWFMovieClip(); // 2 frames // MovieClip 2 mc2 = newSWFMovieClip(); // 1 frames // Add mc2 it = SWFMovieClip_add(mc3, (SWFBlock)mc2); SWFDisplayItem_setDepth(it, 1); SWFDisplayItem_setName(it, "Segments"); // Frame 2 SWFMovieClip_nextFrame(mc3); // Remove mc2 SWFDisplayItem_remove(it); // Add mc1 it = SWFMovieClip_add(mc3, (SWFBlock)mc1); SWFDisplayItem_setDepth(it, 1); SWFDisplayItem_setName(it, "Segments"); SWFMovieClip_nextFrame(mc3); // End mc3 // This is frame 1 of the main timeline // Put our sprite mc3 on stage. it = SWFMovie_add(mo, (SWFBlock)mc3); SWFDisplayItem_setDepth(it, 1); SWFDisplayItem_setName(it, "mc"); // mc4 is just for executing init actions. mc4 = newSWFMovieClip(); SWFMovie_addExport(mo, (SWFBlock)mc4, "__Packages.Bug"); SWFMovie_writeExports(mo); dejagnuclip = get_dejagnu_clip((SWFBlock)get_default_font(srcdir), 10, 0, 0, 800, 600); SWFMovie_add(mo, (SWFBlock)dejagnuclip); ac = newSWFAction( "_global.loops = 0;" "_global.c = 0;" "if( !_global.Bug ) {" " _global.Bug = function () {" " this.onUnload = function() { " " _global.ch('dynamic unload: ' + this.c);" " }; " " this.onLoad = function() { " " _global.ch('dynamic load: ' + this.c);" " }; " " this.c = _global.c;" " _global.ch('ctor: ' + _global.c);" " _global.c++;" " };" "};" ); initac = newSWFInitAction_withId(ac, 4); SWFMovie_add(mo, (SWFBlock)initac); ac = newSWFAction("Object.registerClass('Segments_Name',Bug);"); initac = newSWFInitAction_withId(ac, 1); SWFMovie_add(mo, (SWFBlock)initac); add_actions(mo, "_global.ch('Frame ' + " "_level0._currentframe + ' actions: ' " "+ _level0.mc.Segments.c);"); // Frame 2 of the main timeline SWFMovie_nextFrame(mo); add_actions(mo, "_global.ch('Frame ' + " "_level0._currentframe + ' actions: ' " "+ _level0.mc.Segments.c);"); add_actions(mo, " if (_global.loops < 5) {" " _global.loops++;" " gotoAndPlay(2);" " }" " else {" " delete this.onEnterFrame;" " gotoAndPlay(4);" " };" ); SWFMovie_nextFrame(mo); check_equals(mo, "_global.arr.length", "20"); check_equals(mo, "_global.arr[0]", "'Frame 2 actions: undefined'"); check_equals(mo, "_global.arr[1]", "'ctor: 0'"); xcheck_equals(mo, "_global.arr[2]", "'Frame 3 actions: 0'"); xcheck_equals(mo, "_global.arr[3]", "'dynamic load: 0'"); check_equals(mo, "_global.arr[4]", "'Frame 2 actions: 0'"); check_equals(mo, "_global.arr[5]", "'Frame 3 actions: 0'"); check_equals(mo, "_global.arr[6]", "'Frame 2 actions: 0'"); check_equals(mo, "_global.arr[7]", "'ctor: 1'"); check_equals(mo, "_global.arr[8]", "'dynamic unload: 0'"); xcheck_equals(mo, "_global.arr[9]", "'Frame 3 actions: 0'"); check_equals(mo, "_global.arr[11]", "'Frame 2 actions: 0'"); check_equals(mo, "_global.arr[12]", "'Frame 3 actions: 1'"); check_equals(mo, "_global.arr[13]", "'Frame 2 actions: 1'"); check_equals(mo, "_global.arr[14]", "'ctor: 2'"); check_equals(mo, "_global.arr[15]", "'dynamic unload: 1'"); xcheck_equals(mo, "_global.arr[16]", "'Frame 3 actions: 1'"); xcheck_equals(mo, "_global.arr[17]", "'dynamic load: 2'"); check_equals(mo, "_global.arr[18]", "'Frame 2 actions: 1'"); check_equals(mo, "_global.arr[19]", "'Frame 3 actions: 2'"); xcheck_equals(mo, "_global.arr.toString()", "'Frame 2 actions: undefined,ctor: 0,Frame 3 actions: 0,dynamic load: 0,Frame 2 actions: 0,Frame 3 actions: 0,Frame 2 actions: 0,ctor: 1,dynamic unload: 0,Frame 3 actions: 0,dynamic load: 1,Frame 2 actions: 0,Frame 3 actions: 1,Frame 2 actions: 1,ctor: 2,dynamic unload: 1,Frame 3 actions: 1,dynamic load: 2,Frame 2 actions: 1,Frame 3 actions: 2'"); SWFMovie_nextFrame(mo); add_actions(mo, "totals(21); stop();"); SWFMovie_nextFrame(mo); // SWF_END SWFMovie_save(mo, OUTPUT_FILENAME); return 0; }
int main(int argc, char** argv) { SWFMovie mo; SWFMovieClip mc; SWFSoundStream ss; FILE* sound_f; const char* sound_filename; SWFDisplayItem it; struct stat statbuf; if ( argc>1 ) { sound_filename=argv[1]; } else { sound_filename="sound1.mp3"; } sound_f = fopen(sound_filename, "r"); if ( ! sound_f ) { perror(sound_filename); return EXIT_FAILURE; } printf("Using sound file %s\n", sound_filename); if ( -1 == fstat(fileno(sound_f), &statbuf) ) { perror("fstat"); return EXIT_FAILURE; } if ( S_ISDIR(statbuf.st_mode) ) { fprintf(stderr, "%s is a directory, we need a file\n", sound_filename); return EXIT_FAILURE; } Ming_init(); Ming_useSWFVersion (OUTPUT_VERSION); mo = newSWFMovie(); SWFMovie_setDimension(mo, 100, 100); SWFMovie_setRate(mo, 1); ss = newSWFSoundStream(sound_f); mc = newSWFMovieClip(); SWFMovieClip_setSoundStream(mc, ss, 1); SWFMovieClip_nextFrame(mc); it = SWFMovie_add(mo, mc); SWFMovie_nextFrame(mo); SWFMovie_nextFrame(mo); SWFMovie_nextFrame(mo); SWFMovie_nextFrame(mo); SWFMovie_nextFrame(mo); SWFMovie_nextFrame(mo); SWFMovie_nextFrame(mo); SWFMovie_nextFrame(mo); //Output movie puts("Saving " OUTPUT_FILENAME ); SWFMovie_save(mo, OUTPUT_FILENAME); return EXIT_SUCCESS; }
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 (0, 220, 60, 60, 255, 0, 0, 255, 0, 0); sh2 = make_fill_square (30, 250, 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, 3); //place the sh2 DisplayObject at depth 3 again! add_actions(mo, "note('Placed red shape sh1 and black shape sh2 at the same depth 3. Should both be visible, red on top.');"); xcheck_equals(mo, "sh1", "sh2"); check_equals(mo, "typeof(sh1)", "'movieclip'"); xcheck_equals(mo, "typeof(sh2)", "'movieclip'"); SWFMovie_nextFrame(mo); mc1 = newSWFMovieClip(); it = SWFMovieClip_add(mc1, (SWFBlock)sh1); SWFDisplayItem_setName(it, "sh1"); SWFDisplayItem_moveTo(it, 100, 0); SWFMovieClip_nextFrame(mc1); mc2 = newSWFMovieClip(); it = SWFMovieClip_add(mc2, (SWFBlock)sh2); SWFDisplayItem_setName(it, "sh1"); SWFDisplayItem_moveTo(it, 100, 0); SWFMovieClip_nextFrame(mc2); it = SWFMovie_add(mo, (SWFBlock)mc2); SWFDisplayItem_setName(it, "mc2"); SWFDisplayItem_setDepth(it, 4); //place the mc2 sprite at depth 3 again! it = SWFMovie_add(mo, (SWFBlock)mc1); SWFDisplayItem_setName(it, "mc1"); SWFDisplayItem_setDepth(it, 4); //place the mc1 sprite at depth 3 add_actions(mo, "note('Placed red sprite mc1 and black sprite mc2 at the same depth 4. Should both be visible, black on top.');"); xcheck_equals(mo, "typeof(mc1)", "'movieclip'"); check_equals(mo, "typeof(mc2)", "'movieclip'"); check(mo, "mc1._name != mc2._name"); check_equals(mo, "mc1.getDepth()", "mc2.getDepth()"); // TODO: use SWFMovie_replace and see if it would replace // only one or both DisplayObjects at target depth // (not that we can trust Ming stability here..) add_actions(mo, "_root.totals(7); 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 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 mc1, mc2, dejagnuclip; SWFDisplayItem it1, it2; SWFShape sh_red; /* For the button duplication test */ #if MING_VERSION_CODE >= 00040400 SWFButton but; SWFButtonRecord br; #endif 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, "x1=0; x2=0; x3=0;"); SWFMovie_nextFrame(mo); /* 1st frame */ mc1 = newSWFMovieClip(); sh_red = make_fill_square (100, 300, 60, 60, 255, 0, 0, 255, 0, 0); SWFMovieClip_add(mc1, (SWFBlock)sh_red); add_clip_actions(mc1, "stop();"); SWFMovieClip_nextFrame(mc1); mc2 = newSWFMovieClip(); sh_red = make_fill_square (100, 200, 60, 60, 255, 0, 0, 255, 0, 0); SWFMovieClip_add(mc2, (SWFBlock)sh_red); add_clip_actions(mc2, "stop();"); SWFMovieClip_nextFrame(mc2); it1 = SWFMovie_add(mo, (SWFBlock)mc1); SWFDisplayItem_setDepth(it1, 10); SWFDisplayItem_setName(it1, "mc1"); it2 = SWFMovie_add(mo, (SWFBlock)mc2); SWFDisplayItem_setDepth(it2, 20); SWFDisplayItem_setName(it2, "mc2"); SWFDisplayItem_addAction(it2, compileSWFActionCode(" _root.note('onClipLoad triggered'); " " _root.x1 = _root.x1 + 1; "), SWFACTION_ONLOAD); SWFDisplayItem_addAction(it2, compileSWFActionCode(" _root.note('onClipEnterFrame triggered'); " " _root.x2 = _root.x2 + 1; "), SWFACTION_ENTERFRAME); SWFDisplayItem_addAction(it2, compileSWFActionCode(" _root.note('onClipUnload triggered'); " " _root.x3 = _root.x3 + 1; "), SWFACTION_UNLOAD); add_actions(mo, " mc1.onLoad = function () {}; " " mc1.prop1 = 10; " " duplicateMovieClip('mc1', 'dup1', 1); " " mc2.onLoad = function () {}; " " duplicateMovieClip('mc2', 'dup2', 2); " ); SWFMovie_nextFrame(mo); /* 2nd frame */ check_equals(mo, "mc1.prop1", "10"); check_equals(mo, "typeof(mc1.onLoad)", "'function'"); check_equals(mo, "mc1.getDepth()", "-16374"); /* user defined property will not be duplicated */ check_equals(mo, "dup1.prop1", "undefined"); /* user defined event handler will not be duplicated */ check_equals(mo, "typeof(dup1.onLoad)", "'undefined'"); check_equals(mo, "dup1.getDepth()", "1"); /* check user defined onLoad */ check_equals(mo, "typeof(mc2.onLoad)", "'function'"); /* onClipEvent does not define a function */ check_equals(mo, "typeof(mc2.onEnterFrame)", "'undefined'"); /* user defined event handler will not be duplicated */ check_equals(mo, "typeof(dup2.onLoad)", "'undefined'"); check_equals(mo, "_root.x1", "2"); check_equals(mo, "_root.x2", "2"); SWFMovie_nextFrame(mo); /* 3rd frame */ SWFDisplayItem_remove(it1); SWFDisplayItem_remove(it2); add_actions(mo, " dup2.removeMovieClip(); "); SWFMovie_nextFrame(mo); /* 4th frame */ #if MING_VERSION_CODE >= 00040400 /* Create a button, add it to mc1 */ but = newSWFButton(); br = SWFButton_addCharacter(but, (SWFCharacter)sh_red, SWFBUTTON_UP); SWFButtonRecord_setDepth(br, 10); it1 = SWFMovie_add(mo, (SWFBlock)but); SWFDisplayItem_setName(it1, "button"); /* Sanity check */ check_equals(mo, "typeof(button)", "'object'"); add_actions(mo, "trace(button);" "dupl = MovieClip.prototype.duplicateMovieClip;" "button.dupl = dupl;" "o = { x: 4 };" "d = button.dupl('buttdup', 201, o);" ); xcheck_equals(mo, "typeof(d)", "'object'"); xcheck_equals(mo, "'' + _root.buttdup", "'_level0.buttdup'"); check_equals(mo, "_root.buttdup", "d"); /* initobj not used */ check_equals(mo, "_root.buttdup.x", "undefined"); #endif add_actions(mo, "t = new Object();" "t.dupl = dupl;" "o2 = { x: 44 };" "d2 = t.dupl('objdup', 202, o2);" "trace(_root.objdup);" ); /* Does not work on plain objects */ check_equals(mo, "typeof(d2)", "'undefined'"); check_equals(mo, "typeof(_root.objdup)", "'undefined'"); SWFMovie_nextFrame(mo); /* 5th frame */ check_equals(mo, "_root.x1", "2"); check_equals(mo, "_root.x2", "3"); check_equals(mo, "_root.x3", "2"); add_actions(mo, " _root.totals(); stop(); "); SWFMovie_nextFrame(mo); /* 5th frame */ //Output movie puts("Saving " OUTPUT_FILENAME ); SWFMovie_save(mo, OUTPUT_FILENAME); return 0; }
int main(int argc, char** argv) { SWFMovie mo; const char *srcdir="."; SWFMovieClip dejagnuclip; /********************************************* * * Initialization * *********************************************/ if ( argc>1 ) srcdir=argv[1]; else { fprintf(stderr, "Usage: %s\n", argv[0]); return 1; } puts("Setting things up"); Ming_init(); Ming_useSWFVersion (OUTPUT_VERSION); Ming_setScale(20.0); /* let's talk pixels */ mo = newSWFMovie(); SWFMovie_setRate(mo, 12); //SWFMovie_setDimension(mo, 6400, 4000); SWFMovie_setDimension(mo, 640, 400); /********************************************* * * Body * *********************************************/ dejagnuclip = get_dejagnu_clip((SWFBlock)get_default_font(srcdir), 10, 0, 80, 800, 600); SWFMovie_add(mo, (SWFBlock)dejagnuclip); addRedSquareExport(mo); /* it seems we need a SHOWFRAME for this to be effective */ /* (maybe it's related to loop-back handling ?) */ SWFMovie_nextFrame(mo); /* A load of tests for depth */ add_actions(mo, "attachMovie('redsquare', 'depthtest', -16, initObj);" "d = depthtest.getDepth();"); check_equals(mo, "d", "-16"); add_actions(mo, "attachMovie('redsquare', 'depthtest', -16384, initObj);" "d = depthtest.getDepth();"); check_equals(mo, "d", "-16384"); /* Less than -16384 fails */ add_actions(mo, "attachMovie('redsquare', 'depthtest2', -20000, initObj);" "d = depthtest2.getDepth();"); check_equals(mo, "d", "undefined"); /* It really does */ add_actions(mo, "attachMovie('redsquare', 'depthtest2', -16385, initObj);" "d = depthtest2.getDepth();"); check_equals(mo, "d", "undefined"); /* Up to 2130690044 works */ add_actions(mo, "attachMovie('redsquare', 'depthtest2', 1147483648, initObj);" "d = depthtest2.getDepth();"); check_equals(mo, "d", "1147483648"); /* Up to 2130690044 works */ add_actions(mo, "attachMovie('redsquare', 'depthtest3', 2130690044, initObj);" "d = depthtest3.getDepth();"); check_equals(mo, "d", "2130690044"); /* 2130690045 doesn't work */ add_actions(mo, "attachMovie('redsquare', 'depthtest4', 2130690045, initObj);" "d = depthtest4.getDepth();"); check_equals(mo, "d", "undefined"); /* duplicateMovieClip */ /* Same limits... */ add_actions(mo, "createEmptyMovieClip('original', 10);"); add_actions(mo, "duplicateMovieClip('original', 'dup1', -1);" "d = dup1.getDepth();"); check_equals(mo, "d", "-1"); add_actions(mo, "original.duplicateMovieClip('odup1', -1);" "d = odup1.getDepth();"); check_equals(mo, "d", "-1"); add_actions(mo, "duplicateMovieClip('original', 'dup2', -16384);" "d = dup2.getDepth();"); check_equals(mo, "d", "-16384"); add_actions(mo, "original.duplicateMovieClip('odup2', -16384);" "d = odup2.getDepth();"); check_equals(mo, "d", "-16384"); add_actions(mo, "duplicateMovieClip('original', 'dup3', -16385);" "d = dup3.getDepth();"); check_equals(mo, "d", "undefined"); add_actions(mo, "original.duplicateMovieClip('odup3', -16385);" "d = odup3.getDepth();"); check_equals(mo, "d", "undefined"); add_actions(mo, "duplicateMovieClip('original', 'dup4', 2130690044);" "d = dup4.getDepth();"); check_equals(mo, "d", "2130690044"); add_actions(mo, "original.duplicateMovieClip('odup4', 2130690044);" "d = odup4.getDepth();"); check_equals(mo, "d", "2130690044"); add_actions(mo, "duplicateMovieClip('original', 'dup5', 2130690045);" "d = dup5.getDepth();"); check_equals(mo, "d", "undefined"); add_actions(mo, "original.duplicateMovieClip('odup5', 2130690045);" "d = odup5.getDepth();"); check_equals(mo, "d", "undefined"); add_actions(mo, "totals(); stop();"); SWFMovie_nextFrame(mo); /* showFrame */ /***************************************************** * * Output movie * *****************************************************/ puts("Saving " OUTPUT_FILENAME ); SWFMovie_save(mo, OUTPUT_FILENAME); return 0; }
int main(int argc, char** argv) { SWFMovie mo; SWFMovieClip mc1, mc2, mc3, mc4, mc5, dejagnuclip; SWFDisplayItem it1, it2, it3, it4, it5; SWFShape sh_red; 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, " x2 += 'as_start+'; " " _root.OnLoad = function () { _root.note('_root onLoad called'); x2 += 'load_called+'; }; " " x2 += 'as_end+'; " " _root.onEnterFrame = function () { x3 += 'enterFrame_called+'; }; "); SWFMovie_nextFrame(mo); /* 1st frame */ mc1 = newSWFMovieClip(); sh_red = make_fill_square (0, 300, 60, 60, 255, 0, 0, 255, 0, 0); SWFMovieClip_add(mc1, (SWFBlock)sh_red); add_clip_actions(mc1, " _root.note('actions in 1st frame of mc1'); " // Defining onLoad in first frame of a sprite doesn't work, but works for root " this.onLoad = function() { _root.note('mc1 onLoad called'); _root.x1 += 'YY'; };" " _root.x1 += '2+'; "); SWFMovieClip_nextFrame(mc1); /* mc1, 1st frame */ add_clip_actions(mc1, " _root.note('actions in 2nd frame of mc1'); " " _root.x1 += '12+'; " " stop(); "); SWFMovieClip_nextFrame(mc1); /* mc1, 2nd frame */ mc2 = newSWFMovieClip(); sh_red = make_fill_square (80, 300, 60, 60, 255, 0, 0, 255, 0, 0); SWFMovieClip_add(mc2, (SWFBlock)sh_red); add_clip_actions(mc2, " _root.note('actions in 1st frame of mc2'); " // Defining onLoad in first frame of a sprite doesn't work, but works for root " this.onLoad = function() { _root.note('mc2 onLoad called'); _root.x1 += 'XX'; };" " _root.x1 += '4+'; "); SWFMovieClip_nextFrame(mc2); /* mc2, 1st frame */ add_clip_actions(mc2, " _root.note('actions in 2nd frame of mc2'); " " _root.x1 += '10+'; " " stop(); "); SWFMovieClip_nextFrame(mc2); /* mc2, 2nd frame */ mc3 = newSWFMovieClip(); sh_red = make_fill_square (160, 300, 60, 60, 255, 0, 0, 255, 0, 0); SWFMovieClip_add(mc3, (SWFBlock)sh_red); add_clip_actions(mc3, " _root.note('actions in 1st frame of mc3'); " // Defining onLoad in first frame of a sprite doesn't work, but works for root " this.onLoad = function() { _root.note('mc3 onLoad called'); _root.x1 += 'ZZ'; };" " _root.x1 += '6+';"); SWFMovieClip_nextFrame(mc3); /* mc3, 1st frame */ add_clip_actions(mc3, " _root.note('actions in 2nd frame of mc3'); " " _root.x1 += '8+'; " " stop(); "); SWFMovieClip_nextFrame(mc3); /* mc3, 2nd frame */ /* add mc1 to _root and name it as "mc1" */ it1 = SWFMovie_add(mo, (SWFBlock)mc1); SWFDisplayItem_setDepth(it1, 10); SWFDisplayItem_setName(it1, "mc1"); /* Define Construct ClipEvent */ SWFDisplayItem_addAction(it1, compileSWFActionCode(" _root.note('mc1 Construct called');" " _root.x0 += '01+'; "), SWFACTION_CONSTRUCT); /* Define Load ClipEvent */ SWFDisplayItem_addAction(it1, compileSWFActionCode(" _root.note('mc1 Load called');" " _root.x1 += '1+'; "), SWFACTION_ONLOAD); /* Define Unload ClipEvent */ SWFDisplayItem_addAction(it1, compileSWFActionCode(" _root.note('mc1 Unload called'); " " _root.x1 += '13+'; "), SWFACTION_UNLOAD); /* Define EnterFrame ClipEvent */ SWFDisplayItem_addAction(it1, compileSWFActionCode(" _root.note('mc1 EnterFrame called'); " " _root.x1 += '11+'; "), SWFACTION_ENTERFRAME); /* add mc2 to _root and name it as "mc2" */ it2 = SWFMovie_add(mo, (SWFBlock)mc2); SWFDisplayItem_setDepth(it2, 12); SWFDisplayItem_setName(it2, "mc2"); /* Define Construct ClipEvent */ SWFDisplayItem_addAction(it2, compileSWFActionCode(" _root.note('mc2 Construct called');" " _root.x0 += '02+'; "), SWFACTION_CONSTRUCT); /* Define Load ClipEvent */ SWFDisplayItem_addAction(it2, compileSWFActionCode(" _root.note('mc2 Load called'); " " _root.x1 += '3+'; "), SWFACTION_ONLOAD); /* Define Unload ClipEvent */ SWFDisplayItem_addAction(it2, compileSWFActionCode(" _root.note('mc2 Unload called'); " " _root.x1 += '14+'; "), SWFACTION_UNLOAD); /* Define EnterFrame ClipEvent */ SWFDisplayItem_addAction(it2, compileSWFActionCode(" _root.note('mc2 EnterFrame called'); " " _root.x1 += '9+'; "), SWFACTION_ENTERFRAME); /* add mc3 to _root and name it as "mc3" */ it3 = SWFMovie_add(mo, (SWFBlock)mc3); SWFDisplayItem_setDepth(it3, 11); SWFDisplayItem_setName(it3, "mc3"); /* Define Construct ClipEvent */ SWFDisplayItem_addAction(it3, compileSWFActionCode(" _root.note('mc3 Construct called');" " _root.x0 += '03+'; "), SWFACTION_CONSTRUCT); /* Define Load ClipEvent */ SWFDisplayItem_addAction(it3, compileSWFActionCode(" _root.note('mc3 Load called'); " " _root.x1 += '5+'; "), SWFACTION_ONLOAD); /* Define Unload ClipEvent */ SWFDisplayItem_addAction(it3, compileSWFActionCode(" _root.note('mc3 Unload called'); " " _root.x1 += '15+';" ), SWFACTION_UNLOAD); /* Define EnterFrame ClipEvent */ SWFDisplayItem_addAction(it3, compileSWFActionCode(" _root.note('mc3 EnterFrame called'); " " _root.x1 += '7+'; "), SWFACTION_ENTERFRAME); add_actions(mo, " _root.x3 += '_root_frm2_as+'; "); SWFMovie_nextFrame(mo); /* 2nd frame */ add_actions(mo, " _root.x3 += '_root_frm3_as+'; "); check_equals(mo, "_root.x3", "'enterFrame_called+_root_frm2_as+enterFrame_called+_root_frm3_as+'"); SWFMovie_nextFrame(mo); /* 3rd frame */ /* It's no use to change the order below. After compile, Ming will re-organize them as remove mc1; remove mc2; remove mc3;*/ SWFDisplayItem_remove(it3); SWFDisplayItem_remove(it1); SWFDisplayItem_remove(it2); SWFMovie_nextFrame(mo); /* 4th frame */ check_equals(mo, "_root.x0", "'01+02+03+'"); check_equals(mo, "_root.x1", "'1+2+3+4+5+6+7+8+9+10+11+12+13+14+15+'"); check_equals(mo, "_root.x2", "'as_start+as_end+load_called+'"); add_actions(mo, " _root.totals(); stop(); "); SWFMovie_nextFrame(mo); /* 5th frame */ //Output movie puts("Saving " OUTPUT_FILENAME ); SWFMovie_save(mo, OUTPUT_FILENAME); return 0; }
int main(int argc, char** argv) { SWFMovie mo; const char *srcdir="."; SWFMovieClip dejagnuclip; /********************************************* * * Initialization * *********************************************/ if ( argc>1 ) srcdir=argv[1]; else { fprintf(stderr, "Usage: %s\n", argv[0]); return 1; } puts("Setting things up"); Ming_init(); Ming_useSWFVersion (OUTPUT_VERSION); Ming_setScale(20.0); /* let's talk pixels */ mo = newSWFMovie(); SWFMovie_setRate(mo, 12); //SWFMovie_setDimension(mo, 6400, 4000); SWFMovie_setDimension(mo, 640, 400); /********************************************* * * Body * *********************************************/ dejagnuclip = get_dejagnu_clip((SWFBlock)get_default_font(srcdir), 10, 0, 80, 800, 600); SWFMovie_add(mo, (SWFBlock)dejagnuclip); addRedSquareExport(mo); /* it seems we need a SHOWFRAME for this to be effective */ /* (maybe it's related to loop-back handling ?) */ SWFMovie_nextFrame(mo); // This should run for four frames. The counter should only be reset // on the first frame, i.e. when start is undefined. This should // work for all swf versions, unlike "if (undefined < 4);" add_actions(mo, "initObj = new Object();"); add_actions(mo, "if (!started) { counter = 0; started = true; }"); add_actions(mo, "redsquare = function() { " " trace('hello redsquare'); " " if (counter > 0) {" " check_equals(this._x, counter * 70);" " check_equals(Math.round(this._xscale), 99);" " check_equals(Math.round(this._yscale), " " Math.round((10 * counter +5) / 60 * 100));" " check_equals(this._height, 10 * counter + 5); " " check_equals(this.aProperty, 6); " " } else {" " check_equals(this._x, 0);" " check_equals(this._xscale, 100);" " check_equals(this._height, 60.1);" " check_equals(this.aProperty, undefined); " " };" " };" "redsquare.prototype = new MovieClip();" "Object.registerClass('redsquare', redsquare);" ); add_actions(mo, "if ( counter < 4 ) {" " if ( counter > 0 ) { " " initObj.aProperty = 6;" " initObj._xscale = 99;" " initObj._x = 70*counter;" " initObj._height = 10*counter + 5; " " attachMovie('redsquare', " " 'square'+counter, 70+counter, initObj);" " } else {" /* We don't use an initObject for the first attachMovie call * to verify that the DisplayObject will be kept in DisplayList * at loopback time anyway */ " attachMovie('redsquare', " " 'square'+counter, 70+counter);" " }" " check_equals(this['square'+counter]._x, 70*counter);" " if (counter > 0) {" " check_equals(this['square'+counter]._height, 10 * counter + 5);" " };" " note('Depth is '+70*counter);" " counter++;" " note('Next counter is '+counter);" "} else {" " totals(26); stop();" "}" ); SWFMovie_nextFrame(mo); /* showFrame */ /***************************************************** * * Output movie * *****************************************************/ puts("Saving " OUTPUT_FILENAME ); SWFMovie_save(mo, OUTPUT_FILENAME); return 0; }
int main(int argc, char **argv) { SWFMovie mo; const char *jpeg_filename="red.jpg"; FILE *jpeg_fd; SWFJpegBitmap jpeg_bm; SWFShape jpeg_sh; SWFMovieClip jpeg_mc; /********************************************* * * Initialization * *********************************************/ if ( argc > 1 ) jpeg_filename=argv[1]; else { fprintf(stderr, "Usage: %s <jpegfile>\n", argv[0]); return 1; } puts("Setting things up"); Ming_init(); Ming_useSWFVersion (OUTPUT_VERSION); Ming_setScale(1.0); /* so we talk twips */ mo = newSWFMovie(); /***************************************************** * * Add the RED clip * *****************************************************/ puts("Adding red"); jpeg_fd = fopen(jpeg_filename, "r"); if ( ! jpeg_fd ) { perror(jpeg_filename); return 1; } jpeg_bm = newSWFJpegBitmap(jpeg_fd); jpeg_sh = newSWFShapeFromBitmap((SWFBitmap)jpeg_bm, SWFFILL_CLIPPED_BITMAP); jpeg_mc = newSWFMovieClip(); SWFMovieClip_add(jpeg_mc, (SWFBlock)jpeg_sh); SWFMovieClip_nextFrame(jpeg_mc); /* showFrame */ SWFMovie_add(mo, (SWFBlock)jpeg_mc); puts("Saving " OUTPUT_FILENAME ); SWFMovie_nextFrame(mo); /* showFrame */ SWFMovie_save(mo, OUTPUT_FILENAME); return 0; }
int main(int argc, char *argv[]) { SWFMovie m; SWFShape shape; SWFBitmap b; SWFFill fill; SWFDisplayItem i; FILE *file_bitmap; float n; float height; float width; char *imageFile = "backyard.jpg"; Ming_init(argc, argv); Ming_useSWFVersion(5); m = newSWFMovie(); shape = newSWFShape(); if(!(file_bitmap = fopen(imageFile,"rb"))) { printf("Couldn't find file '%s'", imageFile); } b = (SWFCharacter) newSWFJpegBitmap(file_bitmap); SWFMovie_setDimension(m, SWFBitmap_getWidth(b), SWFBitmap_getHeight(b)); fill = SWFShape_addBitmapFill(shape, b, SWFFILL_TILED_BITMAP); SWFShape_setRightFill(shape, fill); height = (float) SWFBitmap_getHeight(b); width = (float) SWFBitmap_getWidth(b); SWFShape_drawLineTo(shape, width, 0.00); SWFShape_drawLineTo(shape, width, height); SWFShape_drawLineTo(shape, 0.00, height); SWFShape_drawLineTo(shape, 0.00, 0.00); i = SWFMovie_add(m, (SWFBlock) shape); for(n=0; n<20.0; ++n) { SWFDisplayItem_multColor(i, 1.0- n/10.0, 1.0, 1.0, 1.0); SWFDisplayItem_addColor(i, 0xff* n/20.0, 0, 0, 0); SWFMovie_nextFrame(m); } for(n=20.0; n>0; --n) { SWFDisplayItem_multColor(i, 1.0- n/10.0, 1.0, 1.0, 1.0); SWFDisplayItem_addColor(i, 0xff* n/20.0, 0, 0, 0); SWFMovie_nextFrame(m); } SWFMovie_save(m, "cxform.swf"); fclose(file_bitmap); /* Do not close earlier or an error will happen */ return 0; }
int main(int argc, char** argv) { SWFMovie mo; SWFSound so; const char* soundFile; const char* srcdir; int frame; if (argc > 1) { soundFile = argv[1]; } else { soundFile = "brokenchord.wav"; } if (argc > 2) { srcdir = argv[2]; } else { srcdir = "."; } /* setup ming and basic movie properties */ Ming_init(); Ming_useSWFVersion(OUTPUT_VERSION); mo = newSWFMovie(); SWFMovie_setDimension(mo, 800, 600); SWFMovie_setRate(mo, 0.5); setupMovie(mo, srcdir); so = setupSounds(soundFile); /// Add as an export so we can attach it. SWFMovie_addExport(mo, (SWFBlock)so, "es"); SWFMovie_writeExports(mo); add_actions(mo, "c = 0;"); SWFMovie_nextFrame(mo); add_actions(mo, "note('You will hear several short tests with a succession of sounds. " "Each frame is two seconds long.\n" "The movie will describe what you should hear at the beginning of " "the frame.');"); frame = 0; pauseForNextTest(mo); runMultipleSoundsTest(mo, so, &frame); pauseForNextTest(mo); runNoMultipleSoundsTest(mo, so, &frame); pauseForNextTest(mo); runTrimmedSoundsTest(mo, so, &frame); pauseForNextTest(mo); runAttachedSoundsTest(mo, so, &frame); // TODO: test start(<sec_offset>) (+ with loop ?) endOfTests(mo); //Output movie puts("Saving " OUTPUT_FILENAME ); SWFMovie_save(mo, OUTPUT_FILENAME); return 0; }
void R_init_MingSWF(DllInfo *dll) { R_registerRoutines(dll, NULL, CallEntries, NULL, NULL); Ming_init(); }
/*This function is called when the package is loaded because the variables * loaded in Ming_init() persist even when a device is closed. This way the * warning about changing swf version during a run is avoided. */ static void SWF_Init(){ Ming_init(); }
int main(int argc, char** argv) { SWFMovie mo; SWFMovieClip dejagnuclip; SWFDisplayItem it, it1, it2, it3; 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); // low frame rate is needed for visual checking SWFMovie_setRate (mo, 1.0); dejagnuclip = get_dejagnu_clip((SWFBlock)get_default_font(srcdir), 10, 0, 0, 800, 600); SWFMovie_add(mo, (SWFBlock)dejagnuclip); add_actions(mo, "test1=0; test2=0; test3=0; test4=0; test5='0'; test6=0; " "keyPressed=false; keyReleased=false;" "haslooped1=false; haslooped2=false;"); SWFMovie_nextFrame(mo); // _root frame1 // test1: // (1)onKeyDown, onKeyPress and onKeyUp are not global functions // (2)test that global Key object can be overridden // (3)after overriden, previously registered handlers could still respond to new key events add_actions(mo, "_root.var1 = 0; _root.var2 = 0;" "l = new Object();" "l.onKeyDown = function () { _root.note('l.onKeyDown'); _root.var1+=1; _root.Play(); }; " "l.onKeyUp = function () { _root.note('l.onKeyUp'); _root.var2+=1;}; " " Key.addListener(l);" "check_equals(typeof(Key), 'object');" "check_equals(typeof(onKeyUp), 'undefined');" "check_equals(typeof(onKeyDown), 'undefined');" "check_equals(typeof(onKeyPress), 'undefined');" "stop();" "_root.note('1. Press a single key to continue the test');" ); SWFMovie_nextFrame(mo); // _root frame2 SWFMovie_nextFrame(mo); // _root frame3 add_actions(mo, "stop();" "check_equals(var1, 1); " "check_equals(var2, 1); " "Key = 3;" "check_equals(typeof(Key), 'number');" "_root.note('2. Press a single key to continue the test');" ); SWFMovie_nextFrame(mo); // _root frame4 SWFMovie_nextFrame(mo); // _root frame5 add_actions(mo, "stop();" "check_equals(var1, 2); " "check_equals(var2, 2);" "delete Key; " "check_equals(typeof(Key), 'object');" "Key.removeListener(l);" "_root.note('3. Press a single key to continue the test');" "obj1=new Object(); " " obj1.onKeyDown=function() {" " _root.note('obj1.onKeyDown');" " _root.play();" "}; " " Key.addListener(obj1); " ); SWFMovie_nextFrame(mo); // _root frame6 add_actions(mo, "check_equals(var1, 2);" "check_equals(var2, 2);" "Key.removeListener(obj1);" "delete l; delete obj1; " ); SWFMovie_nextFrame(mo); // _root frame7 // test2: // test removing of static clip key listeners SWFMovie_nextFrame(mo); // _root frame8 it = add_static_mc(mo, "listenerClip1", 20); SWFDisplayItem_addAction(it, newSWFAction(" _root.note('listenerClip2.onClipKeyDown'); " " _root.test2++; " "if(!_root.haslooped1){" " _root.haslooped1=true;" " _root.gotoAndPlay(_root._currentframe-1);" "} else {" " _root.gotoAndPlay(_root._currentframe+1);" "}" ), SWFACTION_KEYDOWN); add_actions(mo, "stop();" "_root.note('4. Press a single key to continue the test');" ); SWFMovie_nextFrame(mo); // _root frame9 check_equals(mo, "_root.test2", "2"); SWFDisplayItem_remove(it); SWFMovie_nextFrame(mo); // _root frame10 // test3: // test removing of dynamic sprite key listeners SWFMovie_nextFrame(mo); // _root frame11 add_actions(mo, "stop();" "_root.note('5. Press a single key to continue the test');" "_root.createEmptyMovieClip('dynamic_mc', -10);" "dynamic_mc.onKeyDown = function() " "{" " _root.note('dynamic_mc.onKeyDown triggered');" " _root.check_equals(this, _root.dynamic_mc);" " _root.test3++;" " if(!_root.haslooped2){" " _root.haslooped2=true;" " _root.gotoAndPlay(_root._currentframe-1);" " _root.check_equals(_root._currentframe, 11);" " } else {" " _root.gotoAndPlay(_root._currentframe+1);" " _root.check_equals(_root._currentframe, 13);" " }" "};" "Key.addListener(dynamic_mc);" ); SWFMovie_nextFrame(mo); // _root frame12 check_equals(mo, "_root.test3", "2"); add_actions(mo, "dynamic_mc.swapDepths(10); dynamic_mc.removeMovieClip();"); SWFMovie_nextFrame(mo); // _root frame13 // test4: // GC test add_actions(mo, "_root.note('6. Press a single key to continue the test');" " obj2 = new Object(); " " obj2.x = 100; " " obj2.onKeyDown = function () { " " _root.note('obj2.onKeyDown triggered');" " _root.test4++; " " _root.objRef = this; " " _root.play();" " };" " Key.addListener(obj2); " // After deleting obj2, we still have a key listener kept alive! " delete obj2; " " stop();" ); check_equals(mo, "_root.test4", "0"); SWFMovie_nextFrame(mo); // _root frame14 check_equals(mo, "objRef.x", "100"); check_equals(mo, "_root.test4", "1"); add_actions(mo, "stop();" "_root.note('7. Press a single key to continue the test');" "Key.removeListener(objRef); " // check that objRef is still alive "check_equals(typeof(objRef), 'object');" // delete the objRef, no object and no key listener now. "delete objRef;" "obj3=new Object(); " "obj3.onKeyDown=function() {" " _root.note('obj3.onKeyDown');" " _root.gotoAndPlay(_currentframe+1);" "}; " "Key.addListener(obj3); " ); SWFMovie_nextFrame(mo); // _root frame15 check_equals(mo, "_root.test4", "1"); add_actions(mo, "Key.removeListener(obj3);" "delete obj3; " ); SWFMovie_nextFrame(mo); // _root frame16 // test5: // test key listeners invoking order. // expected behaviour: // (1)for DisplayObject key listeners, first added last called // (2)for general object listeners, first added first called // (3)for DisplayObject listeners, user defined onKeyDown/Up won't be called // if not registered to the global Key object. it1 = add_static_mc(mo, "ls1", 30); SWFDisplayItem_addAction(it1, compileSWFActionCode( "_root.note('ls1.onClipKeyDown');" "_root.test5 += '+ls1';" ), SWFACTION_KEYDOWN); SWFMovie_nextFrame(mo); // _root frame17 it2 = add_static_mc(mo, "ls2", 31); SWFDisplayItem_addAction(it2, compileSWFActionCode( "_root.note('ls2.onClipKeyDown');" "_root.test5 += '+ls2';" ), SWFACTION_KEYDOWN); SWFMovie_nextFrame(mo); // _root frame18 it3 = add_static_mc(mo, "ls3", 29); SWFDisplayItem_addAction(it3, compileSWFActionCode( "_root.note('ls3.onClipKeyDown');" "_root.test5 += '+ls3';" ), SWFACTION_KEYDOWN); SWFMovie_nextFrame(mo); // _root frame19 add_actions(mo, "obj1=new Object();" "obj1.onKeyDown = function () { " " _root.note('obj1.onKeyDown');" " _root.test5 += '+obj1'; " " _root.gotoAndPlay(_root._currentframe+1);" "}; " "Key.addListener(obj1);" "ls1.onKeyDown = function () {" " _root.note('ls1.onKeyDown');" " _root.test5 += '+ls1';" "}; " "Key.addListener(ls1);" "obj2=new Object();" "obj2.onKeyDown = function () {" " _root.note('obj2.onKeyDown');" " _root.test5 += '+obj2';" "}; " "Key.addListener(obj2);" "ls2.onKeyDown = function () {" " _root.note('ls2.onKeyDown');" " _root.test5 += '+ls2';" "}; " "Key.addListener(ls2);" "obj3=new Object();" "obj3.onKeyDown = function () {" " _root.note('obj3.onKeyDown');" " _root.test5 += '+obj3';" "}; " "Key.addListener(obj3);" "ls3.onKeyDown = function () {" " _root.note('ls3.onKeyDown');" " _root.test5 += '+ls3';" "}; " "stop(); " "_root.note('8. Press a single key to continue the test');" ); SWFMovie_nextFrame(mo); // _root frame20 SWFMovie_nextFrame(mo); // _root frame21 add_actions(mo, "stop(); " "_root.note('9. Press a single key to continue the test');" ); SWFDisplayItem_remove(it1); SWFDisplayItem_remove(it2); SWFDisplayItem_remove(it3); SWFMovie_nextFrame(mo); // _root frame22 check_equals(mo, "test5", "'0+ls3+ls2+ls1+obj1+ls1+obj2+ls2+obj3+obj1+obj2+obj3'"); add_actions(mo, "o = new Object();" "_root.t = '';" "o.onKeyDown = function() { t = _root.ff.text; play(); };" "Key.addListener(o);" "_root.createTextField('ff', 987, 300, 20, 200, 40);" "_root.ff.type = 'input';" "_root.ff.text = 'Input here';" "_root.ff.border = true;" "_root.note('10. Click on the TextField and type \"i\"');" "stop();" ); SWFMovie_nextFrame(mo); // _root frame23 // The listener is called before text is updated! check_equals(mo, "_root.t", "'Input here'"); check_equals(mo, "_root.ff.text", "'Input herei'"); add_actions(mo, "totals(); stop();"); SWFMovie_nextFrame(mo); // _root frame24 //Output movie puts("Saving " OUTPUT_FILENAME ); SWFMovie_save(mo, OUTPUT_FILENAME); return 0; }
int main(int argc, char** argv) { SWFMovie mo; SWFMovieClip dejagnuclip; SWFShape static1, static2; SWFDisplayItem it1; 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, 2); static1 = get_shape(60, 60, 255, 0, 0); static2 = get_shape(60, 60, 0, 255, 0); dejagnuclip = get_dejagnu_clip((SWFBlock)get_default_font(srcdir), 10, 0, 0, 800, 600); SWFMovie_add(mo, (SWFBlock)dejagnuclip); SWFMovie_nextFrame(mo); // Frame 2: place DisplayObject at depth 3 (-16381) it1 = SWFMovie_add(mo, (SWFBlock)static1); SWFDisplayItem_setDepth(it1, 3); SWFDisplayItem_moveTo(it1, 100, 300); SWFDisplayItem_setName(it1, "static1"); SWFDisplayItem_addAction(it1, newSWFAction( "_root.note(this+' onClipConstruct');" " _root.check_equals(typeof(_root), 'movieclip');" " if ( isNaN(_root.depth3Constructed) ) {" " _root.depth3Constructed=1; " " } else {" " _root.depth3Constructed++;" " }" " _root.note('_root.depth3Constructed set to '+_root.depth3Constructed);" ), SWFACTION_CONSTRUCT); add_actions(mo, "static1.name='static1';"); check_equals(mo, "typeof(static1)", "'movieclip'"); check_equals(mo, "static1", "_root"); check_equals(mo, "static1.name", "'static1'"); check_equals(mo, "_root.name", "'static1'"); // Gnash allows custom members to shape DisplayObjects... // this is important to verify, see next check for it after REPLACE check_equals(mo, "static1.name", "'static1'"); check_equals(mo, "static1._target", "'/'"); SWFMovie_nextFrame(mo); // Frame 3: replace instance at depth -16381 with DisplayObject 2 if ( SWFMovie_replace(mo, it1, (SWFBlock)static2) ) { abort(); // grace and beauty... } SWFDisplayItem_moveTo(it1, 130, 330); SWFDisplayItem_setName(it1, "static2"); SWFDisplayItem_addAction(it1, newSWFAction( "_root.note(this+' onClipConstruct');" " _root.check_equals(typeof(_root), 'movieclip');" " if ( isNaN(_root.depth3Constructed) ) {" " _root.depth3Constructed=1; " " } else {" " _root.depth3Constructed++;" " }" " _root.note('_root.depth3Constructed set to '+_root.depth3Constructed);" ), SWFACTION_CONSTRUCT); // Can still reference the old DisplayObject and it's variables, after replace xcheck_equals(mo, "typeof(static1)", "'movieclip'"); xcheck_equals(mo, "static1", "_root"); xcheck_equals(mo, "static1.name", "'static1'"); check_equals(mo, "_root.name", "'static1'"); // While the new name results undefined... xcheck_equals(mo, "typeof(static2)", "'undefined'"); // the name wasn't changed // Everything suggests that a new instance is NOT created on replace !!! // Gnash here fails because it creates a NEW instance // We can't check the color or the _x in a self-contained testcase unfortunately, // we'll need a MovieTester-based runner for this. // It is expected the color of the current instane is GREEN, and the boundaries // are from 130 to 190 for X and 330 to 390 for Y. // TODO: implement a MovieTester based runner !! SWFMovie_nextFrame(mo); // Frame 4: jump to frame 2, stop and check add_actions(mo, "gotoAndStop(2); " // Shapes don't get their onConstruct event invoked ! "check_equals(typeof(_root.depth3Constructed), 'undefined');" // Original DisplayObject name is still referenceable "check_equals(typeof(static1), 'movieclip');" // And it still has it's user-provided property "check_equals(static1.name, 'static1');" // We can't check the color or the _x in a self-contained testcase unfortunately, // we'll need a MovieTester-based runner for this. // It is expected the color of the current instance is RED, and the boundaries // are from 100 to 120 for both X and Y. // TODO: implement a MovieTester based runner !! "totals();" ); SWFMovie_nextFrame(mo); //Output movie puts("Saving " OUTPUT_FILENAME ); SWFMovie_save(mo, OUTPUT_FILENAME); return 0; }