(These are just rough initial thoughts for now)

Concepts you need to know when starting out with Ming

Example

  • Note - This is in C

   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         SWFShape square_definition;
  10         SWFDisplayItem square_display_item;
  11         SWFMovie test_movie;
  12 
  13 
  14         // Initialise the movie structure in memory
  15         Ming_init();
  16         test_movie = newSWFMovieWithVersion(7);
  17 
  18         // Set the background color for the movie
  19         SWFMovie_setBackground(test_movie, 0x00, 0x00, 0x00);
  20 
  21         // Set the frame rate for the movie to 12 frames per second
  22         SWFMovie_setRate(test_movie, 12.0);
  23 
  24         // Set the total number of frames in the movie to 120
  25         SWFMovie_setNumberOfFrames(test_movie, 120);
  26 
  27         // Create a new fill style (semi-transparent)
  28         fill_style = newSWFSolidFillStyle(0xa5, 0xa5, 0xff, 0x80);
  29         
  30         // Create a square
  31         square_definition = newSWFShape();
  32         SWFShape_setRightFillStyle(square_definition, fill_style);
  33         SWFShape_drawLine(square_definition, 100.0, 0.0);
  34         SWFShape_drawLine(square_definition, 0.0, 100.0);
  35         SWFShape_drawLine(square_definition, -100.0, 0.0);
  36         SWFShape_drawLine(square_definition, 0.0, -100.0);
  37 
  38         // Add the square to the movie (at 0,0)
  39         square_display_item = SWFMovie_add(test_movie, (SWFBlock) square_definition);
  40 
  41         // Move to 100, 100
  42         SWFDisplayItem_moveTo(square_display_item, 100.00, 100.0);
  43 
  44         // Set the desired compression level for the output (9 = maximum compression)
  45         Ming_setSWFCompression(9);
  46 
  47         // Save the swf movie file to disk
  48         SWFMovie_save(test_movie, "ming-example.swf");
  49 
  50         return EXIT_SUCCESS;
  51 }

libming: ImportantConcepts (last edited 2009-06-25 03:09:37 by localhost)