/* The file doaction-after-placeobject.swf was created from 
 * doaction-before-placeobject.swf by manually swapping the DoAction and
 * PlaceObject2 tags in the file with a hex editor
 */
int
main (int argc, char **argv)
{
  SWFMovie movie;
  SWFMovieClip clip;
  SWFDisplayItem item;

  if (Ming_init ())
    return 1;
  Ming_useSWFVersion (7);

  movie = newSWFMovie();
  SWFMovie_setRate (movie, 1);
  SWFMovie_setDimension (movie, 200, 150);

  clip = newSWFMovieClip ();
  item = SWFMovie_add (movie, (SWFBlock) clip);
  SWFDisplayItem_setName (item, "m");
  SWFDisplayItem_addAction (item, compileSWFActionCode (""
      "  trace (\"clipEvent (load)\");"
      "  trace (this);"
      ""), SWFACTION_ONLOAD);
  SWFMovie_add (movie, (SWFBlock) compileSWFActionCode (""
      "trace (\"Frame 0\");"
      ""));

  SWFMovie_save (movie, "doaction-before-placeobject.swf");
  return 0;
}
示例#2
0
文件: ming_utils.c 项目: aopui/gnash
void
add_actions(SWFMovie mo, const char* code)
{
	SWFAction ac;
	ac = compileSWFActionCode(code);
	SWFMovie_add(mo, (SWFBlock)ac);
}
示例#3
0
文件: ming_utils.c 项目: aopui/gnash
void
add_clip_init_actions(SWFMovieClip mo, const char* code)
{
	SWFAction ac;
	ac = compileSWFActionCode(code);
	SWFMovieClip_addInitAction(mo, ac);
}
示例#4
0
int
main (int argc, char **argv)
{
  SWFMovie movie;
  SWFVideoStream video;
  SWFDisplayItem item;
  SWFAction action;

  if (Ming_init ())
    return 1;
  Ming_useSWFVersion (7);

  movie = newSWFMovie();
  SWFMovie_setRate (movie, 1);
  SWFMovie_setDimension (movie, 200, 150);
  video = newSWFVideoStream ();
  SWFVideoStream_setDimension (video, 200, 150);
  item = SWFMovie_add (movie, (SWFBlock) video);
  SWFDisplayItem_setName (item, "video");
  action = compileSWFActionCode (""
      "trace (\"Test parsing of onMetaData\");"
      "nc = new NetConnection ();"
      "nc.connect (null);"
      "ns = new NetStream (nc);"
      "ns.onMetaData = function (info)"
      "{"
      "  trace ('onMetaData');"
      "  var props = [];"
      "  for (var prop in info) {"
      "    props.push (prop);"
      "  }"
      "  props.sort ();"
      "  for (var i = 0; i < props.length; i++) {"
      "    if (typeof (info[props[i]]) == 'object') {"
      "      var keys = [];"
      "      for (var key in info[props[i]]) {"
      "        keys.push (key);"
      "      }"
      "      keys.sort ();"
      "      trace (props[i] + ' = ');"
      "      for (var j = 0; j < keys.length; j++) {"
      "        trace ('  ' + keys[j] + ' = ' + typeof (info[props[i]][keys[j]]) + ': ' + info[props[i]][keys[j]]);"
      "      }"
      "    } else {"
      "      trace (props[i] + ' = ' + typeof (info[props[i]]) + ': ' + info[props[i]]);"
      "    }"
      "  }"
      "  loadMovie ('FSCommand:quit', '');"
      "};"
      "video.attachVideo (ns);"
      "ns.setBufferTime (5);"
      "trace (\"Calling play\");"
      "ns.play (\"video.flv\");"
      "trace (\"done calling play\");"
      "");
  SWFMovie_add (movie, (SWFBlock) action);
  SWFMovie_save (movie, "netstream-onmetadata.swf");
  return 0;
}
示例#5
0
文件: minghsp.c 项目: tkhaga/MingHSP
EXPORT BOOL WINAPI mhsp_SWFAction(SWFAction *p1, char *script, int p3, int p4)
{
#ifndef NOACTION
	lstrcpy(funcname, "SWFAction");
	*p1 = compileSWFActionCode(script);
#endif
	return 0;
}
示例#6
0
void
add_window(SWFMovie mo, int x, int y)
{
	SWFShape sh_window;
	SWFFillStyle fstyle;
	SWFMovieClip mc_window;
	SWFDisplayItem it;

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

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

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

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

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

}
示例#7
0
void
add_event(SWFMovie mo, const char* name, const char* event, const char* action)
{
	SWFAction ac;
	char buf[1024];

	sprintf(buf,
	"event=undefined;"
	"%s.on%s=function() { %s; };"
	, name, event, action
	);
	ac = compileSWFActionCode(buf);

	SWFMovie_add(mo, (SWFBlock)ac);
}
示例#8
0
文件: ming_utils.c 项目: aopui/gnash
SWFAction 
compile_actions(const char* fmt, ...)
{
	SWFAction ac;
	size_t BUFFER_SIZE = 65535;
	va_list ap;
	char tmp[BUFFER_SIZE];

	va_start (ap, fmt);
	vsnprintf (tmp, BUFFER_SIZE, fmt, ap);
	tmp[BUFFER_SIZE-1] = '\0';

	ac = compileSWFActionCode(tmp);
	va_end (ap);
	return ac;
}
示例#9
0
ActionTAG* swf_ActionCompile(const char* source, int version)
{
    TAG* tag;
    ActionTAG* a = 0;
    void*buffer = 0;
    int len = 0;
    int ret;
    
    tag = swf_InsertTag(NULL, ST_DOACTION);
    ret = compileSWFActionCode(source, version, &buffer, &len);
    if(!ret || buffer==0 || len == 0)
	return 0;

    swf_SetBlock(tag, (U8*)buffer, len);
    swf_SetU8(tag, 0);

    rfx_free(buffer);

    a = swf_ActionGet(tag);
    swf_DeleteTag(0, tag);
    return a;
}
示例#10
0
int
main(int argc, char** argv)
{
  SWFMovie mo;
  SWFMovieClip dejagnuclip;
  SWFDisplayItem  it, 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();
  mo = newSWFMovieWithVersion(OUTPUT_VERSION);
  SWFMovie_setDimension(mo, 800, 600);
  // low frame rate is needed for visual checking
  SWFMovie_setRate (mo, 1.0);

  dejagnuclip = get_dejagnu_clip((SWFBlock)get_default_font(srcdir), 10, 0, 0, 800, 600);
  SWFMovie_add(mo, (SWFBlock)dejagnuclip);
  add_actions(mo, 
    "test1=0; test2=0; test3=0; test4=0; test5='0'; test6=0; "
    "keyPressed=false; keyReleased=false;"
    "haslooped1=false; haslooped2=false;");
  SWFMovie_nextFrame(mo);  // _root frame1

  // test1: 
  //    (1)onKeyDown, onKeyPress and onKeyUp are not global functions
  //    (2)test that global Key object can be overridden
  //    (3)after overriden, previously registered handlers could still respond to new key events
  add_actions(mo, 
    "_root.var1 = 0; _root.var2 = 0;"
    "l = new Object();"
    "l.onKeyDown = function () { _root.note('l.onKeyDown'); _root.var1+=1; _root.Play(); }; "
    "l.onKeyUp = function () { _root.note('l.onKeyUp'); _root.var2+=1;}; "
    " Key.addListener(l);"
    "check_equals(typeof(Key), 'object');"
    "check_equals(typeof(onKeyUp), 'undefined');"
    "check_equals(typeof(onKeyDown), 'undefined');"
    "check_equals(typeof(onKeyPress), 'undefined');"
    "stop();"
    "_root.note('1. Press a single key to continue the test');"
  );
  SWFMovie_nextFrame(mo);  // _root frame2

  SWFMovie_nextFrame(mo);  // _root frame3
  
  add_actions(mo, 
    "stop();"
    "check_equals(var1, 1); "
    "check_equals(var2, 1); "
    "Key = 3;"
    "check_equals(typeof(Key), 'number');"
    "_root.note('2. Press a single key to continue the test');"
    );
  SWFMovie_nextFrame(mo);  // _root frame4
  
  SWFMovie_nextFrame(mo);  // _root frame5
  
  add_actions(mo,
    "stop();"
    "check_equals(var1, 2); "
    "check_equals(var2, 2);"
    "delete Key; "
    "check_equals(typeof(Key), 'object');"
    "Key.removeListener(l);"
    "_root.note('3. Press a single key to continue the test');"
    "obj1=new Object(); "
    " obj1.onKeyDown=function() {"
    "   _root.note('obj1.onKeyDown');"
    "   _root.play();"
    "}; "
    " Key.addListener(obj1); "
  );
  SWFMovie_nextFrame(mo);  // _root frame6
   
  add_actions(mo, 
    "check_equals(var1, 2);"
    "check_equals(var2, 2);"
    "Key.removeListener(obj1);"
    "delete l; delete obj1; "
  );
  SWFMovie_nextFrame(mo);  // _root frame7
  
  // test2:
  //    test removing of static clip key listeners
  SWFMovie_nextFrame(mo);  // _root frame8
  
  it = add_static_mc(mo, "listenerClip1", 20);
  SWFDisplayItem_addAction(it,
    newSWFAction(" _root.note('listenerClip2.onClipKeyDown'); "
                 " _root.test2++; "
                 "if(!_root.haslooped1){"
                 "   _root.haslooped1=true;"
                 "   _root.gotoAndPlay(_root._currentframe-1);"
                 "} else {"
                 "   _root.gotoAndPlay(_root._currentframe+1);"
                 "}"
                ), 
    SWFACTION_KEYDOWN);  
  add_actions(mo,
    "stop();"
    "_root.note('4. Press a single key to continue the test');"
  );
  SWFMovie_nextFrame(mo);  // _root frame9
  
  check_equals(mo, "_root.test2", "2");
  SWFDisplayItem_remove(it);
  SWFMovie_nextFrame(mo);  // _root frame10
  
  
  // test3:
  //    test removing of dynamic sprite key listeners 
  SWFMovie_nextFrame(mo);  // _root frame11
  
  add_actions(mo, 
    "stop();"
    "_root.note('5. Press a single key to continue the test');"
    "_root.createEmptyMovieClip('dynamic_mc', -10);"
    "dynamic_mc.onKeyDown = function() "
    "{"
    "   _root.note('dynamic_mc.onKeyDown triggered');"
    "   _root.check_equals(this, _root.dynamic_mc);"
    "   _root.test3++;"
    "   if(!_root.haslooped2){"
    "       _root.haslooped2=true;"
    "       _root.gotoAndPlay(_root._currentframe-1);"
    "       _root.check_equals(_root._currentframe, 11);"
    "   } else {"
    "       _root.gotoAndPlay(_root._currentframe+1);"
    "       _root.check_equals(_root._currentframe, 13);"
    "   }"
    "};"
    "Key.addListener(dynamic_mc);"
  );
  SWFMovie_nextFrame(mo);  // _root frame12
  
  check_equals(mo, "_root.test3", "2");
  add_actions(mo, "dynamic_mc.swapDepths(10);  dynamic_mc.removeMovieClip();");
  SWFMovie_nextFrame(mo);  // _root frame13
  
  // test4:
  //    GC test
  add_actions(mo, 
    "_root.note('6. Press a single key to continue the test');"
    " obj2 = new Object(); "
    " obj2.x = 100; "
    " obj2.onKeyDown = function () { "
    "   _root.note('obj2.onKeyDown triggered');"
    "   _root.test4++; "
    "   _root.objRef = this; "
    "   _root.play();"
    " };" 
    " Key.addListener(obj2); "
    // After deleting obj2, we still have a key listener kept alive!
    " delete obj2; "
    " stop();"
  );
  check_equals(mo, "_root.test4", "0");
  SWFMovie_nextFrame(mo);  // _root frame14
  
  check_equals(mo, "objRef.x", "100");
  check_equals(mo, "_root.test4", "1");
  add_actions(mo,
    "stop();"
    "_root.note('7. Press a single key to continue the test');"
    "Key.removeListener(objRef); "
    // check that objRef is still alive
    "check_equals(typeof(objRef), 'object');"
    // delete the objRef, no object and no key listener now.
    "delete objRef;"
    "obj3=new Object(); "
    "obj3.onKeyDown=function() {"
    "   _root.note('obj3.onKeyDown');"
    "   _root.gotoAndPlay(_currentframe+1);"
    "}; "
    "Key.addListener(obj3); "
  );
  SWFMovie_nextFrame(mo);  // _root frame15
  
  check_equals(mo, "_root.test4", "1");
  add_actions(mo, 
    "Key.removeListener(obj3);"
    "delete obj3; "
  );
  SWFMovie_nextFrame(mo);  // _root frame16

  // test5:
  //   test key listeners invoking order.
  //   expected behaviour:
  //   (1)for DisplayObject key listeners, first added last called
  //   (2)for general object listeners, first added first called
  //   (3)for DisplayObject listeners, user defined onKeyDown/Up won't be called
  //      if not registered to the global Key object.
  it1 = add_static_mc(mo, "ls1", 30);
  SWFDisplayItem_addAction(it1,
    compileSWFActionCode(
       "_root.note('ls1.onClipKeyDown');"
       "_root.test5 += '+ls1';"
    ),
    SWFACTION_KEYDOWN);
  SWFMovie_nextFrame(mo);  // _root frame17
  
  it2 = add_static_mc(mo, "ls2", 31);
  SWFDisplayItem_addAction(it2,
    compileSWFActionCode(
       "_root.note('ls2.onClipKeyDown');"
       "_root.test5 += '+ls2';"
    ),
    SWFACTION_KEYDOWN);
  SWFMovie_nextFrame(mo);  // _root frame18
   
  it3 = add_static_mc(mo, "ls3", 29);
  SWFDisplayItem_addAction(it3,
    compileSWFActionCode(
       "_root.note('ls3.onClipKeyDown');"
       "_root.test5 += '+ls3';"
    ),
    SWFACTION_KEYDOWN);
  SWFMovie_nextFrame(mo);  // _root frame19

  add_actions(mo, 
    "obj1=new Object();"
    "obj1.onKeyDown = function () { "
    "  _root.note('obj1.onKeyDown');"
    "  _root.test5 += '+obj1'; "
    "  _root.gotoAndPlay(_root._currentframe+1);"
    "}; "
    "Key.addListener(obj1);"
    "ls1.onKeyDown = function () {"
    "  _root.note('ls1.onKeyDown');"
    "  _root.test5 += '+ls1';"
    "}; "
    "Key.addListener(ls1);"
    "obj2=new Object();"
    "obj2.onKeyDown = function () {"
    "  _root.note('obj2.onKeyDown');"
    "  _root.test5 += '+obj2';"
    "}; "
    "Key.addListener(obj2);"
    "ls2.onKeyDown = function () {"
    "  _root.note('ls2.onKeyDown');"
    "  _root.test5 += '+ls2';"
    "}; "
    "Key.addListener(ls2);"
    "obj3=new Object();"
    "obj3.onKeyDown = function () {"
    "  _root.note('obj3.onKeyDown');"
    "  _root.test5 += '+obj3';"
    "}; "
    "Key.addListener(obj3);"
    "ls3.onKeyDown = function () {"
    "  _root.note('ls3.onKeyDown');"
    "  _root.test5 += '+ls3';"
    "}; "
    "stop(); "
    "_root.note('8. Press a single key to continue the test');"
  );
  SWFMovie_nextFrame(mo);  // _root frame20

  SWFMovie_nextFrame(mo);  // _root frame21
  
  add_actions(mo,
    "stop(); "
    "_root.note('9. Press a single key to continue the test');"
  );
  SWFDisplayItem_remove(it1);
  SWFDisplayItem_remove(it2);
  SWFDisplayItem_remove(it3);
  SWFMovie_nextFrame(mo);  // _root frame22
 
  check_equals(mo, "test5", "'0+ls3+ls2+ls1+obj1+ls1+obj2+ls2+obj3+obj1+obj2+obj3'");

  add_actions(mo,
     "o = new Object();"
     "_root.t = '';"
     "o.onKeyDown = function() { t = _root.ff.text; play(); };"
     "Key.addListener(o);"
     "_root.createTextField('ff', 987, 300, 20, 200, 40);"
     "_root.ff.type = 'input';"
     "_root.ff.text = 'Input here';"
     "_root.ff.border = true;"
    "_root.note('10. Click on the TextField and type \"i\"');"
    "stop();"
  );
  
  SWFMovie_nextFrame(mo);  // _root frame23

  // The listener is called before text is updated!
  check_equals(mo, "_root.t", "'Input here'");
  check_equals(mo, "_root.ff.text", "'Input herei'");


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

  return 0;
}
示例#11
0
int
main(int argc, char** argv)
{
  SWFMovie mo;
  SWFMovieClip  mc1, mc2, dejagnuclip;
  SWFDisplayItem it1, it2;
  SWFShape  sh_red;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

  return 0;
}
示例#13
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;
}
示例#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
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;
}
示例#16
0
文件: ming_utils.c 项目: aopui/gnash
static SWFAction
get_dejagnu_actions()
{
	static const char *buf = 
		"TestState = function() {\n"
		" this.passed = 0;\n"
		" this.failed = 0;\n"
		" this.xpassed = 0;\n"
		" this.xfailed = 0;\n"
		" this.untest = 0;\n"
		" this.unresolve = 0;\n"
		"};\n"
		"TestState.prototype.note = function (msg) {\n"
		" _root.xtrace(msg);\n"
		" trace (msg); "
		"};\n"
		"TestState.prototype.fail = function (why) {\n"
		" this.failed++;\n"
		" var msg = 'FAILED: '+why;\n"
		" _root.xtrace(msg);\n"
		" trace (msg); "
		"};\n"
		"TestState.prototype.xfail = function(why) {\n"
		" this.xfailed++;\n"
		" var msg = 'XFAILED: '+why;\n"
		" _root.xtrace(msg);\n"
		" trace (msg); "
		"};\n"
		"TestState.prototype.pass = function(why) {\n"
		" this.passed++;\n"
		" var msg = 'PASSED: '+why;\n"
		// don't visually print successes, still use 'trace' for them
		// " _root.xtrace(msg);\n"
		" trace (msg); "
		"};\n"
		"TestState.prototype.xpass = function(why) {\n"
		" this.xpassed++;\n"
		" var msg = 'XPASSED: '+why;\n"
		// don't visually print successes, even if unexpected,
		// still use 'trace' for them
		// " _root.xtrace(msg);\n"
		" trace (msg); "
		"};\n"
		"TestState.prototype.printtotals = function() {\n"
		" this.note('#passed: '+ this.passed);\n"
		" this.note('#failed: '+ this.failed);\n"
		" if ( this.xpassed ) {\n"
		"   this.note('#unexpected successes: '+ this.xpassed);\n"
		" }\n"
		" if ( this.xfailed ) {\n"
		"   this.note('#expected failures: '+ this.xfailed);\n"
		" }\n"
		" this.note('#total tests run: '+ this.testcount());\n"
		"};\n"
		"TestState.prototype.totals = function(exp, msg) {\n"
		" var obt = this.testcount(); "
		" if ( exp != undefined && obt != exp ) { "
		"   this.fail('Tests run '+obt+' (expected '+exp+') ['+msg+']'); "
		" }"
		" this.printtotals();"
		"};\n"
		"TestState.prototype.xtotals = function(exp, msg) {\n"
		" var obt = this.testcount(); "
		" if ( exp != undefined && obt != exp ) { "
		"   this.xfail('Tests run '+obt+' (expected '+exp+') ['+msg+']'); "
		" } else {"
		"   this.xpass('Tests run: '+obt+' ['+msg+']'); "
		" }"
		" this.printtotals();"
		"};\n"
		"TestState.prototype.testcount = function() {\n"
		" c=this.passed;\n"
		" c+=this.failed;\n"
		" if ( this.xpassed ) c+=this.xpassed;\n"
		" if ( this.xfailed ) c+=this.xfailed;\n"
		" return c;"
		"};\n"

		"_root.runtest = new TestState();\n"

		"_root.check_equals = function(obt, exp, msg) {"
		" if ( obt == exp ) "
        " {"
        "   if ( msg != undefined ) _root.runtest.pass(obt+' == '+exp+' ('+msg+')');"
        "   else _root.runtest.pass(obt+' == '+exp);"
        " }"
		" else "
        " {"
        "   if ( msg != undefined )"
        "   {"
        "       _root.runtest.fail('expected: '+exp+' , obtained: '+obt+' ('+msg+')');"
        "   }"
        "   else _root.runtest.fail('expected: '+exp+' , obtained: '+obt);"
        " }"
		"};\n"

		"_root.xcheck_equals = function(obt, exp) {"
		" if ( obt == exp )"
        " {"
        "   if ( msg != undefined )"
        "   {"
        "     _root.runtest.xpass(obt+' == '+exp+' ('+msg+')');\n"
        "   }"
        "   else"
        "   {"
        "     _root.runtest.xpass(obt+' == '+exp);\n"
        "   }"
        " }"
		" else"
        " {"
        "   if ( msg != undefined )"
        "   {"
        "     _root.runtest.xfail('expected: '+exp+' , obtained: '+obt);\n"
        "   }"
        "   else"
        "   {"
        "     _root.runtest.xfail('expected: '+exp+' , obtained: '+obt);\n"
        "   }"
        " }"
		"};\n"

		"_root.check = function(a, msg) {\n"
		" if ( a ) _root.runtest.pass(msg != undefined ? msg : a);\n"
		" else _root.runtest.fail(msg != undefined ? msg : a);\n"
		"};\n"

		"_root.xcheck = function(a, msg) {\n"
		" if ( a ) _root.runtest.xpass(msg != undefined ? msg : a);\n"
		" else _root.runtest.xfail(msg != undefined ? msg : a);\n"
		"};\n"

		"_root.fail = function(msg) {\n"
		" _root.runtest.fail(msg);\n"
		"};\n"

		"_root.xfail = function(msg) {\n"
		" _root.runtest.xfail(msg);\n"
		"};\n"

		"_root.pass = function(msg) {\n"
		" _root.runtest.pass(msg);\n"
		"};\n"

		"_root.xpass = function(msg) {\n"
		" _root.runtest.xpass(msg);\n"
		"};\n"

		"_root.note = function(msg) {\n"
		" _root.xtrace(msg);\n"
		" trace(msg);\n"
		"};\n"

		"_root.totals = function(exp, info) {\n"
		" _root.runtest.totals(exp, info);\n"
		"};\n"

		"_root.xtotals = function(exp, info) {\n"
		" _root.runtest.xtotals(exp, info);\n"
		"};\n"

		"_root.dejagnu_module_initialized = 1;\n";

	return compileSWFActionCode(buf);
}
示例#17
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;
}
示例#18
0
	sh = newSWFShapeFromBitmap((SWFBitmap)bm, SWFFILL_CLIPPED_BITMAP);
	mc = newSWFMovieClip();
	SWFMovieClip_add(mc, (SWFBlock)sh);
	SWFMovieClip_nextFrame(mc); /* showFrame */
	it = SWFMovie_add(mo, (SWFBlock)mc);
	SWFDisplayItem_setName(it, name);
	SWFDisplayItem_moveTo(it, x, y);

	/* "Click" handler */
	sprintf(action, " \
%s.onPress = function () { \
	_root.CoverArtLoader.loadClip('%s', coverart); \
}; \
", name, url);

	ac = compileSWFActionCode(action);

	SWFMovie_add(mo, (SWFBlock)ac);
}

int
main(int argc, char** argv)
{
	SWFMovie mo;
	char file_lynch[256];
	char file_green[256];
	char file_offspring[256];
	char url_lynch[256];
	char url_green[256];
	char url_offspring[256];
	const char *srcdir=".";