예제 #1
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;
}
예제 #2
0
int
main(int argc, char** argv)
{
  SWFMovie mo;
  SWFMovieClip  mc1, mc2, dejagnuclip;
  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();
  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, " _root.x = '0+'; ");
  SWFMovie_nextFrame(mo); /* 1st frame */


  mc1 = newSWFMovieClip();
  sh1 = make_fill_square (300, 300, 60, 60, 255, 0, 0, 255, 0, 0);
  SWFMovieClip_add(mc1, (SWFBlock)sh1);
  /* add init actions */
  add_clip_init_actions(mc1, " _root.note('mc1.init_actions'); "
                             " _root.x += '1+'; " 
                             " y = 'var_of_root'; " );

  /* add actions */
  add_clip_actions(mc1, " _root.note('mc1.actions');  _root.x += '9+'; ");
  SWFMovieClip_nextFrame(mc1);//1st frame

  mc2 = newSWFMovieClip();
  sh2 = make_fill_square (600, 600, 60, 60, 255, 0, 0, 255, 0, 0);
  SWFMovieClip_add(mc2, (SWFBlock)sh2);
  /* add init actions */
  add_clip_init_actions(mc2, " _root.note('mc2.init_actions'); _root.x += '3+'; ");
  /* add actions */
  add_clip_actions(mc2, " _root.note('mc2.actions');  _root.x += '11+'; ");
  SWFMovieClip_nextFrame(mc2);//1st frame
  

  /* add mc1 to _root */
  SWFDisplayItem it1;
  it1 = SWFMovie_add(mo, (SWFBlock)mc1);
  SWFDisplayItem_setDepth(it1, 10);
  SWFDisplayItem_setName(it1, "mc1");

  SWFDisplayItem_addAction(it1,
    newSWFAction(" _root.note('mc1.onClipInitialize'); _root.x += '2+'; "
	"_root.check_equals(this.__proto__, MovieClip.prototype);"
	),
    SWFACTION_INIT);
    
  SWFDisplayItem_addAction(it1,
    newSWFAction(" _root.note('mc1.onClipConstruct');  _root.x += '5+'; "),
    SWFACTION_CONSTRUCT);
    
  SWFDisplayItem_addAction(it1,
    newSWFAction(" _root.note('mc1.onClipLoad');  _root.x += '8+'; "),
    SWFACTION_ONLOAD);


  /* add mc2 to _root */
  SWFDisplayItem it2;
  it2 = SWFMovie_add(mo, (SWFBlock)mc2);
  SWFDisplayItem_setDepth(it2, 11);
  SWFDisplayItem_setName(it2, "mc2");
 
   SWFDisplayItem_addAction(it2,
    newSWFAction(" _root.note('mc2.onClipInitialize'); _root.x += '4+'; "),
    SWFACTION_INIT);
    
  SWFDisplayItem_addAction(it2,
    newSWFAction(" _root.note('mc2.onClipConstruct');  _root.x += '6+'; "),
    SWFACTION_CONSTRUCT);
    
  SWFDisplayItem_addAction(it2,
    newSWFAction(" _root.note('mc2.onClipLoad');  _root.x += '10+'; "),
    SWFACTION_ONLOAD);
    
    
  /* add main timeline actions */
  add_actions(mo, "_root.note('_root.actions');  _root.x += '7+'; ");
  SWFMovie_nextFrame(mo); /* 2nd frame */

  /* The check below used to succeeds, and started failing when
   * executing init actions "after" DLIST tags.
   * Should be fixed if we postpone the call to ::construct
   * to "after" init actions are executed, which would require
   * some book keeping in sprite_instance class
   */
  check_equals(mo, "_root.x", "'0+1+2+3+4+5+6+7+8+9+10+11+'");

  check_equals(mo, "_root.y", "'var_of_root'");
  add_actions(mo, " _root.totals(); stop(); ");
  SWFMovie_nextFrame(mo); /* 3rd frame */
  

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

  return 0;
}
예제 #3
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;
}
예제 #4
0
int
main(int argc, char** argv)
{
  SWFMovie mo;
  SWFMovieClip  mc1, mc2, dejagnuclip;
  SWFShape  sh1, sh2;
  SWFDisplayItem it1, it2;
  
  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, "testvar1 = 0; testvar2 = 0;");
  SWFMovie_nextFrame(mo); // frame1
  
  //
  // Define movieClips
  //
  mc1 = newSWFMovieClip();
  sh1 = make_fill_square (100, 100, 60, 60, 255, 0, 0, 255, 0, 0);
  SWFMovieClip_add(mc1, (SWFBlock)sh1);  
  SWFMovieClip_nextFrame(mc1);
  
  mc2 = newSWFMovieClip();
  sh2 = make_fill_square (300, 100, 60, 60, 255, 0, 0, 0, 255, 0);
  SWFMovieClip_add(mc2, (SWFBlock)sh2);  
  SWFMovieClip_nextFrame(mc2);
    
  SWFMovie_nextFrame(mo); // frame2

  //
  // Place mc1 at depth 3, place mc1 at depth3 again with a different name;
  // Observed behaviour:  later place does not create a new DisplayObject
  //
  it1 = SWFMovie_add(mo, (SWFBlock)mc1);  
  SWFDisplayItem_setDepth(it1, 3); 
  SWFDisplayItem_setName(it1, "static_mc1");
  SWFDisplayItem_addAction(it1,
    newSWFAction(" _root.testvar1++; trace(this); trace(_root.testvar1); "),
    SWFACTION_INIT | SWFACTION_CONSTRUCT | SWFACTION_ONLOAD);  
  
  it2 = SWFMovie_add(mo, (SWFBlock)mc2); 
  SWFDisplayItem_setDepth(it2, 3); 
  SWFDisplayItem_setName(it2, "static_mc2");
  SWFDisplayItem_addAction(it2,
    newSWFAction(" _root.testvar2++; trace(this); trace(_root.testvar2); "),
    SWFACTION_INIT | SWFACTION_CONSTRUCT | SWFACTION_ONLOAD); 
  
  check_equals(mo, "typeof(static_mc1)", "'movieclip'");
  if(OUTPUT_VERSION > 5)
  {
    // check that "static_mc2" doesn't get placed
    check_equals(mo, "typeof(static_mc2)", "'undefined'");
  }
  else
  {
    // check that "static_mc2" does get placed
    check_equals(mo, "typeof(static_mc2)", "'movieclip'");
  }
  SWFMovie_nextFrame(mo); // frame3
  
  if(OUTPUT_VERSION > 5)
  {
    check_equals(mo, "testvar1", "3");
    check_equals(mo, "testvar2", "0");
  }
  else
  {
    // swf5 does not support CONSTRUCT event
    check_equals(mo, "testvar1", "2");
    check_equals(mo, "testvar2", "2");
  }
  
  //
  // Place mc2 at depth 3 again.
  // Observed behaviour: no new DisplayObject gets created
  //
  it2 = SWFMovie_add(mo, (SWFBlock)mc2); 
  SWFDisplayItem_setDepth(it2, 3); 
  SWFDisplayItem_setName(it2, "static_mc3");
  
  check_equals(mo, "typeof(static_mc1)", "'movieclip'");
  if(OUTPUT_VERSION > 5)
  {
    // check that "static_mc3" doesn't get placed
    check_equals(mo, "typeof(static_mc3)", "'undefined'");
  }
  else
  {
    // check that "static_mc3" does get placed
    check_equals(mo, "typeof(static_mc3)", "'movieclip'");
  }
  SWFMovie_nextFrame(mo); // frame4
  
  //
  // Place mc1 at depth 3 again with ratio set to 0.2
  // Observed behaviour: no new DisplayObject get placed(created).
  //
  it2 = SWFMovie_add(mo, (SWFBlock)mc1); 
  SWFDisplayItem_setDepth(it2, 3); 
  SWFDisplayItem_setName(it2, "static_mc4");
  SWFDisplayItem_setRatio(it2, 0.2); 
  
  check_equals(mo, "typeof(static_mc1)", "'movieclip'");
  if(OUTPUT_VERSION > 5)
  {
    // check that "static_mc4" doesn't get placed.
    check_equals(mo, "typeof(static_mc4)", "'undefined'");
  }
  else
  {
    // check that "static_mc4" does get placed.
    check_equals(mo, "typeof(static_mc4)", "'movieclip'");
  }
  SWFMovie_nextFrame(mo); // frame5
  
  //
  // Place mc2 at depth 3 again with ratio set to 0.2
  // Observed behaviour: no new DisplayObject get placed(created).
  //
  it2 = SWFMovie_add(mo, (SWFBlock)mc2); 
  SWFDisplayItem_setDepth(it2, 3); 
  SWFDisplayItem_setName(it2, "static_mc5");
  SWFDisplayItem_setRatio(it2, 0.2); 
  
  check_equals(mo, "typeof(static_mc1)", "'movieclip'");
  if(OUTPUT_VERSION > 5)
  {
    // check that "static_mc5" doesn't get placed.
    check_equals(mo, "typeof(static_mc5)", "'undefined'");
  }
  else
  {
    // check that "static_mc5" does get placed.
    check_equals(mo, "typeof(static_mc5)", "'movieclip'");
  }
  SWFMovie_nextFrame(mo); // frame6
  
  
  //
  // Odd, where are the movieclips now?
  // Note that all those movieclips are defined above but not now.
  //
  if(OUTPUT_VERSION <= 5)
  {
    add_actions(mo, 
      "check_equals(typeof(static_m1), 'undefined');"
      "check_equals(typeof(static_m2), 'undefined');"
      "check_equals(typeof(static_m3), 'undefined');"
      "check_equals(typeof(static_m4), 'undefined');"
      "check_equals(typeof(static_m5), 'undefined');"
      );
  }
  add_actions(mo, " _root.totals(); stop(); ");
  SWFMovie_nextFrame(mo); // frame7  
  
  //Output movie
  puts("Saving " OUTPUT_FILENAME );
  SWFMovie_save(mo, OUTPUT_FILENAME);

  return 0;
}
예제 #5
0
/// This test checks the event order of key events.
//
/// Known listeners are:
/// 1. MovieClips with a defined key event
/// 2. Button with a defined key event
/// 3. Anything added to Key listeners in ActionScript.
//
/// The test adds objects in this order:
//
/// Frame 1:
/// 1. mc1
/// 3. button1 (responds to 'a')
/// 3. o1 (actionscript key listener object)
/// 4. mc2
///
/// Frame 2:
/// 5. button2 (responds to 'a')
/// 6. button3 (responds to 'b')
/// 3. o2 (actionscript key listener object)
//
/// The test shows that, irrespective of construction order:
/// 1. MovieClips are notified first
/// 2. ActionScript listeners are notified second.
/// 3. Buttons are notified last.
//
/// Additionally:
//
/// 1. Only one button action can respond to any key.
int
main(int argc, char** argv)
{
  SWFMovie mo;
  SWFMovieClip mc, dejagnuclip;
  SWFButtonRecord br;
  SWFButton bu;
  SWFDisplayItem it1, it, 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();
  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);

  add_actions(mo,
          "_root.order = '';"
          "_root.note('Press \"a\" then \"b\"');"
          "_root.note('Do not press any other keys!');"
          );

  mc = newSWFMovieClip();
  it = SWFMovie_add(mo, (SWFBlock)mc);
  SWFDisplayItem_setName(it, "mc1");
  SWFDisplayItem_addAction(it,
          newSWFAction("trace('mc1'); _root.order += 'mc1,';"),
          SWFACTION_KEYDOWN);

  bu = newSWFButton();
  
  sh1 = make_fill_square(200, 0, 40, 40, 0, 0, 0, 0, 0, 0);
  sh2 = make_fill_square(200, 0, 40, 40, 0, 0, 0, 0, 255, 0);

  br = SWFButton_addCharacter(bu, (SWFCharacter)sh1, SWFBUTTON_HIT);
  SWFButtonRecord_setDepth(br, 3);
  
  br = SWFButton_addCharacter(bu, (SWFCharacter)sh1, SWFBUTTON_UP);
  SWFButtonRecord_setDepth(br, 4);

  br = SWFButton_addCharacter(bu, (SWFCharacter)sh2, SWFBUTTON_OVER);
  SWFButtonRecord_setDepth(br, 5);

  SWFButton_addAction(bu,
          newSWFAction("trace('button1'); _root.order += 'button1,';"),
		  SWFBUTTON_KEYPRESS('a'));

  it1 = SWFMovie_add(mo, (SWFBlock)bu);
  SWFDisplayItem_setName(it, "button1");

  SWFMovie_add(mo, newSWFAction(
              "o1 = {};"
              "o1.onKeyDown = function() {"
              "    trace('o1'); "
              "    _root.order += 'o1,';"
              "};"
              "Key.addListener(o1);"
              ));

  mc = newSWFMovieClip();
  it = SWFMovie_add(mo, (SWFBlock)mc);
  SWFDisplayItem_setName(it, "mc2");
  SWFDisplayItem_addAction(it,
          newSWFAction("trace('mc2'); _root.order += 'mc2,';"),
          SWFACTION_KEYDOWN);

  SWFMovie_nextFrame(mo); // Frame 2

  bu = newSWFButton();
  
  sh1 = make_fill_square(240, 0, 40, 40, 0, 0, 0, 0, 0, 0);
  sh2 = make_fill_square(240, 0, 40, 40, 0, 0, 0, 0, 255, 0);

  br = SWFButton_addCharacter(bu, (SWFCharacter)sh1, SWFBUTTON_HIT);
  SWFButtonRecord_setDepth(br, 3);
  
  br = SWFButton_addCharacter(bu, (SWFCharacter)sh1, SWFBUTTON_UP);
  SWFButtonRecord_setDepth(br, 4);

  br = SWFButton_addCharacter(bu, (SWFCharacter)sh2, SWFBUTTON_OVER);
  SWFButtonRecord_setDepth(br, 5);

  SWFButton_addAction(bu,
          newSWFAction("trace('button2'); _root.order += 'button2,';"),
		  SWFBUTTON_KEYPRESS('a'));

  it2 = SWFMovie_add(mo, (SWFBlock)bu);
  SWFDisplayItem_setName(it, "button2");
  
  bu = newSWFButton();
  
  sh1 = make_fill_square(280, 0, 40, 40, 0, 0, 0, 0, 0, 0);
  sh2 = make_fill_square(280, 0, 40, 40, 0, 0, 0, 0, 255, 0);

  br = SWFButton_addCharacter(bu, (SWFCharacter)sh1, SWFBUTTON_HIT);
  SWFButtonRecord_setDepth(br, 3);
  
  br = SWFButton_addCharacter(bu, (SWFCharacter)sh1, SWFBUTTON_UP);
  SWFButtonRecord_setDepth(br, 4);

  br = SWFButton_addCharacter(bu, (SWFCharacter)sh2, SWFBUTTON_OVER);
  SWFButtonRecord_setDepth(br, 5);

  SWFButton_addAction(bu,
          newSWFAction(
              "trace('button3'); "
              "_root.order += 'button3,';"
              "play();"
              ),
		  SWFBUTTON_KEYPRESS('b'));

  it = SWFMovie_add(mo, (SWFBlock)bu);
  SWFDisplayItem_setName(it, "button3");
  
  SWFMovie_add(mo, newSWFAction(
              "o2 = {};"
              "o2.onKeyDown = function() {"
              "    trace('o2'); "
              "    _root.order += 'o2,';"
              "};"
              "Key.addListener(o2);"
              "stop();"
              ));

  SWFMovie_nextFrame(mo);

  xcheck_equals(mo, "_root.order",
          "'mc2,mc1,o1,o2,button1,mc2,mc1,o1,o2,button3,'");
  
  SWFMovie_nextFrame(mo);

  SWFDisplayItem_remove(it2);
  
  add_actions(mo,
          "_root.order = '';"
          "_root.note('Press \"a\" then \"b\" again');"
          "_root.note('Do not press any other keys!');"
          "stop();"
          );
  SWFMovie_nextFrame(mo);

  // Check that removing the second button associated with 'a' does not
  // remove the key trigger for button2. There's no reason to think it should,
  // but it could happen if it's implemented badly!
  check_equals(mo, "_root.order",
          "'mc2,mc1,o1,o2,button1,mc2,mc1,o1,o2,button3,'");

  SWFMovie_add(mo, newSWFAction("stop();"));

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

  return 0;
}
예제 #6
0
int
main(int argc, char** argv)
{
  SWFMovie mo;
  SWFMovieClip dejagnuclip, static3;
  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);

  static3 = get_static_mc(20, 20);

  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 a static DisplayObject at depth 3 (-16381)
  it1 = SWFMovie_add(mo, (SWFBlock)static3);
  SWFDisplayItem_setDepth(it1, 3);
  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);
  SWFMovie_nextFrame(mo); 

  // Frame 3: remove DisplayObject at depth -16381 
  SWFDisplayItem_remove(it1);
  add_actions(mo, "check_equals(typeof(static1), 'undefined');"); // the replacement failed
  SWFMovie_nextFrame(mo); 
 
  // Frame 4: place same static DisplayObject at depth 3 (-16381)
  it1 = SWFMovie_add(mo, (SWFBlock)static3);
  SWFDisplayItem_setDepth(it1, 3);
  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);

  // Frame 5: jump to frame 2, stop and check
  add_actions(mo,
    "check_equals(typeof(static1), 'undefined');"
    "check_equals(typeof(static2), 'movieclip');"

    "gotoAndStop(2); " 

    // two instances were placed in total, the second instance is not
    // supposed to be removed on jump back, being on a depth supposed
    // to contain a timeline instance at that time
    // Gnash fails here by removing the instance placed in a later frame
    "check_equals(_root.depth3Constructed, 2);"

    // Gnash fails here by removing the instance placed in a later frame
    "check_equals(typeof(static1), 'undefined');"

    // Gnash fails here by removing the instance placed in a later frame
    // (thus placing a new instance)
    "check_equals(typeof(static2), 'movieclip');"

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

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

  return 0;
}
예제 #7
0
int
main(int argc, char** argv)
{
    SWFMovie mo;
    const char *srcdir=".";
    SWFMovieClip  dejagnuclip;

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

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

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

    sprintf(loadvars, "e = l.load('%s/vars2.txt');", srcdir);
    sprintf(loademptyvars, "e = l.load('%s/empty.txt');", srcdir);
    puts("Setting things up");

    Ming_init();
    Ming_useSWFVersion (OUTPUT_VERSION);
    Ming_setScale(20.0); /* let's talk pixels */

    mo = newSWFMovie();
    SWFMovie_setRate(mo, 12);
    SWFMovie_setDimension(mo, 640, 400);

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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


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

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

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

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

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


    /// End of tests.

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

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

   puts("Saving " OUTPUT_FILENAME );

   SWFMovie_save(mo, OUTPUT_FILENAME);

   return 0;
}
예제 #8
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;
}
예제 #9
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, '/');"
		"};"
		);

	check_equals(mo, "typeof(square1.button)", "'object'");
	check(mo, "square1.button instanceOf Button");
	check_equals(mo, "typeof(square1.button.useHandCursor)", "'boolean'");
	check_equals(mo, "square1.button.useHandCursor", "true");

	//
	// 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.\n   The cursor should turn to an hand while on the square."
		"');");

	/* 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(164);"
			"_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;
}
예제 #10
0
int
main(int argc, char** argv)
{
  SWFMovie mo;
  const char *srcdir=".";
  char fdbfont[256];
  SWFMovieClip  dejagnuclip;
  
  SWFDisplayItem it;

  /*********************************************
   *
   * 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);
 
  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
   *
   *********************************************/
  SWFBrowserFont bfont = newSWFBrowserFont("_sans");

  int y = 30;
  int inc = 30;

  it = add_text_field(mo, (SWFBlock)bfont, "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)bfont, "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)bfont, "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)bfont, "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)bfont, "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)bfont, "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)bfont, "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)bfont, "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)bfont, "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)bfont, "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)bfont, "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)bfont, "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");


  // As these are device fonts, it's not clear how consistent the textWidth
  // value will be. It's not even clear that it's worth testing it.

  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", "24");
  // Approx 42
  xcheck(mo, "tf1.textWidth >= 40 && tf1.textWidth <= 45");

  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", "24");
  // Approx 69
  xcheck(mo, "tf2.textWidth >= 66 && tf2.textWidth <= 72");

  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", "24");
  // Approx 13
  xcheck(mo, "tf3.textWidth >= 11 && tf3.textWidth <= 15");

  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", "24");
  // Approx 9
  xcheck(mo, "tf4.textWidth >= 7 && tf4.textWidth <= 11");

  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", "24");
  // Approx 10
  xcheck(mo, "tf5.textWidth >= 8 && tf5.textWidth <= 12");

  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", "24");
  // Approx 11
  xcheck(mo, "tf6.textWidth >= 9 && tf6.textWidth <= 13");

  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", "24");
  // Approx 14
  xcheck(mo, "tf7.textWidth >= 14 && tf7.textWidth <= 16");

  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", "24");
  // Approx 25
  xcheck(mo, "tf8.textWidth >= 21 && tf8.textWidth <= 27");

  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", "24");
  // Approx 16
  xcheck(mo, "tf9.textWidth >= 14 && tf9.textWidth <= 18");

  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", "24");
  // Approx 452
  xcheck(mo, "tf10.textWidth >= 440 && tf10.textWidth <= 460");

  // 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");
  add_actions(mo, "trace(tf11.textWidth);");
  xcheck(mo, "tf11.textHeight >= 23 && tf11.textHeight <= 24");
  // Approx 315
  xcheck(mo, "tf11.textWidth >= 305 && tf11.textWidth <= 325");

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

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

  SWFMovie_nextFrame(mo); 

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

  SWFMovie_save(mo, OUTPUT_FILENAME);

  return 0;
}
예제 #11
0
파일: loop_test10.c 프로젝트: diocles/gnash
int
main(int argc, char** argv)
{
  SWFMovie mo;
  SWFDisplayItem it1, it2, it3;
  SWFDisplayItem it41;
  SWFDisplayItem it51;
  SWFMovieClip mc1, mc2, mc3, dejagnuclip;
  SWFMovieClip mc4, mc41;
  SWFMovieClip mc5, mc51;
  SWFShape  sh1, sh2, sh3;

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

  dejagnuclip = get_dejagnu_clip((SWFBlock)get_default_font(srcdir), 10, 0, 0, 800, 600);
  SWFMovie_add(mo, (SWFBlock)dejagnuclip);
  add_actions(mo, " haslooped1=false; haslooped2=false; haslooped3=false;"
                  " mc1Initialized=0; mc1Unloaded=0;"
                  " mc2Initialized=0; mc2Unloaded=0;"
                  " mc3Initialized=0; mc3Unloaded=0;"
                  " asOrder='0+';");
  SWFMovie_nextFrame(mo); // frame1


  sh1 = make_fill_square (100, 100, 60, 60, 255, 0, 0, 255, 0, 0);
  mc1 = newSWFMovieClip();
  SWFMovieClip_add(mc1, (SWFBlock)sh1); 
  SWFMovieClip_nextFrame(mc1);
  
  sh2 = make_fill_square (200, 200, 60, 60, 0, 0, 0, 0, 0, 0);
  mc2 = newSWFMovieClip();
  SWFMovieClip_add(mc2, (SWFBlock)sh2);  
  SWFMovieClip_nextFrame(mc2); 

  sh3 = make_fill_square (300, 300, 60, 60, 0, 0, 0, 0, 0, 0);
  mc3 = newSWFMovieClip();
  SWFMovieClip_add(mc3, (SWFBlock)sh3);  
  SWFMovieClip_nextFrame(mc3); 
 
  it1 = SWFMovie_add(mo, (SWFBlock)mc1);  
  SWFDisplayItem_setName(it1, "mc1"); 
  SWFDisplayItem_setDepth(it1, 100); 
  SWFDisplayItem_addAction(it1, newSWFAction(
        "_root.note(this+' initialized');"
        "_root.mc1Initialized++;"
        "_root.asOrder += '1+';"
        ), SWFACTION_INIT); 
  SWFDisplayItem_addAction(it1, newSWFAction(
        "_root.note(this+' unloaded');"
        "_root.mc1Unloaded++;"
        "_root.asOrder += '3+';"
        ), SWFACTION_UNLOAD);
  SWFMovie_nextFrame(mo); // frame2
  
    
  SWFDisplayItem_remove(it1);
  it2 = SWFMovie_add(mo, (SWFBlock)mc2); 
  SWFDisplayItem_setName(it2, "mc2"); 
  SWFDisplayItem_setRatio(it2, 0.1); 
  SWFDisplayItem_setDepth(it2, 100); 
  SWFDisplayItem_addAction(it2, newSWFAction(
        "_root.note(this+' initialized');"
        "_root.mc2Initialized++;"
        "_root.asOrder += '2+';"
        ), SWFACTION_INIT);
  SWFDisplayItem_addAction(it2, newSWFAction(
        "_root.note(this+' unloaded');"
        "_root.mc2Unloaded++;"
        "_root.asOrder += '5+';"
        ), SWFACTION_UNLOAD);
  SWFMovie_nextFrame(mo);  // frame3


  SWFDisplayItem_remove(it2);
  it3 = SWFMovie_add(mo, (SWFBlock)mc3); 
  SWFDisplayItem_setName(it3, "mc3"); 
  SWFDisplayItem_setRatio(it3, 0.2); 
  SWFDisplayItem_setDepth(it3, 100); 
  SWFDisplayItem_addAction(it3, newSWFAction(
        "_root.note(this+' initialized');"
        "_root.mc3Initialized++;"
        "_root.asOrder += '4+';"
        ), SWFACTION_INIT);
  SWFDisplayItem_addAction(it3, newSWFAction(
        "_root.note(this+' unloaded');"
        "_root.mc3Unloaded++;"
        ), SWFACTION_UNLOAD);
  SWFMovie_nextFrame(mo);  // frame4


  SWFMovie_nextFrame(mo);  // frame 5

  
  add_actions(mo, "if(! haslooped1) {"
                  "   gotoAndPlay(5);"
                  "   haslooped1 = true;"
                  "}" );
  SWFMovie_nextFrame(mo);  // frame 6
  
  
  check_equals(mo, "mc1Initialized", "2");
  check_equals(mo, "mc2Initialized", "2");
  check_equals(mo, "mc3Initialized", "1");
  check_equals(mo, "mc1Unloaded", "2");
  check_equals(mo, "mc2Unloaded", "2");
  check_equals(mo, "mc3Unloaded", "0");
  
  xcheck_equals(mo, "asOrder", "'0+1+2+3+4+5+1+2+3+5+'");
  SWFMovie_nextFrame(mo);  // frame 7
  
  //
  // ==case 2==
  //
  mc4 = newSWFMovieClip();
    mc41 = newSWFMovieClip(); 
    SWFMovieClip_nextFrame(mc41);
    
    it41 = SWFMovieClip_add(mc4, (SWFBlock)mc41); 
    add_clip_actions(mc4, 
        "_root.check_equals(this._target, '/instance3');"
        "inst = this.getInstanceAtDepth(-16383);"
        "if(! haslooped2) {"
        "   haslooped2 = true;"
        "   _root.check_equals(inst._target, '/instance3/instance4');"
        "} else {"
        "   _root.check_equals(inst._target, '/instance3/instance5');"
        "   stop();"
        "}"
   );
  SWFMovieClip_nextFrame(mc4);
    SWFDisplayItem_remove(it41);
  SWFMovieClip_nextFrame(mc4);  
  
  SWFMovie_add(mo, mc4);
  SWFMovie_nextFrame(mo);  // frame 9
  
  SWFMovie_nextFrame(mo);  // frame 10
  
  //
  // ==case 3==
  //
  mc5 = newSWFMovieClip();
    mc51 = newSWFMovieClip(); 
    SWFMovieClip_nextFrame(mc51);
    
    it51 = SWFMovieClip_add(mc5, (SWFBlock)mc51); 
    add_clip_actions(mc5, 
        "_root.check_equals(this._target, '/instance6');"
        "inst = this.getInstanceAtDepth(-16383);"
        "if(! haslooped3) {"
        "   haslooped3 = true;"
        "   _root.check_equals(inst._target, '/instance6/instance7');"
        "} else {"
        "   _root.check_equals(inst._target, '/instance6/instance7');"
        "   stop();"
        "}"
   );
  SWFMovieClip_nextFrame(mc5);
  SWFMovieClip_nextFrame(mc5); 
  
  SWFMovie_add(mo, mc5);
  SWFMovie_nextFrame(mo);  // frame 11
  
  SWFMovie_nextFrame(mo);  // frame 12
  
  SWFMovie_nextFrame(mo);  // frame 13
  
  mc5 = newSWFMovieClip();
  add_clip_actions(mc5, "_root.check_equals(this._target, '/instance9');");
  SWFMovieClip_nextFrame(mc5);
  
  SWFMovie_add(mo, mc5);
  SWFMovie_nextFrame(mo);  // frame 14
  
  add_actions(mo, "totals(16); stop();");
  SWFMovie_nextFrame(mo);  // frame 15
  //Output movie
  puts("Saving " OUTPUT_FILENAME );
  SWFMovie_save(mo, OUTPUT_FILENAME);

  return 0;
}
예제 #12
0
파일: loop_test4.c 프로젝트: diocles/gnash
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;");
  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) 
  //   Place an empty dynamic movieClip4 DisplayObject at depth4 (-16380)
  //

  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);
  
  add_actions(mo, "_root.createEmptyMovieClip('movieClip4', -16380);");
  
  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");
  
  SWFMovie_add(mo, (SWFBlock)newSWFAction( "gotoAndStop(3);"));
  
  check_equals(mo, "typeof(movieClip1)", "'movieclip'");
  check_equals(mo, "typeof(movieClip2)", "'movieclip'");
  check_equals(mo, "typeof(movieClip3)", "'undefined'");
  check_equals(mo, "typeof(movieClip4)", "'undefined'");
  check_equals(mo, "_root.mc1Constructed", "2");
  check_equals(mo, "_root.mc2Constructed", "2");
  check_equals(mo, "_root.mc3Constructed", "1");
  
  SWFMovie_add(mo, (SWFBlock)newSWFAction( "totals(); stop();" ));
  SWFMovie_nextFrame(mo);

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

  return 0;
}
예제 #13
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: move DisplayObject at depth 3 to position 200,200
	SWFDisplayItem_moveTo(it1, 200, 200); 
	add_actions(mo,
		"check_equals(static3.myThing, 'guess');"
		"check_equals(static3._x, 200);"
		"check_equals(static3.getDepth(), -16381);" 
		);
	SWFMovie_nextFrame(mo); 

	// Frame 6: change depth DisplayObject at depth 3 to depth 10 (dynamic zone)
	add_actions(mo,
		"static3.swapDepths(10);"
		"check_equals(static3.getDepth(), 10);" 
		"static3._rotation = 45;"
		"check_equals(static3.myThing, 'guess');"
		);
	SWFMovie_nextFrame(mo); 

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

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

		// Store a reference to the static3 instance
		// before overriding its name
		"dynRef = static3;"

		// this repopulates depth -16381 with a *new* instance 
		"gotoAndStop(4);"

		"note('right after gotoAndStop()');"

		// static3 doesn't refer to the dynamic object anymore !
		"check_equals(typeof(static3.myThing), 'undefined');"

		// but the reference still does !!
		// Gnash fails here due to it's implementation of "soft references"
		// ... argh ...
		// TODO: use a MovieTester based test runner to check for actual
		//       existance of the old (dynamicized) instance by looking
		//       at the real DisplayList and at the rendered buffer
		//
		"check_equals(dynRef.myThing, 'guess');"
		"check_equals(dynRef.getDepth(), 10);" 

		// Luckly we can query for depth chars with getInstanceAtDepth
		"check_equals(typeof(getInstanceAtDepth(-16381)), 'movieclip');"
		"check_equals(typeof(getInstanceAtDepth(10)), 'movieclip');"

		"check_equals(static3.getDepth(), -16381);" 
		"check_equals(static3._x, 50);" 
		"check_equals(depth3Constructed, 2);" 
		"totals();"
		);
	SWFMovie_nextFrame(mo); 

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

	return 0;
}
예제 #14
0
int
main(int argc, char** argv)
{
  SWFMovie mo;
  SWFMovieClip  mc1, mc11, mc2, dejagnuclip;
  SWFDisplayItem it1, it11, it2;

  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 

  /* add mc1, mc2 to the main movie */  
      
  mc1 = newSWFMovieClip();
  mc11 = newSWFMovieClip();
  SWFMovieClip_nextFrame(mc11); 
  it11 = SWFMovieClip_add(mc1, (SWFBlock)mc11);  
  SWFDisplayItem_setDepth(it11, 10); 
  SWFDisplayItem_setName(it11, "mc11"); 
  SWFMovieClip_nextFrame(mc1); 

  add_clip_actions(mc1, 
    "duplicateMovieClip('mc11', 'dup_ch1', 1);"
    "_root.check_equals(typeof(dup_ch1), 'movieclip');"
    
    "duplicateMovieClip('/_root/mc1/mc11', 'dup_ch2', 2);"
    "_root.check_equals(typeof(dup_ch2), 'movieclip');"
    
    "duplicateMovieClip('/:_root/:mc1/:mc11', 'dup_ch3', 3);"
    "_root.check_equals(typeof(dup_ch3), 'movieclip');"
    
    "duplicateMovieClip('mc2', 'dup_ch4', 4);"
    // can not duplicate a movie clip in a different time
    "_root.check_equals(typeof(dup_ch4), 'undefined');"
    
    "duplicateMovieClip('/:mc2', 'dup_ch5', 5);"
    // can not duplicate a movie clip in a different time
    "_root.check_equals(typeof(dup_ch5), 'undefined');"
    
    // Don't do this, duplicate a self-clip will crash the proprietary player"
    // "duplicateMovieClip('/:mc1', 'dup_ch6', 6);"
    "stop();"
    );
  SWFMovieClip_nextFrame(mc1); 
  
  mc2 = newSWFMovieClip();
  SWFMovieClip_nextFrame(mc2); 
  
  it1 = SWFMovie_add(mo, (SWFBlock)mc1); 
  it2 = SWFMovie_add(mo, (SWFBlock)mc2); 
  SWFDisplayItem_setDepth(it1, 10); 
  SWFDisplayItem_setName(it1, "mc1"); 
  SWFDisplayItem_setDepth(it2, 20); 
  SWFDisplayItem_setName(it2, "mc2"); 
  SWFMovie_nextFrame(mo); // 2nd frame


  add_actions(mo, "duplicateMovieClip('mc1', 'dup1', 1);");
  check_equals(mo, "typeof(dup1)", "'movieclip'");
  add_actions(mo, "removeMovieClip(dup1);");
  check_equals(mo, "typeof(dup1)", "'undefined'");
  
  add_actions(mo, "duplicateMovieClip('/:mc1', 'dup2', 2);");
  check_equals(mo, "typeof(dup2)", "'movieclip'");
  add_actions(mo, "removeMovieClip(dup2);");
  check_equals(mo, "typeof(dup2)", "'undefined'");
  
  add_actions(mo, "duplicateMovieClip('/:mc1/', 'dup3', 3);");
  check_equals(mo, "typeof(dup3)", "'movieclip'");
  add_actions(mo, "removeMovieClip(dup3);");
  check_equals(mo, "typeof(dup3)", "'undefined'");
  
  add_actions(mo, "duplicateMovieClip('/_root/mc1/', 'dup4', 4);");
  check_equals(mo, "typeof(dup4)", "'movieclip'");
  add_actions(mo, "removeMovieClip(dup4);");
  check_equals(mo, "typeof(dup4)", "'undefined'");
  
  add_actions(mo, "duplicateMovieClip('_root.mc1', 'dup5', 5);");
  check_equals(mo, "typeof(dup5)", "'movieclip'");
  add_actions(mo, "removeMovieClip(dup5);");
  check_equals(mo, "typeof(dup5)", "'undefined'");
  
  add_actions(mo, "duplicateMovieClip('_root.mc1.mc11', 'dup6', 6);");
  // can not duplicate a movieclip in a different timeline
  check_equals(mo, "typeof(dup6)", "'undefined'");
  
  add_actions(mo, "duplicateMovieClip('/_root/mc1/:mc11', 'dup7', 7);");
  // can not duplicate a movieclip in a different timeline
  check_equals(mo, "typeof(dup7)", "'undefined'");
  
  add_actions(mo, "duplicateMovieClip('/_root/mc1/mc11', 'dup8', 8);");
  // can not duplicate a movieclip in a different timeline
  check_equals(mo, "typeof(dup8)", "'undefined'");
  SWFMovie_nextFrame(mo); // 3rd frame

  add_actions(mo, " _root.totals(); stop(); ");
  SWFMovie_nextFrame(mo); // 4th frame
  
    //Output movie
  puts("Saving " OUTPUT_FILENAME );
  SWFMovie_save(mo, OUTPUT_FILENAME);

  return 0;
}
예제 #15
0
int
main(int argc, char** argv)
{
  SWFMovie mo;
  SWFMovieClip  dejagnuclip;
  SWFDisplayItem  it;

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

  add_actions(mo,
    "var keys = array();"
    "var keynames = array();"
    
    /* Basic test for keys (Good for testrunner) */
    "keys[0] = array (39, 65, 66);"
    "keynames[0] = ('right arrow, A, B');"

    /* More basic tests (Good for testrunner) */    
    "keys[1] = array (13, 17, 112);"
    "keynames[1] = ('Ctrl, Enter, F1');"  

    /* Tests for extended ascii. On many keyboards, some keys should result
    in multiple keycodes being marked as down, but we can't tell which keys
    or keycodes without knowing the keyboard layout. My Essszet (ß) should have
    codes 223 ('ß'), 220 ('\'), and 191 ('?').
    So the test is good for checking isDown for the main DisplayObjects, but the passes
    for !isDown can be bogus, depending on keyboard.    
     */
    "keys[2] = array (223, 228);"
    "keynames[2] = ('Extended ascii: (no shift) a-Umlaut, Essszet\n"
    "(Not a reliable test, because the keycodes supposed to be down are "
    "keymap dependent.');"

    /* More basic tests. (Good for testrunner)*/    
    "keys[3] = array (16, 34, 222);"
    "keynames[3] = ('shift, page-down, doublequote');" 

    /* Test indifference to shift for alphabetic DisplayObjects ... */
    "keys[4] = array (16, 65, 70);"
    "keynames[4] = ('keypress order: press shift, A, F');"

    /* ... Releasing shift before the DisplayObject keys should still remove A
    from the isDown array. Good for testrunner. */
    "keys[5] = array (70, 74);"
    "keynames[5] = ('key order: release shift, release A, press j');"

    /* Test indifference to shift for non-alphabetic DisplayObjects ... */    
    "keys[6] = array (16, 49, 222);"
    "keynames[6] = ('keypress order: shift, !, doublequote');"

    /* ... Releasing shift before the DisplayObject keys should remove ! and " from the
    isDown array. This will not work on non-US keyboards, where " and 2 are on the
    same key. But testing this automatically is not possible in this framework. */
    "keys[7] = array ();"
    "keynames[7] = ('key release order: release shift, release !, release doublequote.\n"
    "Will fail manual test on non-US keyboards');"

    /* Test indifference to shift for extended-ascii alphabetic DisplayObjects ... */    
    "keys[8] = array (228, 246);"
    "keynames[8] = ('(no shift: a-umlaut, o-umlaut');"

    /* ... ä and Ä have different keycodes, but releasing one should mean the other
    is removed from the isDown array when they are on the same key. In fact,
    pressing either on a German keyboard means that codes for both are marked
    as down. Is this true when the DisplayObjects are not on the same key? Probably not. So
    this test might only be possible manually. */
    "keys[9] = array ();"
    "keynames[9] = ('key order: press shift, release A-Umlaut, release O-umlaut, release shift.\n"
    "Will fail manual test on some keyboards');"
    
    "var test = 0;"
    );

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

  SWFMovie_nextFrame(mo);
   
  int i;
  for (i = 0; i <= 9; i++) {
 
  add_actions(mo, 

    "keys[test].push (256);"
    "_root.createEmptyMovieClip('dynamic_mc', -10);"
    "_root.note(keynames[test]);"
    "Key.addListener(dynamic_mc);"
    "_root.onMouseDown = function () { _root.nextFrame(); };"
    "stop();"
  );

  SWFMovie_nextFrame(mo);  // 2nd frame
  
  add_actions(mo, 
    "var j = 0;"
    "for(var i=0; i < 256; i++) {"
        "if (keys[test].length > 0 && i < keys[test][j]) {"
            "xcheck(!Key.isDown(i), 'Key '+ i + ' should not be marked as down!');"
         "} else {"
            "xcheck (Key.isDown(i), 'Key '+ i + ' should be marked as down!');"
            "j++;"
         "};"
      "};"
      "test++;" /* Go on to next test array */
      "stop();"
  );
  }
  //Output movie
  puts("Saving " OUTPUT_FILENAME );
  SWFMovie_save(mo, OUTPUT_FILENAME);

  return 0;
}
예제 #16
0
파일: shape_test.c 프로젝트: sunarto/gnash
int
main(int argc, char** argv)
{
    SWFMovie mo;
    SWFMovieClip dejagnuclip;
    SWFDisplayItem it;
    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();
    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;
}