Return to FunctionReference page

Function

Purpose

  • Moves a SWF Display Item by a given amount.

Parameters

  1. SWF!DisplayItem item - The SWF Display Item to be moved

  2. float x - The x amount to move (delta).

  3. float y - The y amount to move (delta).

Returns

  • void - No return value

Language

  • C

Ming version

  • (unknown). At least 0.4.0 and onwards, possibly earlier versions as well.

Notes

  • None as yet

Example

   1 #include <stdio.h>
   2 #include <stdlib.h>
   3 #include <ming.h>
   4 
   5 int main(void)
   6 {
   7         // Create local variables
   8         SWFFillStyle fill_style;
   9         int i;
  10         SWFShape square_definition;
  11         SWFDisplayItem square_display_item;
  12         SWFMovie test_movie;
  13 
  14 
  15         // Initialise the movie structure in memory
  16         Ming_init();
  17         test_movie = newSWFMovieWithVersion(7);
  18 
  19         // Set the background color for the movie
  20         SWFMovie_setBackground(test_movie, 0x00, 0x00, 0x00);
  21 
  22         // Set the movie dimensions to 640 x 480
  23         SWFMovie_setDimension(test_movie, 640, 480);
  24 
  25         // Set the frame rate for the movie to 24 frames per second
  26         SWFMovie_setRate(test_movie, 24.0);
  27 
  28         // Create a new fill style (semi-transparent)
  29         fill_style = newSWFSolidFillStyle(0xa5, 0xa5, 0xff, 0x80);
  30         
  31         // Create a square
  32         square_definition = newSWFShape();
  33         SWFShape_setRightFillStyle(square_definition, fill_style);
  34         SWFShape_drawLine(square_definition, 200.0, 0.0);
  35         SWFShape_drawLine(square_definition, 0.0, 200.0);
  36         SWFShape_drawLine(square_definition, -200.0, 0.0);
  37         SWFShape_drawLine(square_definition, 0.0, -200.0);
  38 
  39         // Add the square to the movie (at 0,0)
  40         square_display_item = SWFMovie_add(test_movie, (SWFBlock) square_definition);
  41 
  42         // Move to 100, 100
  43         SWFDisplayItem_moveTo(square_display_item, 100.00, 100.0);
  44 
  45         // Progressively move the square down and to the right
  46         for (i = 0; i <= 50; i++)
  47         {
  48                 SWFMovie_nextFrame(test_movie);
  49                 SWFDisplayItem_move(square_display_item, 2, 2);
  50         }
  51 
  52         // Set the desired compression level for the output (9 = maximum compression)
  53         Ming_setSWFCompression(9);
  54 
  55         // Save the swf movie file to disk
  56         SWFMovie_save(test_movie, "ming-test.swf");
  57 
  58         return EXIT_SUCCESS;
  59 }