static void do_movie (int version) { SWFMovie movie; char *real_name; guint i; movie = newSWFMovieWithVersion (version); movie = newSWFMovie(); SWFMovie_setRate (movie, 1); SWFMovie_setDimension (movie, 200, 150); modify_placement (movie, i); SWFMovie_nextFrame (movie); SWFMovie_add (movie, (SWFBlock) newSWFAction ("" #if 0 "loadMovie (\"FSCommand:quit\", \"\");" #else "stop ();" #endif )); SWFMovie_nextFrame (movie); real_name = g_strdup_printf ("duplicate-depth-%d.swf", version); SWFMovie_save (movie, real_name); g_free (real_name); }
static void do_movie (int version) { char name[100]; SWFMovie movie; SWFTextField text; SWFDisplayItem display; movie = newSWFMovieWithVersion (version); movie = newSWFMovie(); SWFMovie_setRate (movie, 1); SWFMovie_setDimension (movie, 200, 150); text = newSWFTextField (); SWFTextField_setVariableName (text, "/:foo"); display = SWFMovie_add (movie, (SWFBlock) text); SWFMovie_nextFrame (movie); SWFMovie_add (movie, (SWFBlock) newSWFAction ( "loadMovie (\"FSCommand:quit\", \"\");" )); SWFMovie_nextFrame (movie); sprintf (name, "crash-0.5.3-text-field-root-variable-%d.swf", version); SWFMovie_save (movie, name); }
/* 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 main() { SWFMovie m = newSWFMovie(); SWFText text = newSWFText(); SWFTextField textfield = newSWFTextField(); SWFDisplayItem it; SWFFont font = newSWFFont_fromFile(MEDIADIR "/font01.fdb"); if(font == NULL) { perror(MEDIADIR "/font01.fdb"); exit(EXIT_FAILURE); } SWFText_setFont(text, font); SWFText_setColor(text, 0, 0, 0xff, 0xff); SWFText_setHeight(text, 20); SWFText_moveTo(text, 100, 100); SWFText_addString(text, "1234567890", NULL); SWFTextField_setFont(textfield, font); SWFTextField_addString(textfield, "1234567890"); SWFTextField_setColor(textfield, 0xff, 0, 0, 0xff); SWFTextField_setHeight(textfield, 20); SWFMovie_add(m, text); it = SWFMovie_add(m, textfield); SWFDisplayItem_moveTo(it, 100, 120); SWFMovie_nextFrame(m); SWFMovie_save(m, "test04.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; }
static void do_movie (int version) { char name[100]; SWFMovie movie; SWFTextField text; SWFDisplayItem display; movie = newSWFMovieWithVersion (version); movie = newSWFMovie(); SWFMovie_setRate (movie, 1); SWFMovie_setDimension (movie, 200, 150); text = newSWFTextField (); display = SWFMovie_add (movie, (SWFBlock) text); SWFMovie_add (movie, (SWFBlock) newSWFAction ("" "trace ('Test whether native properties of TextField are initialized if the movie contains an EditText tag');" "_global.TextField.prototype.hasOwnProperty = ASnative (101, 5);" "trace (_global.TextField.prototype.hasOwnProperty ('text'));" "_global.TextField.prototype = new Object ();" "loadMovie (\"FSCommand:quit\", \"\");" "")); SWFMovie_nextFrame (movie); sprintf (name, "text-field-init-native-%d.swf", version); SWFMovie_save (movie, name); }
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 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() { SWFMovie m = newSWFMovie(); SWFCharacter c = SWFMovie_importCharacter(m, "test.swf", "test"); SWFMovie_add(m, c); SWFMovie_save(m, "test01.swf"); return 0; }
main() { SWFMovie m; m= newSWFMovie(); SWFMovie_namedAnchor(m,"frame0"); SWFMovie_save(m,"test02.swf"); return 0; }
EXPORT BOOL WINAPI mhsp_SWFMovie(SWFMovie *p1, int version, int p3, int p4) { lstrcpy(funcname, "SWFMovie"); if (version) { *p1 = newSWFMovieWithVersion(version); } else { *p1 = newSWFMovie(); } if (!mhsp_movie) { mhsp_movie = *p1; } return 0; }
int main() { SWFMovieClip mc; SWFMovie m; SWFAction a; m = newSWFMovie(); a = newSWFAction("trace('');"); mc = newSWFMovieClip(); SWFMovieClip_addInitAction(mc, a); SWFMovie_addExport(m, mc, "test"); SWFMovie_add(m, mc); SWFMovie_save(m, "test03.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 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() { SWFMovie m = newSWFMovie(); SWFTextField text = newSWFTextField(); SWFFont font = newSWFFont_fromFile(MEDIADIR "/test.ttf"); if(font == NULL) { perror(MEDIADIR "/test.tff"); exit(EXIT_FAILURE); } SWFTextField_setFont(text, font); SWFTextField_setColor(text, 0, 0, 0, 0xff); SWFTextField_setHeight(text, 20); SWFMovie_add(m, text); SWFMovie_nextFrame(m); SWFMovie_save(m, "test02.swf"); return 0; }
int main() { SWFMovie m = newSWFMovie(); SWFTextField text = newSWFTextField(); SWFFont font = newSWFFont_fromFile(MEDIADIR "/test.ttf"); if(font == NULL) { perror(MEDIADIR "/test.tff"); exit(EXIT_FAILURE); } SWFTextField_setFont(text, font); SWFTextField_setColor(text, 0, 0, 0, 0xff); SWFTextField_setHeight(text, 20); SWFTextField_setFlags(text, SWFTEXTFIELD_NOEDIT); SWFTextField_addString(text, "The quick brown fox jumps over the lazy dog. 1234567890"); SWFMovie_add(m, text); SWFMovie_nextFrame(m); SWFMovie_save(m, "test01.swf"); 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 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 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; 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 *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 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; 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 mo; SWFDisplayItem it; const char *srcdir="."; char fdbfont[256]; SWFMovieClip dejagnuclip; /********************************************* * * Initialization * *********************************************/ puts("Setting things up"); Ming_init(); Ming_useSWFVersion (OUTPUT_VERSION); Ming_setScale(20.0); mo = newSWFMovie(); SWFMovie_setDimension(mo, 800, 600); SWFMovie_setRate(mo, 1); 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); FILE *font_file = fopen(fdbfont, "r"); if ( font_file == NULL ) { perror(fdbfont); exit(1); } /*SWFBrowserFont bfont = newSWFBrowserFont("_sans");*/ font = loadSWFFontFromFile(font_file); /* Dejagnu equipment */ dejagnuclip = get_dejagnu_clip((SWFBlock)font, 10, 0, 0, 800, 600); it = SWFMovie_add(mo, (SWFBlock)dejagnuclip); SWFDisplayItem_setDepth(it, 200); SWFDisplayItem_move(it, 200, 0); add_text_field(mo, "textfield", "_root.msg", "Button events", 10, 0, 5); add_text_field(mo, "textfield2", "_root.msg2", "Mouse events", 11, 0, 100); add_text_field(mo, "textfield3", "_root.msg3", "Key events", 12, 0, 80); SWFMovie_nextFrame(mo); /***************************************************** * * Add button * *****************************************************/ it = add_button(mo); SWFDisplayItem_moveTo(it, 40, 30); SWFDisplayItem_setName(it, "square1"); SWFDisplayItem_setDepth(it, 2); // Mouse pointer events //add_actions(mo, "square1.button.onRollOver = function() { _root.msg2 = 'RollOver'; };"); //add_actions(mo, "square1.button.onRollOut = function() { _root.msg2 = 'RollOut'; };"); // Mouse buttons events //add_actions(mo, "square1.button.onPress = function() { _root.msg2 = 'Press'; };"); //add_actions(mo, "square1.button.onRelease = function() { _root.msg2 = 'Release'; gotoAndStop(1); };"); //add_actions(mo, "square1.button.onReleaseOutside = function() { _root.msg2 = 'ReleaseOutside'; };"); // Focus events add_actions(mo, "square1.button.onSetFocus = function() { _root.msg3 = 'SetFocus'; };"); // Key events - button needs focus for these to work add_actions(mo, "square1.button.onKeyDown = function() { _root.msg3 = 'KeyDown'; };"); add_actions(mo, "square1.button.onKeyUp = function() { _root.msg3 = 'KeyUp'; };"); SWFMovie_nextFrame(mo); /* showFrame */ /***************************************************** * * On second frame, add a shape at lower depth * *****************************************************/ { SWFShape sh = make_fill_square(0, 0, 120, 120, 0, 0, 0, 0, 255, 0); SWFDisplayItem itsh = SWFMovie_add(mo, (SWFBlock)sh); SWFDisplayItem_setDepth(itsh, 1); SWFMovie_nextFrame(mo); /* showFrame */ } /***************************************************** * * On third frame, add a shape at higher depth * *****************************************************/ { SWFShape sh = make_fill_square(0, 0, 120, 120, 0, 0, 0, 0, 255, 0); SWFDisplayItem itsh = SWFMovie_add(mo, (SWFBlock)sh); SWFDisplayItem_setDepth(itsh, 3); SWFDisplayItem_setColorAdd(itsh, 0, 0, 0, -128); SWFMovie_nextFrame(mo); /* showFrame */ } /***************************************************** * * On third frame, add a shape at higher depth * *****************************************************/ { add_actions(mo, "square1.button.enabled = false;" //"_root.msg = _root.msg2 = _root.msg3 = 'Idle';" "stop();" "totals();" ); SWFMovie_nextFrame(mo); /* showFrame */ } /***************************************************** * * Save it... * *****************************************************/ puts("Saving " OUTPUT_FILENAME ); SWFMovie_save(mo, OUTPUT_FILENAME); 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; }
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; }
int main(int argc, char** argv) { SWFMovie mo; int frames; SWFVideoStream stream; SWFDisplayItem item; SWFMovieClip dejagnuclip; FILE *flv, *font_file; SWFFont font; char filename[256]; char fdbfont[1024]; if ( argc>1 ) mediadir=argv[1]; else { fprintf(stderr, "Usage: %s <mediadir>\n", argv[0]); return 1; } sprintf(filename, "%s/square.flv", mediadir); flv = fopen(filename, "rb"); if (flv == NULL) { perror(filename); return -1; } sprintf(fdbfont, "%s/Bitstream-Vera-Sans.fdb", mediadir); font_file = fopen(fdbfont, "r"); if ( font_file == NULL ) { perror(fdbfont); exit(1); } Ming_init(); Ming_useSWFVersion (OUTPUT_VERSION); font = loadSWFFontFromFile(font_file); mo = newSWFMovie(); SWFMovie_setDimension(mo, 320, 96); if (mo == NULL) return -1; SWFMovie_setRate(mo, 5); dejagnuclip = get_dejagnu_clip((SWFBlock)font, 10, 0, 0, 200, 200); item = SWFMovie_add(mo, (SWFBlock)dejagnuclip); SWFDisplayItem_setDepth(item, 200); SWFDisplayItem_move(item, 140, 0); stream = newSWFVideoStream_fromFile(flv); item = SWFMovie_add(mo, (SWFBlock)stream); SWFDisplayItem_setName(item, "vid"); // A bug in Ming prevents this from working the // way I liked it to. It was useful to try this // out as it exposed a bad bug in gnash eating up // all memory and a few other issues. // // In order to keep the test *runner* untouched // this will be commented out for now. When Ming // is fixed I'll like to have two instances of // the definition playing one near the other, // both playing all frames. // //item = SWFMovie_add(mo, (SWFBlock)stream); //SWFDisplayItem_move(item, 150, 0); // Mouse clicks toggle play/stop add_actions(mo, "_root.onMouseDown = function() {" " if (stopped) { play(); stopped=false; }" " else { stop(); stopped=true; }" "};"); // Pressing a number jumps to the specified frame add_actions(mo, "_root.onKeyDown = function() {" " var fnum = Key.getAscii() - 47;" //" trace('going to frame '+fnum);" " _root.gotoAndPlay(fnum);" "}; Key.addListener(_root);"); // TODO: dynamic frame rate adjust frames = SWFVideoStream_getNumFrames(stream); for(; frames > 0; frames--) { SWFMovie_nextFrame(mo); } /// Video.clear() should not work on embedded Videos. add_actions(mo, "stop(); vid.clear(); trace(vid);"); add_actions(mo, "note('You should still see the video frame." " Click to replay');" "o = {};" "o.onMouseDown = function() { _root.play(); };" "Mouse.addListener(o);" ); 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="."; SWFMovieClip dejagnuclip; SWFDisplayItem it; /********************************************* * * 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, 1.33); SWFMovie_setDimension(mo, 640, 400); /********************************************* * * Body * *********************************************/ dejagnuclip = get_dejagnu_clip((SWFBlock)get_default_font(srcdir), 10, 0, 80, 800, 600); it = SWFMovie_add(mo, (SWFBlock)dejagnuclip); addSoundExport(mo); SWFMovie_nextFrame(mo); /* end of frame1 */ // Tracker variables for calls to onSoundComplete add_actions(mo, "c_soundComplete = 0;"); add_actions(mo, "d_soundComplete = 0;"); add_actions(mo, "e_soundComplete = 0;"); add_actions(mo, "a = new Sound();"); check_equals(mo, "a.duration", "undefined"); add_actions(mo, "a.attachSound('mono22_mp2');"); check_equals(mo, "a.duration", "13740"); add_actions(mo, "b = new Sound(); b.attachSound('mono22_mp2b');"); add_actions(mo, "c = new Sound(); c.attachSound('stereo8_mp3');"); // Two different Sounds with the same exported sound. add_actions(mo, "d = new Sound(); d.attachSound('stereo8_mp3b');"); add_actions(mo, "e = new Sound(); e.attachSound('stereo8_mp3b');"); add_actions(mo, "check_equals(a.getBytesTotal(), undefined);"); add_actions(mo, "check_equals(a.getBytesLoaded(), undefined);"); add_actions(mo, "check_equals(a.id3, undefined);"); check_equals(mo, "a.position", "0"); add_actions(mo, "a.start();"); // This isn't very consistent either. Please re-enable when it is. //check_equals(mo, "a.position", "0"); check_equals(mo, "b.duration", "13740"); check_equals(mo, "b.position", "0"); add_actions(mo, "b.start();"); // Here, gst gives 46, ffmpeg 0. //check_equals(mo, "b.position", "0"); check_equals(mo, "c.duration", "5224"); check_equals(mo, "c.position", "0"); // Play twice (loop). add_actions(mo, "c.start(0, 2);"); check_equals(mo, "c.position", "0"); check_equals(mo, "d.duration", "5224"); check_equals(mo, "d.position", "0"); // Start twice. add_actions(mo, "d.start();"); add_actions(mo, "d.start(4);"); check_equals(mo, "d.position", "0"); add_actions(mo, "e.start();"); SWFMovie_nextFrame(mo); add_actions(mo, "stop();" "note('will wait for onSoundComplete to finish the test (about " "13 seconds).');"); // This is the longest sound, so the test should end when this is called. add_actions(mo, "a.onSoundComplete = function() {" "check_equals(arguments.length, 0);" "check_equals(a.position, 13740, 'a.position at a.onSoundComplete time');" "check_equals(c_soundComplete, 1, 'c_soundComplete at a.onSoundComplete time');" "check_equals(d_soundComplete, 1, 'd_soundComplete at a.onSoundComplete time');" "check_equals(e_soundComplete, 2, 'e_soundComplete at a.onSoundComplete time');" "totals(26); " "finished = true;" "};"); // Check position of b, c, d, and e after the first loop of c. add_actions(mo, "c.onSoundComplete = function() {" // I'm not sure how reliable this is: "check_equals(b.position, 10472, 'b.position at c.onSoundComplete time');" "check_equals(c.position, 5224, 'c.position at c.onSoundComplete time');" "check_equals(d.position, 5224, 'd.position at c.onSoundComplete time');" "check_equals(e.position, 5224, 'e.position at c.onSoundComplete time');" "c_soundComplete++;" "note('c.onSoundComplete() called '+c_soundComplete+' time(s).');" "};"); add_actions(mo, "d.onSoundComplete = function() {" "check_equals(d.position, 5224, 'd.position at d.onSoundComplete time');" "d_soundComplete++;" "note('d.onSoundComplete() called '+d_soundComplete+' time(s).');" "};"); // This starts e again. It should run twice before the longest // sound stops. add_actions(mo, "e.onSoundComplete = function() {" "check_equals(e.position, 5224, 'e.position at e.onSoundComplete time');" "e_soundComplete++;" "note('e.onSoundComplete() called '+e_soundComplete+' time(s).');" "if ( e_soundComplete < 2 ) e.start();" "};"); /***************************************************** * * 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; SWFShape sh1, sh2, sh3; int framenum; argc=argc; argv=argv; /* unused... */ /********************************************* * * Initialization * *********************************************/ puts("Setting things up"); Ming_init(); Ming_useSWFVersion (OUTPUT_VERSION); Ming_setScale(20.0); mo = newSWFMovie(); /***************************************************** * * Add the square named * *****************************************************/ SWFMovie_setDimension(mo, 100, 100); #define FRAMESGAP 5 sh1 = make_square(10, 10, 20, 20, 255, 0, 0); it1 = SWFMovie_add(mo, (SWFBlock)sh1); SWFDisplayItem_setDepth(it1, 1); SWFDisplayItem_setName(it1, "Name1"); for (framenum=0; framenum<FRAMESGAP; framenum++) { SWFMovie_nextFrame(mo); } sh2 = make_square(35, 10, 20, 20, 0, 255, 0); it2 = SWFMovie_add(mo, (SWFBlock)sh2); SWFDisplayItem_setDepth(it2, 2); SWFDisplayItem_setName(it2, "Name2"); for (framenum=0; framenum<FRAMESGAP; framenum++) { SWFMovie_nextFrame(mo); } sh3 = make_square(10, 35, 45, 20, 0, 0, 255); it3 = SWFMovie_add(mo, (SWFBlock)sh3); SWFDisplayItem_setDepth(it3, 3); SWFDisplayItem_setName(it3, "Name3"); for (framenum=0; framenum<FRAMESGAP; framenum++) { SWFMovie_nextFrame(mo); } SWFMovie_remove(mo, it1); for (framenum=0; framenum<FRAMESGAP; framenum++) { SWFMovie_nextFrame(mo); } SWFMovie_remove(mo, it2); for (framenum=0; framenum<FRAMESGAP; framenum++) { SWFMovie_nextFrame(mo); } SWFMovie_remove(mo, it3); puts("Saving " OUTPUT_FILENAME ); SWFMovie_nextFrame(mo); /* showFrame */ SWFMovie_save(mo, OUTPUT_FILENAME); return 0; }
int main(int argc, char **argv) { SWFMovie mo; SWFDisplayItem it; const char *srcdir="."; char fdbfont[256]; SWFMovieClip dejagnuclip; SWFFont font; puts("Setting things up"); Ming_init(); Ming_useSWFVersion (OUTPUT_VERSION); Ming_setScale(20.0); mo = newSWFMovie(); SWFMovie_setDimension(mo, 800, 600); SWFMovie_setRate(mo, 1); 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); FILE* font_file = fopen(fdbfont, "r"); if (!font_file) { perror(fdbfont); exit(1); } font = loadSWFFontFromFile(font_file); /* Dejagnu equipment */ dejagnuclip = get_dejagnu_clip((SWFBlock)font, 10, 0, 0, 800, 600); it = SWFMovie_add(mo, (SWFBlock)dejagnuclip); SWFDisplayItem_setDepth(it, 200); SWFDisplayItem_move(it, 200, 0); SWFMovie_nextFrame(mo); add_actions(mo, "mc1 = _root.createEmptyMovieClip('mc1', 34);" "mc2 = mc1.createEmptyMovieClip('mc2', 35);" "with(mc2) {" " moveTo(100, 100);" " beginFill(0x20fff0);" " lineTo(100, 200);" " lineTo(200, 200);" " lineTo(200, 100);" "};" "_root.onMouseUp = function() { play(); };" ); // One has all the functions, one has __resolve. add_actions(mo, "resolveevents = [];" "events = [];" "mc1.__resolve = function(a) { resolveevents.push(a); };" "mc2.onEnterFrame = function() { events.push('onEnterFrame'); };" "mc2.onMouseDown = function() { events.push('onMouseDown'); };" "mc2.onMouseUp = function() { events.push('onMouseUp'); };" // Gnash sends a bogus event here, but we're not testing that! //"mc2.onLoad = function() { events.push('onLoad'); };" "mc2.onPress = function() { events.push('onPress'); };" "mc2.onRelease = function() { events.push('onRelease'); };" "mc2.onRollOver = function() { events.push('onRollOver'); };" "mc2.onRollOut = function() { events.push('onRollOut'); };" "mc2.onInitialize = function() { events.push('onInitialize'); };" "mc2.onConstruct = function() { events.push('onConstruct'); };" "mc2.onReleaseOutside = function() { events.push('onReleaseOutside'); };" "mc2.onDragOver = function() { events.push('onDragOver'); };" "mc2.func = function() { events.push('func'); };" ); add_actions(mo, "mc2.func();" "mc1.func();" "mc2.onEnterFrame();" "mc1.onEnterFrame();" "mc2.onRollOver();" "mc1.onRollOver();" ); add_actions(mo, "_root.note('Do not touch anything!');"); // The ones called manually should appear in both. check_equals(mo, "events.toString()", "'func,onEnterFrame,onRollOver'"); check_equals(mo, "resolveevents.toString()", "'func,onEnterFrame,onRollOver'"); SWFMovie_nextFrame(mo); check_equals(mo, "events.toString()", "'func,onEnterFrame,onRollOver,onEnterFrame'"); check_equals(mo, "resolveevents.toString()", "'func,onEnterFrame,onRollOver'"); // Otherwise the number is unpredictable. add_actions(mo, "mc2.onEnterFrame = function() {};"); add_actions(mo, "stop();"); add_actions(mo, "_root.note('Move over square, click and release!');"); SWFMovie_nextFrame(mo); // Expect rollover, onMouseDown, onMouseUp, onRelease check_equals(mo, "events.toString()", "'func,onEnterFrame,onRollOver,onEnterFrame," "onRollOver,onMouseDown,onPress,onMouseUp,onRelease'"); check_equals(mo, "resolveevents.toString()", "'func,onEnterFrame,onRollOver'"); add_actions(mo, "_root.note('Move out of square, click and release!');"); add_actions(mo, "stop();"); SWFMovie_nextFrame(mo); check_equals(mo, "events.toString()", "'func,onEnterFrame,onRollOver,onEnterFrame,onRollOver," "onMouseDown,onPress,onMouseUp,onRelease,onRollOut,onMouseDown," "onMouseUp'"); check_equals(mo, "resolveevents.toString()", "'func,onEnterFrame,onRollOver'"); add_actions(mo, "mevents = [];" "ressiz = resolveevents.length;" "mc2.onMouseMove = function() { mevents.push('onMouseMove'); };"); // Last test! add_actions(mo, "_root.note('Move the mouse about, then click');"); add_actions(mo, "stop();"); SWFMovie_nextFrame(mo); // Check that mouse events aren't carried to resolve. check_equals(mo, "mevents[0]", "'onMouseMove'"); check_equals(mo, "resolveevents.length", "ressiz"); add_actions(mo, "_root.note('End of test!');"); // Finish and save SWFMovie_nextFrame(mo); add_actions(mo, "stop();"); puts("Saving " OUTPUT_FILENAME ); SWFMovie_save(mo, OUTPUT_FILENAME); return 0; }