1;$int--){ $int1=$speed*$int; $instance->addColor(0,0,0,-$int1); $movie->nextFrame(); } } else { for($int=3; $int<$steps+3;$int++){ $int1=$speed*$int; $instance->addColor(0,0,0,-$int1); $movie->nextFrame(); } } } function check_for_files($jpegs,$howmany,$image_list,$captions){ $final=array(); $final_captions=array(); $j=0; for($i=0;$i<$howmany; $i++){ $flipped_list=array_flip($jpegs); // Now think: Which ones are image_list and which are jpegs??? // You actually want to see if the jpegs include the flipped list! if(isset($flipped_list[$image_list[$i]])){ $final[$j]=$image_list[$i]; $final_captions[$j]=$captions[$i]; $j++; } else { /* Nowt much to say here ;-)*/ } } $returnvalue=array($final,$final_captions); return $returnvalue; } /* ***************************************************************** */ /* End of functions. Now here's the program itself. The functions above are essentially support functions and would generally be in another php file with no immediate output such as one that you might include('filename.php') on... */ /* This first part gathers information about the directory we're running in. Note that it expects the jpegs to use to be in the same directory as the script. This is not an essential limitation. It's just like this for the moment. If there's a reason to change it, that's fine too. */ /* Find out what jpegs are in this dir... */ //list($jpegs,$howmany)=getjpegs(); /* Find out what the setup file says... */ //list($image_list,$captions)=read_ini("mingsetup.txt"); /* Delete from the array any files that happen not to be in the directory any more (so as to avoid trying to show nonexistent files...*/ //list($jpegs,$captions)=check_for_files($jpegs,$howmany,$image_list,$captions); /* ************************************************************ */ /* Here's a bunch of constants that you might want to change*/ /* Maximum image width is in $MAXWIDTH ; beyond this size they are rudely cropped*/ $MAXWIDTH=200; /* Maximum image height is broadly similar */ $MAXHEIGHT=200; /* The movie height; is the maximum height + 100, to give us space for the text */ $MOVIEHEIGHT=$MAXHEIGHT+10; /* The movie width is just maximum width for the moment. It exists apart for future purposes... */ $MOVIEWIDTH=$MAXWIDTH; /* The name of this constant really says it all... */ $FONT_HEIGHT=12; /* ************************************************** */ /* Here's the code that actually writes the movie */ /* Instantiate an SWFMovie object... */ $m=new SWFMovie(); /* Set the speed of the movie */ $m ->setRate(20); /* Set the size of the movie */ $m->setDimension($MOVIEWIDTH, $MOVIEHEIGHT); /* Do all this once for each jpeg in the list of jpegs to load... */ for($shapetmp=10; $shapetmp<10000; $shapetmp=$shapetmp+50){ echo "$shapetmp

"; $font = new SWFFont("test.fdb"); $t=array(); $ti=array(); /* Make a text object array */ $t[$shapetmp]=new SWFText(); /* Set the font */ $t[$shapetmp]->setFont($font); $tmpx=($MOVIEWIDTH)/2; /* Move the 'pen' to the place we need it to be */ $t[$shapetmp]->moveTo($tmpx,$MOVIEHEIGHT-40); $t[$shapetmp]->setColor(0,0,0); $t[$shapetmp]->setHeight($FONT_HEIGHT); /* Figure out the size of all the images and stuff */ $tmparray=GetImageSize("./img$shapetmp.jpg"); /* Couple of centering things */ $left_edge=0; $top_edge=0; if($tmparray[0]>=$MAXWIDTH){ $tmparray[0]=$MAXWIDTH; } else { $left_edge=$MAXWIDTH/2-$tmparray[0]/2; //echo "

$tmparray[0] is width and $tmpfoo is width too and maxwidth is $MAXWIDTH "; } if($tmparray[1]>=$MAXHEIGHT){ $tmparray[1]=$MAXHEIGHT; } else { $top_edge=$MAXHEIGHT/2-$tmparray[1]/2; //echo "

$tmparray[1] is height as is $tmpfoo2 and maxheight is $MAXHEIGHT

"; } /* Initialise the shape array and so on... */ $s=array(); $f=array(); $i=array(); $s[$shapetmp]=new SWFShape(); $f[$shapetmp]=$s[$shapetmp]->addFill(new SWFBitmap("img$shapetmp.jpg")); $s[$shapetmp]->setRightFill($f[$shapetmp]); $s[$shapetmp]->drawLine($tmparray[0],0); $s[$shapetmp]->drawLine(0,$tmparray[1]); $s[$shapetmp]->drawLine(-$tmparray[0],0); $s[$shapetmp]->drawLine(0,-$tmparray[1]); $i[$shapetmp]=$m->add($s[$shapetmp]); $i[$shapetmp]->moveTo($left_edge,$top_edge); /* Fade into the picture */ //fade(20,10,PLUS,$i[$shapetmp],$m); if(isset($captions[$shapetmp])){ /* Do we have any captions for this image? If so, use the caption for the text string */ $caption=$captions[$shapetmp]; } else { /* If we don't have any caption, make the text string equal to ' ' There are reasons to define it as something, rather than null, because otherwise we do lots of things with a null string and there's a chance you might get a result like a caption that literally /says/ 'null' */ $caption=" "; } /* Figure out font metrics to get the thing to print in the right place */ $font_width=$font->getWidth($caption); /* The 1024 comes from the way Ming works. It sees all font metrics from the perspective of a person who wants to write in 1024-pt text */ $font_width=$font_width*$FONT_HEIGHT/1024; $tmp2=$tmpx-$font_width/2; /* Move the pen to where the text ought to be written */ $t[$shapetmp]->moveTo($tmp2,$MOVIEHEIGHT-40); /* Add the caption to the text object */ $t[$shapetmp]->addString($caption); /* Add the text object to the movie whilst the image is fully resolved (ie until before it starts to fade) and return an instance */ $ti[$shapetmp]= $m->add($t[$shapetmp]); /* Let the current image continue happening for the next 100 identical frames */ for($int=0; $int<4;$int++){ $m->nextFrame(); } /* Remove the text instance from the movie... */ $m->remove($ti[$shapetmp]); /* And... fade OUT... */ //fade(20,10,MINUS,$i[$shapetmp],$m); /* And remove the faded image from the movie */ $m->remove($i[$shapetmp]); /* Now cycle back to the beginning of this loop to make the next part of the movie with the next jpeg */ } /* And... save the resulting movie! */ $m->save("jpegfill.swf"); ?> Ming Demonstration