int
main(int argc, char** argv)
{
  SWFMovie mo;
  SWFMovieClip  mc_red1, mc_red2, mc_red3, mc_red4, mc_red5, dejagnuclip;
  SWFDisplayItem it_red1, it_red2, it_red3, it_red4, it_red5;
  SWFShape  sh_red;

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

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

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

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

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

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


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

  return 0;
}
Пример #2
0
int main(int argc, char** argv)
{
  SWFMovie  movie;
  SWFMovieClip dejagnuclip;
  SWFAction ac[FRAME_COUNT];

  SWFDisplayItem it;
  SWFMovieClip mc1;

  int i;
  const char *srcdir=".";

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

  Ming_init();
  movie = newSWFMovie();
  SWFMovie_setDimension(movie, 800, 600);

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

  // Add frame ActionScipts to frames
  ac[0] = action_in_frame1();
  ac[1] = action_in_frame2();
  ac[2] = action_in_frame3();
  ac[3] = action_in_frame4();
  
  for(i=0; i<FRAME_COUNT; i++)
  {
    SWFMovie_add(movie, (SWFBlock)ac[i]);
    SWFMovie_nextFrame(movie); 
  }

  SWFMovie_add(movie, (SWFBlock)newSWFAction("_level0.ar = [];"));

  // This checks that a change of target in onEnterFrame code does
  // not change the target for other code.
  mc1 = newSWFMovieClip();
  SWFMovieClip_add(mc1, (SWFBlock)newSWFAction("this.g = 'moo'; _level0.ar.push(g);"));
  SWFMovieClip_nextFrame(mc1);
  SWFMovieClip_add(mc1, (SWFBlock)newSWFAction("_level0.ar.push(g);"));
  SWFMovieClip_nextFrame(mc1);

  it = SWFMovie_add(movie, (SWFBlock)mc1);
  SWFDisplayItem_addAction(it,
    compileSWFActionCode(" _root.note('onEnterFrame');"
                         " _level0.ar.push('setTarget');"
                         " asm { push '_level0' settargetexpr }; "),
                         SWFACTION_ENTERFRAME);  
  
  SWFMovie_nextFrame(movie); 

  check_equals(movie, "ar.toString()", "'moo,setTarget,moo'");

  SWFMovie_add(movie, (SWFBlock)newSWFAction("_root.totals(); stop();"));
  SWFMovie_nextFrame(movie); 

  // save files
  puts("Saving " OUTPUT_FILENAME );
  SWFMovie_save(movie, OUTPUT_FILENAME);

  return 0;
}
Пример #3
0
int
main(int argc, char** argv)
{
  
  SWFMovie mo;
  SWFMovieClip dejagnuclip;
  SWFMovieClip mc1, mc11;
  SWFDisplayItem it1, it11;


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

  // _root.frame1
  dejagnuclip = get_dejagnu_clip((SWFBlock)get_default_font(srcdir), 10, 0, 0, 800, 600);
  SWFMovie_add(mo, (SWFBlock)dejagnuclip);
  add_actions(mo, " x1=0; x2=0; x3=0; x4=0; x5=0; x6=0; x7=0; x8=0; x9=0; x10=0; ");
  SWFMovie_nextFrame(mo); 

  //
  // _root.frame2: define movieclips and some functions.
  //
  // Define mc11
  mc11 = newSWFMovieClip();
  add_clip_actions(mc11, " func1 =  function () { _root.x1=1;  _root.x2=this; }; "
                          "stop();");
  SWFMovieClip_nextFrame(mc11); 
  add_clip_actions(mc11, "_root.x3 = 1; stop();");
  SWFMovieClip_nextFrame(mc11); 
  add_clip_actions(mc11, "_root.x4 = 1; stop();");
  SWFMovieClip_nextFrame(mc11); 
  
  // Define mc1, add mc11 to mc1   
  mc1 = newSWFMovieClip();
  it11 = SWFMovieClip_add(mc1, (SWFBlock)mc11);  
  SWFDisplayItem_setDepth(it11, 3); 
  SWFDisplayItem_setName(it11, "mc11"); 
  add_clip_actions(mc1, " func2 =  function () { _root.x5=1;  _root.x6=this; }; "
                        "stop();");
  SWFMovieClip_nextFrame(mc1); 
  add_clip_actions(mc1, "_root.x7 = 1; stop();");
  SWFMovieClip_nextFrame(mc1); 
  add_clip_actions(mc1, "_root.x8 = 1; stop();");
  SWFMovieClip_nextFrame(mc1);
  
  // place mc1 
  it1 = SWFMovie_add(mo, (SWFBlock)mc1); 
  SWFDisplayItem_setDepth(it1, 4); 
  SWFDisplayItem_setName(it1, "mc1"); 
  SWFMovie_nextFrame(mo); 
  
  //
  // _root.frame3: invoke function calls
  //
  add_actions(mo,  "asm{"
                   "push 0 "
                   "push  '_root.mc1.mc11.func1' " // valid format
                   "callfunction " 
                   "};");
  add_actions(mo,  "asm{"
                   "push 2 "
                   "push 1 "
                   "push  '_root.mc1.mc11.gotoAndStop' " // valid format
                   "callfunction " 
                   "};");
  add_actions(mo,  "asm{"
                   "push 0 "
                   "push  '_root.mc1:func2' " // valid format
                   "callfunction " 
                   "};");
  add_actions(mo,  "asm{"
                   "push 2 "
                   "push 1 "
                   "push  '/mc1/:gotoAndStop' " // valid format
                   "callfunction " 
                   "};");
  add_actions(mo,  "asm{"
                   "push 3 "
                   "push 1 "
                   "push  '/_root/mc1/mc11/gotoAndStop' " // *invalid* format
                   "callfunction " 
                   "};");
 add_actions(mo,  "asm{"
                   "push 3 "
                   "push 1 "
                   "push  '_root:mc1:gotoAndStop' " // valid format
                   "callfunction " 
                   "};");
  SWFMovie_nextFrame(mo); 
  
  //
  // _root.frame4: check if the function call succeeded
  //
  check_equals(mo, "_root.x1", "1");
  check_equals(mo, "_root.x2", "_root.mc1.mc11");
  check_equals(mo, "_root.x3", "1");
  check_equals(mo, "_root.x4", "0");
  check_equals(mo, "_root.x5", "1");
  check_equals(mo, "_root.x6", "_root.mc1");
  check_equals(mo, "_root.x7", "1");
  check_equals(mo, "_root.x8", "1");
  
  add_actions(mo, " _root.totals(); stop(); ");
  SWFMovie_nextFrame(mo); 
  
  
  //Output movie
  puts("Saving " OUTPUT_FILENAME );
  SWFMovie_save(mo, OUTPUT_FILENAME);

  return 0;
}
int
main(int argc, char** argv)
{
    SWFMovie mo;
    SWFMovieClip  mc_red, dejagnuclip;
    SWFShape  sh_red;

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

    Ming_init();
    mo = newSWFMovieWithVersion(OUTPUT_VERSION);
    SWFMovie_setDimension(mo, 800, 600);
    SWFMovie_setRate (mo, 1.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 -  so we can use _root.note */

    mc_red = newSWFMovieClip();
    sh_red = make_fill_square (0, 300, 60, 60, 255, 0, 0, 255, 0, 0);
    SWFMovieClip_add(mc_red, (SWFBlock)sh_red);
    add_clip_actions(mc_red, " _root.note('frm1 of mc_red - gotoAndStop(2)'); "
                     "x = 'as_in_frm1_of_mc_red'; "
                     "gotoAndStop(2); ");
    SWFMovieClip_nextFrame(mc_red); /* 1st frame */
    add_clip_actions(mc_red, " _root.note('frm2 of mc_red - gotoAndStop(3)'); "
                     "x = 'as_in_frm2_of_mc_red'; "
                     "gotoAndStop(3); ");
    SWFMovieClip_nextFrame(mc_red); /* 2nd frame */
    add_clip_actions(mc_red, " _root.note('frm3 of mc_red - gotoAndStop(4)'); "
                     "x = 'as_in_frm3_of_mc_red'; "
                     "gotoAndStop(4); ");
    SWFMovieClip_nextFrame(mc_red); /* 3rd frame */
    SWFMovieClip_nextFrame(mc_red); /* 4th frame */


    SWFDisplayItem it_red;
    it_red = SWFMovie_add(mo, (SWFBlock)mc_red);
    SWFDisplayItem_setDepth(it_red, 3);
    SWFDisplayItem_setName(it_red, "mc_red");

    add_actions(mo, " _root.note('frm2 of root - gotoAndStop(3)'); "
                "mc_red.x = 'as_in_frm2_of_root'; "
                "gotoAndStop(3); ");
    SWFMovie_nextFrame(mo); /* 2nd frame */

    /* mc_red.x has been set after playing the 1st frame, check it here */
    add_actions(mo, " check_equals(mc_red.x, 'as_in_frm1_of_mc_red'); "
                " _root.note('frm3 of root - gotoAndStop(4)');"
                "mc_red.x = 'as_in_frm3_of_root'; "
                "gotoAndStop(4); ");
    SWFMovie_nextFrame(mo); /* 3rd frame */

    /* mc_red.x has been set again after playing the 2nd frame, check it again */
    add_actions(mo, " check_equals(mc_red.x, 'as_in_frm2_of_mc_red'); "
                " _root.note('frm4 of root - gotoAndStop(5)');"
                " mc_red.x = \"as_in_frm4_of_root\"; "
                " gotoAndStop(5); ");
    SWFMovie_nextFrame(mo); /* 4th frame */

    /* mc_red.x has been set again after playing the 3rd frame, check it again */
    check_equals(mo, "mc_red.x", "'as_in_frm3_of_mc_red'");
    add_actions(mo, " _root.totals(); stop(); ");
    SWFMovie_nextFrame(mo); /* 5th frame */

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

    return 0;
}
Пример #5
0
int
main(int argc, char** argv)
{
  SWFMovie mo;
  SWFMovieClip mc1, mc2, mc3, dejagnuclip;
  SWFShape  sh1, sh2, sh3;
  SWFDisplayItem it1, it2, it3;

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

  // Frame 1: Place dejagnu clip

  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 two static DisplayObjects

  sh1 = make_fill_square (300, 300, 60, 60, 255, 0, 0, 255, 0, 0);
  mc1 = newSWFMovieClip();
  SWFMovieClip_add(mc1, (SWFBlock)sh1); 
  SWFMovieClip_nextFrame(mc1);
  
  sh2 = make_fill_square (330, 270, 120, 120, 0, 0, 0, 0, 0, 0);
  mc2 = newSWFMovieClip();
  SWFMovieClip_add(mc2, (SWFBlock)sh2);  
  SWFMovieClip_nextFrame(mc2); 

  sh3 = make_fill_square (330, 270, 120, 180, 0, 255, 0, 0, 255, 0);
  mc3 = newSWFMovieClip();
  SWFMovieClip_add(mc3, (SWFBlock)sh3);
  SWFMovieClip_nextFrame(mc3); 

  it1 = SWFMovie_add(mo, (SWFBlock)mc1);  //add movieClip1 to the _root
  SWFDisplayItem_setName(it1, "movieClip1"); //name movieClip1
  SWFDisplayItem_addAction(it1, newSWFAction(
		"_root.note(this+' constructed');"
		"_root.mc1Constructed++;"
		), SWFACTION_CONSTRUCT);
  SWFDisplayItem_setDepth(it1, 3); // depth of movieClip1 is 3 (-16381)

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

  it3 = SWFMovie_add(mo, (SWFBlock)mc3);  //add movieClip3 to the _root
  SWFDisplayItem_setName(it3, "movieClip3"); //name movieClip3
  SWFDisplayItem_addAction(it3, newSWFAction(
		"_root.note(this+' constructed');"
		"_root.mc3Constructed++;"),
		  SWFACTION_CONSTRUCT);
  SWFDisplayItem_setDepth(it3, 30001); // depth of movieClip3 is 30001 (13617)

  SWFMovie_add(mo, (SWFBlock)newSWFAction(
      "check_equals(movieClip3.getDepth(), 13617);"
  ));
  
  SWFMovie_nextFrame(mo);
  
  // Frame4: RemoveObject(mc3) - one of those out of static depth zone

  SWFDisplayItem_remove(it3);

  // Frame4: gotoAndStop(1), check..

  SWFMovie_add(mo, (SWFBlock)newSWFAction(

      "var mc1_depth = movieClip1.getDepth();"
      "var mc2_depth = movieClip2.getDepth();"
      "movieClip1.secretCode = 'mc1';"
      "movieClip2.secretCode = 'mc2';"

      "check_equals(movieClip1.getDepth(), -16381);" 
      "check_equals(movieClip2.getDepth(), 13616);"
      // movieClip3 was removed, despite it's depth is out of the static zone
      "check_equals(typeof(movieClip3), 'undefined');"

      "gotoAndStop(1);"

      // MC1 (in static depth zone) has been removed
      "check_equals(typeof(movieClip1), 'undefined');"
      // MC2 (in dynamic depth zone) has been kept
      "check_equals(typeof(movieClip2), 'movieclip');"

      // The kept instance wasn't detroyed
      "check_equals(movieClip2.secretCode, 'mc2');"

      // Both chars have been constructed once (consistency check)
      "check_equals(mc1Constructed, 1);"
      "check_equals(mc2Constructed, 1);"

      "totals(9);"

	));
  SWFMovie_nextFrame(mo);

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

  return 0;
}
Пример #6
0
int
main(int argc, char** argv)
{
    SWFMovie mo;
    SWFMovieClip mc3, mc2, dejagnuclip;
    SWFAction ac, ac1, initac;
    SWFDisplayItem it;
    SWFShape sha;

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

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


    sha = newSWFShape();

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

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

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

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

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

    // Frame 3
    SWFMovie_nextFrame(mo);

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

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

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

    // Frame 5
    SWFMovie_nextFrame(mo);

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

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

    return 0;
}
Пример #7
0
int
main(int argc, char** argv)
{
  SWFMovie mo;
  SWFMovieClip  mc1, mc2, dejagnuclip;
  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
  

  mc1 = newSWFMovieClip();
  SWFMovieClip_nextFrame(mc1);
  it1 = SWFMovie_add(mo, (SWFBlock)mc1);  
  SWFDisplayItem_setName(it1, "static_mc1");
  SWFDisplayItem_addAction(it1,
    newSWFAction(
        " this.createEmptyMovieClip('dyn1', 100); "
        " _root.check_equals(dyn1.getDepth(), 100);"
        " _root.dyn1Ref = dyn1;"
        // shouldn't be executed.
        " dyn1.onUnload = function () { _root.check(false); } ;"
        "trace(this);"
    ),
    SWFACTION_UNLOAD);  
  
  mc2 = newSWFMovieClip();
  SWFMovieClip_nextFrame(mc2);
  it2 = SWFMovie_add(mo, (SWFBlock)mc2);  
  SWFDisplayItem_setName(it2, "static_mc2");
  SWFDisplayItem_addAction(it2,
    newSWFAction(
       " this.createEmptyMovieClip('dyn2', 200); "
       " _root.check_equals(dyn2.getDepth(), 200);"
       " dyn2.onUnload = function () {_root.dyn2testvar = 'executed'; } ;"
    ),
    SWFACTION_ONLOAD);  
  SWFDisplayItem_addAction(it2,
    newSWFAction(
      " _root.check_equals(_level0.dyn1Ref.getDepth(), 100);"
      " _level0.dyn1Ref.swapDepths(101); "
      // Check that we can still swap the new child created in onClipUnload(mc1)
      // Note mc1 is already unloaded(this is in mc2.unload).
      " _root.check_equals(_level0.dyn1Ref.getDepth(), 101);"
    ),
    SWFACTION_UNLOAD); 
  SWFMovie_nextFrame(mo); // frame2

  SWFDisplayItem_remove(it1);
  SWFDisplayItem_remove(it2);
  SWFMovie_nextFrame(mo); // frame3
  
  check_equals(mo, "typeof(_root.dyn1Ref)", "'movieclip'");
  check_equals(mo, "_root.dyn1Ref.valueof()", "null");
  // check that dyn2.onUnload was triggered
  check_equals(mo, "_root.dyn2testvar", "'executed'");
  SWFMovie_nextFrame(mo); // frame4

  add_actions(mo, " _root.totals(7); stop(); ");
  SWFMovie_nextFrame(mo); // frame5 
  
  //Output movie
  puts("Saving " OUTPUT_FILENAME );
  SWFMovie_save(mo, OUTPUT_FILENAME);

  return 0;
}
Пример #8
0
int
main(int argc, char** argv)
{
  SWFMovie mo;
  SWFMovieClip dejagnuclip, staticSquare;
  SWFShape shape;
  SWFDisplayItem it;

  if ( argc>1 ) mediadir=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);

  if (mo == NULL) return -1;

  addRedSquareExport(mo);

  add_actions(mo, "_root.onKeyDown = _root.onMouseUp = function() {"
	                "play(); }; "
                    "Key.addListener(_root);");

  SWFMovie_setRate(mo, 12);
    dejagnuclip = get_dejagnu_clip(
            (SWFBlock)get_default_font(mediadir), 10, 10, 150, 800, 600);
    SWFMovie_add(mo, (SWFBlock)dejagnuclip);
 
  SWFMovie_nextFrame(mo);

  add_actions(mo, "BitmapData = flash.display.BitmapData;"
		  "Rectangle = flash.geom.Rectangle;"
		  "bmp = new BitmapData(150, 150, false);"
		  "rect = new Rectangle(10, 10, 100, 100);"
		  "bmp.fillRect(rect, 0x00ff00);"
		  "mc = _root.createEmptyMovieClip('mc', getNextHighestDepth());"
          "d = mc.getNextHighestDepth();"
          "mc.attachBitmap(bmp, d);"
          "bmp2 = new BitmapData(20, 20, true);"
          "rect2 = new Rectangle (10, 10, 20, 20);"
          "bmp2.fillRect(rect2, 0xffffff00);"
          "d2 = mc.getNextHighestDepth();"
          "mc.attachBitmap(bmp2, d2);"
          "note('1. You should see a small yellow square in the top left "
                "corner of a larger green square. Click to proceed.');"
          "stop();"
          );

    SWFMovie_nextFrame(mo);

    add_actions(mo, "rect = new Rectangle (90, 90, 120, 120);"
		    "bmp.fillRect(rect, 0x0000FF);"
            "note('2. You should see a new blue square covering the "
                "bottom right corner of the large green square. Click"
                " to proceed.');"
            "stop();"
            );

    SWFMovie_nextFrame(mo);

    add_actions(mo, "mc.createEmptyMovieClip('d', d);"
            "note('3. You should see just the small yellow square in the top "
                "left corner. Click to proceed.');");

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

    SWFMovie_nextFrame(mo);
    
    // Place a dynamic DisplayObject at depth 4
    add_actions(mo, "mc.removeMovieClip();"
            "_root.attachMovie('redsquare', 'rs', 4);");

    // Place a static DisplayObject at depth 3
    staticSquare = newSWFMovieClip();
    shape = make_fill_square (300, 0, 60, 60, 255, 0, 255, 255, 0, 255);
    SWFMovieClip_add(staticSquare, (SWFBlock)shape);  
    SWFMovieClip_nextFrame(staticSquare);
    
    it = SWFMovie_add(mo, (SWFBlock)staticSquare);  
    SWFDisplayItem_setDepth(it, 3); 
    SWFDisplayItem_setName(it, "staticSquare");

    add_actions(mo, 
            "note('4. You should see a red square in the top left and a "
            "purple square in the top right. Click to proceed.');");
    add_actions(mo, "stop();");

    SWFMovie_nextFrame(mo);

    add_actions(mo, "staticSquare.swapDepths(20);"
            "note('5. There should have been no change. Click to proceed.');"
            "stop();"
            );

    SWFMovie_nextFrame(mo);

    add_actions(mo, "_root.attachBitmap(bmp, 2);"
            "note('6. You should see the green and blue squares "
            "under the red square. The purple square should still be there. "
            "Click to proceed.');"
            "stop();"
            );

    SWFMovie_nextFrame(mo);

    add_actions(mo, "_root.attachBitmap(bmp, 3);"
            "note('7. There should have been no change. Click to proceed.');"
            "stop();"
            );

    SWFMovie_nextFrame(mo);

    SWFDisplayItem_remove(it);
    
    add_actions(mo, "_root.attachBitmap(bmp2, 20);"
            "note('8. The purple square should have gone. The small yellow "
            "square should have replaced the top left corner of the red "
            "square. The green and blue squares should still be there. "
            "Click to proceed.');"
            "stop();"
            );

    SWFMovie_nextFrame(mo);    

    add_actions(mo, "bmp.dispose(); bmp2.dispose();"
            "note('9. You should see just the red square. Click to proceed.');"
            "stop();"
            );

    SWFMovie_nextFrame(mo);    

    add_actions(mo, "bmp = new BitmapData(100, 100, false, 0x0000ff);"
            "note('10. There should have been no change. Click to proceed.');"
            "stop();"
            );

    SWFMovie_nextFrame(mo);    
    
    add_actions(mo, "bmp3 = new BitmapData(100, 100, false);"
            "rect3 = new Rectangle(20, 20, 90, 90);"
            "bmp3.fillRect(rect3, 0x0000ff);"
            "ch = _root.createEmptyMovieClip('original', 40);"
            "original.attachBitmap(bmp3, getNextHighestDepth());"
            "ch._name = 'duplicate';"
            "newch = _root.createEmptyMovieClip('original', "
                    "getNextHighestDepth());"
            "note('11. You should see a large blue square only. "
            "Click to proceed.');"
            "stop();"
            );

    SWFMovie_nextFrame(mo);    
    
    add_actions(mo, 
            "original.removeMovieClip();"
            "note('12. There should have been no change. Click to proceed.');"
            "stop();"
            );

    SWFMovie_nextFrame(mo);    
    
    add_actions(mo, 
            "duplicate.removeMovieClip();"
            "note('13. You should see the red square again. Click to "
            "proceed.');"
            "stop();"
            );

    SWFMovie_nextFrame(mo);

    add_actions(mo,
            "_root.createEmptyMovieClip('mcLeft', getNextHighestDepth());"
            "mcLeft.duplicateMovieClip('mcMiddle', getNextHighestDepth(),"
                        " { _x: 300, _y: 0 } );"
            "mcLeft.attachBitmap(bmp3, getNextHighestDepth());"
            "mcMiddle.attachBitmap(bmp3, getNextHighestDepth());"
            "mcMiddle.duplicateMovieClip('mcRight', getNextHighestDepth(),"
                        " { _x: 600, _y: 0 } );"
            "note('14. You should see two blue squares. Click to proceed.');"
            "stop();"
            );

    SWFMovie_nextFrame(mo);

    add_actions(mo,
            "bmp3.noise(293);"
            "note('15. You should see two noise patterns where the two "
            "squares were. Click to proceed.');"
            "stop();"
            );

    add_actions(mo, "_root.onKeyDown = _root.onMouseUp = undefined;"
            "_root.eof = true;" // hook for test runner...
            "note(' - END OF TEST - thanks for flying with us ! ');"
            //"totals(6);" // no AS based tests...
            );

    SWFMovie_nextFrame(mo);

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

  return 0;
}
Пример #9
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;
}
Пример #10
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;
}
Пример #11
0
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
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  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;
}
Пример #14
0
gboolean swf_add_mouse_click(SWFMovie this_movie, gint click_type)
{
	// Local variables
	gfloat				click_duration;
	guint				click_frames;
	GString				*click_name;				// The name of the mouse click sound we'll need to play
	guint				i;							// Counter
	GString				*message;					// Used to construct message strings
	SWFDisplayItem 		sound_display_item;
	FILE				*sound_file;				// The file we load the sound from
	SWFMovieClip		sound_movie_clip;			// Movie clip specifically to hold a sound
	SWFSoundStream 		sound_stream;				// The sound we use gets loaded into this
	gchar				*sound_pathname = NULL;		// Full pathname to a sound file to load is constructed in this
	SWFAction			swf_action;					// Used when constructing action script


	// Initialisation
	click_name = g_string_new(NULL);

	// Determine the sound file to load
	switch (click_type)
	{
		case MOUSE_LEFT_ONE:
		case MOUSE_RIGHT_ONE:
		case MOUSE_MIDDLE_ONE:

			// If we've already added the sound to the movie, we don't need to add it again
			if (FALSE == get_mouse_click_single_added())
			{
				// Single click mouse sound
				sound_pathname = g_build_path(G_DIR_SEPARATOR_S, SOUND_DIR, "mouse_single_click.mp3", NULL);

				// Make sure we only add this click sound once
				set_mouse_click_single_added(TRUE);
			}

			click_name = g_string_assign(click_name, "mousesingleclick");
			click_duration = 0.5;
			break;

		case MOUSE_LEFT_DOUBLE:
		case MOUSE_RIGHT_DOUBLE:
		case MOUSE_MIDDLE_DOUBLE:

			// If we've already added the sound to the movie, we don't need to add it again
			if (FALSE == get_mouse_click_double_added())
			{
				// Double click mouse sound
				sound_pathname = g_build_path(G_DIR_SEPARATOR_S, SOUND_DIR, "mouse_double_click.mp3", NULL);

				// Make sure we only add this click sound once
				set_mouse_click_double_added(TRUE);
			}

			click_name = g_string_assign(click_name, "mousedoubleclick");
			click_duration = 0.5;
			break;

		case MOUSE_LEFT_TRIPLE:
		case MOUSE_RIGHT_TRIPLE:
		case MOUSE_MIDDLE_TRIPLE:

			// If we've already added the sound to the movie, we don't need to add it again
			if (FALSE == get_mouse_click_triple_added())
			{
				// Triple click mouse sound
				sound_pathname = g_build_path(G_DIR_SEPARATOR_S, SOUND_DIR, "mouse_triple_click.mp3", NULL);

				// Make sure we only add this click sound once
				set_mouse_click_triple_added(TRUE);
			}

			click_name = g_string_assign(click_name, "mousetripleclick");
			click_duration = 0.5;
			break;
	}

	if (NULL != sound_pathname)
	{
		// Create the sound object we'll be using
		if (get_debug_level()) printf("%s: '%s'\n", _("Full path name to sound file is"), sound_pathname);

		// Load the sound file
		sound_file = fopen(sound_pathname, "rb");
		if (NULL == sound_file)
		{
			// Something went wrong when loading the sound file, so return
			message = g_string_new(NULL);
			g_string_printf(message, "%s ED412: %s", _("Error"), _("Something went wrong when opening a mouse click sound file."));
			display_warning(message->str);
			g_string_free(message, TRUE);
			return FALSE;
		}
		sound_stream = newSWFSoundStream(sound_file);

		// Create a new movie clip file, containing only the sound
		sound_movie_clip = newSWFMovieClip();

		// Ensure the clip doesn't start out playing nor keep looping
		swf_action = compileSWFActionCode("this.stop(); ");
		SWFMovieClip_add(sound_movie_clip, (SWFBlock) swf_action);
		SWFMovieClip_nextFrame(sound_movie_clip);

		// Add the sound stream to the sound movie clip
		SWFMovieClip_setSoundStream(sound_movie_clip, sound_stream, 1);
		SWFMovieClip_nextFrame(sound_movie_clip);

		// Add extra frames to allow the click to play it's full length
		click_frames = roundf(click_duration * get_frames_per_second());
		for (i = 0; i < click_frames; i++)
		{
			SWFMovieClip_nextFrame(sound_movie_clip);
		}

		// Add the sound movie clip to the swf movie
		sound_display_item = SWFMovie_add(this_movie, (SWFBlock) sound_movie_clip);

		// Name the display item
		SWFDisplayItem_setName(sound_display_item, click_name->str);

		// Ensure the object is at the correct display depth
		SWFDisplayItem_setDepth(sound_display_item, 1000 + click_type); // Trying to pick a non conflicting depth
	}

	// Free the memory allocated in this functions
	g_string_free(click_name, TRUE);

	return TRUE;
}
Пример #15
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;
}
Пример #16
0
int
main(int argc, char** argv)
{
  SWFMovie mo;
  SWFMovieClip mc1, mc2, dejagnuclip;
  SWFDisplayItem it1, it2;
  SWFShape  sh1,sh2;
  SWFAction ac;
  int i;

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

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

  // Frame 1: Place dejagnu clip

  dejagnuclip = get_dejagnu_clip((SWFBlock)get_default_font(srcdir), 10, 0, 0, 800, 600);
  SWFMovie_add(mo, (SWFBlock)dejagnuclip);
  add_actions(mo, "mc1Constructed=0; mc2Constructed=0; mc3Constructed=0; mc4Constructed=0;");
  SWFMovie_nextFrame(mo); 
  
  //
  // Frame 2: 
  //   Place red static movieClip1 DisplayObject at depth 3 (-16381)
  //
  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);
  SWFDisplayItem_addAction(it1, newSWFAction(
    "_root.note(this+' unloaded');"
    "_root.mc1Unloaded++;"
    ), SWFACTION_UNLOAD);

  check_equals(mo, "typeof(movieClip1)", "'movieclip'");
  check_equals(mo, "_root.mc1Constructed", "1");

  SWFMovie_nextFrame(mo);  

  // Frame3: Remove red square
  SWFDisplayItem_remove(it1);
  // After compile, the RemoveObject2 tag is *after* the DoAction tag which 
  // contains the following check. So it's not surprise that we can still access
  // "movieClip1" here when considering the gloabal ActionQueue model! If the 
  // RemoveObject2 is *before* the DoAction, then typeof(movieClip1) will reurn 'undefined'.
  // So Gnash fails here because of action execution order!
  // TODO: add testcase for this(RemoveObject2 placed *before* DoAction within the same frame).
  check_equals(mo, "typeof(movieClip1)", "'movieclip'"); // kept alive for calling onUnload!
  check_equals(mo, "_root.mc1Constructed", "1");
  SWFMovie_nextFrame(mo);  
  
  // Frame4: nothing new
  SWFMovie_nextFrame(mo); 
  
  // Frame5: check, gotoAndStop(4), check..

  check_equals(mo, "typeof(movieClip1)", "'undefined'");
  SWFMovie_add(mo, (SWFBlock)newSWFAction( "gotoAndStop(4);"));
  check_equals(mo, "typeof(movieClip1)", "'movieclip'");

  // onConstruct is called twice
  check_equals(mo, "_root.mc1Constructed", "2");

  // this is due to action execution order, it's called twice, but
  // the second time it's called *after* the end of *this* DOACTION block ..
  check_equals(mo, "_root.mc1Unloaded", "1");

  SWFMovie_add(mo, (SWFBlock)newSWFAction( "totals(); stop();" ));
  SWFMovie_nextFrame(mo);

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

  return 0;
}
Пример #17
0
SWFDisplayItem
add_button(SWFMovie mo)
{
	SWFDisplayItem it;
	SWFMovieClip mc;
	SWFButtonRecord br;
	SWFShape sh1, sh2, sh3, sh4, sh1a, sh2a, sh3a, sh4a;
	SWFButton bu = newSWFButton();
	static SWFMovieClip ermc; /* Events-reporting mc */
	mc = newSWFMovieClip();

	if ( ! ermc )
	{
		ermc = newSWFMovieClip();
		SWFMovieClip_add(ermc, newSWFAction(
			"_global.dumpObj = function(o,indent) {"
			"	var s = '';"
			"	if ( typeof(o) == 'object' ) {"
			"		s += '{';"
			"		var first=1;"
			"		for (var i in o) {"
			"			if (!first) s+=',';"
			"			s+= i+':'+dumpObj(o[i]);"
			"			first=0;"
			"		}"
			"		s += '}';"
			"	} else {"
			"		s += o;"
			"	}"
			"	return s;"
			"};"
			"if ( _root.buttonChild == undefined ) _root.buttonChild = [];"
			"var myDepth = getDepth()+16383;"
			"var myName = ''+this;"
			"if ( _root.buttonChild[myDepth] == undefined ) _root.buttonChild[myDepth] = {nam:myName,exe:1,uld:0};"
			"else _root.buttonChild[myDepth]['exe']++;"
			 //"_root.note('Actions in frame0 of '+this+' at depth '+myDepth+' executed.');" 
			"this.onUnload = function() {"
			"	var myDepth = -(getDepth()+32769-16383);"
			//"	_root.note(''+this+' at depth '+myDepth+' unloaded.');"
			"	_root.buttonChild[myDepth]['uld']++;"
			"};"
            "for (i in _level0.square1.button) { trace (i); };"
			//"_root.note('buttonChilds:'+dumpObj(_root.buttonChild));"
		));
		SWFMovieClip_nextFrame(ermc);
	}

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

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

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

	/* Higher depth DisplayObject is intentionally added before lower depth one */
	br = SWFButton_addCharacter(bu, (SWFCharacter)sh3a, SWFBUTTON_DOWN );
	SWFButtonRecord_setDepth(br, 2);
	br = SWFButton_addCharacter(bu, (SWFCharacter)sh3, SWFBUTTON_DOWN );
	SWFButtonRecord_setDepth(br, 1);

	/* Higher depth DisplayObject is intentionally added before lower depth one */
	br = SWFButton_addCharacter(bu, (SWFCharacter)sh4a, SWFBUTTON_OVER );
	SWFButtonRecord_setDepth(br, 2);
	br = SWFButton_addCharacter(bu, (SWFCharacter)sh4, SWFBUTTON_OVER );
	SWFButtonRecord_setDepth(br, 1);

	/* Add events reported DisplayObject in all states at depth 10 */
	br = SWFButton_addCharacter(bu, (SWFCharacter)ermc, SWFBUTTON_HIT|SWFBUTTON_DOWN|SWFBUTTON_OVER|SWFBUTTON_UP);
	SWFButtonRecord_setDepth(br, 10);

	/* Add events reported DisplayObject just HIT state at depth 11 */
	br = SWFButton_addCharacter(bu, (SWFCharacter)ermc, SWFBUTTON_HIT);
	SWFButtonRecord_setDepth(br, 11);

	/* Add events reported DisplayObject just UP state at depth 12 */
	br = SWFButton_addCharacter(bu, (SWFCharacter)ermc, SWFBUTTON_UP);
	SWFButtonRecord_setDepth(br, 12);

	/* Add events reported DisplayObject just OVER state at depth 13 */
	br = SWFButton_addCharacter(bu, (SWFCharacter)ermc, SWFBUTTON_OVER);
	SWFButtonRecord_setDepth(br, 13);

	/* Add events reported DisplayObject just DOWN state at depth 14 */
	br = SWFButton_addCharacter(bu, (SWFCharacter)ermc, SWFBUTTON_DOWN);
	SWFButtonRecord_setDepth(br, 14);


	SWFButton_addAction(bu, compileSWFActionCode(
		"_root.msg='MouseOut';"
		"if ( _root.testno == 4 || _root.testno == 9 || _root.testno == 14 ) {"
		"	_root.check_equals(_root.printBounds(getBounds()), '-0.05,-0.05 40.05,40.05');"
		/* Target of button action is the button's parent sprite */
		"	_root.check_equals(_target, '/square1');"
		"	setTarget('/');"
		"	_root.check_equals(_target, '/');"
		"	_root.testno++;"
		"	_root.note(_root.testno+'. Press mouse button inside the square, and release it outside.');"
		"} else {"
		//"	_root.note('SWFBUTTON_MOUSEOUT');"
		"	_root.xfail('Unexpectedly got SWFBUTTON_MOUSEOUT event (testno:'+_root.testno+')');"
		"}"
		), SWFBUTTON_MOUSEOUT);

	SWFButton_addAction(bu, compileSWFActionCode(
		"_root.msg='MouseOver';"

		"if ( _root.testno == 1 ) {" /* ONLY CHECK buttonChild on first frame */

		/* "_root.note('buttonChild is '+dumpObj(_root.buttonChild));" */

		/* added OVER state char */
		"	_root.check_equals(_root.buttonChild.realLength(), 3);"

		/* OVER state char loaded */
		"	_root.check_equals(typeof(_root.buttonChild[13]), 'object');"
		"	_root.check_equals(_root.buttonChild[13].nam, '_level0.square1.button.instance7');"
		"	_root.check_equals(_root.buttonChild[13].exe, 1);" /* OVER state char */
		"	_root.check_equals(_root.buttonChild[13].uld, 0);" /* OVER state char */

		/* UP state char unloaded */
		"	_root.check_equals(_root.buttonChild[12].exe, 1);"
		"	_root.check_equals(_root.buttonChild[12].uld, 1);"
		"	_root.check_equals(typeof(_level0.square1.button.instance6), 'movieclip');"
		"	_root.check_equals(_level0.square1.button.instance6._name, 'instance6');"
		"	_root.check_equals(_level0.square1.button.instance6.getDepth(), -16398);"

		/* ALL state char still there, not reloaded, not unloaded */
		"	_root.check_equals(_root.buttonChild[10].exe, 1);"
		"	_root.check_equals(_root.buttonChild[10].uld, 0);"

		"}"

		"if ( _root.testno == 1 || _root.testno == 6 || _root.testno == 11 ) {"

		//"	_root.note('buttonChild is '+dumpObj(_root.buttonChild));"
		"	_root.check_equals(_root.printBounds(getBounds()), '-0.05,-0.05 40.05,40.05');"
		/* Target of button action is the button's parent sprite */
		"	_root.check_equals(_target, '/square1');"
		"	setTarget('/');"
		"	_root.check_equals(_target, '/');"
		"	_root.testno++;"
		"	_root.note(_root.testno+'. Press (and keep pressed) the mouse button inside the square.');"
		"} else {"
		//"	_root.note('SWFBUTTON_MOUSEOVER');"
		// need MOUSEOVER for MOUSEUPOUTSIDE
		"	if ( _root.testno != 5 && _root.testno != 10 && _root.testno != 15 ) {"
		"		_root.fail('Unexpectedly got SWFBUTTON_MOUSEOVER event (testno:'+_root.testno+')');"
		"	}"
		"}"
		), SWFBUTTON_MOUSEOVER);

	SWFButton_addAction(bu, compileSWFActionCode(
		"_root.msg='MouseDown';"

		"if ( _root.testno == 2 ) {" /* ONLY CHECK buttonChild on first frame */

		/* Added DOWN state char */
		"	_root.check_equals(_root.buttonChild.realLength(), 4);"

		/* DOWN state char loaded */
		"	_root.check_equals(typeof(_root.buttonChild[14]), 'object');"
		"	_root.check_equals(_root.buttonChild[14].nam, '_level0.square1.button.instance8');"
		"	_root.check_equals(_root.buttonChild[14].exe, 1);" 
		"	_root.check_equals(_root.buttonChild[14].uld, 0);" 

		/* OVER state char unloaded */
		"	_root.check_equals(_root.buttonChild[13].exe, 1);" 
		"	_root.check_equals(_root.buttonChild[13].uld, 1);"

		/* ALL state char still there, not reloaded, not unloaded */
		"	_root.check_equals(_root.buttonChild[10].exe, 1);"
		"	_root.check_equals(_root.buttonChild[10].uld, 0);"

		"}"

		"if ( _root.testno == 2 || _root.testno == 7 || _root.testno == 12 ) {"
		"	_root.check_equals(_root.printBounds(getBounds()), '-0.05,-0.05 40.05,40.05');"
		/* Target (and name) of button action is the button's parent sprite */
		"	_root.check_equals(_target, '/square1');"
		"	_root.check_equals(_name, 'square1');"
		"	setTarget('/');"
		"	_root.check_equals(_target, '/');"
		"	_root.check_equals(typeof(_name), 'string');"
		"	_root.check_equals(_name, '');"
		"	_root.testno++;"
		"	_root.note(_root.testno+'. Depress the mouse button inside the square.');"
		"} else {"
		//"	_root.note('SWFBUTTON_MOUSEDOWN');"
		// need MOUSEDOWN for MOUSEUPOUTSIDE
		"	if ( _root.testno != 5 && _root.testno != 10 && _root.testno != 15 ) {"
		"		_root.fail('Unexpectedly got SWFBUTTON_MOUSEDOWN event (testno:'+_root.testno+')');"
		"	}"
		"}"
		), SWFBUTTON_MOUSEDOWN);

	SWFButton_addAction(bu, compileSWFActionCode(
		"_root.msg='MouseUp';"
		"if ( _root.testno == 3 || _root.testno == 8 || _root.testno == 13 ) {"
		"	_root.check_equals(_root.printBounds(getBounds()), '-0.05,-0.05 40.05,40.05');"
		/* Target of button action is the button's parent sprite */
		"	_root.check_equals(_target, '/square1');"
		"	setTarget('/');"
		"	_root.check_equals(_target, '/');"
		"	_root.testno++;"
		"	_root.note(_root.testno+'. Move the mouse pointer off the square.');"
		"} else {"
		//"	_root.note('SWFBUTTON_MOUSEUP');"
		"	_root.fail('Unexpectedly got SWFBUTTON_MOUSEUP event (testno:'+_root.testno+')');"
		"}"
		), SWFBUTTON_MOUSEUP);

	/* SWFBUTTON_MOUSEUPOUTSIDE *should* be invoked !! */
	SWFButton_addAction(bu, compileSWFActionCode(
		"_root.msg='MouseUpOutside';"
		"if ( _root.testno == 5 || _root.testno == 10 || _root.testno == 15 ) {"
		"	_root.check_equals(_root.printBounds(getBounds()), '-0.05,-0.05 40.05,40.05');"
		/* Target of button action is the button's parent sprite */
		"	_root.check_equals(_target, '/square1');"
		"	_root.check_equals(_name, 'square1');"
		"	setTarget('/');"
		"	_root.check_equals(_target, '/');"
		"	_root.nextFrame();"
		"} else {"
		//"	_root.note('SWFBUTTON_MOUSEUPOUTSIDE');"
		"	_root.fail('Unexpectedly got SWFBUTTON_MOUSEUPOUTSIDE event (testno:'+_root.testno+')');"
		"}"
		), SWFBUTTON_MOUSEUPOUTSIDE);

	/* Keypress */
	SWFButton_addAction(bu, compileSWFActionCode(
		"_root.note('KeyPress: a');"
		//"_root.check(Key.isDown('a'));"
	), SWFBUTTON_KEYPRESS('a'));
	SWFButton_addAction(bu, compileSWFActionCode(
		"_root.note('KeyPress: b');"
		//"_root.check(Key.isDown('b'));"
	), SWFBUTTON_KEYPRESS('b'));

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

	it = SWFMovie_add(mo, (SWFBlock)mc);
	return it;
}
Пример #18
0
SWFDisplayItem
add_button(SWFMovie mo)
{
	SWFDisplayItem it;
	SWFMovieClip mc;
	SWFShape sh1, sh2, sh3, sh4;
	SWFMovieClip bu = newSWFMovieClip();

	mc = newSWFMovieClip();

	sh1 = make_fill_square(0, 0, 40, 40, 0, 0, 0, 0, 0, 0); // black
	sh2 = make_fill_square(0, 0, 40, 40, 255, 0, 0, 255, 0, 0); // red
	sh3 = make_fill_square(0, 0, 40, 40, 0, 255, 0, 0, 255, 0); // green
	sh4 = make_fill_square(0, 0, 40, 40, 255, 255, 0, 255, 255, 0); // yellow

	SWFMovieClip_add(bu, (SWFBlock)sh2); // red when idle
	SWFMovieClip_add(bu, (SWFBlock)compileSWFActionCode(
		"onRollOut = function() {"
		"	_root.note('onRollOut');"
		"	updateAfterEvent();"
		"	_root.msg='RollOut';"
		"	gotoAndStop(1);"
		"};"
		"onRollOver = function() {"
		"	_root.note('onRollOver');"
		"	updateAfterEvent();"
		"	_root.msg='RollOver';"
		"	gotoAndStop(3);"
		"};"
		"onMouseDown = function() {"
		"	_root.note('onMouseDown');"
		"	updateAfterEvent();"
		"	_root.msg2='MouseDown';"
		"};"
		"onMouseUp = function() {"
		"	_root.note('onMouseUp');"
		"	updateAfterEvent();"
		"	_root.msg2='MouseUp';"
		"};"
		"onPress = function() {"
		"	_root.note('onPress');"
		"	updateAfterEvent();"
		"	_root.msg='Press';"
		"	gotoAndStop(2);"
		"};"
		"onRelease = function() {"
		"	_root.note('onRelease');"
		"	updateAfterEvent();"
		"	_root.msg='Release';"
		"	gotoAndStop(3);"
		"};"
		"onReleaseOutside = function() {"
		"	_root.note('onReleaseOutside');"
		"	updateAfterEvent();"
		"	_root.msg='ReleaseOutside';"
		"	gotoAndStop(1);"
		"};"
        "_root.onMouseWheel = function(delta, t) {"
		"	_root.note('onMouseWheel: ' + delta + ', ' + t + ', ' + arguments.length);"
        "   _root.note('onMouseWheel: ' + delta + ', ' +  t);"
		"	_root.msg='onMouseWheel: ' + delta + ', ' + t + ', ' + arguments.length;"
        "};"
        "Mouse.addListener(_root);"
		"stop();"
	));

	SWFMovieClip_nextFrame(bu);

	SWFMovieClip_add(bu, (SWFBlock)sh3); // green on button press
	SWFMovieClip_add(bu, (SWFBlock)newSWFAction("stop();"));
	SWFMovieClip_nextFrame(bu);

	SWFMovieClip_add(bu, (SWFBlock)sh4); //  yellow on mouse over
	SWFMovieClip_add(bu, (SWFBlock)newSWFAction("stop();"));
	SWFMovieClip_nextFrame(bu);

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

	it = SWFMovie_add(mo, (SWFBlock)mc);
	return it;
}
Пример #19
0
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;
}