Exemplo n.º 1
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;
}
Exemplo n.º 2
0
SEXP MingSWFNew(SEXP file, SEXP height, SEXP width, SEXP scale, SEXP version, SEXP bg, SEXP fonts, SEXP initAS, SEXP labelMethod){
	int bgcolor = RGBpar(bg,0);

	/* R Graphics Device: in GraphicsDevice.h */
	pDevDesc RGD;

	/* R Graphics Engine: in GraphicsEngine.h */
	pGEDevDesc RGE;

	/* Ming Graphics Device */
	MingSWFDesc *MGD;

	if (!(RGD = (pDevDesc)calloc(1, sizeof(NewDevDesc))))
		return R_NilValue;

    if (!(MGD = (MingSWFDesc *)calloc(1, sizeof(MingSWFDesc)))){
		free(RGD);
	    error("unable to start device mingswf");
		return R_NilValue;
	}
	MGD->version = asInteger(version);
	Ming_setScale(asInteger(scale));/* default for library is 20 */
	MGD->movie = newSWFMovieWithVersion(MGD->version);
	MGD->file=(char *)CHAR(STRING_ELT(file,0));

	/* Initialize SWF file */
	SWFMovie_setDimension(MGD->movie,asReal(width),asReal(height));
	SWFMovie_setBackground(MGD->movie, REDC(bgcolor), GREENC(bgcolor), BLUEC(bgcolor));
	SWFMovie_setRate(MGD->movie, 1.0);
	SWFMovie_setNumberOfFrames(MGD->movie, 1);
	SWFMovie_add(MGD->movie,newSWFInitAction(newSWFAction(
	"_root.createEmptyMovieClip('popup',65534);"
	"_root.popup._visible = false;"
	"_root.popup.createTextField('Label',65535,0,0,0,0);"
	"_root.popup.Label.multiline = true;"
	"_root.popup.Label.html = true;"
	"_root.movePopUp = function (){"
	"	if (_root._xmouse <= _root.popup.Label._width+20){"
	"		_root.popup._x = _root._xmouse+20;"
	"	} else {"
	"		_root.popup._x = _root._xmouse-_root.popup.Label._width-10;"
	"	}"
	"	if (_root._ymouse <= _root.popup.Label._height+20){"
	"		_root.popup._y = _root._ymouse+15;"
	"	} else {"
	"		_root.popup._y = _root._ymouse-_root.popup.Label._height-10;"
	"	}"
	"	updateAfterEvent();"
	"};"
	"_root.showPopUp = function(obj){"
	"	_root.popup.Label.htmlText = obj.Label;"
	"   obj.oldAlpha = obj._alpha;"
	"   obj._alpha = 50;"
	"	_root.popup.Label.autoSize = true;"
	"	_root.popup.lineStyle(20,0xc2c2c2);"
	"	_root.popup.beginFill(0xc2c2c2);"
	"	_root.popup.moveTo(0,0);"
	"	_root.popup.lineTo(_root.popup.Label._width-5,0);"
	"	_root.popup.lineTo(_root.popup.Label._width-5,_root.popup.Label._height-5);"
	"	_root.popup.lineTo(0,_root.popup.Label._height-5);"
	"	_root.popup.lineTo(0,0);"
	"	_root.popup._visible = true;"
	"	obj.onMouseMove = _root.movePopUp;"
	"	_root.movePopUp();"
	"};"
	"_root.hidePopUp = function(obj){"
	"   obj._alpha = obj.oldAlpha;"
	"	delete obj.onMouseMove;"
	"	_root.popup.clear();"
	"	_root.popup._visible = false;"
	"};"
	)));

    RGD->deviceSpecific = (void *) MGD;

	/* Callbacks */
    RGD->close = MingSWFClose;
    RGD->activate = MingSWFActivate;
    RGD->deactivate = MingSWFDeactivate;
    RGD->size = MingSWFSize;
    RGD->newPage = MingSWFNewPage;
    RGD->clip = MingSWFClip;
    RGD->strWidth = MingSWFStrWidth;
    RGD->text = MingSWFText;
    RGD->rect = MingSWFRect;
    RGD->circle = MingSWFCircle;
    RGD->line = MingSWFLine;
    RGD->polyline = MingSWFPolyline;
    RGD->polygon = MingSWFPolygon;
    RGD->locator = MingSWFLocator;
    RGD->mode = MingSWFMode;
    RGD->metricInfo = MingSWFMetricInfo;
	RGD->hasTextUTF8 = TRUE;
    RGD->strWidthUTF8 = MingSWFStrWidth;
    RGD->textUTF8 = MingSWFText;
	RGD->wantSymbolUTF8 = TRUE;

	/* Initialise RGD */
	RGD->left = RGD->clipLeft = 0;
	RGD->top = RGD->clipTop = 0;
	RGD->right = RGD->clipRight = asReal(width);
	RGD->bottom = RGD->clipBottom = asReal(height);
	RGD->xCharOffset = 0.4900;
	RGD->yCharOffset = 0.3333;
	RGD->yLineBias = 0.1;
	RGD->ipr[0] = 1.0/72.0;
	RGD->ipr[1] = 1.0/72.0;
	RGD->cra[0] = 0.9 * 12;
	RGD->cra[1] = 1.2 * 12;
	RGD->gamma = 1.0;
	RGD->canClip = FALSE;
    RGD->canChangeGamma = FALSE;
    RGD->canHAdj = 2;
	RGD->startps = 12.0;
	RGD->startcol = R_RGB(0,0,0);
	RGD->startfill = 0xffffffff;
	RGD->startlty = LTY_SOLID;
	RGD->startfont = 1;
	RGD->startgamma = RGD->gamma;
    RGD->displayListOn = TRUE;


	/* Add to the device list */
	RGE = GEcreateDevDesc(RGD);
	MGD->RGE = RGE;
	GEaddDevice(RGE);
	GEinitDisplayList(RGE);

	return ScalarInteger(1 + GEdeviceNumber(RGE));
}
Exemplo n.º 3
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;
}
Exemplo n.º 4
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;
}
Exemplo n.º 5
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;
}
Exemplo n.º 6
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;
}
Exemplo n.º 7
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;
}
Exemplo n.º 8
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;
}
Exemplo n.º 9
0
int
main(int argc, char** argv)
{
	SWFMovie mo;
	SWFMovieClip dejagnuclip;
	SWFDisplayItem it;

	char url_png[512];
    char url_indexpng[512];
    char url_greypng[512];
    char url_gif[512];
    char url_igif[512];

    char png_action[256];
    char indexpng_action[256];
    char greypng_action[256];
    char gif_action[256];
    char igif_action[256];


	/*********************************************
	 *
	 * Initialization
	 *
	 *********************************************/

	if ( argc>1 ) mediadir=argv[1];
	else
	{
		fprintf(stderr, "Usage: %s <mediadir>\n", argv[0]);
		return 1;
	}

	sprintf(url_png, "%s/png.png", mediadir);
	sprintf(url_indexpng, "%s/indexed.png", mediadir);
	sprintf(url_greypng, "%s/greyscale.png", mediadir);
	sprintf(url_gif, "%s/gif.gif", mediadir);
	sprintf(url_igif, "%s/gif-interlaced.gif", mediadir);

	puts("Setting things up");

	Ming_init();
    Ming_useSWFVersion (OUTPUT_VERSION);
	Ming_setScale(20.0); /* so we talk pixels */
 
	mo = newSWFMovie();
    SWFMovie_setDimension (mo, 800, 600); 
    SWFMovie_setRate (mo, 12.0); 
    SWFMovie_setBackground (mo, 255, 255, 255); 

	/*****************************************************
	 *
	 * Add Dejagnu clip
	 *
	 *****************************************************/

	dejagnuclip = get_dejagnu_clip((SWFBlock)get_default_font(mediadir), 10, 0, 0, 800, 600);
	it = SWFMovie_add(mo, (SWFBlock)dejagnuclip);
	SWFDisplayItem_moveTo(it, 0, 250);
	SWFMovie_nextFrame(mo); 

	/*****************************************************
	 *
	 * Add the clips
	 *
	 *****************************************************/

    sprintf(png_action, "_root.window.loadMovie(\"%s\");", url_png);
    add_button(mo, 50, 100, "Load PNG", newSWFAction(png_action));

    sprintf(indexpng_action, "_root.window.loadMovie(\"%s\");", url_indexpng);
    add_button(mo, 50, 125, "Load indexed PNG", newSWFAction(indexpng_action));

    sprintf(greypng_action, "_root.window.loadMovie(\"%s\");", url_greypng);
    add_button(mo, 50, 150, "Load greyscale PNG", newSWFAction(greypng_action));

    sprintf(gif_action, "_root.window.loadMovie(\"%s\");", url_gif);
    add_button(mo, 50, 175, "Load GIF", newSWFAction(gif_action));

    sprintf(igif_action, "_root.window.loadMovie(\"%s\");", url_igif);
    add_button(mo, 50, 200, "Load interlaced GIF", newSWFAction(igif_action));


	/*****************************************************
	 *
	 * Add the window clip
	 *
	 *****************************************************/

	puts("Adding window");

	add_window(mo, 600, 100);

	add_actions(mo, "stop();");
	SWFMovie_nextFrame(mo); /* showFrame */

	/*****************************************************
	 *
	 * Output movie
	 *
	 *****************************************************/

	puts("Saving " OUTPUT_FILENAME );

	SWFMovie_save(mo, OUTPUT_FILENAME);

	return 0;
}
Exemplo n.º 10
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, 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);  /* end of frame1 */

	add_actions(mo, "counter = 1; onLoadCalled = new Array();");

	add_actions(mo,
		"var name1 = 'square'+counter;"
		"attachMovie('redsquare', name1, 70+counter);"
		"var clip1 = this[name1];"
		"counter++;"
		);

	SWFMovie_nextFrame(mo); /* end of frame2 */

	add_actions(mo,
		"function CustomClass() { this._x = 80; }"
		"CustomClass.prototype.onLoad = function() { note(this+'.onLoad called'); _root.onLoadCalled.push(this); };"
		"registerClassRet = Object.registerClass('redsquare', CustomClass);"
		);

	check_equals(mo, "typeof(registerClassRet)", "'boolean'");
	check_equals(mo, "registerClassRet", "true");

	add_actions(mo,
		"var name2 = 'square'+counter;"
		"attachMovie('redsquare', name2, 70+counter);"
		"var clip2 = this[name2];"
		"counter++;"
		);


	SWFMovie_nextFrame(mo); /* end of frame3 */

	add_actions(mo,
		"function CustomClass2() { this._x = 160; check_equals(typeof(super.lineTo), 'function'); }"
		"CustomClass2.prototype = new MovieClip;"
		"registerClassRet = Object.registerClass('redsquare', CustomClass2);"
		);

	check_equals(mo, "_root.onLoadCalled.length", "1");
	check_equals(mo, "_root.onLoadCalled[0]", "_level0.square2");
	check_equals(mo, "typeof(registerClassRet)", "'boolean'");
	check_equals(mo, "registerClassRet", "true");

	add_actions(mo,
		"var name3 = 'square'+counter;"
		"attachMovie('redsquare', name3, 70+counter);"
		"var clip3 = this[name3];"
		"counter++;"
		);

	SWFMovie_nextFrame(mo); /* end of frame4 */

	add_actions(mo,
		"registerClassRet = Object.registerClass('redsquare');"
		);

	check_equals(mo, "typeof(registerClassRet)", "'boolean'");
	check_equals(mo, "registerClassRet", "false");

	add_actions(mo,
		"var name4 = 'square'+counter;"
		"attachMovie('redsquare', name4, 70+counter);"
		"var clip4 = this[name4];"
		"clip4._x = 240;"
		"counter++;"
		);

	SWFMovie_nextFrame(mo); /* end of frame5 */

	check_equals(mo, "typeof(clip1)", "'movieclip'");
	check(mo, "clip1 instanceOf MovieClip");
	check_equals(mo, "clip1._x", "0");
	check(mo, "! clip1 instanceOf CustomClass");
	
	// Check that non-enumerable properties (unnamed instances,
	// constructor, __constructor__) are not enumerated.
	add_actions(mo, "var s = ''; for (i in clip1) { s += i + ','; };");
	check_equals(mo, "s", "'onRollOver,'");

	check_equals(mo, "typeof(clip2)", "'movieclip'");
	check(mo, "clip2 instanceOf CustomClass");
	check(mo, "clip2.hasOwnProperty('__constructor__')");
	check(mo, "clip2.hasOwnProperty('constructor')");
	check(mo, "clip2.hasOwnProperty('__proto__')");
	check_equals(mo, "clip2.__proto__", "CustomClass.prototype");
	check_equals(mo, "clip2.__constructor__", "CustomClass");
	check_equals(mo, "clip2.constructor", "CustomClass");
	check_equals(mo, "clip2._x", "80");
	check_equals(mo, "typeof(clip2.lineTo)", "'undefined'");
	check(mo, "! clip2 instanceOf MovieClip");
	
	// Check that non-enumerable properties (unnamed instances,
	// constructor, __constructor__) are not enumerated.
	add_actions(mo, "var s = ''; for (i in clip2) { s += i + ','; };");
	check_equals(mo, "s", "'onLoad,onRollOver,'");

	check(mo, "clip3.hasOwnProperty('__constructor__')");
	check(mo, "clip3.hasOwnProperty('constructor')");
	check(mo, "clip3.hasOwnProperty('__proto__')");
	check_equals(mo, "clip3.__proto__", "CustomClass2.prototype");
	check_equals(mo, "clip3.__constructor__", "CustomClass2");
	check_equals(mo, "clip3.constructor", "CustomClass2");
	check_equals(mo, "typeof(clip3)", "'movieclip'");
	check_equals(mo, "clip3._x", "160");
	check(mo, "clip3 instanceOf CustomClass2");
	check(mo, "clip3 instanceOf MovieClip");
	
	// Check that non-enumerable properties (unnamed instances,
	// constructor, __constructor__) are not enumerated.
	add_actions(mo, "var s = ''; for (i in clip3) { s += i + ','; };");
	check_equals(mo, "s", "'onRollOver,'");

	check(mo, "clip4.hasOwnProperty('__constructor__')");
	check(mo, "clip4.hasOwnProperty('constructor')");
	check(mo, "clip4.hasOwnProperty('__proto__')");
	check_equals(mo, "clip4.__proto__", "CustomClass2.prototype");
	check_equals(mo, "clip4.__constructor__", "CustomClass2");
	check_equals(mo, "clip4.constructor", "CustomClass2");
	check_equals(mo, "typeof(clip4)", "'movieclip'");
	check_equals(mo, "clip4._x", "240");
	check(mo, "clip4 instanceOf MovieClip");

	add_actions(mo,
		"totals(47);"
		"stop();"
		);

	SWFMovie_nextFrame(mo); /* end of frame5 */

	/*****************************************************
	 *
	 * Output movie
	 *
	 *****************************************************/

	puts("Saving " OUTPUT_FILENAME );

	SWFMovie_save(mo, OUTPUT_FILENAME);

	return 0;
}
Exemplo n.º 11
0
int
main(int argc, char **argv)
{
	SWFMovie mo;
	SWFDisplayItem it;
	const char *srcdir=".";
	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, 12);

	if ( argc>1 ) srcdir=argv[1];
	else
	{
		fprintf(stderr, "Usage: %s <mediadir>\n", argv[0]);
		return 1;
	}

	font = get_default_font(srcdir); 

	/* 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); /* showFrame */

	/*****************************************************
	 *
	 * Add button
	 *
	 *****************************************************/

	it = add_button(mo);
	SWFDisplayItem_moveTo(it, 40, 30);
	SWFDisplayItem_setName(it, "square1");
	SWFDisplayItem_setDepth(it, 2);

	add_actions(mo,
		"function printBounds(b) {"
		"   return ''+Math.round(b.xMin*100)/100+','+Math.round(b.yMin*100)/100+' '+Math.round(b.xMax*100)/100+','+Math.round(b.yMax*100)/100;"
		"}"
	);

	//
	// Mouse pointer events
	//

	add_actions(mo,
		"square1.button.onRollOver = function() { "
		"	_root.msg2 = 'RollOver'; "
		// Target is the one this function was defined in
		"	check_equals(_target, '/');"
		"};"
		);

	add_actions(mo,
		"square1.button.onRollOut = function() {"
		"	_root.msg2 = 'RollOut'; "
		// Target is the one this function was defined in
		"	check_equals(_target, '/');"
		"};"
		);

	//
	// Mouse buttons events
	//

	add_actions(mo,
		"square1.button.onPress = function() {"
		"	_root.msg2 = 'Press'; "
		// Target is the one this function was defined in
		"	check_equals(_target, '/');"
		"};"
		);

	add_actions(mo,
		"square1.button.onRelease = function() {"
		"	_root.msg2 = 'Release'; "
		// Target is the one this function was defined in
		"	check_equals(_target, '/');"
		"};"
		);

	add_actions(mo,
		"square1.button.onReleaseOutside = function() {"
		"	_root.msg2 = 'ReleaseOutside'; "
		// Target is the one this function was defined in
		"	check_equals(_target, '/');"
		"};"
		);

	//
	// Focus events
	//

	add_actions(mo,
		"square1.button.onSetFocus = function() {"
		"	_root.msg3 = 'SetFocus';"
		// Target is the one this function was defined in
		"	check_equals(_target, '/');"
		"};"
		);

	//
	// Key events - button needs focus for these to work
	//

	add_actions(mo,
		"square1.button.onKeyDown = function() {"
		"	_root.msg3 = 'KeyDown';"
		// Target is the one this function was defined in
		"	check_equals(_target, '/');"
		"};"
		);

	add_actions(mo, 
		"square1.button.onKeyUp = function() {"
		"	_root.msg3 = 'KeyUp';"
		// Target is the one this function was defined in
		"	check_equals(_target, '/');"
		"};"
		);

	SWFMovie_nextFrame(mo); /* showFrame */

	/*****************************************************
	 *
	 * On second frame, check construction of the button
	 * DisplayObject states and give instructions to proceed
	 *
	 *
	 *****************************************************/

	add_actions(mo, "Array.prototype.realLength = function() {"
		" var l=0; for (var i in this) { "
		"	if (Number(i) == i) l++;" /* count only numbers */
		" };"
		" return l;"
		"};");

	/* buttonChild was initialized with 2 elements */
	check_equals(mo, "typeof(_root.buttonChild)", "'object'");
	check(mo, "_root.buttonChild instanceof Array");
	check_equals(mo, "_root.buttonChild.realLength()", "2"); /* UP and ALL states */

	/* sprite for ALL states */
	check_equals(mo, "typeof(_root.buttonChild[10])", "'object'");
	check_equals(mo, "(_root.buttonChild[10].nam)", "'_level0.square1.button.instance5'"); 
	check_equals(mo, "(_root.buttonChild[10].exe)", "1");
	check_equals(mo, "(_root.buttonChild[10].uld)", "0");

	/* sprite for UP state */
	check_equals(mo, "typeof(_root.buttonChild[12])", "'object'");
	check_equals(mo, "(_root.buttonChild[12].nam)", "'_level0.square1.button.instance6'"); 
	check_equals(mo, "(_root.buttonChild[12].exe)", "1");
	check_equals(mo, "(_root.buttonChild[12].uld)", "0");
	check_equals(mo, "_level0.square1.button.instance6._name", "'instance6'");
	check_equals(mo, "_level0.square1.button.instance6.getDepth()", "-16371");

	/* sprite for HIT state not constructed */
	check_equals(mo, "typeof(_root.buttonChild[11])", "'undefined'");

	/* sprite for DOWN state not constructed */
	check_equals(mo, "typeof(_root.buttonChild[13])", "'undefined'"); 

	add_actions(mo,
		"stop();"
		/*"_root.note('buttonChild is '+dumpObj(_root.buttonChild));"*/
		"_root.testno=0;"
		"_root.square1.onRollOut = function() { _root.testno++; delete _root.square1.onRollOut; nextFrame(); };"
		"_root.note('"
		"0. Roll over and out the red square, not touching the small dark-red square in it."
		"');");

	/* hitTest should work on every child, not just first added */
	check(mo, "_level0.square1.hitTest(60,60,true)");

	SWFMovie_nextFrame(mo); /* showFrame */

	/*****************************************************
	 *
	 * On third frame, start the button event test
	 *
	 *****************************************************/

	add_actions(mo,
		"stop();"
		/*"_root.note('buttonChild is '+dumpObj(_root.buttonChild));"*/
		"_root.testno=1;"
		"_root.note('"
		"1. Roll over the red square."
		"');");

	SWFMovie_nextFrame(mo); /* showFrame */

	/*****************************************************
	 *
	 * On fourth frame, add a shape at lower depth,
	 * and check bounds of square1
	 *
	 *
	 *****************************************************/

	{
		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);

		check_equals(mo, "printBounds(square1.getBounds())", "'-0.05,-0.05 40.05,40.05'");

		/* buttonChild should now have a total of 4 elements (UP,DOWN, OVER and ALL states) */
		check_equals(mo, "typeof(_root.buttonChild)", "'object'");
		check(mo, "_root.buttonChild instanceof Array");
		check_equals(mo, "_root.buttonChild.realLength()", "4"); 

		/* sprite for ALL states */
		check_equals(mo, "typeof(_root.buttonChild[10])", "'object'");
		check_equals(mo, "(_root.buttonChild[10].nam)", "'_level0.square1.button.instance5'"); 
		check_equals(mo, "(_root.buttonChild[10].exe)", "1");
		check_equals(mo, "(_root.buttonChild[10].uld)", "0");

		/* sprite for UP state */
		check_equals(mo, "typeof(_root.buttonChild[12])", "'object'");
		check_equals(mo, "(_root.buttonChild[12].nam)", "'_level0.square1.button.instance6'"); 
		check_equals(mo, "(_root.buttonChild[12].exe)", "3"); 
		check_equals(mo, "(_root.buttonChild[12].uld)", "2");

		/* sprite for OVER state */
		check_equals(mo, "typeof(_root.buttonChild[13])", "'object'");
		check_equals(mo, "(_root.buttonChild[13].nam)", "'_level0.square1.button.instance7'"); 
		check_equals(mo, "(_root.buttonChild[13].exe)", "4");
		check_equals(mo, "(_root.buttonChild[13].uld)", "4");

		/* sprite for DOWN state */
		check_equals(mo, "typeof(_root.buttonChild[14])", "'object'");
		check_equals(mo, "(_root.buttonChild[14].nam)", "'_level0.square1.button.instance8'"); 
		check_equals(mo, "(_root.buttonChild[14].exe)", "2");
		check_equals(mo, "(_root.buttonChild[14].uld)", "2");

		/* sprite for HIT state never constructed */
		check_equals(mo, "typeof(_root.buttonChild[11])", "'undefined'"); 



		add_actions(mo,
			"stop();"
			"_root.note('-- Added shape at lower depth --');"
			"_root.testno++;"
			"_root.note(_root.testno+'. Roll over the square.');"
		);

		SWFMovie_nextFrame(mo); /* showFrame */
	}

	/*****************************************************
	 *
	 * On fifth 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);

		/* buttonChild should now have a total of 4 elements (UP,DOWN, OVER and ALL states) */
		check_equals(mo, "typeof(_root.buttonChild)", "'object'");
		check(mo, "_root.buttonChild instanceof Array");
		check_equals(mo, "_root.buttonChild.realLength()", "4"); 

		/* sprite for ALL states */
		check_equals(mo, "typeof(_root.buttonChild[10])", "'object'");
		check_equals(mo, "(_root.buttonChild[10].nam)", "'_level0.square1.button.instance5'"); 
		check_equals(mo, "(_root.buttonChild[10].exe)", "1");
		check_equals(mo, "(_root.buttonChild[10].uld)", "0");

		/* sprite for UP state */
		check_equals(mo, "typeof(_root.buttonChild[12])", "'object'");
		check_equals(mo, "(_root.buttonChild[12].nam)", "'_level0.square1.button.instance6'"); 
		check_equals(mo, "(_root.buttonChild[12].exe)", "5"); 
		check_equals(mo, "(_root.buttonChild[12].uld)", "4");

		/* sprite for OVER state */
		check_equals(mo, "typeof(_root.buttonChild[13])", "'object'");
		check_equals(mo, "(_root.buttonChild[13].nam)", "'_level0.square1.button.instance7'"); 
		check_equals(mo, "(_root.buttonChild[13].exe)", "8");
		check_equals(mo, "(_root.buttonChild[13].uld)", "8");

		/* sprite for DOWN state */
		check_equals(mo, "typeof(_root.buttonChild[14])", "'object'");
		check_equals(mo, "(_root.buttonChild[14].nam)", "'_level0.square1.button.instance8'"); 
		check_equals(mo, "(_root.buttonChild[14].exe)", "4");
		check_equals(mo, "(_root.buttonChild[14].uld)", "4");

		/* sprite for HIT state never constructed */
		check_equals(mo, "typeof(_root.buttonChild[11])", "'undefined'"); 

		add_actions(mo,
			"stop();"
			"_root.note('-- Added shape at higher depth --');"
			"_root.testno++;"
			"_root.note(_root.testno+'. Roll over the square.');"
		);

		SWFMovie_nextFrame(mo); /* showFrame */
	}

	/*****************************************************
	 *
	 * On sixth frame, disable the button
	 * and check total tests so far
	 *
	 *****************************************************/

	{

		add_actions(mo,
            "check_equals(square1.button.enabled, true);"
			"square1.button.enabled = 6;"
            "check_equals(square1.button.enabled, 6);"
			"square1.button.enabled = 'string';"
            "check_equals(square1.button.enabled, 'string');"
            "square1.button._visible = false;"
            "check_equals(square1.button.enabled, 'string');"
            "square1.button._visible = true;"
			"square1.button.enabled = false;"
			"stop();"
			"_root.totals(160);"
			"_root.note('-- Button disabled, try playing with it, nothing should happen --');"
		);
		SWFMovie_nextFrame(mo); /* showFrame */
	}

	/*****************************************************
	 *
	 * Save it...
	 *
	 *****************************************************/

	puts("Saving " OUTPUT_FILENAME );

	SWFMovie_save(mo, OUTPUT_FILENAME);

	return 0;
}
Exemplo n.º 12
0
EXPORT BOOL WINAPI ming_setScale(float scale, int p2, int p3, int p4)
{
	lstrcpy(funcname, "ming_setScale");
	Ming_setScale(scale);
	return 0;
}
Exemplo n.º 13
0
int
main(int argc, char** argv)
{
	SWFMovie mo;
	SWFMovieClip dejaclip;
	const char *srcdir=".";
	SWFFont bfont; 


	/*********************************************
	 *
	 * Initialization
	 *
	 *********************************************/

	if ( argc>1 ) srcdir=argv[1];
	else
	{
		fprintf(stderr, "Usage: %s <mediadir>\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);
	SWFMovie_setDimension(mo, 628, 1024);

	bfont = get_default_font(srcdir);

	/*********************************************
	 *
	 * Body
	 *
	 *********************************************/

	dejaclip = get_dejagnu_clip((SWFBlock)bfont, 3000, 0, 50, 800, 800);

	SWFMovie_add(mo, (SWFBlock)dejaclip);
	SWFMovie_addExport(mo, (SWFBlock)dejaclip, "dejagnu");
	SWFMovie_addExport(mo, (SWFBlock)SWFMovie_addFont(mo, bfont),
		"dejafont");

	SWFMovie_nextFrame(mo); /* showFrame */


	/*****************************************************
	 *
	 * Output movie
	 *
	 *****************************************************/

	puts("Saving " OUTPUT_FILENAME );

	SWFMovie_save(mo, OUTPUT_FILENAME);

	return 0;
}
Exemplo n.º 14
0
int
main(int argc, char** argv)
{
    SWFMovie mo;
    const char *srcdir=".";
    SWFMovieClip  dejagnuclip;

    char loadvars[1048];
    char loademptyvars[1048];

    /*********************************************
     *
     * Initialization
     *
     *********************************************/

    if ( argc>1 ) srcdir=argv[1];
    else
    {
       fprintf(stderr, "Usage: %s\n", argv[0]);
       return 1;
    }

    sprintf(loadvars, "e = l.load('%s/vars2.txt');", srcdir);
    sprintf(loademptyvars, "e = l.load('%s/empty.txt');", srcdir);
    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, 640, 400);

    /*********************************************
     *
     * Body
     *
     *********************************************/

    dejagnuclip = get_dejagnu_clip((SWFBlock)get_default_font(srcdir),
                 10, 0, 80, 800, 600);
    SWFMovie_add(mo, (SWFBlock)dejagnuclip);

    add_actions(mo, 
                 "odatB = LoadVars.prototype.onData;"
                 "olB = LoadVars.prototype.onLoad;"
                 "odecB = LoadVars.prototype.decode;"
                 "loadString = '';"
                 "decodeString = '';"
                 "dataString = '';"
                 "callCount = 0;");

    add_actions(mo, "ourLoad = function(arg) {"
                 "loadString += callCount + ': onLoad called with ' + "
                 "typeof(arg) + ' argument ' + arg;"
                 "callCount++;"
                 "play();"
                 "};");

    add_actions(mo, "ourData = function(arg) {"
                 "trace('onData called');"
                 "dataString += callCount + ': onData called with ' + "
                 "typeof(arg) + ' argument ' + arg;"
                 "callCount++;"
                 "play();"
                 "};");

   
    add_actions(mo, "decodeCalled = 0;");
    add_actions(mo, "ourDecode = function(arg) {"
                 "decodeString += 'decode called with ' + typeof(arg)"
                 "+ ' argument ' + arg;"
                 "decodeCalled++;"
                 "};");

    /// The decode method is overwritten to see where it gets
    /// called from. We don't call it ourselves. Don't forget to 
    /// overwrite it again when the LoadVars object is constructed again.

    /// What happens when load fails?
    //
    /// The onLoad method is called from the default implementation of
    /// onData. The "loaded" property is immediately set to false on a 
    /// call to "load".
   
    SWFMovie_nextFrame(mo);

    /// onData
    add_actions(mo, "l = new LoadVars;");
    check_equals(mo, "l.loaded", "undefined");
    add_actions(mo, "l.decode = ourDecode;");

    add_actions(mo, "l.onData = ourData;"
                 "dataString = '';"
                 "e = l.load('fail');");
    check_equals(mo, "e", "true");
    add_actions(mo, "stop();");

    /// Wait for data before proceeding to next frame.
    SWFMovie_nextFrame(mo);
   
    // Check result, restore state.
    check_equals(mo, "dataString",
                 "'0: onData called with undefined argument undefined'");
    check_equals(mo, "l.loaded", "false");
    add_actions(mo, "l.onData = odatB;");

    /// onLoad
    add_actions(mo, "l = new LoadVars;");
    check_equals(mo, "l.loaded", "undefined");
    add_actions(mo, "l.decode = ourDecode;");

    add_actions(mo, "l.onLoad = ourLoad;"
                 "loadString = '';"
                 "e = l.load('fail');");
    check_equals(mo, "e", "true");
    add_actions(mo, "stop();");

    SWFMovie_nextFrame(mo);
          
    check_equals(mo, "loadString",
                 "'1: onLoad called with boolean argument false'");
    check_equals(mo, "l.loaded", "false");
    add_actions(mo, "l.onLoad = olB;");

    /// Both onData and onLoad
    add_actions(mo, "l = new LoadVars;");
    check_equals(mo, "l.loaded", "undefined");
    add_actions(mo, "l.decode = ourDecode;");

    add_actions(mo, "l.onLoad = ourLoad;"
                    "l.onData = ourData;"
                    "loadString = '';"
                    "dataString = '';"
                    "e = l.load('fail');");
    check_equals(mo, "e", "true");
    add_actions(mo, "stop();");

    SWFMovie_nextFrame(mo);
          
    check_equals(mo, "loadString", "''");
    check_equals(mo, "dataString",
                 "'2: onData called with undefined argument undefined'");
    check_equals(mo, "l.loaded", "false");
    add_actions(mo, "l.onLoad = olB;"
                    "l.onData = odatB;");

    /// What happens when load succeeds?
    //
    /// Both methods are called separately. The "loaded" property is set
    /// to true only when "onData" isn't overwritten.

    // onData
    add_actions(mo, "l = new LoadVars;");
    check_equals(mo, "l.loaded", "undefined");
    add_actions(mo, "l.decode = ourDecode;");

    add_actions(mo, "l.onData = ourData;"
                     "dataString = '';");
    add_actions(mo, loadvars);
    check_equals(mo, "e", "true");
    add_actions(mo, "stop();");

    SWFMovie_nextFrame(mo);
    // check_equals is too braindead to do this without escaping.
    check_equals(mo, "escape(dataString)",
           "'3%3A%20onData%20called%20with%20string%20argument%20v2%5Fvar1%3D"
        "val1%26v2%5Fvar2%3Dval2%26%0A'");
    check_equals(mo, "l.loaded", "false");
    add_actions(mo, "l.onData = odatB;");

    check_equals(mo, "decodeCalled", "0");
    check_equals(mo, "decodeString", "''");

    // onLoad
    add_actions(mo, "l = new LoadVars;");
    check_equals(mo, "l.loaded", "undefined");
    add_actions(mo, "l.decode = ourDecode;");

    add_actions(mo, "l.onLoad = ourLoad;"
                    "loadString = '';");
    add_actions(mo, loadvars);
    check_equals(mo, "e", "true");
    add_actions(mo, "stop();");

    SWFMovie_nextFrame(mo);
    check_equals(mo, "loadString",
                 "'4: onLoad called with boolean argument true'");
    add_actions(mo, "l.onLoad = olB;");

    /// decode is called from onData (i.e. it's called when we overwrite
    /// onLoad, not onData).
    check_equals(mo, "decodeCalled", "1");
    // check_equals is too braindead to do this without escaping.
    check_equals(mo, "escape(decodeString)",
              "'decode%20called%20with%20string%20argument%20v2%5Fvar1%3D"
        "val1%26v2%5Fvar2%3Dval2%26%0A'");


    /// What happens on load of empty data?
    //
    /// Same as a load failure.

    // onData
    add_actions(mo, "l = new LoadVars;");
    check_equals(mo, "l.loaded", "undefined");
    add_actions(mo, "l.decode = ourDecode;");

    add_actions(mo, "l.onData = ourData;"
                     "dataString = '';");
    add_actions(mo, loademptyvars);
    check_equals(mo, "e", "true");
    add_actions(mo, "stop();");

    SWFMovie_nextFrame(mo);
    // check_equals is too braindead to do this without escaping.
    check_equals(mo, "escape(dataString)",
           "'5%3A%20onData%20called%20with%20undefined%20"
           "argument%20undefined'");
    check_equals(mo, "l.loaded", "false");
    add_actions(mo, "l.onData = odatB;");

    // No more calls to decode.
    check_equals(mo, "decodeCalled", "1");


    /// End of tests.

   add_actions(mo, "totals(29);");
   add_actions(mo, "stop();");

   /*****************************************************
    *
    * Output movie
    *
    *****************************************************/

   puts("Saving " OUTPUT_FILENAME );

   SWFMovie_save(mo, OUTPUT_FILENAME);

   return 0;
}
Exemplo n.º 15
0
int
main(int argc, char **argv)
{
	SWFMovie mo;
	SWFDisplayItem it;
	const char *srcdir=".";
	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, 12);

	if ( argc>1 ) srcdir=argv[1];
	else
	{
		fprintf(stderr, "Usage: %s <mediadir>\n", argv[0]);
		return 1;
	}

	font = get_default_font(srcdir); 

	/* 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); /* showFrame */

	/*****************************************************
	 *
	 * Add button
	 *
	 *****************************************************/

	it = add_button(mo);
	SWFDisplayItem_moveTo(it, 40, 30);
	SWFDisplayItem_setName(it, "square1");
	SWFDisplayItem_setDepth(it, 2);

    /* This button has one character per state. It shows that each state
     * except HIT generates one new instance and deletes the old one.
     * HIT deletes the old instance property and does not add a new one.
     */

    add_actions(mo, "note('This is a very simple test. Do anything you like "
            "with the buttons and you should get no failures');");

    add_actions(mo, "var c = 2;");
    add_actions(mo,
            "props = function() {"
            "   s=''; "
            "   for (i in square1.button) { "
            "       if (i.substr(0, 8) == 'instance') { s += i; }; "
            "   };"
            "   return s;"
            "};");
    add_actions(mo, "check_equals(props(), 'instance' + c++);");
    add_actions(mo,
            "square1.button.onRollOver = function() {"
            "   check_equals(props(), '');"
            "};"
            "square1.button.onRollOut = function() {"
            "   check_equals(props(), 'instance' + c++);"
            "};"
            "square1.button.onMouseDown = function() {"
            "   check_equals(props(), 'instance' + c++);"
            "};"
            "square1.button.onPress = function() {"
            "   check_equals(props(), 'instance' + c++);"
            "};"
            "square1.button.onRelease = function() {"
            "   check_equals(props(), '');"
            "};"
            "square1.button.onReleaseOutside = function() {"
            "   check_equals(props(), 'instance' + c++);"
            "};"
            );
                   
    //add_actions(mo, "onEnterFrame = function() { props(); trace (s); };");
    add_actions(mo, "stop();");
	SWFMovie_nextFrame(mo); /* showFrame */

	/*****************************************************
	 *
	 * Save it...
	 *
	 *****************************************************/

	puts("Saving " OUTPUT_FILENAME );

	SWFMovie_save(mo, OUTPUT_FILENAME);

	return 0;
}