Example #1
0
void
add_text_field(SWFMovie mo, const char* name, const char* varname, const char* initial_label, int depth, int x, int y)
{
	SWFDisplayItem it;
	SWFTextField tf = newSWFTextField();
	SWFTextField_setFont(tf, (void*)font);
	SWFTextField_addChars(tf, " abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ012345689:.,/\\#@?!");
	SWFTextField_setVariableName(tf, varname);
	SWFTextField_addString(tf, "Idle");
	SWFTextField_setBounds(tf, 120, 12);
	SWFTextField_setFlags(tf, SWFTEXTFIELD_DRAWBOX|SWFTEXTFIELD_NOEDIT);

	it = SWFMovie_add(mo, (SWFBlock)tf);
	SWFDisplayItem_moveTo(it, x, y+2);
	SWFDisplayItem_setDepth(it, depth);
	SWFDisplayItem_setName(it, name); // "textfield");

	// Label 
	tf = newSWFTextField();
	SWFTextField_setFont(tf, (void*)font);
	SWFTextField_addString(tf, initial_label);
	SWFTextField_setFlags(tf, SWFTEXTFIELD_DRAWBOX|SWFTEXTFIELD_NOEDIT);
	it = SWFMovie_add(mo, (SWFBlock)tf);
	SWFDisplayItem_scale(it, 0.3, 0.3);
	SWFDisplayItem_setDepth(it, depth*10);
	SWFDisplayItem_moveTo(it, x, y);
}
Example #2
0
static void ming_ellipse(GVJ_t * job, pointf * A, int filled)
{
    SWFMovie movie = (SWFMovie)(job->context);
    SWFShape shape;
    SWFFill fill;
    SWFDisplayItem item;
    obj_state_t *obj = job->obj;
    gvcolor_t pencolor = obj->pencolor;
    gvcolor_t fillcolor = obj->fillcolor;
    double rx, ry;

    shape = newSWFShape();
    SWFShape_setLine(shape, obj->penwidth,
	 pencolor.u.rgba[0],
	 pencolor.u.rgba[1],
	 pencolor.u.rgba[2],
	 pencolor.u.rgba[3]);
    if (filled) {
	fill = SWFShape_addSolidFill(shape,
	    fillcolor.u.rgba[0],
	    fillcolor.u.rgba[1],
	    fillcolor.u.rgba[2],
	    fillcolor.u.rgba[3]);
	SWFShape_setRightFill(shape, fill);
    }
    SWFShape_movePenTo(shape, 0, 0);
    rx = A[1].x - A[0].x;
    ry = A[1].y - A[0].y;
    SWFShape_drawCircle(shape, rx);
    item = SWFMovie_add(movie, (SWFBlock)shape);
    SWFDisplayItem_scale(item, 1., ry/rx);
    SWFDisplayItem_moveTo(item, A[0].x, A[0].y);
}
Example #3
0
/* TODO: respect hadj */
void swfTextUTF8(double x, double y, const char *str, double rot, double hadj, const pGEcontext gc, pDevDesc dd)
{
#ifdef SWF_DEBUG
    Rprintf("textUTF8 called\n");
    Rprintf("** family = %s, font = %d\n", gc->fontfamily, gc->fontface);
    Rprintf("** textUTF8(str[0] = %d, str[1] = %d, str[2] = %d, str[3] = %d)\n",
            str[0], str[1], str[2], str[3]);
#endif
    pswfDesc swfInfo = (pswfDesc) dd->deviceSpecific;
    SWFShape text = newSWFShape();
    SWFDisplayItem text_display;
    /* Convert UTF-8 string to Unicode array */
    int maxLen = strlen(str);
    wchar_t *unicode = (wchar_t *) calloc(maxLen + 1, sizeof(wchar_t));
    int len = utf8towcs(unicode, str, maxLen);
    
    FT_Face face = swfGetFTFace(gc, swfInfo);
    double fontSize = gc->ps * gc->cex;

    swfSetTextColor(text, gc, swfInfo);
    SWFShape_addString(text, unicode, len, fontSize, face,
                       &(swfInfo->outlnFuns));
    
    text_display = SWFMovieClip_add(swfInfo->currentFrame, (SWFBlock) text);
    SWFDisplayItem_moveTo(text_display, x, y);
    SWFDisplayItem_rotate(text_display, rot);
}
Example #4
0
SWFDisplayItem
add_static_mc(SWFMovie mo, const char* name, int depth, int x, int y, int width, int height)
{
	SWFShape sh;
	SWFMovieClip mc;
	SWFDisplayItem it;

	sh = make_fill_square (-(width/2), -(height/2), width, height, 255, 0, 0, 255, 0, 0);
	mc = newSWFMovieClip();
	SWFMovieClip_add(mc, (SWFBlock)sh);

	SWFMovieClip_nextFrame(mc);

	it = SWFMovie_add(mo, (SWFBlock)mc);
	SWFDisplayItem_setDepth(it, depth); 
	SWFDisplayItem_moveTo(it, x, y); 
	SWFDisplayItem_setName(it, name);
	SWFDisplayItem_addAction(it, newSWFAction(
			"_root.note(this+' onClipConstruct');"
			" _root.check_equals(typeof(_root), 'movieclip');"
		        " if ( isNaN(_root.depth3Constructed) ) {"
			"	_root.depth3Constructed=1; "
			" 	_root.note('_root.depth3Constructed set to '+_root.depth3Constructed);"
			" } else {"
			"	_root.depth3Constructed++;"
			" 	_root.note('_root.depth3Constructed set to '+_root.depth3Constructed);"
			" }"
			), SWFACTION_CONSTRUCT);

	return it;
}
Example #5
0
void
add_clip(SWFMovie mo, char* file, char* name,
		char* url, int x, int y)
{
	FILE *fd;
	SWFJpegBitmap bm;
	SWFShape sh;
	SWFMovieClip mc;
	SWFDisplayItem it;
	SWFAction ac;
	char action[1024];

	printf("Adding %s\n", file);

	fd = fopen(file, "r");
	if ( ! fd ) {
		perror(file);
		exit(1);
	}
	bm = newSWFJpegBitmap(fd);
	sh = newSWFShapeFromBitmap((SWFBitmap)bm, SWFFILL_CLIPPED_BITMAP);
	mc = newSWFMovieClip();
	SWFMovieClip_add(mc, (SWFBlock)sh);
	SWFMovieClip_nextFrame(mc); /* showFrame */
	it = SWFMovie_add(mo, (SWFBlock)mc);
	SWFDisplayItem_setName(it, name);
	SWFDisplayItem_moveTo(it, x, y);

	/* "Click" handler */
	sprintf(action, " \
%s.onPress = function () { \
	_root.CoverArtLoader.loadClip('%s', coverart); \
}; \
Example #6
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;
}
Example #7
0
void
add_xtrace_function_clip(SWFMovieClip mc, SWFBlock font, int depth, int x, int y, int width, int height)
{
	SWFTextField tf;
	SWFDisplayItem it;
	int flags;

	tf = newSWFTextField();

	SWFTextField_setFont(tf, font);

	/* setting flags seem unneeded */
	flags = 0;
	//flags |= SWFTEXTFIELD_USEFONT;
	flags |= SWFTEXTFIELD_WORDWRAP;
	//flags |= SWFTEXTFIELD_NOEDIT;
	SWFTextField_setFlags(tf, flags);

	/* Add all ascii chars */
	SWFTextField_addChars(tf, asciichars);
	SWFTextField_addString(tf, " - xtrace enabled -\n");

	SWFTextField_setBounds(tf, width, height);

	/*
	 * Hopefully we have a *single* _root.
	 */
	SWFTextField_setVariableName(tf, "_root._trace_text");

	/*
	 * Set flags explicitly so that the field is selectable
	 * and you can cut&paste results.
	 * (the default seems to include SWFTEXTFIELD_NOSELECT)
	 */
	SWFTextField_setFlags(tf, SWFTEXTFIELD_NOEDIT);

	/*SWFTextField_setHeight(tf, 240);*/
	/*SWFTextField_setColor(tf, 0x00, 0x00, 0x00, 0xff);*/
	/*SWFTextField_setAlignment(tf, SWFTEXTFIELD_ALIGN_LEFT);*/
	/*SWFTextField_setLeftMargin(tf, 0);*/
	/*SWFTextField_setRightMargin(tf, 0);*/
	/*SWFTextField_setIndentation(tf, 0);*/
	/*SWFTextField_setLineSpacing(tf, 40);*/
	/*SWFTextField_setLineSpacing(tf, 40);*/

	it = SWFMovieClip_add(mc, (SWFBlock)tf);
	SWFDisplayItem_moveTo(it, x, y);
	SWFDisplayItem_setDepth(it, depth);
	SWFDisplayItem_setName(it, "_xtrace_win");

	add_clip_actions(mc,
		" _root.xtrace = function (msg) { "
		" _root._trace_text += msg + '\n'; "
		"};");

}
Example #8
0
static void ming_textpara(GVJ_t * job, pointf p, textpara_t * para)
{
    SWFMovie movie = (SWFMovie)(job->context);
    SWFTextField textfield;
    SWFDisplayItem item;
    obj_state_t *obj = job->obj;
    gvcolor_t pencolor = obj->pencolor;
    pointf offset;
    char *font_file_name;
    char *libdir;
    static SWFFont font;

/* FIXME - hardcoded to a Times-like font */
    if (font == NULL) {
    	libdir=gvconfig_libdir();
	font_file_name = malloc(strlen(libdir)+strlen(FONT)+2);
	strcpy(font_file_name, libdir);
	strcat(font_file_name, "/");
	strcat(font_file_name, FONT);
	font = newSWFFont_fromFile(font_file_name);
	free(font_file_name);
    }

    textfield = newSWFTextField();
    SWFTextField_setFont(textfield, (SWFBlock)font);
    SWFTextField_addChars(textfield, para->str);
    SWFTextField_addUTF8String(textfield, para->str);
    SWFTextField_setColor(textfield,
	 pencolor.u.rgba[0],
	 pencolor.u.rgba[1],
	 pencolor.u.rgba[2],
	 pencolor.u.rgba[3]);
    SWFTextField_setHeight(textfield, para->fontsize);

    switch (para->just) {
    case 'r':
	offset.x = 0.;
	break;
    case 'l':
	offset.x = -para->width;
	break;
    case 'n':
    default:
	offset.x = -para->width/2.;
	break;
    }
    /* offset to baseline */
    offset.y = -para->height + para->fontsize*.4;  /* empirically determined */

    item = SWFMovie_add(movie, (SWFBlock)textfield);
    SWFDisplayItem_moveTo(item, p.x + offset.x, p.y + offset.y);
}
Example #9
0
    /*
     * device_Text should have the side-effect that the
     * given text is drawn at the given location.
     * The text should be rotated according to rot (degrees)
     *
     * R_GE_gcontext parameters that should be honoured (if possible):
     *   font, cex, ps, col, gamma
     */
static void SWF_Text( double x, double y, const char *str,
		double rot, double hadj, const pGEcontext plotParams, 
		pDevDesc deviceInfo)
{
	/* Shortcut pointers to variables of interest. */
	swfDevDesc *swfInfo = (swfDevDesc *) deviceInfo->deviceSpecific;
	
	if( swfInfo->debug == TRUE ){
		fprintf(swfInfo->logFile,
			"SWF_Text: Writing Text \"%s\"\n", str);
		fflush(swfInfo->logFile);
	}
	
	/* It is possible that this will be very expensive and storing 
	 * a single text object in swfInfo may be better.
	 */
	SWFText text_object = newSWFText();
	SWFDisplayItem text_display;
	/*Ming (0,0) is the top left, convert to R (0,0) at bottom left*/
	y = deviceInfo->top - y;
	
	//found = !strcmp(name, fontlist->family->fxname);
	
	// Tell the text object to use the font previously loaded
	SWFText_setFont(text_object, 
		selectFont(plotParams->fontface, plotParams->fontfamily, swfInfo));
	
	// Set the height of the text
	SWFText_setHeight(text_object, plotParams->ps * plotParams->cex);
	
	// Set the color of the text
	byte red = R_RED(plotParams->col);
	byte green = R_GREEN(plotParams->col);
	byte blue = R_BLUE(plotParams->col);
	byte alpha =  R_ALPHA(plotParams->col);
	SWFText_setColor(text_object, red, green, blue, alpha);
	
	// Add a string to the text object
	SWFText_addString(text_object, str, NULL);
	
	// Add the text object to the movie (at 0,0)
	text_display = SWFMovie_add(swfInfo->m, (SWFBlock) text_object);
	
	addToDisplayList( text_display );
	
	// Move to correct coordinate and rotate
	SWFDisplayItem_moveTo(text_display, x, y);
	SWFDisplayItem_rotate(text_display, rot);
	
			
}
Example #10
0
void
add_button(SWFMovie mo, int x, int y, const char* label, SWFAction ac)
{
	SWFMovieClip btnclip = newSWFMovieClip();
	SWFFont font = get_default_font(mediadir);
	SWFDisplayItem it;
	SWFTextField tf = get_label(label, font);

	SWFMovieClip_add(btnclip, (SWFBlock)tf);
	SWFMovieClip_nextFrame(btnclip);

	it = SWFMovie_add(mo, (SWFBlock)btnclip);
	SWFDisplayItem_moveTo(it, x, y);
	SWFDisplayItem_addAction(it, ac, SWFACTION_PRESS);
}
Example #11
0
SWFDisplayItem
add_static_mc(SWFMovie mo, const char* name, int depth, int x, int y, int width, int height)
{
  SWFMovieClip mc;
  SWFDisplayItem it;

  mc = get_static_mc(width, height, 255, 0, 0);

  it = SWFMovie_add(mo, (SWFBlock)mc);
  SWFDisplayItem_setDepth(it, depth); 
  SWFDisplayItem_moveTo(it, x, y); 
  SWFDisplayItem_setName(it, name);

  return it;
}
Example #12
0
void
add_xtrace_function(SWFMovie mo, SWFBlock font, int depth, int x, int y, int width, int height)
{
	SWFTextField tf;
	SWFDisplayItem it;

	tf = newSWFTextField();

	SWFTextField_setFont(tf, font);

	/* setting flags seem unneeded */
	/*SWFTextField_setFlags(tf, SWFTEXTFIELD_USEFONT|SWFTEXTFIELD_NOEDIT);*/

	/* Add all ascii chars */
	SWFTextField_addChars(tf, asciichars);
	SWFTextField_addString(tf, " - xtrace enabled -\n");

	SWFTextField_setBounds(tf, width, height);

	/*
	 * Hopefully we have a *single* _root.
	 */
	SWFTextField_setVariableName(tf, "_root._trace_text");

	/*SWFTextField_setHeight(tf, 240);*/
	/*SWFTextField_setColor(tf, 0x00, 0x00, 0x00, 0xff);*/
	/*SWFTextField_setAlignment(tf, SWFTEXTFIELD_ALIGN_LEFT);*/
	/*SWFTextField_setLeftMargin(tf, 0);*/
	/*SWFTextField_setRightMargin(tf, 0);*/
	/*SWFTextField_setIndentation(tf, 0);*/
	/*SWFTextField_setLineSpacing(tf, 40);*/
	/*SWFTextField_setLineSpacing(tf, 40);*/

	it = SWFMovie_add(mo, (SWFBlock)tf);
	SWFDisplayItem_moveTo(it, x, y);
	SWFDisplayItem_setDepth(it, depth);
	SWFDisplayItem_setName(it, "_xtrace_win");

	add_actions(mo,
		" _root.xtrace = function (msg) { "
		" trace (msg); "
		" _root._trace_text += msg + '\n'; "
		"};");
}
Example #13
0
SWFDisplayItem
add_static_mc(SWFMovie mo, const char* name, int depth, int x, int y, int width, int height)
{
  SWFShape sh;
  SWFMovieClip mc;
  SWFDisplayItem it;

  sh = make_fill_square (-(width/2), -(height/2), width, height, 255, 0, 0, 255, 0, 0);
  mc = newSWFMovieClip();
  SWFMovieClip_add(mc, (SWFBlock)sh);

  SWFMovieClip_nextFrame(mc);

  it = SWFMovie_add(mo, (SWFBlock)mc);
  SWFDisplayItem_setDepth(it, depth); 
  SWFDisplayItem_moveTo(it, x, y); 
  SWFDisplayItem_setName(it, name);

  return it;
}
Example #14
0
void
add_window(SWFMovie mo, int x, int y)
{
	SWFShape sh_window;
	SWFFillStyle fstyle;
	SWFMovieClip mc_window;
	SWFDisplayItem it;

	sh_window = newSWFShape();
	fstyle = SWFShape_addSolidFillStyle(sh_window, 0,0,0,255);
	SWFShape_setRightFillStyle(sh_window, fstyle);
	SWFShape_movePenTo(sh_window, 170, 170);
	SWFShape_drawLine(sh_window, -170, 0);
	SWFShape_drawLine(sh_window, 0, -170);
	SWFShape_drawLine(sh_window, 170, 0);
	SWFShape_drawLine(sh_window, 0, 170);

	mc_window = newSWFMovieClip();
	SWFMovieClip_add(mc_window, (SWFBlock)sh_window);
	SWFMovieClip_add(mc_window, (SWFBlock)newSWFAction(
		"_root.xcheck(getBytesLoaded() < _root.getBytesLoaded());"
		"_root.xcheck(getBytesTotal() < _root.getBytesTotal());"
	));
	SWFMovieClip_nextFrame(mc_window); /* showFrame */

	it = SWFMovie_add(mo, (SWFBlock)mc_window);
	SWFDisplayItem_setName(it, "window"); 
	SWFDisplayItem_moveTo(it, x, y);

    SWFDisplayItem_addAction(it, compileSWFActionCode(
        "_root.note('Click on \"Load PNG\" to load a PNG movie here.');"
        ),
		SWFACTION_ROLLOVER);

	SWFDisplayItem_addAction(it, compileSWFActionCode(
		"delete _level0.window.onMouseDown;"
		),
		SWFACTION_ROLLOUT);

}
Example #15
0
static void
modify_placement (SWFMovie movie, guint mod)
{
  SWFDisplayItem item;
  SWFBlock clip, clip2;

  clip = (SWFBlock) newSWFMovieClip ();
  add_rectangle ((SWFMovieClip) clip, 255, 0, 0);
  SWFMovieClip_nextFrame ((SWFMovieClip) clip);
  clip2 = (SWFBlock) newSWFMovieClip ();
  add_rectangle ((SWFMovieClip) clip2, 0, 0, 255);
  SWFMovieClip_nextFrame ((SWFMovieClip) clip2);
  
  item = SWFMovie_add (movie, clip);
  SWFDisplayItem_setDepth (item, 1);
  SWFDisplayItem_setName (item, "a");
  SWFMovie_nextFrame (movie);

  item = SWFMovie_add (movie, clip2);
  SWFDisplayItem_setDepth (item, 1);
  SWFDisplayItem_moveTo (item, 20, 20);
  SWFDisplayItem_setName (item, "b");
}
Example #16
0
int
main(int argc, char **argv)
{
	SWFMovie mo;
	SWFInput in;
	SWFBitmap bitmap;
	SWFShape shpSmt;
	SWFShape shpHrd;
	SWFMovieClip mc;
	SWFDisplayItem it;
	int swfversion;
	SWFFont font;
	SWFMovieClip dejagnuclip;
	char outputFilename[256];
    FILE* imgfile;

	if ( argc < 2 ) {
		fprintf(stderr, "Usage: %s <swf_version>\n", argv[0]);
		exit(EXIT_FAILURE);
	}

	swfversion = atoi(argv[1]);
	sprintf(outputFilename, "BitmapSmoothingTest-v%d.swf", swfversion);

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


	puts("Setting things up");

	Ming_init();
        Ming_useSWFVersion (swfversion);
 
	mo = newSWFMovieWithVersion(swfversion);

	/****************************************************
	* Create filled shapes mc
	****************************************************/
    imgfile = fopen(MEDIADIR"/vstroke.png", "rb");
    if (!imgfile) {
        fprintf(stderr, "Failed to open bitmap file");
        return EXIT_FAILURE;
    }

    // Note that recent ming version have the more convenient
    // newSWFInput_filename() function, but we want to support
    // older versions.
    in = newSWFInput_file(imgfile);
	bitmap = newSWFBitmap_fromInput(in);
	if (!bitmap) {
		return EXIT_FAILURE;
	}

	shpSmt = newSWFShapeFromBitmap(bitmap,
		SWFFILL_CLIPPED_BITMAP);

	shpHrd = newSWFShapeFromBitmap(bitmap,
		SWFFILL_NONSMOOTHED_CLIPPED_BITMAP);

	mc = newSWFMovieClip();
	SWFMovieClip_add(mc, (SWFBlock)shpSmt);
	it = SWFMovieClip_add(mc, (SWFBlock)shpHrd);
	SWFDisplayItem_moveTo(it, 0, 5);
	SWFMovieClip_nextFrame(mc); 

	/****************************************************
	* Create filled shapes mc, and scale it
	****************************************************/

	it = SWFMovie_add(mo, (SWFBlock)mc);
	SWFDisplayItem_scaleTo(it, 30, 10);

	SWFMovie_setDimension(mo, SWFBitmap_getWidth(bitmap)*30, 500);

	/****************************************************
	* Add dejagnu clip
	****************************************************/

	font = get_default_font(MEDIADIR);
	dejagnuclip = get_dejagnu_clip((SWFBlock)font, 10, 0, 0, 200, 200);
	it = SWFMovie_add(mo, (SWFBlock)dejagnuclip);
	SWFDisplayItem_setDepth(it, 200); 
	SWFDisplayItem_move(it, 0, 100); 

	/****************************************************
	* TODO: Add actions
	****************************************************/


	/****************************************************
	* Save things up
	****************************************************/

	printf("Saving %s\n", outputFilename);

	SWFMovie_nextFrame(mo); /* showFrame */

	SWFMovie_save(mo, outputFilename);

    fclose(imgfile);

	return EXIT_SUCCESS;
}
Example #17
0
EXPORT BOOL WINAPI i_moveTo(float x, float y, int p3, int p4)
{
	lstrcpy(funcname, "i_moveTo");
	SWFDisplayItem_moveTo(mhsp_item, x, y);
	return 0;
}
Example #18
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;
}
Example #19
0
int
main(int argc, char** argv)
{
  SWFMovie mo;
  const char *srcdir=".";
  char fdefont[256];
  SWFMovieClip  dejagnuclip;
  
  SWFDisplayItem it;

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

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

  sprintf(fdefont, "%s/Bitstream-Vera-Sans.fdb", srcdir);
  FILE *font_file = fopen(fdefont, "r");
  if ( font_file == NULL )
  {
    perror(fdefont);
    exit(1);
  }
  SWFFont efont = loadSWFFontFromFile(font_file);

  puts("Setting things up");

  Ming_init();
  Ming_useSWFVersion (OUTPUT_VERSION);
 
  mo = newSWFMovie();
  SWFMovie_setRate(mo, 1.0);
  SWFMovie_setDimension(mo, 800, 600);
  
  dejagnuclip = get_dejagnu_clip((SWFBlock)get_default_font(srcdir), 10,
          0, 0, 800, 600);
  SWFMovie_add(mo, (SWFBlock)dejagnuclip);
  SWFMovie_nextFrame(mo); // 1st frame 

  /*********************************************
   *
   * Add some textfields
   *
   *********************************************/

  int y = 30;
  int inc = 30;

  it = add_text_field(mo, (SWFBlock)efont, "Normal", 1, 2, 3,
          SWFTEXTFIELD_ALIGN_LEFT, 10, 0, 0, 0, 255);
  SWFDisplayItem_moveTo(it, 50, y);
  SWFDisplayItem_setName(it, "tf1");
  
  y += inc;

  it = add_text_field(mo, (SWFBlock)efont, "Transparent", 1, 2, 3,
          SWFTEXTFIELD_ALIGN_LEFT, 10, 0, 0, 0, 0);
  SWFDisplayItem_moveTo(it, 50, y);
  SWFDisplayItem_setName(it, "tf2");
  
  y += inc;
  
  it = add_text_field(mo, (SWFBlock)efont, "X scaled by 16, no indent or "
          "margin", 0, 0, 0, SWFTEXTFIELD_ALIGN_LEFT, 10, 0, 0, 0, 255);
  SWFDisplayItem_moveTo(it, 50, y);
  SWFDisplayItem_scale(it, 16, 1);
  SWFDisplayItem_setName(it, "tf3");

  y += inc;
  
  it = add_text_field(mo, (SWFBlock)efont, "X scaled by 16, indent 4",
          4, 0, 0, SWFTEXTFIELD_ALIGN_LEFT, 10, 0, 0, 0, 255);
  SWFDisplayItem_moveTo(it, 50, y);
  SWFDisplayItem_scale(it, 16, 1);
  SWFDisplayItem_setName(it, "tf4");
  
  y += inc;
  
  it = add_text_field(mo, (SWFBlock)efont, "X scaled by 16, left margin 4",
          0, 4, 0, SWFTEXTFIELD_ALIGN_LEFT, 10, 0, 0, 0, 255);
  SWFDisplayItem_moveTo(it, 50, y);
  SWFDisplayItem_scale(it, 16, 1);
  SWFDisplayItem_setName(it, "tf5");
  
  y += inc;
  it = add_text_field(mo, (SWFBlock)efont, "X scaled by 16, right margin 4",
          0, 0, 4, SWFTEXTFIELD_ALIGN_LEFT, 10, 0, 0, 0, 255);
  SWFDisplayItem_moveTo(it, 50, y);
  SWFDisplayItem_scale(it, 16, 1);
  SWFDisplayItem_setName(it, "tf6");
  
  y += inc;
  
  it = add_text_field(mo, (SWFBlock)efont, "X scaled by 16, left margin 4, "
          "indent 4", 4, 4, 0, SWFTEXTFIELD_ALIGN_LEFT, 10, 0, 0, 0, 255);
  SWFDisplayItem_moveTo(it, 50, y);
  SWFDisplayItem_scale(it, 16, 1);
  SWFDisplayItem_setName(it, "tf7");
  
  y += inc;
  
  it = add_text_field(mo, (SWFBlock)efont, "X scaled by 8, no indent or margin",
          0, 0, 0, SWFTEXTFIELD_ALIGN_LEFT, 10, 0, 0, 0, 255);
  SWFDisplayItem_moveTo(it, 50, y);
  SWFDisplayItem_scale(it, 8, 1);
  SWFDisplayItem_setName(it, "tf8");

  y += inc;
  
  it = add_text_field(mo, (SWFBlock)efont, "X scaled by 8, indent 4", 4, 0, 0,
          SWFTEXTFIELD_ALIGN_LEFT, 10, 0, 0, 0, 255);
  SWFDisplayItem_moveTo(it, 50, y);
  SWFDisplayItem_scale(it, 8, 1);
  SWFDisplayItem_setName(it, "tf9");
  y += inc;
  
  it = add_text_field(mo, (SWFBlock)efont, "X scaled by 0.2", 8, 8, 8,
          SWFTEXTFIELD_ALIGN_LEFT, 10, 0, 0, 0, 255);
  SWFDisplayItem_moveTo(it, 50, y);
  SWFDisplayItem_scale(it, 0.2, 1);
  SWFDisplayItem_setName(it, "tf10");
  
  y += inc;
  
  it = add_text_field(mo, (SWFBlock)efont, "Y scaled by 4", 4, 4, 0,
          SWFTEXTFIELD_ALIGN_LEFT, 10, 0, 0, 0, 255);
  SWFDisplayItem_moveTo(it, 50, y);
  SWFDisplayItem_scale(it, 1, 4);
  SWFDisplayItem_setName(it, "tf11");
  
  y += inc * 3;
  
  it = add_text_field(mo, (SWFBlock)efont, "Y scaled by 8", 4, 4, 0,
          SWFTEXTFIELD_ALIGN_LEFT, 10, 0, 0, 0, 255);
  SWFDisplayItem_moveTo(it, 50, y);
  SWFDisplayItem_scale(it, 1, 8);
  SWFDisplayItem_setName(it, "tf12");


  // It's not clear how consistent the textWidth or textHeight
  // values are. As they are embedded, it may be possible to reproduce
  // exactly, in which case the test can be made more precise.

  check_equals(mo, "tf1._width", "84");
  check_equals(mo, "tf1._height", "20");
  xcheck_equals(mo, "tf1._x", "48");
  xcheck_equals(mo, "tf1._y", "28");
  xcheck_equals(mo, "tf1.textHeight", "23");
  // Approx 46
  add_actions(mo, "trace(tf1.textWidth);");
  xcheck(mo, "tf1.textWidth >= 44 && tf1.textWidth <= 48");

  check_equals(mo, "tf2._width", "84");
  check_equals(mo, "tf2._height", "20");
  xcheck_equals(mo, "tf2._x", "48");
  xcheck_equals(mo, "tf2._y", "58");
  xcheck_equals(mo, "tf2.textHeight", "23");
  // Approx 78
  add_actions(mo, "trace(tf2.textWidth);");
  xcheck(mo, "tf2.textWidth >= 76 && tf2.textWidth <= 80");

  check_equals(mo, "tf3._width", "1344");
  check_equals(mo, "tf3._height", "20");
  xcheck_equals(mo, "tf3._x", "18");
  xcheck_equals(mo, "tf3._y", "88");
  xcheck_equals(mo, "tf3.textHeight", "23");
  // Approx 230
  add_actions(mo, "trace(tf3.textWidth);");
  xcheck(mo, "tf3.textWidth >= 225 && tf3.textWidth <= 235");

  check_equals(mo, "tf4._width", "1344");
  check_equals(mo, "tf4._height", "20");
  xcheck_equals(mo, "tf4._x", "18");
  xcheck_equals(mo, "tf4._y", "118");
  xcheck_equals(mo, "tf4.textHeight", "23");
  // Approx 156
  add_actions(mo, "trace(tf4.textWidth);");
  xcheck(mo, "tf4.textWidth >= 153 && tf4.textWidth <= 159");

  check_equals(mo, "tf5._width", "1344");
  check_equals(mo, "tf5._height", "20");
  xcheck_equals(mo, "tf5._x", "18");
  xcheck_equals(mo, "tf5._y", "148");
  xcheck_equals(mo, "tf5.textHeight", "23");
  // Approx 186
  add_actions(mo, "trace(tf5.textWidth);");
  xcheck(mo, "tf5.textWidth >= 183 && tf5.textWidth <= 189");

  check_equals(mo, "tf6._width", "1344");
  check_equals(mo, "tf6._height", "20");
  xcheck_equals(mo, "tf6._x", "18");
  xcheck_equals(mo, "tf6._y", "178");
  xcheck_equals(mo, "tf6.textHeight", "23");
  // Approx 194
  add_actions(mo, "trace(tf6.textWidth);");
  xcheck(mo, "tf6.textWidth >= 189 && tf6.textWidth <= 199");

  check_equals(mo, "tf7._width", "1344");
  check_equals(mo, "tf7._height", "20");
  xcheck_equals(mo, "tf7._x", "18");
  xcheck_equals(mo, "tf7._y", "208");
  xcheck_equals(mo, "tf7.textHeight", "23");
  // Approx 247
  add_actions(mo, "trace(tf7.textWidth);");
  xcheck(mo, "tf7.textWidth >= 240 && tf7.textWidth <= 254");

  check_equals(mo, "tf8._width", "672");
  check_equals(mo, "tf8._height", "20");
  xcheck_equals(mo, "tf8._x", "34");
  xcheck_equals(mo, "tf8._y", "238");
  xcheck_equals(mo, "tf8.textHeight", "23");
  // Approx 222
  add_actions(mo, "trace(tf8.textWidth);");
  xcheck(mo, "tf8.textWidth >= 217 && tf8.textWidth <= 227");

  check_equals(mo, "tf9._width", "672");
  check_equals(mo, "tf9._height", "20");
  xcheck_equals(mo, "tf9._x", "34");
  xcheck_equals(mo, "tf9._y", "268");
  xcheck_equals(mo, "tf9.textHeight", "23");
  // Approx 148
  add_actions(mo, "trace(tf9.textWidth);");
  xcheck(mo, "tf9.textWidth >= 144 && tf9.textWidth <= 152");

  check_equals(mo, "tf10._width", "16.8");
  check_equals(mo, "tf10._height", "20");
  xcheck_equals(mo, "tf10._x", "49.6");
  xcheck_equals(mo, "tf10._y", "298");
  xcheck_equals(mo, "tf10.textHeight", "23");
  // Approx 99
  add_actions(mo, "trace(tf10.textWidth);");
  xcheck(mo, "tf10.textWidth >= 95 && tf10.textWidth <= 103");

  // The textHeight for the following two fields varies.
  check_equals(mo, "tf11._width", "84");
  check_equals(mo, "tf11._height", "80");
  xcheck_equals(mo, "tf11._x", "48");
  xcheck_equals(mo, "tf11._y", "322");
  xcheck_equals(mo, "tf11.textHeight", "23");
  // Approx 86
  add_actions(mo, "trace(tf11.textWidth);");
  xcheck(mo, "tf11.textWidth >= 84 && tf11.textWidth <= 88");

  check_equals(mo, "tf12._width", "84");
  check_equals(mo, "tf12._height", "160");
  xcheck_equals(mo, "tf12._x", "48");
  xcheck_equals(mo, "tf12._y", "404");
  xcheck_equals(mo, "tf12.textHeight", "23");
  // Approx 86
  add_actions(mo, "trace(tf12.textWidth);");
  xcheck(mo, "tf12.textWidth >= 84 && tf12.textWidth <= 88");

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

  SWFMovie_nextFrame(mo); 

  /*****************************************************
   *
   * Output movie
   *
   *****************************************************/
  puts("Saving " OUTPUT_FILENAME );

  SWFMovie_save(mo, OUTPUT_FILENAME);

  return 0;
}
Example #20
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;
}
Example #21
0
int
main(int argc, char** argv)
{
	SWFMovie mo;
	SWFMovieClip dejagnuclip;
	SWFDisplayItem it1;


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

	Ming_init();
	mo = newSWFMovieWithVersion(OUTPUT_VERSION);
	SWFMovie_setDimension(mo, 800, 600);
	SWFMovie_setRate (mo, 2);

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

	// Frame 2: Add a static movieclip at depth 3 with origin at 10,200
	it1 = add_static_mc(mo, "static3", 3, 10, 200, 20, 20);
	add_actions(mo,
		"static3.myThing = 'guess';"
		"check_equals(static3._x, 10);"
		"check_equals(static3.myThing, 'guess');"
		"check_equals(static3.getDepth(), -16381);" 
		);
	SWFMovie_nextFrame(mo); 

	// Frame 3: nothing new
	SWFMovie_nextFrame(mo); 

	// Frame 4: move DisplayObject at depth 3 to position 50,200
	SWFDisplayItem_moveTo(it1, 50, 200); 
	add_actions(mo,
		"check_equals(static3._x, 50);"
		"check_equals(static3.getDepth(), -16381);" 
		);
	SWFMovie_nextFrame(mo); 

	// Frame 5: nothing new
	SWFMovie_nextFrame(mo); 

	// Frame 6: nothing new
	SWFMovie_nextFrame(mo); 

	// Frame 7: go to frame 2
	add_actions(mo,

		"check_equals(static3.myThing, 'guess');"
		"check_equals(static3._x, 50);"

		// Store a reference to the static3 instance
		// before jumping back
		"dynRef = static3;"

		// this reset char at depth -16381 to be at position 10,200
		"gotoAndStop(2);"

		// Static3 refers to same instance
		"check_equals(static3.myThing, 'guess');" 
		"check_equals(static3.getDepth(), -16381);" 

		// But it has now be reset to position 10,100 as specified
		// by PlaceObject2 tag in frame 2.
		// Note that the PlaceObject2 in frame 2 has the "move" flag
		// set to off as it's really intended to be used to *create*
		// an instance. Instead, since that depth is already occupied,
		// it behave as if it was a transforming PlaceObject2
		"check_equals(static3._x, 10);" 

		// The reference still refers to the same instance
		//  (see http://www.gnashdev.org/wiki/index.php/SoftReferences)
		"check_equals(dynRef.myThing, 'guess');" 
		"check_equals(dynRef.getDepth(), -16381);" 
		"check_equals(typeof(dynRef), 'movieclip');"
		"check_equals(dynRef._x, 10);"
		"check_equals(dynRef, static3);"

		// A single instance is created in total
		"check_equals(depth3Constructed, 1);"  

		"totals();"
		);
	SWFMovie_nextFrame(mo); 

	//Output movie
	puts("Saving " OUTPUT_FILENAME );
	SWFMovie_save(mo, OUTPUT_FILENAME);

	return 0;
}
Example #22
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;
}
Example #23
0
int
main(int argc, char** argv)
{
  SWFMovie mo;
  const char *srcdir=".";
  char fdbfont[256];
  SWFMovieClip  dejagnuclip;
  
  /*********************************************
   *
   * Initialization
   *
   *********************************************/

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

  sprintf(fdbfont, "%s/Bitstream-Vera-Sans.fdb", srcdir);

  puts("Setting things up");

  Ming_init();
  Ming_useSWFVersion (OUTPUT_VERSION);
  //Ming_setScale(20.0); /* so we talk twips */
 
  mo = newSWFMovie();
  SWFMovie_setRate(mo, 1.0);
  SWFMovie_setDimension(mo, 800, 600);
  
  dejagnuclip = get_dejagnu_clip((SWFBlock)get_default_font(srcdir), 10, 0, 0, 800, 600);
  SWFMovie_add(mo, (SWFBlock)dejagnuclip);
  SWFMovie_nextFrame(mo); // 1st frame 

  // Check that the dejagnu clip is really a TextField.
  check_equals(mo, "_root.getInstanceAtDepth(-16383)",
          "_level0.instance1");
  check(mo, "_level0.instance1._xtrace_win "
          "instanceof TextField");

  // Note: the dejagnuclip already placed some texts, so the following
  // should be true.
  check(mo, "TextField.prototype.hasOwnProperty('background')");
  check(mo, "TextField.prototype.hasOwnProperty('backgroundColor')");
  check(mo, "TextField.prototype.hasOwnProperty('text')");
  check(mo, "TextField.prototype.hasOwnProperty('textColor')");

  /*********************************************
   *
   * Add some textfields
   *
   *********************************************/
  {
    SWFDisplayItem it;
    FILE *font_file = fopen(fdbfont, "r");
    if ( font_file == NULL )
    {
      perror(fdbfont);
      exit(1);
    }
    SWFBrowserFont bfont = newSWFBrowserFont("_sans");
    SWFFont efont = loadSWFFontFromFile(font_file);

    it = add_text_field(mo, (SWFBlock)bfont, "Hello", 1, 2, 3, SWFTEXTFIELD_ALIGN_LEFT, 10, 100, 101, 102, 50);
    SWFDisplayItem_setName(it, "dtext1");
    SWFDisplayItem_moveTo(it, 0, 200);
    it = add_text_field(mo, (SWFBlock)efont, "Hello", 4, 5, 6, SWFTEXTFIELD_ALIGN_CENTER, 11, 110, 111, 112, 51);
    SWFDisplayItem_setName(it, "etext1");
    SWFDisplayItem_moveTo(it, 0, 300);

    SWFBrowserFont bfont2 = newSWFBrowserFont("times");
    it = add_text_field(mo, (SWFBlock)bfont2, "Hello", 7, 8, 9, SWFTEXTFIELD_ALIGN_RIGHT, 12, 120, 121, 122, 52);
    SWFDisplayItem_setName(it, "dtext2");
    SWFDisplayItem_moveTo(it, 0, 400);
  }
  SWFMovie_nextFrame(mo); 

  check_equals(mo, "dtext1.embedFonts", "false");
  check_equals(mo, "etext1.embedFonts", "true");
  check_equals(mo, "etext1.hasOwnProperty('embedFonts')", "false");

  add_actions(mo, "ret = Selection.setFocus(dtext1);"
                  "check_equals(ret, false);"
                  "check_equals(Selection.getFocus(), '_level0.dtext1');");
  add_actions(mo, "ret = Selection.setFocus(etext1);"
                  "check_equals(ret, false);"
                  "check_equals(Selection.getFocus(), '_level0.etext1');");

  add_actions(mo, "createTextField('dynamictext1', 99, 10, 10, 10, 10);");

  add_actions(mo, "ret = Selection.setFocus(dynamictext1);"
               "check_equals(ret, false);"
               "check_equals(Selection.getFocus(), '_level0.dynamictext1');");

  check_equals(mo, "dtext1.__proto__", "TextField.prototype");
  check_equals(mo, "etext1.__proto__", "TextField.prototype");
  check_equals(mo, "etext1.__proto__", "dynamictext1.__proto__");

  // checks after placing some swf defined TextField
  check(mo, "TextField.prototype.hasOwnProperty('background')");
  check(mo, "TextField.prototype.hasOwnProperty('backgroundColor')");
  check(mo, "TextField.prototype.hasOwnProperty('text')");
  check(mo, "TextField.prototype.hasOwnProperty('textColor')");
  check(mo, "!TextField.prototype.hasOwnProperty('_parent')");
  check(mo, "!TextField.prototype.hasOwnProperty('_xmouse')");
  check(mo, "!TextField.prototype.hasOwnProperty('_ymouse')");
  check(mo, "!TextField.prototype.hasOwnProperty('_xscale')");
  check(mo, "!TextField.prototype.hasOwnProperty('_yscale')");
  
  check_equals(mo, "typeof(dtext1)", "'object'");
  check_equals(mo, "typeof(dtext1.text)", "'string'");
  check_equals(mo, "typeof(dtext1.background)", "'boolean'");
  check_equals(mo, "typeof(dtext1.backgroundColor)", "'number'");
  check_equals(mo, "typeof(dtext1.textColor)", "'number'");
  check_equals(mo, "typeof(dtext1._alpha)", "'number'");
  check_equals(mo, "typeof(dtext1.type)", "'string'");
  check_equals(mo, "dtext1.type", "'input'");
  
  check_equals(mo, "typeof(dtext1.__proto__.text)", "'undefined'");
  check_equals(mo, "typeof(dtext1.__proto__.background)", "'undefined'");
  check_equals(mo, "typeof(dtext1.__proto__.backgroundColor)", "'undefined'");
  check_equals(mo, "typeof(dtext1.__proto__.textColor)", "'undefined'");
  check_equals(mo, "typeof(dtext1.__proto__._alpha)", "'undefined'");

  check_equals(mo, "dtext1.hasOwnProperty('text')", "false");
  check_equals(mo, "dtext1.hasOwnProperty('background')", "false");
  check_equals(mo, "dtext1.hasOwnProperty('backgroundColor')", "false");
  check_equals(mo, "dtext1.hasOwnProperty('textColor')", "false");
  check_equals(mo, "dtext1.hasOwnProperty('_alpha')", "false");
  check(mo, "!dtext1.hasOwnProperty('_parent')");
  check(mo, "!dtext1.hasOwnProperty('_xmouse')");
  check(mo, "!dtext1.hasOwnProperty('_ymouse')");
  check(mo, "!dtext1.hasOwnProperty('_xscale')");
  check(mo, "!dtext1.hasOwnProperty('_yscale')");
  check(mo, "!etext1.hasOwnProperty('_parent')");
  check(mo, "!etext1.hasOwnProperty('_xmouse')");
  check(mo, "!etext1.hasOwnProperty('_ymouse')");
  check(mo, "!etext1.hasOwnProperty('_xscale')");
  check(mo, "!etext1.hasOwnProperty('_yscale')");
  
  check(mo, "dtext1.__proto__.hasOwnProperty('text')");
  check_equals(mo, "dtext1.__proto__.hasOwnProperty('background')", "true");
  check_equals(mo, "dtext1.__proto__.hasOwnProperty('backgroundColor')", "true");
  check_equals(mo, "dtext1.__proto__.hasOwnProperty('textColor')", "true");
  // Why _alpha is special???
  check_equals(mo, "dtext1.__proto__.hasOwnProperty('_alpha')", "false");
  
  check_equals(mo, "dtext1.text", "'Hello'");
  check_equals(mo, "etext1.text", "'Hello'");
  check_equals(mo, "dtext2.text", "'Hello'");
  check_equals(mo, "dtext1.background", "false");
  check_equals(mo, "etext1.background", "false");
  check_equals(mo, "dtext2.background", "false");
  check_equals(mo, "dtext1.backgroundColor", "0xffffff");
  check_equals(mo, "etext1.backgroundColor", "0xffffff");
  check_equals(mo, "dtext2.backgroundColor", "0xffffff");
  check_equals(mo, "dtext1.textColor", "6579558");
  check_equals(mo, "etext1.textColor", "7237488");
  check_equals(mo, "dtext2.textColor", "7895418");
  check_equals(mo, "dtext1._alpha", "100");
  check_equals(mo, "etext1._alpha", "100");
  check_equals(mo, "dtext2._alpha", "100");
  check_equals(mo, "etext1._parent", "_root");
  check_equals(mo, "dtext2._parent", "_root");
  check_equals(mo, "etext1._xscale", "100");
  check_equals(mo, "dtext2._xscale", "100");
  check_equals(mo, "etext1._yscale", "100");
  check_equals(mo, "dtext2._yscale", "100");
  check_equals(mo, "typeof(etext1._xmouse)", "'number'");
  check_equals(mo, "typeof(dtext2._xmouse)", "'number'");
  check_equals(mo, "typeof(etext1._ymouse)", "'number'"); 
  check_equals(mo, "typeof(dtext2._ymouse)", "'number'"); 

  // TextFormat objects are created on the fly
  add_actions(mo,
	"etext1.tf = etext1.getTextFormat();"
	"dtext2.tf = dtext2.getTextFormat();"
	);
  check_equals(mo, "typeof(etext1.tf)", "'object'"); 
  check_equals(mo, "typeof(dtext2.tf)", "'object'"); 
  check_equals(mo, "etext1.tf.size", "12"); 
  check_equals(mo, "dtext2.tf.size", "12"); 
  check_equals(mo, "etext1.tf.font", "'Bitstream Vera Sans'");
  check_equals(mo, "dtext2.tf.font", "'times'"); 
  check_equals(mo, "typeof(etext1.tf.bold)", "'boolean'");
  check_equals(mo, "typeof(dtext2.tf.bold)", "'boolean'");
  check_equals(mo, "etext1.tf.bold", "false");
  check_equals(mo, "dtext2.tf.bold", "false"); 
  check_equals(mo, "typeof(etext1.tf.italic)", "'boolean'");
  check_equals(mo, "typeof(dtext2.tf.italic)", "'boolean'");
  check_equals(mo, "etext1.tf.italic", "false");
  check_equals(mo, "dtext2.tf.italic", "false"); 
  check_equals(mo, "typeof(etext1.tf.indent)", "'number'");
  check_equals(mo, "typeof(dtext2.tf.indent)", "'number'");
  check_equals(mo, "etext1.tf.indent", "4");
  check_equals(mo, "dtext2.tf.indent", "7"); 
  check_equals(mo, "typeof(etext1.tf.leftMargin)", "'number'");
  check_equals(mo, "typeof(dtext2.tf.leftMargin)", "'number'");
  check_equals(mo, "etext1.tf.leftMargin", "5");
  check_equals(mo, "dtext2.tf.leftMargin", "8"); 
  check_equals(mo, "typeof(etext1.tf.rightMargin)", "'number'");
  check_equals(mo, "typeof(dtext2.tf.rightMargin)", "'number'");
  check_equals(mo, "etext1.tf.rightMargin", "6");
  check_equals(mo, "dtext2.tf.rightMargin", "9"); 
  check_equals(mo, "typeof(etext1.tf.align)", "'string'");
  check_equals(mo, "typeof(dtext2.tf.align)", "'string'");
  check_equals(mo, "etext1.tf.align", "'center'");
  check_equals(mo, "dtext2.tf.align", "'right'"); 
  check_equals(mo, "typeof(etext1.tf.leading)", "'number'");
  check_equals(mo, "typeof(dtext2.tf.leading)", "'number'");
  check_equals(mo, "etext1.tf.leading", "11");
  check_equals(mo, "dtext2.tf.leading", "12"); 
  check_equals(mo, "typeof(etext1.tf.color)", "'number'");
  check_equals(mo, "typeof(dtext2.tf.color)", "'number'");
  check_equals(mo, "etext1.tf.color", "7237488");
  check_equals(mo, "dtext2.tf.color", "7895418");
  check_equals(mo, "typeof(etext1.tf.blockIndent)", "'number'");
  check_equals(mo, "typeof(dtext2.tf.blockIndent)", "'number'");
  check_equals(mo, "etext1.tf.blockIndent", "0");
  check_equals(mo, "dtext2.tf.blockIndent", "0");
  check_equals(mo, "typeof(etext1.tf.underline)", "'boolean'");
  check_equals(mo, "typeof(dtext2.tf.underline)", "'boolean'");
  check_equals(mo, "etext1.tf.underline", "false");
  check_equals(mo, "dtext2.tf.underline", "false");

  add_actions(mo, "dtext1.background = true;"
                  "etext1.background = true;"
                  "dtext2.background = true;"
                  "dtext1.backgroundColor = 0xff0000;"
                  "etext1.backgroundColor = 0x00ff00;"
                  "dtext2.backgroundColor = 0x0000ff;"
                  "dtext1.textColor = 0x00ffff;"
                  "etext1.textColor = 0xff00ff;"
                  "dtext2.textColor = 0xffff00;"
                  "dtext1.text += ' world';"
                  "etext1.text += ' world';"
                  "dtext2.text += ' world';" );

  check_equals(mo, "etext1.getTextFormat().color", "0xff00ff");
  check_equals(mo, "dtext2.getTextFormat().color", "0xffff00"); 

  check_equals(mo, "dtext1.text", "'Hello world'");
  check_equals(mo, "etext1.text", "'Hello world'");
  check_equals(mo, "dtext2.text", "'Hello world'");
  check_equals(mo, "dtext1.background", "true");
  check_equals(mo, "etext1.background", "true");
  check_equals(mo, "dtext2.background", "true");
  check_equals(mo, "dtext1.backgroundColor", "0xff0000");
  check_equals(mo, "etext1.backgroundColor", "0x00ff00");
  check_equals(mo, "dtext2.backgroundColor", "0x0000ff");
  check_equals(mo, "dtext1.textColor", "0x00ffff");
  check_equals(mo, "etext1.textColor", "0xff00ff");
  check_equals(mo, "dtext2.textColor", "0xffff00");
  SWFMovie_nextFrame(mo); 
  
  add_actions(mo, "dtext1._alpha = 0;"
                  "etext1._alpha = 0;"
                  "dtext2._alpha = 0;" );
  check_equals(mo, "dtext1._alpha", "0");
  check_equals(mo, "etext1._alpha", "0");
  check_equals(mo, "dtext2._alpha", "0");
  SWFMovie_nextFrame(mo); 

  add_actions(mo, "dtext1._alpha = 100; dtext1.embedFonts=true; dtext1.text = 'embedFonts';"
                  "etext1._alpha = 100; etext1.embedFonts=false; etext1.text = '!embedFonts';"
                  "dtext2._alpha = 100;" );

  check_equals(mo, "dtext1.embedFonts", "true");
  check_equals(mo, "etext1.embedFonts", "false");

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

  /*****************************************************
   *
   * Output movie
   *
   *****************************************************/
  puts("Saving " OUTPUT_FILENAME );

  SWFMovie_save(mo, OUTPUT_FILENAME);

  return 0;
}
Example #24
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;
}
Example #25
0
int
main(int argc, char** argv)
{
  SWFMovie mo;
  SWFMovieClip dejagnuclip;
  SWFShape static1, static2;
  SWFDisplayItem it1;


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

  Ming_init();
  mo = newSWFMovieWithVersion(OUTPUT_VERSION);
  SWFMovie_setDimension(mo, 800, 600);
  SWFMovie_setRate (mo, 2);

  static1 = get_shape(60, 60, 255, 0, 0);
  static2 = get_shape(60, 60, 0, 255, 0);

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

  // Frame 2: place DisplayObject at depth 3 (-16381)
  it1 = SWFMovie_add(mo, (SWFBlock)static1);
  SWFDisplayItem_setDepth(it1, 3);
  SWFDisplayItem_moveTo(it1, 100, 300);
  SWFDisplayItem_setName(it1, "static1");
  SWFDisplayItem_addAction(it1, newSWFAction(
			"_root.note(this+' onClipConstruct');"
			" _root.check_equals(typeof(_root), 'movieclip');"
		        " if ( isNaN(_root.depth3Constructed) ) {"
			"	_root.depth3Constructed=1; "
			" } else {"
			"	_root.depth3Constructed++;"
			" }"
			" _root.note('_root.depth3Constructed set to '+_root.depth3Constructed);"
			), SWFACTION_CONSTRUCT);
  add_actions(mo, "static1.name='static1';"); 

  check_equals(mo, "typeof(static1)", "'movieclip'"); 
  check_equals(mo, "static1", "_root");
  check_equals(mo, "static1.name", "'static1'");
  check_equals(mo, "_root.name", "'static1'");

  // Gnash allows custom members to shape DisplayObjects...
  // this is important to verify, see next check for it after REPLACE
  check_equals(mo, "static1.name", "'static1'");

  check_equals(mo, "static1._target", "'/'");
  SWFMovie_nextFrame(mo); 

  // Frame 3: replace instance at depth -16381 with DisplayObject 2
  if ( SWFMovie_replace(mo, it1, (SWFBlock)static2) )
  {
	  abort(); // grace and beauty...
  }
  SWFDisplayItem_moveTo(it1, 130, 330);
  SWFDisplayItem_setName(it1, "static2");
  SWFDisplayItem_addAction(it1, newSWFAction(
			"_root.note(this+' onClipConstruct');"
			" _root.check_equals(typeof(_root), 'movieclip');"
		        " if ( isNaN(_root.depth3Constructed) ) {"
			"	_root.depth3Constructed=1; "
			" } else {"
			"	_root.depth3Constructed++;"
			" }"
			" _root.note('_root.depth3Constructed set to '+_root.depth3Constructed);"
			), SWFACTION_CONSTRUCT);


  // Can still reference the old DisplayObject and it's variables, after replace
  xcheck_equals(mo, "typeof(static1)", "'movieclip'"); 
  xcheck_equals(mo, "static1", "_root");
  xcheck_equals(mo, "static1.name", "'static1'");
  check_equals(mo, "_root.name", "'static1'");

  // While the new name results undefined...
  xcheck_equals(mo, "typeof(static2)", "'undefined'"); // the name wasn't changed

  // Everything suggests that a new instance is NOT created on replace !!!
  // Gnash here fails because it creates a NEW instance

  // We can't check the color or the _x in a self-contained testcase unfortunately,
  // we'll need a MovieTester-based runner for this.
  // It is expected the color of the current instane is GREEN, and the boundaries
  // are from 130 to 190 for X and 330 to 390 for Y.
  // TODO: implement a MovieTester based runner !!

  SWFMovie_nextFrame(mo); 
 
  // Frame 4: jump to frame 2, stop and check

  add_actions(mo,

    "gotoAndStop(2); " 

    // Shapes don't get their onConstruct event invoked !
    "check_equals(typeof(_root.depth3Constructed), 'undefined');"

    // Original DisplayObject name is still referenceable
    "check_equals(typeof(static1), 'movieclip');"

    // And it still has it's user-provided property
    "check_equals(static1.name, 'static1');"

    // We can't check the color or the _x in a self-contained testcase unfortunately,
    // we'll need a MovieTester-based runner for this.
    // It is expected the color of the current instance is RED, and the boundaries
    // are from 100 to 120 for both X and Y.
    // TODO: implement a MovieTester based runner !!

    "totals();"
    );
  SWFMovie_nextFrame(mo); 

  //Output movie
  puts("Saving " OUTPUT_FILENAME );
  SWFMovie_save(mo, OUTPUT_FILENAME);

  return 0;
}
Example #26
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;
}
Example #27
0
int main(void)
{
        // Create local variables
        int i;
        SWFDisplayItem image_display_item;
        SWFFont font_object;
        SWFMovie test_movie;
        SWFText text_object;


        // Initialise the movie structure in memory
        Ming_init();
        test_movie = newSWFMovieWithVersion(7);

        // Set the desired compression level 
		// for the output (9 = maximum compression)
        Ming_setSWFCompression(9);

        // Set the background color for the movie
        SWFMovie_setBackground(test_movie, 0x00, 0x00, 0x00);

        // Adjust the dimensions of the movie
        SWFMovie_setDimension(test_movie, 800, 600);

        // Set the frame rate for the movie to 24 frames per second
        SWFMovie_setRate(test_movie, 24.0);

        // Load a font from disk
        font_object = newSWFFont_fromFile("../../fonts/vera/Vera.ttf");
        if (NULL == font_object)
        {
                // Something went wrong, so exit
                printf("Unable to load font from file.\n");
                return EXIT_FAILURE;
        }

        // Create a new, empty text object
        text_object = newSWFText();

        // Tell the text object to use the font previously loaded
        SWFText_setFont(text_object, font_object);

        // Set the height of the text
        SWFText_setHeight(text_object, 18.0);

        // Set the color of the text
        SWFText_setColor(text_object, 0x00, 0x00, 0xff, 0xff);

        // Add a string to the text object
        SWFText_addString(text_object, "This is some example text", NULL);

        // Add the text object to the movie (at 0,0)
        image_display_item = SWFMovie_add(test_movie, (SWFBlock) text_object);

        // Move to 100, 100
        SWFDisplayItem_moveTo(image_display_item, 100.00, 100.0);

        // Progressively move the text down and to the right
        for (i = 0; i <= 250; i++)
        {
                SWFMovie_nextFrame(test_movie);
                SWFDisplayItem_move(image_display_item, 2, 2);
        }

        // Save the swf movie file to disk
        SWFMovie_save(test_movie, "ming-test-text.swf");

        // Free the swf movie in memory
        destroySWFMovie(test_movie);

        // Free the swf text object
        destroySWFText(text_object);

        return EXIT_SUCCESS;
}
Example #28
0
int
main(int argc, char** argv)
{
  SWFMovie mo;
  const char *srcdir=".";
  char fdbfont[256];
  SWFMovieClip  dejagnuclip;
  
  /*********************************************
   *
   * Initialization
   *
   *********************************************/

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

  sprintf(fdbfont, "%s/Bitstream-Vera-Sans.fdb", srcdir);

  puts("Setting things up");

  Ming_init();
  Ming_useSWFVersion (OUTPUT_VERSION);
  //Ming_setScale(20.0); /* so we talk twips */
 
  mo = newSWFMovie();
  SWFMovie_setRate(mo, 1.0);
  SWFMovie_setDimension(mo, 800, 600);
  
  dejagnuclip = get_dejagnu_clip((SWFBlock)get_default_font(srcdir), 10, 0, 0, 800, 600);
  SWFMovie_add(mo, (SWFBlock)dejagnuclip);
  SWFMovie_nextFrame(mo); // 1st frame 


  /*********************************************
   *
   * Add some textfields
   *
   *********************************************/
  {
    SWFDisplayItem it;
    FILE *font_file = fopen(fdbfont, "r");
    if ( font_file == NULL )
    {
      perror(fdbfont);
      exit(1);
    }
    SWFFont efont = loadSWFFontFromFile(font_file);

    it = add_text_field(mo, efont, "First text");
    SWFDisplayItem_setName(it, "dtext1");
    SWFDisplayItem_moveTo(it, 0, 200);
    it = add_text_field(mo, efont, "Zweites Textfeld");
    SWFDisplayItem_setName(it, "etext1");
    SWFDisplayItem_moveTo(it, 0, 300);

    it = add_text_field(mo, efont, "Some more static text here... abcdefgh");
    SWFDisplayItem_setName(it, "dtext2");
    SWFDisplayItem_moveTo(it, 0, 400);
  }
  SWFMovie_nextFrame(mo); 

  add_actions(mo, "createTextField('dynamictext1', 99, 10, 10, 10, 10);"
		  "this.dynamictext1.text = 'Dynamic Text';");
  
  add_actions(mo, "ts = this.getTextSnapshot();");
  check(mo, "ts instanceof TextSnapshot");
  check_equals(mo, "ts.getCount()", "64");

  check_equals(mo, "ts.getText(0, 1)", "'F'");
  check_equals(mo, "ts.getText(3, 3)", "'s'");
  check_equals(mo, "ts.getText(-5, 5)", "'First'");
  check_equals(mo, "ts.getText(10, 6)", "'Z'");
  check_equals(mo, "ts.getText(0, 100)", "'First textZweites TextfeldSome more "
		  "static text here... abcdefgh'");
  add_actions(mo, "ss = ts.getText(100, 110);");
  check_equals(mo, "typeof(ss)", "'string'");
  check_equals(mo, "ss", "'h'");
  check_equals(mo, "ss.length", "1");
  
  check_equals(mo, "ts.getText(0, 100, true)", 
          "'First text\nZweites Textfeld\nSome more "
		  "static text here... abcdefgh'");
  
  check_equals(mo, "ts.getText(0, 14, true)", "'First text\nZwei'");

  check_equals(mo, "ts.findText(0, '', false)", "-1");
  check_equals(mo, "ts.findText(0, 'f', false)", "0");
  check_equals(mo, "ts.findText(0, 'f', true)", "22");
  check_equals(mo, "ts.findText(1, 'Rst', false)", "2");
  check_equals(mo, "ts.findText(3, 'RSt', false)", "-1");
  check_equals(mo, "ts.findText(100, 'h', false)", "-1");
  check_equals(mo, "ts.findText(64, 'h', false)", "-1");
  check_equals(mo, "ts.findText(-5, 'Zwei', true)", "-1");
  check_equals(mo, "ts.findText(-5, 'gh', true)", "-1");

  add_actions(mo, "ts.setSelected(5, 30, true);");
  check_equals(mo, "ts.getSelectedText()", "' textZweites TextfeldSome'");
  check_equals(mo, "ts.getSelectedText(true)", "' text\nZweites "
          "Textfeld\nSome'");
  check_equals(mo, "ts.getSelectedText(false)", "' textZweites TextfeldSome'");
  check_equals(mo, "ts.getSelected(0, 4)", "false");
  check_equals(mo, "ts.getSelected(1, 9)", "true");
  check_equals(mo, "ts.getSelected(-4, 10)", "true");
  check_equals(mo, "ts.getSelected(-4, 6)", "true");
  check_equals(mo, "ts.getSelected(28, 23)", "true");
  check_equals(mo, "ts.getSelected(20, 20)", "true");
  check_equals(mo, "ts.getSelected(20, 27)", "true");
  check_equals(mo, "ts.getSelected(-3, -1)", "false");
  check_equals(mo, "ts.getSelected(30, 31)", "false");
  check_equals(mo, "ts.getSelected(0, 5)", "false");
  check_equals(mo, "ts.getSelected(40, 45)", "false");
  check_equals(mo, "ts.getSelected(31, 34)", "false");

  check_equals(mo, "ts.getSelected(0)", "undefined");
  check_equals(mo, "ts.getSelected(1)", "undefined");
  check_equals(mo, "ts.getSelected(-4)", "undefined");
  check_equals(mo, "ts.getSelected(-4)", "undefined");
  check_equals(mo, "ts.getSelected(28)", "undefined");
  check_equals(mo, "ts.getSelected(20)", "undefined");

  // Selected text is stored in the textfield and reset when a new
  // snapshot is taken.
  add_actions(mo, "ts2 = new TextSnapshot(this);");
  check_equals(mo, "ts.getSelectedText(false)", "''");
  check_equals(mo, "ts2.getCount()", "64");
  check_equals(mo, "ts2.getSelectedText()", "''");
  add_actions(mo, "ts2 = this.getTextSnapshot();");
  check_equals(mo, "ts2.getCount()", "64");
  check_equals(mo, "ts2.getSelectedText()", "''");

  add_actions(mo, "ts2.setSelected(3, 10, true);");
  check_equals(mo, "ts2.getSelectedText(false).length", "7");
  check_equals(mo, "ts.getSelectedText(false).length", "7");

  add_actions(mo, "ts.setSelectedColor(0xffff00);");
  add_actions(mo, "ts2.setSelectedColor(0x0000ff);");

  check_equals(mo, "ts.getSelectedText(false)", "'st text'");
  add_actions(mo, "ri = ts.getTextRunInfo(4, 10);");
  check_equals(mo, "typeof(ri)", "'object'");
  check(mo, "ri instanceof Array");
  check_equals(mo, "ri.length", "7");

  add_actions(mo, "el = ri[1];");
  check_equals(mo, "typeof(el)", "'object'");
  check(mo, "!el.hasOwnProperty('indexInRun')");
  check_equals(mo, "el.indexInRun", "5");
  check_equals(mo, "el.selected", "true");
  check_equals(mo, "el.font", "'Bitstream Vera Sans'");
  check_equals(mo, "el.color", "0");
  check_equals(mo, "el.height", "12");
  check_equals(mo, "el.matrix_a", "1");
  check_equals(mo, "el.matrix_b", "0");
  check_equals(mo, "el.matrix_c", "0");
  check_equals(mo, "el.matrix_d", "1");
  check_equals(mo, "el.matrix_tx", "25.95");
  check_equals(mo, "el.matrix_ty", "200");
  xcheck_equals(mo, "el.corner0x", "25.95");
  xcheck_equals(mo, "el.corner0y", "202.8");
  xcheck_equals(mo, "el.corner1x", "29.75");
  xcheck_equals(mo, "el.corner1y", "202.8");
  xcheck_equals(mo, "el.corner2x", "29.75");
  xcheck_equals(mo, "el.corner2y", "188.85");
  xcheck_equals(mo, "el.corner3x", "25.95");
  xcheck_equals(mo, "el.corner3y", "188.85");

  // Check properties individually
  check_equals(mo, "ri[2].height", "12");
  check_equals(mo, "ri[3].height", "12");
  check_equals(mo, "ri[4].height", "12");
  check_equals(mo, "ri[5].height", "12");
  check_equals(mo, "ri[6].height", "12");

  check_equals(mo, "ri[2].selected", "true");
  check_equals(mo, "ri[3].selected", "true");
  check_equals(mo, "ri[4].selected", "true");
  check_equals(mo, "ri[5].selected", "true");
  check_equals(mo, "ri[6].selected", "false");

  check_equals(mo, "ri[2].matrix_tx", "29.75");
  check_equals(mo, "ri[2].matrix_ty", "200");
  check_equals(mo, "ri[3].matrix_tx", "34.4");
  check_equals(mo, "ri[3].matrix_ty", "200");
  check_equals(mo, "ri[4].matrix_tx", "41.75");
  check_equals(mo, "ri[4].matrix_ty", "200");

  xcheck_equals(mo, "ri[2].corner0x", "29.75");
  xcheck_equals(mo, "ri[2].corner0y", "202.8");
  xcheck_equals(mo, "ri[3].corner0x", "34.4");
  xcheck_equals(mo, "ri[3].corner0y", "202.8");
  xcheck_equals(mo, "ri[4].corner0x", "41.75");
  xcheck_equals(mo, "ri[4].corner0y", "202.8");
  
  xcheck_equals(mo, "ri[2].corner2y", "188.85");
  xcheck_equals(mo, "ri[3].corner2y", "188.85");
  xcheck_equals(mo, "ri[4].corner2y", "188.85");

  add_actions(mo, "ts.setSelected(0, 10, true);");
  add_actions(mo, "ts.setSelected(15, 20, false);");
  check_equals(mo, "ts2.getSelectedText().length", "10");

  add_actions(mo, "ri2 = ts.getTextRunInfo(0, 100);");

  check_equals(mo, "ri2[0].selected", "true");
  check_equals(mo, "ri2[1].selected", "true");
  check_equals(mo, "ri2[2].selected", "true");
  check_equals(mo, "ri2[3].selected", "true");
  check_equals(mo, "ri2[4].selected", "true");
  check_equals(mo, "ri2[5].selected", "true");
  check_equals(mo, "ri2[6].selected", "true");
  check_equals(mo, "ri2[15].selected", "false");
  check_equals(mo, "ri2[16].selected", "false");
  check_equals(mo, "ri2[17].selected", "false");
  check_equals(mo, "ri2[18].selected", "false");

  xcheck_equals(mo, "ri2[50].corner2y", "388.85");
  xcheck_equals(mo, "ri2[50].corner2x", "156.6");
  xcheck_equals(mo, "ri2[51].corner2y", "388.85");
  xcheck_equals(mo, "ri2[51].corner2x", "163.95");

  check_equals(mo, "ri2[50].matrix_tx", "151.65");
  check_equals(mo, "ri2[51].matrix_tx", "156.55");

  add_actions(mo, "ts = this.getTextSnapshot();");
  check_equals(mo, "typeof(ts)", "'object'");
  add_actions(mo, "backup = TextSnapshot;");
  add_actions(mo, "TextSnapshot = undefined;");
  add_actions(mo, "t = new TextSnapshot();");
  check_equals(mo, "typeof(t)", "'undefined'");

  check_equals(mo, "typeof(TextSnapshot)", "'undefined'");
  add_actions(mo, "ts = this.getTextSnapshot();");
  xcheck_equals(mo, "typeof(ts)", "'undefined'");
  add_actions(mo, "TextSnapshot = backup;");
  add_actions(mo, "ts = this.getTextSnapshot();");
  check_equals(mo, "typeof(ts)", "'object'");
  
  add_actions(mo, "backup = TextSnapshot.prototype;");
  add_actions(mo, "TextSnapshot.prototype = undefined;");
  add_actions(mo, "ts = this.getTextSnapshot();");
  check_equals(mo, "typeof(ts)", "'object'");
  add_actions(mo, "TextSnapshot.prototype = backup;");
  add_actions(mo, "ts = this.getTextSnapshot();");
  check_equals(mo, "typeof(ts)", "'object'");
  
  add_actions(mo, "totals(); stop();");
  
  SWFMovie_nextFrame(mo); 

  /*****************************************************
   *
   * Output movie
   *
   *****************************************************/
  puts("Saving " OUTPUT_FILENAME );

  SWFMovie_save(mo, OUTPUT_FILENAME);

  return 0;
}
Example #29
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;
}
Example #30
0
int
main(int argc, char** argv)
{
  SWFMovie mo;
  SWFMovieClip dejagnuclip;
  SWFDisplayItem it1;


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

  Ming_init();
  mo = newSWFMovieWithVersion(OUTPUT_VERSION);
  SWFMovie_setDimension(mo, 800, 600);
  SWFMovie_setRate (mo, 2);

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

  // Frame 2: Add a static movieclip at depth 3 with origin at 10,200, then change it's _y to 202 with AS code.
  it1 = add_static_mc(mo, "static3", 3, 10, 200, 20, 20);
  add_actions(mo,
    "check_equals(static3.getDepth(), -16381);" 
    "static3.myThing = 'guess';"
    // dynamically transform it
    "static3._y += 2;"
    );
  SWFMovie_nextFrame(mo); 

  // Frame 3: nothing new, just checks, and end of test on second run
  SWFMovie_nextFrame(mo); 
  add_actions(mo,
    "if ( typeof(_root.runs) == 'undefined' ) {"
    " check_equals(static3._y, 202);" 
    " _root.runs=1;"
    "} else {"
    " check_equals(static3._y, 204);"  
    " totals();"
    " stop();"
    "}"
    );

  // Frame 4: move DisplayObject at depth 3 to position 50,200
  SWFDisplayItem_moveTo(it1, 50, 200); 
  add_actions(mo,
    // immune to MOVE after _y set by AS
    "check_equals(static3._x, 10);" 
    "check_equals(static3.getDepth(), -16381);" 
    );
  SWFMovie_nextFrame(mo); 

  // Frame 5: nothing new
  SWFMovie_nextFrame(mo); 

  // Frame 6: nothing new
  SWFMovie_nextFrame(mo); 

  // Frame 7: go to frame 2  and playe (movie will end on second execution of frame 3 actions)
  add_actions(mo,

    "   gotoAndPlay(2); " // The movie will be ended in frame 5
    
    // Static3 refers to same instance
    "check_equals(static3.myThing, 'guess');" 
    "check_equals(static3._x, 10);" // Probably PlaceObject was a no-op...

    // actions in frame 2 would be executed again, making this a 204, but only *after* this action block terminates..
    "check_equals(static3._y, 202);" 

    "check_equals(static3.getDepth(), -16381);" 
    );
  SWFMovie_nextFrame(mo); 

  //Output movie
  puts("Saving " OUTPUT_FILENAME );
  SWFMovie_save(mo, OUTPUT_FILENAME);

  return 0;
}