René Nyffenegger's collection of things on the web
René Nyffenegger on Oracle - Most wanted - Feedback -
 

Dragging II [Ming wrapper example]

This example is similar to this example.
See also the Hit test example.
This flash movie was created with the following program.
Dragging2.cpp
#include "SWFMovie.h"

void AddDraggable(Movie& m, Shape& s, int x, int y) {
  MovieClip clip;
  Button    button;

  TextField text(Font("Verdana.fdb"), 14, 0, 14, "x=???, y=???", 0x40, 0x60, 0x80, 0xff);

  int all_states = SWFBUTTON_UP | SWFBUTTON_OVER | SWFBUTTON_HIT | SWFBUTTON_DOWN;
  button.Add(s, all_states);

  button.Add(Action("this.startDrag();"), SWFBUTTON_MOUSEDOWN);
  button.Add(Action("this.stopDrag ();"), SWFBUTTON_MOUSEUP  );

  DisplayItem iBtn  = clip.Add(button);
  DisplayItem iText = clip.Add(text);

  iBtn. MoveTo(x, y);
  iText.MoveTo(x, y);

  iText.Name("txt");

  DisplayClip iClip = m.Add(clip);
  iClip.OnMouseMove(Action("this.txt.text='dx='+this._x+', dy='+this._y;"));

  clip.NextFrame();
}

int main() {
  Movie  movie ("Dragging2.swf", 400, 400);

  Shape  button_shape; 
  button_shape.LineStyle(1, 99,99,99);
  button_shape.FillStyle(222,222,222);
  button_shape.Line(120, 0);
  button_shape.Line(0 ,20);
  button_shape.Line(-120 ,0);
  button_shape.Line(0 ,-20);

  AddDraggable(movie, button_shape, 100, 200);
  AddDraggable(movie, button_shape, 200, 300);
  AddDraggable(movie, button_shape, 300, 100);

  movie.NextFrame();
}
This is one of a series of examples that demonstrates the C++ ming wrapper classes. Other examples can be found here.