
#include "ming.h"

int main()
{
  int n;

  SWFShape s;
  SWFFill f;
  SWFMovieClip p;
  SWFDisplayItem i;
  SWFMovie m;

  Ming_init();
  Ming_setScale(1.0);

  s = newSWFShape();
  f = SWFShape_addSolidFill(s, 0xff, 0, 0, 0xff);
  SWFShape_setRightFill(s, f);

  SWFShape_movePenTo(s, -500,-500);
  SWFShape_drawLineTo(s, 500,-500);
  SWFShape_drawLineTo(s, 500,500);
  SWFShape_drawLineTo(s, -500,500);
  SWFShape_drawLineTo(s, -500,-500);

  p = newSWFMovieClip();

  i = SWFMovieClip_add(p, s);
  SWFDisplayItem_setDepth(i, 1);
  SWFMovieClip_nextFrame(p);

  for(n=0; n<5; ++n)
  {
    SWFDisplayItem_rotate(i, -15);
    SWFMovieClip_nextFrame(p);
  }

  m = newSWFMovie();
  SWFMovie_setBackground(m, 0xff, 0xff, 0xff);
  SWFMovie_setDimension(m, 6000,4000);

  i = SWFMovie_add(m, p);
  SWFDisplayItem_setDepth(i, 1);
  SWFDisplayItem_moveTo(i, -500,2000);
  SWFDisplayItem_setName(i, "box");

  SWFMovie_add(m, compileSWFActionCode("x=-100;"));
  SWFMovie_nextFrame(m);
  SWFMovie_add(m, compileSWFActionCode("x+=3; /box.x=x;"));
  SWFMovie_nextFrame(m);
  SWFMovie_add(m, compileSWFActionCode("gotoFrame(1); play();"));
  SWFMovie_nextFrame(m);

  SWFMovie_save(m, "test.swf");

  exit(0);
}
