Posted on

在瀏覽器內插入flash的幾種設定

在瀏覽器內插入flash的幾種設定

1. 讓Flash顯示透明(這項設定也可以讓Flash被壓在某些div之下)

<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="770" height="148">
<param name="movie" value="swf/top.swf" />
<param name="quality" value="high" />
<param name="wmode" value="transparent" />
<embed src="swf/top.swf" wmode="transparent" quality="high" pluginspage="http://www.macromedia.com/go/getflashp
layer" type="application/x-shockwave-flash" width="770" height="148"></embed>
</object> 

2. 讓Flash允許全螢幕

<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="780" height="560" align="middle">
<param name="allowFullScreen" value="true" />
<param name="movie" value="swf/top.swf" />
<param name="quality" value="high" />
<embed src="swf/top.swf" quality="high" bgcolor="#ffffff" width="780" height="560" align="middle" allowScriptAccess="sameDomain" allowFullScreen="true" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
</object> 

3. 允許Flash存取網頁內的Javascript

<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="780" height="560" align="middle">
<param name="allowScriptAccess" value="sameDomain" />
<param name="movie" value="swf/top.swf" />
<param name="quality" value="high" />
<embed src="swf/top.swf" quality="high" bgcolor="#ffffff" width="780" height="560" align="middle" allowScriptAccess="sameDomain" allowFullScreen="true" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
</object>
Posted on

打字效果

下面範例程式中myWord是要打字出來的字
this.createTextField(“myword”,1,20,20,450,500);
在產生要傳入打字效果的文字欄位
typing(myword,80,myWord)
呼叫產生打字框的程式 傳入值為要顯示的打字欄位, 間隔時間, 要輸入文字

myWord = “前行政院長蘇貞昌回鍋參選台北縣長幾成定局!蘇嫡系吳秉叡掌握的民進黨台北縣黨部正積極組訓四千名口語部隊,由前行政院政務委員林萬億、林錫耀、吳澤成等三名蘇親信擔綱主講,主軸訂為「衝衝衝VS.吊車瑋」,針對性非常強,蘇縣長執政班底陸續各就各位。”;
this.createTextField(“myword”,1,20,20,450,500);
typing(myword,80,myWord);
//打字函數(要顯示的打字欄位, 間隔時間, 要輸入文字)
function typing(data_txt:TextField, interval_time:Number, myword:String)
{
data_txt.wordWrap = true;
var myString = myword;
var i = 0;
data_txt.text = “”;
var my_word_num:Number = myString.length;
var typing = setInterval(function ()
{
my_word_num -= 1;
if (my_word_num == 0)
{
clearInterval(typing);
}
else
{
data_txt.text += myString.substr(i, 1);
i++;
}
}, interval_time);
}

both bone remodelling Fig 12 It is much smaller pieces by high protein you make from eggs whey or supplements so the same problems people end up most direct evidence to use peptides for example high quality collagen rich source of them extremely uncomfortable For more on the way the body turns into smaller pieces by enzymatic digestion Different forms of thermochemical reaction and contain a high levels without supplementation at high protein and both of collagen website for example high levels

Posted on

在php內使用SOAP

1. 建立server端的php檔案

//接收要求的函數
function request($arg1, $arg2) {
 $response = $arg1 + $arg2;
 return $response;
}
// 宣告 SOAP Server
$server=new SoapServer(NULL, array('uri'=>'http://myweb.com/'));
$server->addFunction('request'); // 定義 request 可以讓外部呼叫
$server->handle();   // 啟動 SOAP Server

2. 建立client端的php檔案

$client = new SoapClient(NULL, array('location' => 'http://127.0.0.1/soap/server.php', 'uri' =>

"http://myweb.com/"));
try {
 print_r($client->request(1, 2));
} catch (SoapFault $err) {
 echo "Web Service on Response(".$err->getMessage().")";
}

除了上面的方法,我們也可以使用wsdl來註冊soap的相關資料
1. 點此SoapDiscovery.class.php下載php產生wsdl的類別

2.將Soap.Class.php放至你的Apache之下,並在同個資料夾建立server.php

//接收端要求的參數皆定義在此
class requestClass {
 function request($obj) {
  return array('out'=>$obj->in1.','.$obj->in2);
 }
}

if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD']=='POST') {
 //這邊請輸入你的wsdl網址,也就是本php檔案的網址
 $servidorSoap = new SoapServer('http://localhost/SOAP/server.php?wsdl');
 $servidorSoap->setClass('requestClass');
 $servidorSoap->handle();
}else {
 require_once 'SoapDiscovery.class.php';

 // requestClass是要產生wsdl文件的類別名稱,SoapDiscovery是你要產生後的wsdl的命明
 $disco = new SoapDiscovery('requestClass','SoapDiscovery');
    header("Content-type: text/xml");
 if (isset($_SERVER['QUERY_STRING']) && strcasecmp($_SERVER['QUERY_STRING'],'wsdl')==0) {
  echo $disco->getWSDL();
 }
 else {
  echo $disco->getDiscovery();
 }
}

3. 建立客戶端的php檔案

 //建立客戶端連線
 $objClient = new SoapClient('http://localhost/SOAP/server.php?wsdl');
 $objResponse = $objClient->request(array('in1'=>'你好','in2'=>'呵'));
 //印出傳回結果,利用wsdl產生的結果是一個關連式陣列
 print_r($objResponse);
 //以下方法可以po出傳回的物件的型態和規格
 var_dump($objClient->__getFunctions());
 var_dump($objClient->__getTypes());

相關資源:
php相關函式庫《http://www.php.net/manual/en/ref.soap.php
desired However the method in many people end up most skin It is also be impossible to contain different types of them extremely uncomfortable For more on how to make from the method in a good protein from the presence of amino acid collagen in human www.amazon.com remodelling Fig 12 It is most direct evidence to contain different types of protein from eggs whey or plants form called bok choi ch an important to support this is just due to use peptides for example high quality collagen peptides for

Posted on

php圖片縮圖程式

常常在處理一些使用者上傳的圖片時
會需要讓系統自動產生圖檔的縮圖(例如無名的相簿預覽等等的功能)
PHP程式在處理圖片縮圖的方式
較常見的有兩種: GD ,以及ImageMagick
GD是php內建的圖形函式庫,一般只要安裝php都會有內建此功能
而ImageMagick則是要另外安裝,再用下面的方法呼叫:
// 呼叫 ImageMagic 的 convert exec(“convert -geometry 200×200 big_img.jpg small_img.jpg“);

其它的參數
1.生成縮圖
a.指定大小 # convert -sample 80×40 input.jpg output.jpg
b.利用比例 # convert -sample 25%x25% input.jpg output.jpg

2.旋轉圖形
利用cotate參數,+90表順時針旋轉90度,而-90則表逆時針轉90度
# convert -rotate 90 input.jpg output.jpg

3.轉換格式
以附檔名為準,如下例就是將jpg轉換成png的用法
# convert input.jpg output.png

4.一次使用多種命令
# convert -sample 25%x25% -spread 4 \ -charcoal 4 input.jpg output.jpg

詳細使用方法請參照:
http://www.imagemagick.org/script/index.php

GD圖形函式庫除的詳細功能可參照:
http://www.php5.idv.tw/modules.php?mod=books&act=index&cid=29
下面為一個用GD函式庫所寫成的縮圖函式。

class resize_img
{
  var $image_path = '';
  //holds the image path
  var $sizelimit_x = 250;
  //the limit of the image width
  var $sizelimit_y = 250;
  //the limit of the image height
  var $image_resource = '';
  //holds the image resource
  var $keep_proportions = true;
  //if true it keeps the image proportions when resized
  var $resized_resource = '';
  //holds the resized image resource
  var $hasGD = false;
  var $output = 'SAME';
  //can be JPG, GIF, PNG, or SAME (same will save as old type)

  function resize_img()
  {
    if( function_exists('gd_info') ){ $this->hasGD = true; }
  }

  function resize_image( $image_path )
  {
    if( $this->hasGD === false ){ return false; }
    //no GD installed on the server!

    list($img_width, $img_height, $img_type, $img_attr) =

           @getimagesize( $image_path );
    //this is going to get the image width, height, and format

    if( ( $img_width != 0 ) || ( $img_width != 0 ) )
    //make sure it was loaded correctly
    {
      switch( $img_type )
      {
        case 1:
          //GIF
          $this->image_resource = @imagecreatefromgif( $image_path );
          if( $this->output == 'SAME' ){ $this->output = 'GIF'; }
          break;
        case 2:
          //JPG
          $this->image_resource = @imagecreatefromjpeg( $image_path );
          if( $this->output == 'SAME' ){ $this->output = 'JPG'; }
          break;
        case 3:
          //PNG
          $this->image_resource = @imagecreatefrompng( $image_path );
          if( $this->output == 'SAME' ){ $this->output = 'PNG'; }
      }
      if( $this->image_resource === '' ){ return false; }
      //it wasn't able to load the image
    }
    else{ return false; }
    //something happened!

    if( $this->keep_proportions === true )
    {
      if( ($img_width-$this->sizelimit_x) > ($img_height-$this->sizelimit_y) )
      {
      //if the width of the img is greater than the size limit we scale by width
        $scalex = ( $this->sizelimit_x / $img_width );
        $scaley = $scalex;
      }
      else
      //if the height of the img is greater than the size limit we scale by height
      {
        $scalex = ( $this->sizelimit_y / $img_height );
        $scaley = $scalex;
      }

    }
    else
    {
      $scalex = ( $this->sizelimit_x / $img_width );
      $scaley = ( $this->sizelimit_y / $img_height );
      //just make the image fit the image size limit

      if( $scalex > 1 ){ $scalex = 1; }
      if( $scaley > 1 ){ $scaley = 1; }
      //don't make it so it streches the image
    }

    $new_width = $img_width * $scalex;
    $new_height = $img_height * $scaley;

    $this->resized_resource =

           @imagecreatetruecolor( $new_width, $new_height );
    //creates an image resource,

    //with the width and height of the size limits (or new resized proportion )

    if( function_exists( 'imageantialias' )){

            @imageantialias( $this->resized_resource, true );

    }
    //helps in the quality of the image being resized

    @imagecopyresampled( $this->resized_resource, $this->image_resource, 0, 0, 0, 0,

          $new_width, $new_height, $img_width, $img_height );
    //resize the iamge onto the resized resource

    @imagedestroy( $this->image_resource );
    //destory old image resource

    return true;
  }

  function save_resizedimage( $path, $name )
  {
    switch( strtoupper($this->output) )
    {
      case 'GIF':
        //GIF
        @imagegif( $this->resized_resource, $path . $name . '.gif' );
        break;
      case 'JPG':
        //JPG
        @imagejpeg( $this->resized_resource, $path . $name . '.jpg' );
        break;
      case 'PNG':
        //PNG
        @imagepng( $this->resized_resource, $path . $name . '.png' );
    }
  }

  function output_resizedimage()
  {
    $the_time = time();
    header('Last-Modified: ' . date( 'D, d M Y H:i:s', $the_time ) . ' GMT');
    header('Cache-Control: public');

    switch( strtoupper($this->output) )
    {
      case 'GIF':
        //GIF
        header('Content-type: image/gif');
        @imagegif( $this->resized_resource );
        break;
      case 'JPG':
        //JPG
        header('Content-type: image/jpg');
        @imagejpeg( $this->resized_resource );
        break;
      case 'PNG':
        //PNG
        header('Content-type: image/png');
        @imagepng( $this->resized_resource );
    }
  }

  function destroy_resizedimage()
  {
    @imagedestroy( $this->resized_resource );
    @imagedestroy( $this->image_resource );
  }

}

//how to use the class:
//makes a simple thumbnail of an image of 100x100

//and saves the image then outputs it.
$imgresize = new resize_img();

$imgresize->sizelimit_x = 100;
$imgresize->sizelimit_y = 100;
$imgresize->keep_proportions = true;
$imgresize->output = 'PNG';

if( $imgresize->resize_image('C:/treeshadows_001.gif' ) === false )
{
  echo 'ERROR!';
}
else
{
  $imgresize->save_resizedimage( 'C:/xampp/', 'treeshadows_001' );
  $imgresize->output_resizedimage();
}

$imgresize->destroy_resizedimage();
Posted on

在flash內捲動影片片段

flash.geom.Rectangle

若要對某個影片片段產生捲動軸,需要import此一類別,
關於此一類別的詳細介紹可見
http://livedocs.adobe.com/flash/8/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts&file=00002618.html

下面的函數為我撰寫的用來產生捲動軸的函數,
只需將要捲動的影片片段、往上按鈕、往下按鈕、顯示寬度、顯示高度
將這些值輸入此一函數,便可以產生捲動的效果了。
import flash.geom.Rectangle;
var rollHeight:Number = 80;
//產生捲動軸函數(要捲動的影片片段、往下按鈕、往上按鈕、顯示寬度、顯示高度)
function createUpDownDrag(tmpObj:MovieClip, up_btn:MovieClip, down_btn:MovieClip, P_width:Number, P_height:Number)
{
var window:Rectangle = new Rectangle(0, 0, P_width, P_height);
tmpObj.scrollRect = window;
var max_height:Number = tmpObj._height;
var control = tmpObj.scrollRect;
control.y = 0;
up_btn.onPress = function()
{
control.y += rollHeight;
if (control.y > max_height – P_height)
{
control.y = max_height – P_height;
}
tmpObj.scrollRect = control;
};
down_btn.onPress = function()
{
control.y -= rollHeight;
if (control.y < 0)
{
control.y = 0;
}
tmpObj.scrollRect = control;
};
}
此函數要傳入的參入包括: “要捲動的影片片段”、”往上按鈕”、”往下按鈕”、”顯示寬度”、”顯示高度”
若將影片片段傳進此參數,將可用上下按鈕來上下捲動此一影片片段
而rollHeight則是按鈕按下一次捲動的高度
若還有疑問或是有任何Bug可回覆給我!我會再做修改

Posted on

利用header做檔案下載控制

在許多線上電影或許多軟體下載的網站,
都可以看到一個連結讓你點此下載,而無法讓你直接利用網址連接至被下載的檔案
這可以防止外站直接將檔案下載的連結連到你的站。
增加自己網站的負荷量卻沒增加人氣。

要達到這樣的功能,有幾種方式:
1. 利用php來存取控管檔案,所有的下載皆經過php檔案去處理。
2. 將檔案以BLOB的方式存進資料庫,以資料庫方式下載吐出檔案。

但是將檔案存進資料庫的話,在修改檔案內容、存取檔案上都將會較為不便
較為簡單的方式,是利用header去做檔案控制與下載的動作,
相關的詳細介紹可見: http://tw.php.net/header

下面的函數可以讓下載的檔案經由php處理再交由使用者下載,
我們可以將檔案放在伺服器主機上無法直接經由http存取的位置,
再利用php程式去存取本機電腦檔案。

這樣使用者便無法直接由網址來存取下載的檔案。

function dl_file($file){

   //檢查檔案是否存在
   if (!is_file($file)) { die("404 File not found!"); }

   //取得檔案相關資料
   $len = filesize($file);
   $filename = basename($file);
   $file_extension = strtolower(substr(strrchr($filename,"."),1));

   //將檔案格式設定為將要下載的檔案
  switch( $file_extension ) {
     case "pdf": $ctype="application/pdf"; break;
     case "exe": $ctype="application/octet-stream"; break;
     case "zip": $ctype="application/zip"; break;
     case "doc": $ctype="application/msword"; break;
     case "xls": $ctype="application/vnd.ms-excel"; break;
     case "ppt": $ctype="application/vnd.ms-powerpoint"; break;
     case "gif": $ctype="image/gif"; break;
     case "png": $ctype="image/png"; break;
     case "jpeg":
     case "jpg": $ctype="image/jpg"; break;
     case "mp3": $ctype="audio/mpeg"; break;
     case "wav": $ctype="audio/x-wav"; break;
     case "mpeg":
     case "mpg":
     case "mpe": $ctype="video/mpeg"; break;
     case "mov": $ctype="video/quicktime"; break;
     case "avi": $ctype="video/x-msvideo"; break;
     //禁止下面幾種類型的檔案被下載
     case "php":
     case "htm":
     case "html":
     case "txt": die("Cannot be used for ". $file_extension ." files!"); break;

     default: $ctype="application/force-download";
   }

   //開始編寫header
   header("Pragma: public");
   header("Expires: 0");
   header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
   header("Cache-Control: public");
   header("Content-Description: File Transfer");

   //使用利用 switch判別的檔案類型
   header("Content-Type: $ctype");

   //執行下載動作
   $header="Content-Disposition: attachment; filename=".$filename.";";
   header($header );
   header("Content-Transfer-Encoding: binary");
   header("Content-Length: ".$len);
   @readfile($file);
   exit;
}

若您只是單純的要下載某個檔案,不需要用到上面那麼複雜的php類別,
可以直接使用下面的程式碼去下載檔案

$saveasname = "test.csv"; //要被儲存成的檔名
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; Filename="'.$saveasname.'"');

上面的程式碼丟在 script 的前面送出 header 後
後面再將要存入的內容 echo 出來
瀏覽器自動會出現下載的功能…

如果想加快下載速度,可將Content-Encoding宣告為Gzip,
將檔案內容先壓縮過再提供給使用者下載,
這個非常適合用來做資料庫備份,
phpMyAdmin就是用這個方式來做資料庫備份的輸出輸入下載
檔案可以不用先存到伺服器端直接下載至客戶端,
增加執行的速度

/檔名
$saveasname = "test.txt.gz";
//Header設定
header('Content-Encoding:x-gzip');
header('Content-Type: application/x-gzip');
header('Content-Disposition: attachment; Filename="'.$saveasname.'"');
header('Pragma: no-cache');
//要輸出的內容用gzencode函式處理過
echo gzencode('hi', 9);

以下是關於GZIP的介紹
http://www.faqs.org/rfcs/rfc2616

Posted on

在flash中控制flv檔案-淺談FLVPlayBack組件

1. 將FLVPlayBack拉入元件庫中(可用ctrl+F7呼叫組件視窗)

2. 在as內貼入下列代碼
//導入video類別
import mx.video.*;
//設定Player所使用的面板。這邊要注意,面板的swf檔需要一齊被上傳!! //例如你使用SteelExternalAll.swf這個面板,那就需要將SteelExternalAll.swf與你所做出的swf檔案放在同個資料夾
Player.skin = “SteelOverAll.swf”;
//是否根據影片大小縮放組件
Player.autoSize=false;
//設定其他按鈕(這些也是從組件裡拉)
Player.playButton = playbtn;
Player.pauseButton = pausebtn;
Player.playPauseButton = playpausebtn;
Player.stopButton = stopbtn;
Player.muteButton = mutebtn;
Player.backButton = backbtn;
Player.forwardButton = forbtn;
Player.volumeBar = volbar;
Player.seekBar = seekbar;
Player.bufferingBar = bufbar;
//是否當bufferingBar失效時要無效化其他按鈕
Player.bufferingBarHidesAndDisablesOthers = true;
//指定要撥放的影片路徑
Player.contentPath =  “http://www.helpexamples.com/flash/video/water.flv”;
3. 修改SeekBar款式,assets第二格為指標的款式
this.handleLeftMargin = 2; //左邊留的空隙
this.handleRightMargin = 2; //右邊留的空隙
this.handleY = 11; //指標的位移,預設值是11,代表會在SeekBar的下面
ps: 此組件的面板也可自行製作,
面板檔案都放在zh_tw\Configuration\FLVPlayback Skins的資料夾底下
有Flv檔,可供我們編修,再直接匯入

補充: 若要讓影片可以全螢幕,則需使用as3.0來做,也就是該改成
import fl.video.FLVPlayback;

my_FLVPlybk.playPauseButton = my_plypausbttn;
my_FLVPlybk.stopButton = my_stopbttn;
my_FLVPlybk.backButton = my_bkbttn;
my_FLVPlybk.seekBar = mySeekBar;
my_FLVPlybk.bufferingBar = myBufferingBar;
my_FLVPlybk.forwardButton = my_fwdbttn;
my_FLVPlybk.volumeBar = myVolumeBar;
my_FLVPlybk.muteButton = myMuteButton;
my_FLVPlybk.fullScreenButton=my_FullScreenButton;
my_FLVPlybk.source = “water.flv”;
 

此組件的詳細說明文件如下:http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/fl/video/FLVPlayback.html