Return to FunctionReference page
Function
Purpose
Set the total frame count for a given movie clip.
Parameters
SWF!MovieClip clip - Movie clip to be adjusted
int frames - New total number of frames
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 int i;
9 SWFDisplayItem image_display_item;
10 SWFFont font_object;
11 SWFMovieClip movie_clip;
12 SWFMovie test_movie;
13 SWFText text_object;
14
15
16 // Initialise the movie structure in memory
17 Ming_init();
18 test_movie = newSWFMovieWithVersion(7);
19
20 // Set the desired compression level for the output (9 = maximum compression)
21 Ming_setSWFCompression(9);
22
23 // Set the background color for the movie
24 SWFMovie_setBackground(test_movie, 0xff, 0xff, 0xff);
25
26 // Adjust the dimensions of the movie
27 SWFMovie_setDimension(test_movie, 800, 600);
28
29 // Set the frame rate for the movie to 24 frames per second
30 SWFMovie_setRate(test_movie, 24.0);
31
32 // Load a font from disk
33 font_object = newSWFFont_fromFile("font.fdb");
34 if (NULL == font_object)
35 {
36 // Something went wrong, so exit
37 printf("Unable to load font from file.\n");
38 return EXIT_FAILURE;
39 }
40
41 // Create a new, empty text object
42 text_object = newSWFText();
43
44 // Tell the text object to use the font previously loaded
45 SWFText_setFont(text_object, font_object);
46
47 // Set the height of the text
48 SWFText_setHeight(text_object, 18.0);
49
50 // Set the color of the text
51 SWFText_setColor(text_object, 0x00, 0x00, 0xff, 0xff);
52
53 // Add a string to the text object
54 SWFText_addString(text_object, "This is some example text inside a movie clip", NULL);
55
56 // Create the movie clip object
57 movie_clip = newSWFMovieClip();
58
59 // Add the text object to the movie clip
60 SWFMovieClip_add(movie_clip, (SWFBlock) text_object);
61
62 // Advance the movie clip one frame, else it doesn't get displayed
63 SWFMovieClip_nextFrame(movie_clip);
64
65 // Set the total number of frames in the movie clip
66 SWFMovieClip_setNumberOfFrames(movie_clip, 50);
67
68 // Add the movie clip object to the main movie
69 image_display_item = SWFMovie_add(test_movie, (SWFBlock) movie_clip);
70
71 // Move to 100, 100
72 SWFDisplayItem_moveTo(image_display_item, 100.00, 100.0);
73
74 // Set the name of this display item
75 SWFDisplayItem_setName(image_display_item, "my_display_item");
76
77 // Progressively move the text down and to the right
78 for (i = 0; i <= 250; i++)
79 {
80 SWFMovie_nextFrame(test_movie);
81 SWFDisplayItem_move(image_display_item, 2, 2);
82 }
83
84 // Save the swf movie file to disk
85 SWFMovie_save(test_movie, "ming-test.swf");
86
87 // Free the swf movie in memory
88 destroySWFMovie(test_movie);
89
90 // Free the movie clip object
91 destroySWFMovieClip(movie_clip);
92
93 // Free the swf text object
94 destroySWFText(text_object);
95
96 return EXIT_SUCCESS;
97 }