Hi everybody 🙂
Iam building a wrapper class for Ming SWF but i've got serious trouble with it 🙁
I've tried to put some code in a function like this:
// First some basic settings
ming_setscale(20);
ming_useswfversion(6);
$obj_swf_movie = new swfmovie();
$obj_swf_movie->setframes($arr_svf[header][FRAMES]);
$obj_swf_movie->setrate($arr_svf[header][FRAMERATE]);
$obj_swf_movie->setdimension($arr_svf[header][WIDTH],$arr_svf[header][HEIGHT]);
// Convert multiple color codes to rgb-arrary
$arr_background_color = system::colorcode($arr_svf[header][BACKGROUND]);
$obj_swf_movie->setbackground($arr_background_color[0],$arr_background_color[1],$arr_background_color[2]);
// This is the code i want to change into a function:
// It just adds one image to the swf and is working this way (no errors)
/*
$obj_swf_shape = new swfshape();
$obj_swf_res_bitmap = file_get_contents($arr_svf[folder][IMAGE].$arr_svf[object][IMAGE][0][src]);
$obj_swf_hdl_bitmap = $obj_swf_shape->addfill( $obj_swf_bitmap = new swfbitmap( $obj_swf_res_bitmap ) );
$obj_swf_shape->setrightfill( $obj_swf_hdl_bitmap );
$obj_swf_shape->drawLine( $obj_swf_bitmap->getwidth(),0 );
$obj_swf_shape->drawLine( 0, $obj_swf_bitmap->getheight() );
$obj_swf_shape->drawLine( ($obj_swf_bitmap->getwidth()*-1), 0 );
$obj_swf_shape->drawLine( 0, ($obj_swf_bitmap->getheight()*-1) );
$hdl_image = $obj_swf_movie->add( $obj_swf_shape );
*/
// This is the function which should replace the above commented code:
// It returns the resource for the image
function module_video_swf_image( $val_parameter = "" )
{
//This only changes $val_parameter to $val_parameter[file]
$val_parameter = system::system_parameter( $val_parameter, "file" );
$obj_shape = new swfshape();
$str_image = file_get_contents( $val_parameter[file] );
$obj_image = new swfbitmap( $str_image );
$res_image = $obj_shape->addfill( $obj_image );
$obj_shape->setrightfill( $res_image );
$obj_shape->drawLine( $obj_image->getwidth(),0 );
$obj_shape->drawLine( 0, $obj_image->getheight() );
$obj_shape->drawLine( ($obj_image->getwidth()*-1), 0 );
$obj_shape->drawLine( 0, ($obj_image->getheight()*-1) );
return $obj_shape;
}
// Call the function
$obj_swf_image = module_video_swf_image($arr_svf[folder][IMAGE].$arr_svf[object][IMAGE][0][src]);
// Add to movie
$hdl_image = $obj_swf_movie->add( $obj_swf_image );
// Save it
// But it wont work with the function
$obj_swf_movie->save($arr_svf[header][NAME].".swf");
// Play it
print system::video(array("src"=>$arr_svf[header][NAME].".swf","width"=>1000,"height"=>310));
The question is: Why does it work in plain coding, but not with the function, which does exactly the same and works for itself properly (returns the shape resource) ??
It does the following error responses:
#4096 ()
SWFMovie::save() [function.SWFMovie-save]: Initial Jpeg marker not found!
C:\Programme\Webserver\xampp\htdocs\.SystemPHP\dev.php 150
#4096 ()
SWFMovie::save() [function.SWFMovie-save]: Jpeg SOI not found!
C:\Programme\Webserver\xampp\htdocs\.SystemPHP\dev.php 150
#4096 ()
SWFMovie::save() [function.SWFMovie-save]: Jpeg marker not found where expected!
C:\Programme\Webserver\xampp\htdocs\.SystemPHP\dev.php 150
#4096 ()
SWFMovie::save() [function.SWFMovie-save]: Jpeg marker not found where expected!
C:\Programme\Webserver\xampp\htdocs\.SystemPHP\dev.php 150
#4096 ()
SWFMovie::save() [function.SWFMovie-save]: Unexpected end of Jpeg file (EOI found)!
C:\Programme\Webserver\xampp\htdocs\.SystemPHP\dev.php 150
#4096 ()
SWFMovie::save() [function.SWFMovie-save]: Unexpected end of Jpeg file (EOF found)!
C:\Programme\Webserver\xampp\htdocs\.SystemPHP\dev.php 150
[...(and so on)]
I encountered this error before (without function) but it got solved by using $var = file_contents(); instead of directly use of file_contents();
How can i put this to work within a function?
EDIT:
phpinfo() says:
Ming SWF output library enabled
Version 0.3beta1
Any idea where to find v0.4(beta5 i guess)? (win32 dll)