Ejemplo n.º 1
0
int main()
{
	int i;
	SWFMovie m = newSWFMovieWithVersion(8);

	SWFShape shape1 = newSWFShape();
	SWFShape shape2 = newSWFShape();
	
	SWFShape_setLine2(shape1, 1, 25, 0, 0, 128, SWF_LINESTYLE_FLAG_HINTING, 0);
	SWFShape_movePenTo(shape1, 5, 5);
        SWFShape_drawLineTo(shape1, 50, 30);

	SWFShape_setLine2(shape2, 1, 25, 100, 100, 255, SWF_LINESTYLE_FLAG_HINTING, 0);
	SWFShape_movePenTo(shape2, 5, 5);
        SWFShape_drawLineTo(shape2, 50, 130);

	SWFDisplayItem item = SWFMovie_add(m, shape1);
	SWFMovie_nextFrame(m);
	SWFMovie_replace(m, item, shape2);
	SWFMovie_nextFrame(m);

	SWFMovie_save(m,"test01.swf");

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