1.::SWF::Movie(3)      User Contributed Perl Documentation     .::SWF::Movie(3)
2
3
4

NAME

6       SWF::Movie - SWF Movie class
7

SYNOPSIS

9               use SWF::Movie;
10
11               $m = new SWF::Movie();
12               $m = SWF::Movie::newSWFMovieWithVersion(8);
13

DESCRIPTION

15       SWF::Movie is the root object of your flashfile. It contains all your
16       other objects you want in your movie.  Ming supports many Flash4,
17       Flash5 F6,7,8,9.. features.
18
19       The SWF::Movie object contains information like the flashversion, the
20       size, the frames per second, the background color. Except that, the
21       SWF::Movie behaves like a SWF::MovieClip. It only cannot be added to
22       another SWF::Movie or SWF::MovieClip.
23
24       Notice: The version of your flashmovie can be set by the object SWF.
25       See SWF for more details.
26

METHODS

28       $m = new SWF::Movie()
29           Creates a Movie object.
30
31       $m = newSWFMovieWithVersion(version)
32           Creates a Movie object with version value (e.g. 8) set.
33
34       $displayItem=$m->add($SWFObject)
35           Add an instance of a SWF-object to your current frame. The
36           returnvalue is a SWF::DisplayItem.
37
38                   Some possible SWF-objects are:
39
40                   SWF::Action
41                   SWF::MovieClip
42                   SWF::Shape
43                   SWF::Sound
44                   SWF::Text
45                   SWF::TextField
46                   SWF::Bitmap
47                   SWF::PrebuiltClip
48
49                   $m->add($shape); # possible, but not more accessible for us
50                   $shape_1 = m->add($shape); # good instance
51
52       $m->addExport($block, $name)
53           Prepare linkage to Action script code.
54
55                   $m->addExport($mc, 'mc');
56                   # and later inside action script....:
57                   $ac = new SWF::Action("_root.attachMovie('mc','mc1',11);");
58
59       $m->writeExports()
60           Export prepared names to Action script.
61
62       remove($displayItem)
63           Removes the given SWF::DisplayItem instance from the current and
64           following frames of the main timeline.
65
66                   $m->remove($shape_i);
67
68       nextFrame()
69           Finish a frame of the main timeline. New added objects will be
70           added in the next frame.
71
72                   $m->nextFrame();
73
74       setNumberOfFrames($frames) =item setFrames($frames)
75           Preset the number of frames of the main timeline. n not used frames
76           before finishing the movie will filled with n nextFrame()
77           statements.  If you inserted more nextFrame() commands than you set
78           with setFrames() the setFrames() will be ignored.
79
80                   $m->setFrames(100);
81
82       $m->setBackground($red,$green,$blue)
83           Set the background in red, green, blue values. Possible value are
84           0..255 or hexvalues 0x0..0xff.
85
86                   $m-setBackground(0xff,0x99,0x00); # orange bg
87                   $m-setBackground(0,200,255)       # green bg
88
89           A transparency level isn't available I asume. (In Flash MX/F6?). A
90           transparent background can be set in the HTML-code for Internet
91           Explorer. Please inform the Authors if that is available for nonIE-
92           browsers.
93
94       $m->namedAnchor($label)
95           This function adds a named anchor to the movie.
96
97       $m->setDimension(x,y)
98           Set the dimension in pixel.
99
100                   #ToDo:
101                   #min: (0.0,0.0)   # ;-)
102                   #max: (?,?)
103                   #default: (0.0?,0.0?)
104                   #Behavior when values <min: ming sets it to min
105                   #Behavior when values >max: ming sets it to max
106
107                   $m->setDimension(200,100);
108                   $m->setDimension(123.45,67.89);
109
110       $m->setRate(int)
111           Set the playing speed in frames/second.
112
113                   #ToDo:
114                   #min: 0
115                   #max: ?
116                   #default: ?
117                   #Behavior when value <min: ming sets it to min
118                   #Behavior when value >max: ming sets it to max
119
120                   $m->setRate(30);
121
122       $m->protect()
123           A feature that prevents only flashnewbies from importing your movie
124           into Macromedias Flash authoring tools. It cannot protect your
125           content from being loaded by other flashmovies, deleting of the
126           protection with a hexeditor or disassembling with tools.
127
128       $m->setSoundStream($soundstream, [$skip])
129           Puts an SWF::SoundStream object as streaming sound into the main
130           timeline.  The optional skip parameter describes the time in
131           seconds to be skiped.
132
133                   $m->setSoundStream($soundstream);
134
135       $m->streamMp3($filename)
136           Simplifies the setSoundStream(). You only need the filename.
137
138                   $m->streamMp3("iloveyou.mp3");
139
140           Hint: If you want to reuse this sound/mp3 later in this movie,
141           create a reusable SWF::SoundStream object and then put it into
142           setSoundstream().
143
144       $soundinstance = $m->startSound($sound)
145           Play a prepared SWF::Sound object into the main timeline. Returns
146           an object of SWF::SoundInstance.
147
148                   $sound = new SWF::Sound("loveyoutoo.mp3", SWF_SOUND_MP3_COMPRESSED );
149                   $si = $m->startSound($sound);
150
151       $m->stopSound($sound)
152           Stop playing sound.
153
154       $m->labelFrame($string)
155           Gives the current frame a label that can be used by actionscript as
156           anchor. Then you don't have to count your nextFrame() lines
157           anymore. :-)
158
159                   $m->labelFrame("win");
160                   #ToDo:
161                   #max characters of a label???
162                   #What happen if we put there a big string??
163                   #Which characters are allowed??
164
165       $m->setScriptLimits($maxRecursion, $timeout)
166           Set limits for resource usage, related to action script. Setting
167           timeout will protect your computer from too long loops and stack
168           overflow. So endless scripts like "while (1){};" will be
169           interrupted after timeout seconds.  The default recursion depth is
170           265, the default timeout is 15 seconds.
171
172       $m->defineScene($offset, $name)
173           Define scenes for the movies' main timeline using integer value for
174           frame offset and name of the scene.
175
176       $m->setNetworkAccess($flag)
177           Sets network / fileaccess policy. If the flag is set to 0 a localy
178           loaded movie will be unable to access the network but is allowed to
179           access local files.  If the flag ist set to 1 a localy loaded movie
180           will be unable to access local files but is allowed to access the
181           network. For SWF >= 8: default is 0,
182
183       $m->addMetadata($xml)
184           Adds Metadata to the movie: this function inserts a metadata-tag
185           into the movie. Only one metadata-tag can be set to a movie.
186           Metadata is specified as an XML string.
187
188       $m->assignSymbol($character, $name)
189           Assigns a symbolic name for a SWF::Character object.  Such classes
190           are available for usage in other SWF files and can be referenced
191           from inside the current movie.  To assign a symbol to the root
192           movie use NULL as character value.
193
194       $m->setTabIndex($depth, $index)
195           Sets tab index for specified depth level.
196
197       $fontchar = $m->addFont($font)
198           Adds a font to a movie. An object of SWF::FontCharacter class
199           returned.
200
201                   $font = new SWF::Font('Arial.fdb');
202                   $fch  = $m->addFont($font);
203
204       $fontchar = $m->importFont($file, $name)
205           Imports a font from an other SWFFile. An object of
206           SWF::FontCharacter class returned.
207
208                   $fch = $m->importFont('textField.swf', 'Arial337a');
209
210       $m->importCharacter($url, $name)
211           Not yet documented (ToDo!)
212
213       $result = $m->replace($item, $block)
214           This method replaces a displayable character with a new one.
215           Returns 0 on success , -1 else.
216
217                   $dispitem = $movie->add($shape1);
218                   $movie->nextFrame();
219                   print $movie->replace($dispitem, $shape2);
220                   $movie->nextFrame();
221
222       $written = $m->xs_output([$compresslevel])
223       $written = $m->output([$compresslevel])
224           Writes the SWF::Movie to stdout. This is normally used for
225           webservers/cgi-scripts.  Don't forget to send the
226           "Content-Type:"-lines before writing out the movie.
227
228           The parameter compresslevel is optional. compresslevel between 0
229           and 9. Higher values will be interpreted as 9. Values smaller 0
230           mean no compression. By default the SWF::Movie will be send without
231           compression.  Notice: compression available since Flash MX(Flash
232           6). Ming does not check this for you if you write flash4 or flash5
233           movies.
234
235           Unlike xs_output() the output() method prepared for using via
236           webservers (but not limited to webservers).
237
238           Both methods return number of bytes written.
239
240       $written = $m->save($filename [, $compresslevel])
241           Method saves the SWF::Movie to a file and returns the number of
242           bytes written.  The parameter compresslevel is optional.
243           compresslevel between 0 and 9. Higher values will be interpreted as
244           9. Values smaller 0 mean no compression. By default the SWF::Movie
245           will be saved without compression.  Notice: compression available
246           since Flash MX(Flash 6). Ming does not check this for you if you
247           write flash4 or flash5 movies.
248

EXAMPLE

250       3 examples: a regular minimal SWF::Movie, one with all methods and a
251       more interesting.
252
253       minimal empty example
254                   #!/usr/bin/perl -w
255                   use SWF::Movie;
256
257                   $m = new SWF::Movie();
258                   $m->nextFrame();
259                   $m->save("emptyminimal.swf");
260
261       full empty examples
262                   #!/usr/bin/perl -w
263                   use SWF::Movie;
264
265                   $m = new SWF::Movie();
266                   $m->setVersion(4);
267                   $m->setBackground(0xff,0xcc,0x0);
268                   $m->setDimension(200,100);
269                   $m->protect();
270                   $m->setRate(30);
271                   $m->setFrames(10); # ming fills it automatic with frames
272
273                   $m->nextFrame()
274                   $m->save("empty.swf");
275
276       streaming example
277                   #!/usr/bin/perl -w
278                   use SWF("Shape");
279                   SWF::setVersion(6);
280
281                   $m = new SWF::Movie();
282                   $m->setBackground(0xff,0xcc,0x0);
283                   $m->setDimension(200,100);
284                   $m->setFrames(10);
285                   $m->streamMp3("forever.mp3");
286
287                   $s= new SWF::Shape();
288                   $s->setLine(40,0xff,0xff,0);
289                   $s->setRightFill(0xff,0,0);
290                   $s->drawLine(50,0);
291                   $s->drawLine(0,20);
292                   $s->drawLineTo(0,0);
293
294                   $s_1= $m->add($s);
295                   $s_2= $m->add($s);
296                   $s_1->move(50,40);
297                   $s_2->move(10,40);
298                   for($i=1;$i<5;$i++) {
299                           $m->nextFrame();
300                           $s_2->move(0,10);
301                   }
302                   $m->nextFrame();
303                   print "Content-type: application/x-shockwave-flash\n\n";
304                   $m->output(9); # with compression level 9 (since flash6)
305

AUTHOR

307       Soheil Seyfaie (soheil at users.sourceforge.net), Albrecht Kleine and
308       developers of ming.sourceforge.net
309

SEE ALSO

311       SWF, SWF::Action, SWF::Bitmap, SWF::Button, SWF::Constants,
312       SWF::DisplayItem, SWF::Fill, SWF::Font, SWF::FontCharacter,
313       SWF::Gradient, SWF::Morph, SWF::MovieClip, SWF::Shape,
314       SWF::PrebuiltClip, SWF::Sound, SWF::SoundStream, SWF::TextField,
315       SWF::Text, SWF::Filter, SWF::Character
316
317
318
319perl v5.30.0                      2019-10-02                  .::SWF::Movie(3)
Impressum