Re: Question about pictureanimation

fee <[email protected]> Fri, 12 Sep 2003 03:32:21 +0200
Newsgroups gmane.comp.web.ming.general
Message-ID <[email protected]>
> can I add a picture add to a shape using ming and is it able to animate
> the picture in the browser.
yes.

> Is the able to do this using ming alone or have I to use actionscript in
> addition to ming.

yes, possible without actionscript. Use the mathfunctions of your prefered
language or data.

A complete example:

#!/usr/bin/perl -w
use SWF qw(Shape);
SWF::setVersion(4);
$m = new SWF::Movie;

$m->setRate(30);
$m->setDimension(300, 200);
$m->setBackground(0xff, 0xff, 0xff);

$s1 = new SWF::Shape;
$f=$s1->addFill(new SWF::Bitmap("ming-fun.jpg"));
$s1->setRightFill($f);
$s1->setLine(80,0xff,0x99,0);
$s1->drawLine(109,0);
$s1->drawLine(0,163);
$s1->drawLine(-109,0);
$s1->drawLineTo(0,0);

$displayItem=$m->add($s1);

# some animations
for($i=0.0;$i<5.0;$i=$i+0.05){
 $displayItem->moveTo(150+20*$i*sin($i),100+20*cos($i));
 $displayItem->rotate($i*10);
 $displayItem->scaleTo(sin($i)/2);
 $m->nextFrame;
}
# and back
for($i=5.0;$i>0.0;$i=$i-0.05){
 $displayItem->moveTo(150+20*$i*sin($i),100+20*cos($i));
 $displayItem->rotate(-$i*10);
 $displayItem->scaleTo(sin($i)/2);
 $m->nextFrame;
}
$m->save("$0.swf");

Peter Liscovius