SWF::Movie
SWF Movie class
- Provided by: libswf-perl (Version: 1:0.4.5-1.2ubuntu7)
- Source: ming
- Report a bug
SWF Movie class
use SWF::Movie;
$m = new SWF::Movie();
$m = SWF::Movie::newSWFMovieWithVersion(8);
SWF::Movie is the root object of your flashfile. It contains all your other objects you want in your movie. Ming supports many Flash4, Flash5 F6,7,8,9.. features.
The SWF::Movie object contains information like the flashversion, the size, the frames per second, the background color. Except that, the SWF::Movie behaves like a SWF::MovieClip. It only cannot be added to another SWF::Movie or SWF::MovieClip.
Notice: The version of your flashmovie can be set by the object SWF. See SWF for more details.
Some possible SWF-objects are:
SWF::Action
SWF::MovieClip
SWF::Shape
SWF::Sound
SWF::Text
SWF::TextField
SWF::Bitmap
SWF::PrebuiltClip
$m->add($shape); # possible, but not more accessible for us
$shape_1 = m->add($shape); # good instance
$m->addExport($mc, 'mc');
# and later inside action script....:
$ac = new SWF::Action("_root.attachMovie('mc','mc1',11);");
$m->remove($shape_i);
$m->nextFrame();
$m->setFrames(100);
$m-setBackground(0xff,0x99,0x00); # orange bg
$m-setBackground(0,200,255) # green bg
A transparency level isn't available I asume. (In Flash MX/F6?). A transparent background can be set in the HTML-code for Internet Explorer. Please inform the Authors if that is available for nonIE-browsers.
#ToDo:
#min: (0.0,0.0) # ;-)
#max: (?,?)
#default: (0.0?,0.0?)
#Behavior when values <min: ming sets it to min
#Behavior when values >max: ming sets it to max
$m->setDimension(200,100);
$m->setDimension(123.45,67.89);
#ToDo:
#min: 0
#max: ?
#default: ?
#Behavior when value <min: ming sets it to min
#Behavior when value >max: ming sets it to max
$m->setRate(30);
$m->setSoundStream($soundstream);
$m->streamMp3("iloveyou.mp3");
Hint: If you want to reuse this sound/mp3 later in this movie, create a reusable SWF::SoundStream object and then put it into setSoundstream().
$sound = new SWF::Sound("loveyoutoo.mp3", SWF_SOUND_MP3_COMPRESSED );
$si = $m->startSound($sound);
$m->labelFrame("win");
#ToDo:
#max characters of a label???
#What happen if we put there a big string??
#Which characters are allowed??
$font = new SWF::Font('Arial.fdb');
$fch = $m->addFont($font);
$fch = $m->importFont('textField.swf', 'Arial337a');
$dispitem = $movie->add($shape1);
$movie->nextFrame();
print $movie->replace($dispitem, $shape2);
$movie->nextFrame();
The parameter compresslevel is optional. compresslevel between 0 and 9. Higher values will be interpreted as 9. Values smaller 0 mean no compression. By default the SWF::Movie will be send without compression. Notice: compression available since Flash MX(Flash 6). Ming does not check this for you if you write flash4 or flash5 movies.
Unlike xs_output() the output() method prepared for using via webservers (but not limited to webservers).
Both methods return number of bytes written.
3 examples: a regular minimal SWF::Movie, one with all methods and a more interesting.
#!/usr/bin/perl -w
use SWF::Movie;
$m = new SWF::Movie();
$m->nextFrame();
$m->save("emptyminimal.swf");
#!/usr/bin/perl -w
use SWF::Movie;
$m = new SWF::Movie();
$m->setVersion(4);
$m->setBackground(0xff,0xcc,0x0);
$m->setDimension(200,100);
$m->protect();
$m->setRate(30);
$m->setFrames(10); # ming fills it automatic with frames
$m->nextFrame()
$m->save("empty.swf");
#!/usr/bin/perl -w
use SWF("Shape");
SWF::setVersion(6);
$m = new SWF::Movie();
$m->setBackground(0xff,0xcc,0x0);
$m->setDimension(200,100);
$m->setFrames(10);
$m->streamMp3("forever.mp3");
$s= new SWF::Shape();
$s->setLine(40,0xff,0xff,0);
$s->setRightFill(0xff,0,0);
$s->drawLine(50,0);
$s->drawLine(0,20);
$s->drawLineTo(0,0);
$s_1= $m->add($s);
$s_2= $m->add($s);
$s_1->move(50,40);
$s_2->move(10,40);
for($i=1;$i<5;$i++) {
$m->nextFrame();
$s_2->move(0,10);
}
$m->nextFrame();
print "Content-type: application/x-shockwave-flash\n\n";
$m->output(9); # with compression level 9 (since flash6)
Soheil Seyfaie (soheil at users.sourceforge.net), Albrecht Kleine and developers of ming.sourceforge.net
SWF, SWF::Action, SWF::Bitmap, SWF::Button, SWF::Constants, SWF::DisplayItem, SWF::Fill, SWF::Font, SWF::FontCharacter, SWF::Gradient, SWF::Morph, SWF::MovieClip, SWF::Shape, SWF::PrebuiltClip, SWF::Sound, SWF::SoundStream, SWF::TextField, SWF::Text, SWF::Filter, SWF::Character