Ejemplo n.º 1
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;
}
Ejemplo n.º 2
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); \
}; \
Ejemplo n.º 3
0
static void
embed_image(SWFMovie movie, char *f)
{
	SWFFill fill;
	SWFBitmap bm;
	SWFShape shape;
	SWFMovieClip clip;
	SWFDisplayItem it, it2;
	FILE *raster;
	SWFInput in;
	int height, width;
	char *name;

        if (!(raster = fopen (f, "rb")))
        {
                fprintf (stdout, "%s: %s\n", f, strerror (errno));
		exit(1);
        }

        if (!(in = newSWFInput_file(raster)))
        {
                fprintf (stdout, "Can't create SWFInput from file\n");
		exit(1);
        }

        if (!(bm = newSWFBitmap_fromInput (in)))
        {
                fprintf (stdout, "Error creating bitmap");
		exit(1);
        }

	height = SWFBitmap_getHeight(bm);
	width = SWFBitmap_getWidth(bm);


	shape = newSWFShape();
  
	SWFShape_movePenTo(shape, 0, 0);

	fill = SWFShape_addBitmapFill(shape, bm, SWFFILL_CLIPPED_BITMAP);
	SWFShape_setRightFill(shape, fill);
	SWFShape_drawLineTo(shape, width, 0);
	SWFShape_drawLineTo(shape, width, height);
	SWFShape_drawLineTo(shape, 0, height);
	SWFShape_drawLineTo(shape, 0, 0);

	clip = newSWFMovieClip();
	it2 = SWFMovieClip_add(clip, (SWFBlock)shape);
	SWFMovieClip_nextFrame(clip);

	it = SWFMovie_add(mo, (SWFBlock)clip);

	name = base_name(f);

	SWFDisplayItem_setName(it, name);

	free(name);

}
Ejemplo n.º 4
0
int
main(int argc, char** argv)
{
  SWFMovie mo;
  SWFMovieClip  mc, dejagnuclip;

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

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

  dejagnuclip = get_dejagnu_clip((SWFBlock)get_default_font(srcdir), 10, 0, 0, 800, 600);
  SWFMovie_add(mo, (SWFBlock)dejagnuclip);
  SWFMovie_nextFrame(mo); /* 1st frame */

  mc = newSWFMovieClip();
  add_clip_actions(mc, "_root.x = 1;"
                       "_root.check_equals(_root.x, 1);");
  SWFMovieClip_nextFrame(mc);
 
 
  add_actions(mo, " gotoAndPlay(4); ");
  SWFMovie_nextFrame(mo); /* 2nd frame */
  
  SWFMovie_nextFrame(mo); /* 3rd frame */
  
   
  /* add mc to _root and name it as "mc" */
  SWFDisplayItem it;
  it = SWFMovie_add(mo, (SWFBlock)mc);  
  SWFDisplayItem_setDepth(it, 3); 
  SWFDisplayItem_setName(it, "mc"); 
  add_actions(mo, " _root.x = 2; "
                  " _root.check_equals(_root.x, 2); ");
  SWFMovie_nextFrame(mo); /* 4th frame */

	SWFDisplayItem_remove(it);
  check_equals(mo, "_root.x", "1");
  check_equals(mo, "typeof(mc)", "'undefined'");
  add_actions(mo, " _root.totals(); stop(); ");
  SWFMovie_nextFrame(mo); /* 5th frame */

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

  return 0;
}
Ejemplo n.º 5
0
static void MingSWFCircle(double x, double y, double r, const pGEcontext gc, pDevDesc RGD)
{
	MingSWFDesc *MGD = (MingSWFDesc *)RGD->deviceSpecific;
	SWFShape circle = newSWFShape();
	SWFMovieClip mcCircle;
	SWFDisplayItem display_item;
	char strBuffer[1024];

	mcCircle = newSWFMovieClip();
	sprintf(strBuffer,"var Label = \"x=<b>%.2f</b>, y=%.2f\\nradius is %.2f\";",x,y,r);
	SWFMovieClip_add(mcCircle, (SWFBlock) newSWFAction(strBuffer));


	if (gc->fill){
		SWFShape fcircle; 
		SWFFillStyle fill;
		fcircle = newSWFShape();
		SWFShape_movePenTo(fcircle, x, y);
		MINGSWF_SET_COLOR(MGD,gc->fill);
		fill = newSWFSolidFillStyle(MGD->red,MGD->green,MGD->blue,MGD->alpha);
        SWFShape_setRightFillStyle(fcircle, fill);
		Fixed_SWFShape_drawCircle(fcircle, r<2.0?2.0:r, 0 , 360);
		/*SWFMovie_add(MGD->movie, (SWFBlock) fcircle);*/
		SWFMovieClip_add(mcCircle, (SWFBlock) fcircle);
	}

	SWFShape_movePenTo(circle, x, y);
	MINGSWF_SET_COLOR(MGD,gc->col);
	MINGSWF_SET_LINE(MGD,circle,gc);
	/* curve drawing is flawed with setLine2() for some reason */
	/*SWFShape_setLine(circle,gc->lwd,MGD->red,MGD->green,MGD->blue,MGD->alpha);*/

	/* SWFShape_drawCircle(circle, (int)(r<2.0?2.0:r)); */
	Fixed_SWFShape_drawCircle(circle, r<2.0?2.0:r, 0 , 360);
	/*SWFDisplayItem_moveTo(SWFMovie_add(MGD->movie, (SWFBlock) circle) , x, y);*/
	/* SWFMovie_add(MGD->movie, (SWFBlock) circle);*/
	/* destroySWFShape(circle); */
	if (gc->fill){
		/*destroySWFFillStyle(fill);*/
	}

	SWFMovieClip_add(mcCircle, (SWFBlock) circle);
	SWFMovieClip_nextFrame(mcCircle);

	/* Add Label Actions */
	MingSWF_SetLabelActions(SWFMovie_add(MGD->movie, (SWFBlock) mcCircle));

#ifdef MINGSWFDEBUG
	Rprintf("Circle(x=%f,y=%f,r=%f,gc=0x%x,RGD=0x%x)\n",x,y,r,gc,RGD);
	Rprintf("\tuser coords: x=%f,y=%f\n",fromDeviceX(x,GE_NDC,MGD->RGE),fromDeviceY(y,GE_NDC,MGD->RGE));
#endif
}
Ejemplo n.º 6
0
SWFMovieClip
get_static_mc(int width, int height, int r, int g, int b)
{
  SWFShape sh = get_shape(width, height, r, g, b);
  SWFMovieClip mc = newSWFMovieClip();

  SWFMovieClip_add(mc, (SWFBlock)sh);

  SWFMovieClip_nextFrame(mc);

  return mc;

}
Ejemplo n.º 7
0
SWFMovieClip
get_dejagnu_clip(SWFBlock font, int depth, int x, int y, int width, int height)
{
	SWFMovieClip mc = newSWFMovieClip();
	SWFAction ac = get_dejagnu_actions();

	add_xtrace_function_clip(mc, font, depth, x, y, width, height);

	SWFMovieClip_add(mc, (SWFBlock)ac);

	SWFMovieClip_nextFrame(mc);

	return mc;
}
Ejemplo n.º 8
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");
}
Ejemplo n.º 9
0
SWFDisplayItem
add_button(SWFMovie mo)
{
	SWFDisplayItem it;
	SWFMovieClip mc, mc1;
	SWFButtonRecord br;
	SWFShape sh1, sh2, sh3, sh4, sh1a, sh2a, sh3a, sh4a;
	SWFButton bu = newSWFButton();
	mc = newSWFMovieClip();

	sh1 = make_fill_square(0, 0, 40, 40, 0, 0, 0, 0, 0, 0);
	sh1a = make_fill_square(30, 30, 5, 5, 128, 128, 128, 128, 128, 128);
	sh2 = make_fill_square(0, 0, 40, 40, 255, 0, 0, 255, 0, 0);
	sh2a = make_fill_square(30, 30, 5, 5, 128, 0, 0, 128, 0, 0);
	sh3 = make_fill_square(0, 0, 40, 40, 0, 255, 0, 0, 255, 0);
	sh3a = make_fill_square(30, 30, 5, 5, 0, 128, 0, 0, 128, 0);
	sh4 = make_fill_square(0, 0, 40, 40, 255, 255, 0, 255, 255, 0);
	sh4a = make_fill_square(30, 30, 5, 5, 128, 128, 0, 128, 128, 0);

	/* Higher depth DisplayObject is intentionally added before lower depth one */
	br = SWFButton_addCharacter(bu, (SWFCharacter)sh1a, SWFBUTTON_HIT);
	SWFButtonRecord_setDepth(br, 2);
	br = SWFButton_addCharacter(bu, (SWFCharacter)sh1, SWFBUTTON_HIT);
	SWFButtonRecord_setDepth(br, 1);

	/* Higher depth DisplayObject is intentionally added before lower depth one */
	br = SWFButton_addCharacter(bu, (SWFCharacter)sh2a, SWFBUTTON_UP );
	SWFButtonRecord_setDepth(br, 2);
	br = SWFButton_addCharacter(bu, (SWFCharacter)sh2, SWFBUTTON_UP );
	SWFButtonRecord_setDepth(br, 1);

    mc1 = newSWFMovieClip();
    br = SWFButton_addCharacter(bu, (SWFCharacter)mc1, SWFBUTTON_UP);
	SWFButtonRecord_setDepth(br, 8);

    br = SWFButton_addCharacter(bu, (SWFCharacter)mc1, SWFBUTTON_DOWN);
	SWFButtonRecord_setDepth(br, 7);

    br = SWFButton_addCharacter(bu, (SWFCharacter)mc1, SWFBUTTON_HIT);
	SWFButtonRecord_setDepth(br, 9);

	it = SWFMovieClip_add(mc, (SWFBlock)bu);
	SWFDisplayItem_setName(it, "button");
	SWFMovieClip_nextFrame(mc); /* showFrame */


	it = SWFMovie_add(mo, (SWFBlock)mc);
	return it;
}
Ejemplo n.º 10
0
SWFMovieClip
get_static_mc(int width, int height)
{
  SWFShape sh;
  SWFMovieClip mc;

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

  return mc;

}
Ejemplo n.º 11
0
int main()
{
	SWFMovie m;
	SWFMovieClip mc;
	SWFSoundStream stream;
	FILE* file;

	file = fopen(MEDIADIR "/sound1.mp3", "rb");
	if(!file)
	{
		perror(MEDIADIR "/sound1.mp3");
		return EXIT_FAILURE;
	}

	m = newSWFMovieWithVersion(7);
	SWFMovie_setRate(m, 1);

	stream = newSWFSoundStream(file);
	if(stream == NULL)
	{
		fprintf(stderr, "SoundStream failed\n");
		return EXIT_FAILURE;
	}

	mc = newSWFMovieClip();
	SWFMovieClip_setSoundStream(mc, stream, 1);
	SWFMovieClip_nextFrame(mc);	
	SWFMovieClip_nextFrame(mc);	
	
	SWFMovie_add(m, mc);
	SWFMovie_nextFrame(m);

	SWFMovie_save(m, "test01.swf");
	fclose(file);
	return EXIT_SUCCESS;
}
Ejemplo n.º 12
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);
}
Ejemplo n.º 13
0
static int
add_imports()
{
	int i;
	SWFMovieClip mc;
	SWFDisplayItem di;
	SWFAction ac;
	struct stat statbuf;

	mc = newSWFMovieClip();

	for (i=0; i<numimport_specs; i++)
	{
		char *spec = import_specs[i];
		char *file = strtok(spec, ":");
		char *sym;
		char unchecked = 0;

   		if ( -1 == stat(file, &statbuf) )
		{
			unchecked = 1;
		}

		printf("Importing symbols from ");
		if ( unchecked ) printf("[UNAVAILABLE] ");
		printf("%s:", file);
		fflush(stdout);
		while ((sym=strtok(NULL, ",")))
		{
			SWFCharacter ch;

			printf(" %s", sym);
			fflush(stdout);
			ch = SWFMovie_importCharacter(mo, file, sym);
			SWFMovieClip_add(mc, (SWFBlock)ch);
		}
		printf("\n");
	}

	SWFMovieClip_nextFrame(mc);
	di = SWFMovie_add(mo, (SWFBlock)mc);
	SWFDisplayItem_setName(di, "__shared_assets");
	ac = newSWFAction("__shared_assets._visible=false;");
	SWFMovie_add(mo, (SWFBlock)ac);

	return 1;
}
Ejemplo n.º 14
0
void swfClose(pDevDesc dd)
{
#ifdef SWF_DEBUG
    Rprintf("close called\n");
#endif
    pswfDesc swfInfo = (pswfDesc) dd->deviceSpecific;
    
    if(swfInfo->currentFrame)
    {
        SWFMovieClip_nextFrame(swfInfo->currentFrame);
        SWFMovie_add(swfInfo->m, (SWFBlock) swfInfo->currentFrame);
        SWFMovie_nextFrame(swfInfo->m);
    }
    SWFMovie_save(swfInfo->m, swfInfo->filename);
    destroySWFFillStyleArray(swfInfo->array);
    free(swfInfo);
}
Ejemplo n.º 15
0
SWFDisplayItem
add_static_mc(SWFMovie mo, const char* name, int depth)
{
  SWFShape  sh;
  SWFMovieClip mc;
  SWFDisplayItem it;

  mc = newSWFMovieClip();
  sh = make_fill_square (300, 300, 60, 60, 255, 0, 0, 255, 0, 0);
  SWFMovieClip_add(mc, (SWFBlock)sh);  
  SWFMovieClip_nextFrame(mc);

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

  return it;
}
Ejemplo n.º 16
0
void
addRedSquareExport(SWFMovie mo)
{
	SWFShape sh;
	SWFMovieClip mc;

	sh = make_fill_square (0, 0, 60, 60, 255, 0, 0, 255, 0, 0);
	mc = newSWFMovieClip();

	SWFMovieClip_add(mc, (SWFBlock)sh);
	/* This is here just to turn the clip into an active one */
	add_clip_actions(mc, "onRollOver = function() {};");
	SWFMovieClip_nextFrame(mc);

	SWFMovie_addExport(mo, (SWFBlock)mc, "redsquare");

	SWFMovie_writeExports(mo);
}
Ejemplo n.º 17
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;
}
Ejemplo n.º 18
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);

}
Ejemplo n.º 19
0
/* We do the following when open a new page (frame):
   1. Add all pending shape objects to the current frame
   2. Add current frame to the movie
   3. Advance movie by 1 frame
   4. Since in Flash, when you advance the movie to the next frame,
      all items in the previous frame will be preserved.
      To keep in accordance with R's plotting model, we need to
      remove the content of previous frame
   5. Create a new empty canvas (frame)
   6. Reset the clip layer
*/
void swfNewPage(const pGEcontext gc, pDevDesc dd)
{
#ifdef SWF_DEBUG
    Rprintf("newPage called\n");
#endif
    pswfDesc swfInfo = (pswfDesc) dd->deviceSpecific;
    SWFDisplayItem display = NULL;
    
    /* Add current frame to the movie */
    if(swfInfo->currentFrame)
    {
        SWFMovieClip_nextFrame(swfInfo->currentFrame);
        display = SWFMovie_add(swfInfo->m, (SWFBlock) swfInfo->currentFrame);
        SWFMovie_nextFrame(swfInfo->m);
    }
    /* To move to the next frame, we need to first clear the previous one */
    if(display) SWFMovie_remove(swfInfo->m, display);
    /* Create a new canvas(frame) for next plot() */
    swfInfo->currentFrame = newSWFMovieClip();
    SWFMovieClip_setNumberOfFrames(swfInfo->currentFrame, 1);
    /* Renew the clip layer */
    swfInfo->currentClip = NULL;
}
Ejemplo n.º 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 (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;
}
Ejemplo n.º 21
0
int main(int argc, char* argv[])
{

    SWFMovie mo;
    SWFMovieClip mc1, mc2, mc3, mc4, dejagnuclip;
    SWFDisplayItem it;
    SWFAction ac;
    SWFInitAction initac;

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

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

    add_actions(mo,
            "if (!_global.hasOwnProperty('arr')) { _global.arr = []; };"
            "_global.ch = function(a, b) {"
            "   trace(a);"
            "   if (typeof(b)=='undefined' || (typeof(b)=='boolean' && b)) {"
            "       _global.arr.push(a);"
            "   };"
            "};"
            "this.onEnterFrame = function() { "
            "   _global.ch('onEnterFrame', false);"
            "};"
            );

    SWFMovie_nextFrame(mo);

    //  MovieClip 1 
    mc1 = newSWFMovieClip(); // 1 frames 

    // SWF_EXPORTASSETS 
    SWFMovie_addExport(mo, (SWFBlock)mc1, "Segments_Name");
    SWFMovie_writeExports(mo);

    //  MovieClip mc3 has two frames. In each frame a different MovieClip
    //  is placed with the name Segments.
    mc3 = newSWFMovieClip(); // 2 frames 

    //  MovieClip 2 
    mc2 = newSWFMovieClip(); // 1 frames 

    // Add mc2
    it = SWFMovieClip_add(mc3, (SWFBlock)mc2);
    SWFDisplayItem_setDepth(it, 1);
    SWFDisplayItem_setName(it, "Segments");

    // Frame 2
    SWFMovieClip_nextFrame(mc3);

    // Remove mc2
    SWFDisplayItem_remove(it);

    // Add mc1
    it = SWFMovieClip_add(mc3, (SWFBlock)mc1);
    SWFDisplayItem_setDepth(it, 1);
    SWFDisplayItem_setName(it, "Segments");

    SWFMovieClip_nextFrame(mc3);

    // End mc3


    // This is frame 1 of the main timeline

    // Put our sprite mc3 on stage.
    it = SWFMovie_add(mo, (SWFBlock)mc3);
    SWFDisplayItem_setDepth(it, 1);
    SWFDisplayItem_setName(it, "mc");

    //  mc4 is just for executing init actions.
    mc4 = newSWFMovieClip(); 
    SWFMovie_addExport(mo, (SWFBlock)mc4, "__Packages.Bug");
    SWFMovie_writeExports(mo);
    
    dejagnuclip = get_dejagnu_clip((SWFBlock)get_default_font(srcdir), 10,
                0, 0, 800, 600);
    SWFMovie_add(mo, (SWFBlock)dejagnuclip);

    ac = newSWFAction(
        "_global.loops = 0;"
        "_global.c = 0;"
        "if( !_global.Bug ) {"
        "   _global.Bug = function () {"
        "       this.onUnload = function() { "
        "           _global.ch('dynamic unload: ' + this.c);"
        "       }; "
        "       this.onLoad = function() { "
        "           _global.ch('dynamic load: ' + this.c);"
        "       }; "
        "       this.c = _global.c;"
        "       _global.ch('ctor: ' + _global.c);"
        "       _global.c++;"
        "   };"
        "};"
    );

    initac = newSWFInitAction_withId(ac, 4);
    SWFMovie_add(mo, (SWFBlock)initac);
    
    ac = newSWFAction("Object.registerClass('Segments_Name',Bug);");
    initac = newSWFInitAction_withId(ac, 1);
    SWFMovie_add(mo, (SWFBlock)initac);
    add_actions(mo, "_global.ch('Frame ' + "
                            "_level0._currentframe + ' actions: ' "
                            "+ _level0.mc.Segments.c);");

    // Frame 2 of the main timeline
    SWFMovie_nextFrame(mo);
    add_actions(mo, "_global.ch('Frame ' + "
                            "_level0._currentframe + ' actions: ' "
                            "+ _level0.mc.Segments.c);");
    
    add_actions(mo,
        "    if (_global.loops < 5) {"
        "        _global.loops++;"
        "        gotoAndPlay(2);"
        "   }"
        "   else {"
        "      delete this.onEnterFrame;"
        "      gotoAndPlay(4);"
        "   };"
        );
    
    SWFMovie_nextFrame(mo);
    
    check_equals(mo, "_global.arr.length", "20");
    check_equals(mo, "_global.arr[0]", "'Frame 2 actions: undefined'");
    check_equals(mo, "_global.arr[1]", "'ctor: 0'");
    xcheck_equals(mo, "_global.arr[2]", "'Frame 3 actions: 0'");
    xcheck_equals(mo, "_global.arr[3]", "'dynamic load: 0'");
    check_equals(mo, "_global.arr[4]", "'Frame 2 actions: 0'");
    check_equals(mo, "_global.arr[5]", "'Frame 3 actions: 0'");
    check_equals(mo, "_global.arr[6]", "'Frame 2 actions: 0'");
    check_equals(mo, "_global.arr[7]", "'ctor: 1'");
    check_equals(mo, "_global.arr[8]", "'dynamic unload: 0'");
    xcheck_equals(mo, "_global.arr[9]", "'Frame 3 actions: 0'");
    check_equals(mo, "_global.arr[11]", "'Frame 2 actions: 0'");
    check_equals(mo, "_global.arr[12]", "'Frame 3 actions: 1'");
    check_equals(mo, "_global.arr[13]", "'Frame 2 actions: 1'");
    check_equals(mo, "_global.arr[14]", "'ctor: 2'");
    check_equals(mo, "_global.arr[15]", "'dynamic unload: 1'");
    xcheck_equals(mo, "_global.arr[16]", "'Frame 3 actions: 1'");
    xcheck_equals(mo, "_global.arr[17]", "'dynamic load: 2'");
    check_equals(mo, "_global.arr[18]", "'Frame 2 actions: 1'");
    check_equals(mo, "_global.arr[19]", "'Frame 3 actions: 2'");
    xcheck_equals(mo, "_global.arr.toString()",
		    "'Frame 2 actions: undefined,ctor: 0,Frame 3 actions: 0,dynamic load: 0,Frame 2 actions: 0,Frame 3 actions: 0,Frame 2 actions: 0,ctor: 1,dynamic unload: 0,Frame 3 actions: 0,dynamic load: 1,Frame 2 actions: 0,Frame 3 actions: 1,Frame 2 actions: 1,ctor: 2,dynamic unload: 1,Frame 3 actions: 1,dynamic load: 2,Frame 2 actions: 1,Frame 3 actions: 2'");

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

    // SWF_END 
    SWFMovie_save(mo, OUTPUT_FILENAME);

    return 0;
}
Ejemplo n.º 22
0
int
main(int argc, char** argv)
{
  SWFMovie mo;
  SWFMovieClip mc;
  SWFSoundStream ss;
  FILE* sound_f;
  const char* sound_filename;
  SWFDisplayItem it;
  struct stat statbuf;

  if ( argc>1 ) {
    sound_filename=argv[1];
  } else {
    sound_filename="sound1.mp3";
  }

  sound_f = fopen(sound_filename, "r");
  if ( ! sound_f ) {
    perror(sound_filename);
    return EXIT_FAILURE;
  }

  printf("Using sound file %s\n", sound_filename);

  if ( -1 == fstat(fileno(sound_f), &statbuf) )
  {
    perror("fstat");
    return EXIT_FAILURE;
  }
  if ( S_ISDIR(statbuf.st_mode) )
  {
    fprintf(stderr, "%s is a directory, we need a file\n", sound_filename);
    return EXIT_FAILURE;
  }

  Ming_init();
  Ming_useSWFVersion (OUTPUT_VERSION);
  
  mo = newSWFMovie();
  SWFMovie_setDimension(mo, 100, 100);
  SWFMovie_setRate(mo, 1);

  ss = newSWFSoundStream(sound_f);

  mc = newSWFMovieClip();
  SWFMovieClip_setSoundStream(mc, ss, 1);
  SWFMovieClip_nextFrame(mc);

  it = SWFMovie_add(mo, mc);
  SWFMovie_nextFrame(mo);
  SWFMovie_nextFrame(mo);
  SWFMovie_nextFrame(mo);
  SWFMovie_nextFrame(mo);
  SWFMovie_nextFrame(mo);
  SWFMovie_nextFrame(mo);
  SWFMovie_nextFrame(mo);
  SWFMovie_nextFrame(mo);

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

  return EXIT_SUCCESS;
}
Ejemplo n.º 23
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;
}
Ejemplo n.º 24
0
int
main(int argc, char** argv)
{
  SWFMovie mo;
  SWFMovieClip mc1, mc2, dejagnuclip;
  SWFDisplayItem it1, it2;
  SWFShape  sh1,sh2;

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

  Ming_init();
  Ming_useSWFVersion (OUTPUT_VERSION);
  
  mo = newSWFMovie();
  SWFMovie_setDimension(mo, 800, 600);
  SWFMovie_setRate(mo, 6);

  // Frame 1: Place dejagnu clip

  dejagnuclip = get_dejagnu_clip((SWFBlock)get_default_font(srcdir), 10, 0, 0, 800, 600);
  SWFMovie_add(mo, (SWFBlock)dejagnuclip);
  add_actions(mo, "mc1Constructed=0; mc2Constructed=0; mc3Constructed=0; mc4Constructed=0;");
  SWFMovie_nextFrame(mo); 
  
  //
  // Frame 2: 
  //   Place red static movieClip1 DisplayObject at depth 3 (-16381)
  //   Place black static movieClip1 DisplayObject at depth 4 (-16380)
  //
  sh1 = make_fill_square (300, 300, 60, 60, 255, 0, 0, 255, 0, 0);
  mc1 = newSWFMovieClip();
  SWFMovieClip_add(mc1, (SWFBlock)sh1); 
  SWFMovieClip_nextFrame(mc1);
  
  it1 = SWFMovie_add(mo, (SWFBlock)mc1);  //add movieClip1 to the _root
  SWFDisplayItem_setDepth(it1, 3);
  SWFDisplayItem_setName(it1, "movieClip1"); //name movieClip1
  SWFDisplayItem_addAction(it1, newSWFAction(
    "_root.note(this+' constructed');"
    "_root.mc1Constructed++;"
    ), SWFACTION_CONSTRUCT);


  sh2 = make_fill_square (330, 270, 120, 120, 0, 0, 0, 0, 0, 0);
  mc2 = newSWFMovieClip();
  SWFMovieClip_add(mc2, (SWFBlock)sh2);  
  SWFMovieClip_nextFrame(mc2); 

  it2 = SWFMovie_add(mo, (SWFBlock)mc2);  //add movieClip2 to the _root
  SWFDisplayItem_setDepth(it2, 4);
  SWFDisplayItem_setName(it2, "movieClip2"); //name movieClip2
  SWFDisplayItem_addAction(it2, newSWFAction(
    "_root.note(this+' constructed');"
    "_root.mc2Constructed++;"),
      SWFACTION_CONSTRUCT);
  
  SWFMovie_nextFrame(mo);  

  // Frame3: nothing new
  SWFMovie_nextFrame(mo);  
  
  // Frame4: remove "movieClip1" and "movieClip2"
  
  SWFDisplayItem_remove(it1);
  SWFDisplayItem_remove(it2);
  SWFMovie_nextFrame(mo); 
  
  //
  // Frame5: 
  //   Place red static movieClip3 DisplayObject at depth 3 (-16381) with ratio set to 2.0
  //   Place black static movieClip4 DisplayObject at depth4 (-16380) with ratio set to 0.0
  //

  it1 = SWFMovie_add(mo, (SWFBlock)mc1);  //add movieClip3 to the _root
  SWFDisplayItem_setDepth(it1, 3);
  SWFDisplayItem_setName(it1, "movieClip3"); //name movieClip3
  SWFDisplayItem_setRatio(it1, 2.0); // It's important to set this, don't why yet.
  SWFDisplayItem_addAction(it1, newSWFAction(
    "_root.note(this+' constructed');"
    "_root.mc3Constructed++;"
    ), SWFACTION_CONSTRUCT);
  
  it2 = SWFMovie_add(mo, (SWFBlock)mc2);  //add movieClip4 to the _root
  SWFDisplayItem_setDepth(it2, 4);
  SWFDisplayItem_setName(it2, "movieClip4"); //name movieClip4
  SWFDisplayItem_setRatio(it2, 0.0); // It's important to set this, don't why yet.
  SWFDisplayItem_addAction(it2, newSWFAction(
    "_root.note(this+' constructed');"
    "_root.mc4Constructed++;"
    ), SWFACTION_CONSTRUCT);
  
  SWFMovie_nextFrame(mo); 
  
  //
  // Frame4: check, gotoAndStop(3), check..
  //
  check_equals(mo, "typeof(movieClip1)", "'undefined'");
  check_equals(mo, "typeof(movieClip2)", "'undefined'");
  check_equals(mo, "typeof(movieClip3)", "'movieclip'");
  check_equals(mo, "typeof(movieClip4)", "'movieclip'");
  check_equals(mo, "_root.mc1Constructed", "1");
  check_equals(mo, "_root.mc2Constructed", "1");
  check_equals(mo, "_root.mc3Constructed", "1");
  check_equals(mo, "_root.mc4Constructed", "1");
  
  SWFMovie_add(mo, (SWFBlock)newSWFAction( "gotoAndStop(3);"));
  
  check_equals(mo, "typeof(movieClip1)", "'movieclip'");
  check_equals(mo, "typeof(movieClip2)", "'undefined'");
  // the difference of movieClip3 and movieClip4 was caused by the ratio value
  check_equals(mo, "typeof(movieClip3)", "'undefined'");
  check_equals(mo, "typeof(movieClip4)", "'movieclip'");
  check_equals(mo, "_root.mc1Constructed", "2");
  check_equals(mo, "_root.mc2Constructed", "1");
  check_equals(mo, "_root.mc3Constructed", "1");
  check_equals(mo, "_root.mc4Constructed", "1");
  
  SWFMovie_add(mo, (SWFBlock)newSWFAction( "totals(); stop();" ));
  SWFMovie_nextFrame(mo);

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

  return 0;
}
Ejemplo n.º 25
0
int
main(int argc, char** argv)
{
  SWFMovie mo;
  SWFMovieClip  mc1, mc2, dejagnuclip;
  SWFDisplayItem it1, it2;
  SWFShape  sh_red;

  /* For the button duplication test */
#if MING_VERSION_CODE >= 00040400
  SWFButton but;
  SWFButtonRecord br;
#endif

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

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

  dejagnuclip = get_dejagnu_clip((SWFBlock)get_default_font(srcdir), 10, 0, 0, 800, 600);
  SWFMovie_add(mo, (SWFBlock)dejagnuclip);
  add_actions(mo, "x1=0; x2=0; x3=0;");
  SWFMovie_nextFrame(mo);  /* 1st frame */

  
  mc1 = newSWFMovieClip();
  sh_red = make_fill_square (100, 300, 60, 60, 255, 0, 0, 255, 0, 0);
  SWFMovieClip_add(mc1, (SWFBlock)sh_red);  
  add_clip_actions(mc1, "stop();");
  SWFMovieClip_nextFrame(mc1);

  mc2 = newSWFMovieClip();
  sh_red = make_fill_square (100, 200, 60, 60, 255, 0, 0, 255, 0, 0);
  SWFMovieClip_add(mc2, (SWFBlock)sh_red);  
  add_clip_actions(mc2, "stop();");
  SWFMovieClip_nextFrame(mc2);

  it1 = SWFMovie_add(mo, (SWFBlock)mc1); 
  SWFDisplayItem_setDepth(it1, 10); 
  SWFDisplayItem_setName(it1, "mc1"); 

  it2 = SWFMovie_add(mo, (SWFBlock)mc2); 
  SWFDisplayItem_setDepth(it2, 20); 
  SWFDisplayItem_setName(it2, "mc2"); 
  SWFDisplayItem_addAction(it2,
    compileSWFActionCode(" _root.note('onClipLoad triggered'); "
                         " _root.x1 = _root.x1 + 1; "),
    SWFACTION_ONLOAD);  
  SWFDisplayItem_addAction(it2,
    compileSWFActionCode(" _root.note('onClipEnterFrame triggered'); "
                         " _root.x2 = _root.x2 + 1; "),
    SWFACTION_ENTERFRAME);  
  SWFDisplayItem_addAction(it2,
    compileSWFActionCode(" _root.note('onClipUnload triggered'); "
                         " _root.x3 = _root.x3 + 1; "),
    SWFACTION_UNLOAD); 

  add_actions(mo, " mc1.onLoad = function () {}; "
                  " mc1.prop1 = 10; "
                  " duplicateMovieClip('mc1', 'dup1', 1); "
                  " mc2.onLoad = function () {}; "
                  " duplicateMovieClip('mc2', 'dup2', 2); " );
  SWFMovie_nextFrame(mo); /* 2nd frame */
  
  
  check_equals(mo, "mc1.prop1", "10");
  check_equals(mo, "typeof(mc1.onLoad)", "'function'");
  check_equals(mo, "mc1.getDepth()", "-16374");
  /* user defined property will not be duplicated */
  check_equals(mo, "dup1.prop1", "undefined");  
  /* user defined event handler will not be duplicated */
  check_equals(mo, "typeof(dup1.onLoad)", "'undefined'"); 
  check_equals(mo, "dup1.getDepth()", "1");
  /* check user defined onLoad */
  check_equals(mo, "typeof(mc2.onLoad)", "'function'");
  /* onClipEvent does not define a function */
  check_equals(mo, "typeof(mc2.onEnterFrame)", "'undefined'");
  /* user defined event handler will not be duplicated */
  check_equals(mo, "typeof(dup2.onLoad)", "'undefined'"); 
  check_equals(mo, "_root.x1", "2");
  check_equals(mo, "_root.x2", "2");
  SWFMovie_nextFrame(mo); /* 3rd frame */
  
  SWFDisplayItem_remove(it1);
  SWFDisplayItem_remove(it2);
  add_actions(mo, " dup2.removeMovieClip(); ");

  SWFMovie_nextFrame(mo); /* 4th frame */
  
#if MING_VERSION_CODE >= 00040400

  /* Create a button, add it to mc1 */
  but = newSWFButton();
  br = SWFButton_addCharacter(but, (SWFCharacter)sh_red, SWFBUTTON_UP);
  SWFButtonRecord_setDepth(br, 10);
  it1 = SWFMovie_add(mo, (SWFBlock)but);
  SWFDisplayItem_setName(it1, "button");

  /* Sanity check */
  check_equals(mo, "typeof(button)", "'object'");

  add_actions(mo,
          "trace(button);"
          "dupl = MovieClip.prototype.duplicateMovieClip;"
          "button.dupl = dupl;"
          "o = { x: 4 };"
          "d = button.dupl('buttdup', 201, o);"
          );
  
  xcheck_equals(mo, "typeof(d)", "'object'");
  xcheck_equals(mo, "'' + _root.buttdup", "'_level0.buttdup'");
  check_equals(mo, "_root.buttdup", "d");
  
  /* initobj not used */
  check_equals(mo, "_root.buttdup.x", "undefined");
#endif

  add_actions(mo,
          "t = new Object();"
          "t.dupl = dupl;"
          "o2 = { x: 44 };"
          "d2 = t.dupl('objdup', 202, o2);"
          "trace(_root.objdup);"
          );

  /* Does not work on plain objects */
  check_equals(mo, "typeof(d2)", "'undefined'");
  check_equals(mo, "typeof(_root.objdup)", "'undefined'");

  SWFMovie_nextFrame(mo); /* 5th frame */

  check_equals(mo, "_root.x1", "2");
  check_equals(mo, "_root.x2", "3");
  check_equals(mo, "_root.x3", "2");  
  add_actions(mo, " _root.totals(); stop(); ");
  SWFMovie_nextFrame(mo); /* 5th frame */
  //Output movie
  puts("Saving " OUTPUT_FILENAME );
  SWFMovie_save(mo, OUTPUT_FILENAME);

  return 0;
}
Ejemplo n.º 26
0
int
main(int argc, char** argv)
{
  SWFMovie mo;
  SWFMovieClip  mc1, mc2, mc3, mc4, mc5, dejagnuclip;
  SWFDisplayItem it1, it2, it3, it4, it5;
  SWFShape  sh_red;

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

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

  dejagnuclip = get_dejagnu_clip((SWFBlock)get_default_font(srcdir), 10, 0, 0, 800, 600);
  SWFMovie_add(mo, (SWFBlock)dejagnuclip);
  add_actions(mo, " x2 += 'as_start+'; "
                  " _root.OnLoad = function () { _root.note('_root onLoad called'); x2 += 'load_called+'; }; "
                  " x2 += 'as_end+'; "
                  " _root.onEnterFrame = function () { x3 += 'enterFrame_called+'; }; ");
  SWFMovie_nextFrame(mo); /* 1st frame */

  
  mc1 = newSWFMovieClip();
  sh_red = make_fill_square (0, 300, 60, 60, 255, 0, 0, 255, 0, 0);
  SWFMovieClip_add(mc1, (SWFBlock)sh_red);  
  add_clip_actions(mc1, " _root.note('actions in 1st frame of mc1'); "
			// Defining onLoad in first frame of a sprite doesn't work, but works for root
			" this.onLoad = function() { _root.note('mc1 onLoad called'); _root.x1 += 'YY'; };"
                        " _root.x1 += '2+'; ");
  SWFMovieClip_nextFrame(mc1); /* mc1, 1st frame */
  add_clip_actions(mc1, " _root.note('actions in 2nd frame of mc1'); "
                        " _root.x1 += '12+'; "
                        " stop(); ");
  SWFMovieClip_nextFrame(mc1); /* mc1, 2nd frame */
 
  mc2 = newSWFMovieClip();
  sh_red = make_fill_square (80, 300, 60, 60, 255, 0, 0, 255, 0, 0);
  SWFMovieClip_add(mc2, (SWFBlock)sh_red); 
  add_clip_actions(mc2, " _root.note('actions in 1st frame of mc2'); "
			// Defining onLoad in first frame of a sprite doesn't work, but works for root
			" this.onLoad = function() { _root.note('mc2 onLoad called'); _root.x1 += 'XX'; };"
                        " _root.x1 += '4+'; "); 
  SWFMovieClip_nextFrame(mc2); /* mc2, 1st frame */
  add_clip_actions(mc2, " _root.note('actions in 2nd frame of mc2'); "
                        " _root.x1 += '10+'; "
                        " stop(); "); 
  SWFMovieClip_nextFrame(mc2); /* mc2, 2nd frame */
  
  mc3 = newSWFMovieClip();
  sh_red = make_fill_square (160, 300, 60, 60, 255, 0, 0, 255, 0, 0);
  SWFMovieClip_add(mc3, (SWFBlock)sh_red);  
  add_clip_actions(mc3, " _root.note('actions in 1st frame of mc3'); "
			// Defining onLoad in first frame of a sprite doesn't work, but works for root
			" this.onLoad = function() { _root.note('mc3 onLoad called'); _root.x1 += 'ZZ'; };"
                        " _root.x1 += '6+';"); 
  SWFMovieClip_nextFrame(mc3); /* mc3, 1st frame */
  add_clip_actions(mc3, " _root.note('actions in 2nd frame of mc3'); "
                        " _root.x1 += '8+'; "
                        " stop(); "); 
  SWFMovieClip_nextFrame(mc3); /* mc3, 2nd frame */
  
  
  /* add mc1 to _root and name it as "mc1" */
  it1 = SWFMovie_add(mo, (SWFBlock)mc1);  
  SWFDisplayItem_setDepth(it1, 10); 
  SWFDisplayItem_setName(it1, "mc1"); 
  /* Define Construct ClipEvent */
  SWFDisplayItem_addAction(it1,
    compileSWFActionCode(" _root.note('mc1 Construct called');"
                         " _root.x0 += '01+'; "),
    SWFACTION_CONSTRUCT);
  /* Define Load ClipEvent */
  SWFDisplayItem_addAction(it1,
    compileSWFActionCode(" _root.note('mc1 Load called');"
                         " _root.x1 += '1+'; "),
    SWFACTION_ONLOAD);
  /* Define Unload ClipEvent */
  SWFDisplayItem_addAction(it1,
    compileSWFActionCode(" _root.note('mc1 Unload called'); "
                         " _root.x1 += '13+'; "),
    SWFACTION_UNLOAD);
  /* Define EnterFrame ClipEvent */
  SWFDisplayItem_addAction(it1,
    compileSWFActionCode(" _root.note('mc1 EnterFrame called'); "
                         " _root.x1 += '11+'; "),
    SWFACTION_ENTERFRAME);
    
  /* add mc2 to _root and name it as "mc2" */
  it2 = SWFMovie_add(mo, (SWFBlock)mc2);  
  SWFDisplayItem_setDepth(it2, 12); 
  SWFDisplayItem_setName(it2, "mc2"); 
  /* Define Construct ClipEvent */
  SWFDisplayItem_addAction(it2,
    compileSWFActionCode(" _root.note('mc2 Construct called');"
                         " _root.x0 += '02+'; "),
    SWFACTION_CONSTRUCT);
  /* Define Load ClipEvent */
  SWFDisplayItem_addAction(it2,
    compileSWFActionCode(" _root.note('mc2 Load called'); "
                         " _root.x1 += '3+'; "),
    SWFACTION_ONLOAD);
  /* Define Unload ClipEvent */
  SWFDisplayItem_addAction(it2,
    compileSWFActionCode(" _root.note('mc2 Unload called'); "
                         " _root.x1 += '14+'; "),
    SWFACTION_UNLOAD);
  /* Define EnterFrame ClipEvent */
  SWFDisplayItem_addAction(it2,
    compileSWFActionCode(" _root.note('mc2 EnterFrame called'); "
                         " _root.x1 += '9+'; "),
    SWFACTION_ENTERFRAME);
    
  /* add mc3 to _root and name it as "mc3" */
  it3 = SWFMovie_add(mo, (SWFBlock)mc3);  
  SWFDisplayItem_setDepth(it3, 11); 
  SWFDisplayItem_setName(it3, "mc3"); 
  /* Define Construct ClipEvent */
  SWFDisplayItem_addAction(it3,
    compileSWFActionCode(" _root.note('mc3 Construct called');"
                         " _root.x0 += '03+'; "),
    SWFACTION_CONSTRUCT);
  /* Define Load ClipEvent */
  SWFDisplayItem_addAction(it3,
    compileSWFActionCode(" _root.note('mc3 Load called'); "
                         " _root.x1 += '5+'; "),
    SWFACTION_ONLOAD);
  /* Define Unload ClipEvent */
  SWFDisplayItem_addAction(it3,
    compileSWFActionCode(" _root.note('mc3 Unload called'); "
                         " _root.x1 += '15+';" ),
    SWFACTION_UNLOAD);
  /* Define EnterFrame ClipEvent */
  SWFDisplayItem_addAction(it3,
    compileSWFActionCode(" _root.note('mc3 EnterFrame called'); "
                         " _root.x1 += '7+'; "),
    SWFACTION_ENTERFRAME);
  
  add_actions(mo, " _root.x3 += '_root_frm2_as+'; ");
  SWFMovie_nextFrame(mo); /* 2nd frame */

  add_actions(mo, " _root.x3 += '_root_frm3_as+'; ");
  check_equals(mo, "_root.x3", "'enterFrame_called+_root_frm2_as+enterFrame_called+_root_frm3_as+'");
  SWFMovie_nextFrame(mo); /* 3rd frame */
  
  /* It's no use to change the order below.
  After compile, Ming will re-organize them as 
  remove mc1; remove mc2; remove mc3;*/
  SWFDisplayItem_remove(it3);  
  SWFDisplayItem_remove(it1);
  SWFDisplayItem_remove(it2);
  SWFMovie_nextFrame(mo); /* 4th frame */

  check_equals(mo, "_root.x0", "'01+02+03+'");
  check_equals(mo, "_root.x1", "'1+2+3+4+5+6+7+8+9+10+11+12+13+14+15+'");
  check_equals(mo, "_root.x2", "'as_start+as_end+load_called+'");
  add_actions(mo, " _root.totals(); stop(); ");
  SWFMovie_nextFrame(mo); /* 5th frame */
  
  
  //Output movie
  puts("Saving " OUTPUT_FILENAME );
  SWFMovie_save(mo, OUTPUT_FILENAME);

  return 0;
}
Ejemplo n.º 27
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;
}
Ejemplo n.º 28
0
int
main(int argc, char** argv)
{
  SWFMovie mo;
  SWFMovieClip  mc_red1, mc_red2, mc_red3, mc_red4, mc_red5, dejagnuclip;
  SWFDisplayItem it_red1, it_red2, it_red3, it_red4, it_red5;
  SWFShape  sh_red;

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

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

  dejagnuclip = get_dejagnu_clip((SWFBlock)get_default_font(srcdir), 10, 0, 0, 800, 600);
  SWFMovie_add(mo, (SWFBlock)dejagnuclip);
  SWFMovie_nextFrame(mo); /* 1st frame */

  
  mc_red1 = newSWFMovieClip();
  sh_red = make_fill_square (0, 300, 60, 60, 255, 0, 0, 255, 0, 0);
  SWFMovieClip_add(mc_red1, (SWFBlock)sh_red);  
  add_clip_actions(mc_red1, " _root.x1 += \"depth10+\"; ");
  SWFMovieClip_nextFrame(mc_red1); /* mc_red1, 1st frame */
  add_clip_actions(mc_red1, " _root.x2 += \"depth10+\"; stop(); ");
  SWFMovieClip_nextFrame(mc_red1); /* mc_red1, 2nd frame */
 
  mc_red2 = newSWFMovieClip();
  sh_red = make_fill_square (80, 300, 60, 60, 255, 0, 0, 255, 0, 0);
  SWFMovieClip_add(mc_red2, (SWFBlock)sh_red); 
  add_clip_actions(mc_red2, " _root.x1 += \"depth12+\"; "); 
  SWFMovieClip_nextFrame(mc_red2); /* mc_red2, 1st frame */
  add_clip_actions(mc_red2, " _root.x2 += \"depth12+\"; stop(); "); 
  SWFMovieClip_nextFrame(mc_red2); /* mc_red2, 2nd frame */
  
  mc_red3 = newSWFMovieClip();
  sh_red = make_fill_square (160, 300, 60, 60, 255, 0, 0, 255, 0, 0);
  SWFMovieClip_add(mc_red3, (SWFBlock)sh_red);  
  add_clip_actions(mc_red3, " _root.x1 += \"depth11+\"; "); 
  SWFMovieClip_nextFrame(mc_red3); /* mc_red3, 1st frame */
  add_clip_actions(mc_red3, " _root.x2 += \"depth11+\";  stop();"); 
  SWFMovieClip_nextFrame(mc_red3); /* mc_red3, 2nd frame */
  
  
  /* add mc_red1 to _root and name it as "mc_red1" */
  it_red1 = SWFMovie_add(mo, (SWFBlock)mc_red1);  
  SWFDisplayItem_setDepth(it_red1, 10); 
  SWFDisplayItem_setName(it_red1, "mc_red1"); 
  
  /* add mc_red2 to _root and name it as "mc_red2" */
  it_red2 = SWFMovie_add(mo, (SWFBlock)mc_red2);  
  SWFDisplayItem_setDepth(it_red2, 12); 
  SWFDisplayItem_setName(it_red2, "mc_red2"); 
  
  /* add mc_red3 to _root and name it as "mc_red3" */
  it_red3 = SWFMovie_add(mo, (SWFBlock)mc_red3);  
  SWFDisplayItem_setDepth(it_red3, 11); 
  SWFDisplayItem_setName(it_red3, "mc_red3"); 
  
  SWFMovie_nextFrame(mo); /* 2nd frame */

  /* Action order is not dependent on DisplayList depth here! */
  check_equals(mo, "_root.x1", "'depth10+depth12+depth11+'");
  SWFMovie_nextFrame(mo); /* 3rd frame */

  mc_red4 = newSWFMovieClip();
  sh_red = make_fill_square (240, 300, 60, 60, 255, 0, 0, 255, 0, 0);
  SWFMovieClip_add(mc_red4, (SWFBlock)sh_red);  
  add_clip_actions(mc_red4, " _root.x2 += \"depth9+\"; "); 
  SWFMovieClip_nextFrame(mc_red4); /* mc_red4, 1st frame */
  
   /* add mc_red4 to _root and name it as "mc_red4" */
  it_red4 = SWFMovie_add(mo, (SWFBlock)mc_red4);  
  SWFDisplayItem_setDepth(it_red4, 9); 
  SWFDisplayItem_setName(it_red4, "mc_red4"); 
  
  mc_red5 = newSWFMovieClip();
  sh_red = make_fill_square (240, 300, 60, 60, 255, 0, 0, 255, 0, 0);
  SWFMovieClip_add(mc_red5, (SWFBlock)sh_red);  
  add_clip_actions(mc_red5, " _root.x2 += \"depth13+\"; "); 
  SWFMovieClip_nextFrame(mc_red5); /* mc_red4, 1st frame */
  
  /* add mc_red5 to _root and name it as "mc_red5" */
  it_red5 = SWFMovie_add(mo, (SWFBlock)mc_red5);  
  SWFDisplayItem_setDepth(it_red5, 13); 
  SWFDisplayItem_setName(it_red5, "mc_red4"); 
  
  SWFMovie_nextFrame(mo); /* 4th frame */


  check_equals(mo, "_root.x2", "'depth11+depth12+depth10+depth9+depth13+'");
  add_actions(mo, " _root.totals(); stop(); ");
  SWFMovie_nextFrame(mo); /* 5th frame */
  
  
  //Output movie
  puts("Saving " OUTPUT_FILENAME );
  SWFMovie_save(mo, OUTPUT_FILENAME);

  return 0;
}
Ejemplo n.º 29
0
int
main(int argc, char** argv)
{
    SWFMovie mo;
    SWFMovieClip mc3, mc2, dejagnuclip;
    SWFAction ac, ac1, initac;
    SWFDisplayItem it;
    SWFShape sha;

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

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


    sha = newSWFShape();

    // Character ID 2. Has 1 showframe. Is exported first.
    mc2 = newSWFMovieClip();
    SWFMovieClip_add(mc2, (SWFBlock)sha);
    SWFMovieClip_nextFrame(mc2);

    // Export it.
    SWFMovie_addExport(mo, (SWFBlock)mc2, "C2");
    SWFMovie_writeExports(mo);

    // Main timeline actions for frame 1
    add_actions(mo, "var c = 0; var i = 0; trace('frame 1'); gotoAndStop(3);");
    initac = newSWFAction("trace('onInitialize'); _root.i++;");
    
    // ID 3 is defined here. It has no showframe. It is exported immediately.
    mc3 = newSWFMovieClip();
    SWFMovie_addExport(mo, (SWFBlock)mc3, "ctor");
    SWFMovie_writeExports(mo);

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

    // Init actions for ID 3. This only exists to create the constructor
    // for mc2 in its initactions.
    ac = newSWFAction(
    "   _global.ctor = function () {"
    "       super();"
    "       trace('Object ID 2 is constructed');"
    "       c += 1;"
    "   };"
    );
    SWFInitAction ia = newSWFInitAction_withId(ac, 3);
    SWFMovie_add(mo, (SWFBlock)ia);
    
    // Init actions for ID 2 (registered class)
    ac1 = newSWFAction("Object.registerClass('C2', ctor); "
            "trace('Registered class');");
    ia = newSWFInitAction_withId(ac1, 2);
    SWFMovie_add(mo, (SWFBlock)ia);
	
    
    // Frame 2
    SWFMovie_nextFrame(mo);
    add_actions(mo, "trace('Frame 2');");
    
    // Place object ID 2.
    it = SWFMovie_add(mo, (SWFBlock)mc2);
    SWFDisplayItem_setName(it, "mc2");
    SWFDisplayItem_addAction(it, initac, SWFACTION_INIT);

    // Frame 3
    SWFMovie_nextFrame(mo);

    // Remove object ID 2
    SWFMovie_remove(mo, it);

    add_actions(mo, "trace('frame 3');");
    
    // The class should not be constructed if the object is removed after
    // being placed. It should be constructed if it's not removed. MovieClips
    // with an onUnload handler are always constructed.
    check_equals(mo, "c", "0");
    check_equals(mo, "i", "0");
    check(mo, "_root.mc2 == undefined");
    add_actions(mo, "gotoAndPlay(5);");

    // Frame 4
    SWFMovie_nextFrame(mo);
    add_actions(mo, "trace('Frame 4');");
    
    // Place object ID 2 again
    it = SWFMovie_add(mo, (SWFBlock)mc2);
    SWFDisplayItem_setName(it, "mc2a");
    SWFDisplayItem_addAction(it, initac, SWFACTION_INIT);

    // Frame 5
    SWFMovie_nextFrame(mo);

    // This time the MovieClip was not removed before we get here,
    // so it should be present and the constructor should be
    // called.
    add_actions(mo, "trace('frame 5');");
    check_equals(mo, "c", "1");
    check_equals(mo, "i", "1");
    check(mo, "typeof(_root.mc2a) == 'movieclip'");
    add_actions(mo, "stop();");

    SWFMovie_nextFrame(mo);
  
    puts("Saving " OUTPUT_FILENAME );
    SWFMovie_save(mo, OUTPUT_FILENAME);

    return 0;
}
Ejemplo n.º 30
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;
}