How many ways we can create a swf file?

we can create a swf movie in at least 3 way

 

1) by adobe flash, created from *.fla

2) by flex create from *.mxml

3) and we can create *.swf file by a backend controller, say, php or perl.

 

We now focus on 3). All we want is the open source swf library, named "Ming". It's a api to create swf file.

 

 

Here is what I think it can be used for:

 

1) protect your private image, you want to hide the url of your image and don't want others to say it as a local image file:

 

 

$path = "my_movie_dir"; //relative path to the jpg/png or bmp files 
$frame_rate=30; //frame rate of the flash movie 
$quality=50; //image quality during conversion (only valid if not jpeg) 
$skip_rate=5; //how many frames to skip 
set_time_limit("600"); //this could take some time 

$converter=new images_to_swf($path,$frame_rate,$skip_rate); 

//$converter->convert_images(70); //Use this if using non jpeg files or decreasing the quality 

$converter->make_movie();//Make the movie 

//Do two things with it 
$converter->save_movie("my_movie_dir/my_movie.swf"); 
$converter->output_movie(); 

class images_to_swf { 
    
    var $path; //path to the image files 
    var $skip_rate; 
    var $movie; 
    var $images=array(); 
    
    function images_to_swf($path,$frame_rate=30,$skip_rate=5) { 
        $this->path=$path; 
        $this->skip_rate=$skip_rate; 
        
        $this->movie=new swfmovie (); 
        $this->movie->setrate ($frame_rate); 
    } 
    
    function convert_images($quality=80,$delete_old_files=1) { 
        $main = opendir($this->path); 
        rewinddir($main); 
        //first convert to jpeg (if we have to) 
        //also change the quality 
        while($filename = readdir($main)) { 
            
            //only use valid file types 
            if (ereg("(png|bmp|jpg|jpeg)\$",$filename)) { 
                $file_path=$this->path."/".$filename; 
                
                if (ereg("png\$",$filename)) $temp_img=imagecreatefrompng ($file_path); 
                else if (ereg("bmp\$",$filename)) $temp_img=imagecreatefrompng ($file_path); 
                else if (ereg("(jpg|jpeg)\$",$filename)) $temp_img=imagecreatefromjpeg ($file_path); 
                
                if (ereg("(png|bmp)\$",$filename)) { 
                    if ($delete_old_files) unlink($file_path); 
                    $new_file_path=$file_path.".jpg"; 
                } 
                else $new_file_path=$file_path; 
                
                ImageJPEG($temp_img,$new_file_path,$quality); 
                
                //echo "Converted $filename to $new_file_path at quality $quality<br />"; 
            } 
        } 
    } 
    
    function make_movie() { 
        $main = opendir($this->path); 
        rewinddir($main); 
        //Get all valid jpegs 
        while($filename = readdir($main)) { 
            if (ereg("(jpg|jpeg)\$",$filename)) { 
                $file_path=$this->path."/".$filename; 
                $valid_paths[]=$file_path; 
            } 
        } 
        
        //Put jpegs in order 
        sort($valid_paths); 
        
        //then create the movie 
        for ($a=0; $a<count($valid_paths); $a=$a+$this->skip_rate) { 
            $fp = fopen($valid_paths[$a],"rb"); 
            $this->images[$a] = fread($fp,999999); 
            fclose($fp); 
            $this->movie->add(new swfbitmap($this->images[$a])); 
            $this->movie->nextframe(); 
            //echo "Added ".$valid_paths[$a]." to the movie<br />\n"; 
        } 
    } 
    
    function save_movie($file_name) { 
        $this->movie->save($file_name); 
    } 
    
    function output_movie() { 
        header('Content-type: application/x-shockwave-flash'); 
        $this->movie->output(); 
    } 

 

2) construct a complex flash componet according to your backend database

 

More sample can be reached at: http://www.gazbming.com/

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值