Return to FunctionReference page
Function
void SWFText_moveTo(SWFText text, float x, float y);
Purpose
- Moves the pen position in a text object (without drawing), so further strings appear at the new offsets.
Parameters
SWFText text - The text object to move the pen in.
float x - The new X position for the pen. NOT a delta.
float y - The new Y position for the pen. NOT a delta.
Returns
void - No return value
Language
- C
Ming version
- (unknown). At least 0.4.0 and onwards, possibly earlier versions as well.
Notes
- If 0 (zero) is given for either the x or y value, that value is skipped.
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 SWFMovie test_movie;
12 SWFText text_object;
13
14
15 // Initialise the movie structure in memory
16 Ming_init();
17 test_movie = newSWFMovieWithVersion(7);
18
19 // Set the desired compression level for the output (9 = maximum compression)
20 Ming_setSWFCompression(9);
21
22 // Set the background color for the movie
23 SWFMovie_setBackground(test_movie, 0x00, 0x00, 0x00);
24
25 // Adjust the dimensions of the movie
26 SWFMovie_setDimension(test_movie, 800, 600);
27
28 // Set the frame rate for the movie to 24 frames per second
29 SWFMovie_setRate(test_movie, 24.0);
30
31 // Load a font from disk
32 font_object = newSWFFont_fromFile("font.fdb");
33 if (NULL == font_object)
34 {
35 // Something went wrong, so exit
36 printf("Unable to load font from file.\n");
37 return EXIT_FAILURE;
38 }
39
40 // Create a new, empty text object
41 text_object = newSWFText();
42
43 // Tell the text object to use the font previously loaded
44 SWFText_setFont(text_object, font_object);
45
46 // Set the height of the text
47 SWFText_setHeight(text_object, 18.0);
48
49 // Set the color of the text
50 SWFText_setColor(text_object, 0x00, 0x00, 0xff, 0xff);
51
52 // Add a string to the text object
53 SWFText_addString(text_object, "This is some example text", NULL);
54
55 // Move the pen position in the text object
56 SWFText_moveTo(text_object, 20.0, 20.0);
57
58 // Add a another string to the text object, from the new pen position
59 SWFText_addString(text_object, "This is more example text", NULL);
60
61 // Add the text object to the movie (at 0,0)
62 image_display_item = SWFMovie_add(test_movie, (SWFBlock) text_object);
63
64 // Move to 100, 100
65 SWFDisplayItem_moveTo(image_display_item, 100.00, 100.0);
66
67 // Progressively move the text down and to the right
68 for (i = 0; i <= 250; i++)
69 {
70 SWFMovie_nextFrame(test_movie);
71 SWFDisplayItem_move(image_display_item, 2, 2);
72 }
73
74 // Save the swf movie file to disk
75 SWFMovie_save(test_movie, "ming-test.swf");
76
77 // Free the swf movie in memory
78 destroySWFMovie(test_movie);
79
80 // Free the swf text object
81 destroySWFText(text_object);
82
83 return EXIT_SUCCESS;
84 }