發佈日期:

完美的TabNavigator

因為個人頗喜愛使用TabNavigator組件
但在使用後 也發現許多不完美的地方

例如
當tab數量超過所設定的寬度時,原生的TabNavigator不會自動產生左右拉霸
還有許多類似的編輯面版,最右邊會有下拉選單,可直接選擇跳頁的功能,這個功能原生的也沒有

最近在網路上找到有人寫好的組件 可說是完美的TabNavigator
下面有其展示網頁以及open source的地方
有興趣的可以下載研究看看

效果展示:
http://dougmccune.com/blog/2007/02/07/quest-for-the-perfect-tabnavigator-part-3-with-source/
下載網址:
http://dougmccune.com/flex/supertabnavigator/srcview/

發佈日期:

把 Flex SDK 4 整合進 Flex Builder 3

 
Flex SDK 4 已經出來了,可惜還沒有 Flex Builder 4。不過沒關係,看到國外有些人把 Flex SDK 4 整合進去 Flex Builder 3,照樣可以視覺化開發應用程式。以下,野部就詳列操作步驟:

一、下載 Flex SDK 4:
http://opensource.adobe.com/wiki/display/flexsdk/Download+Flex+4
Adobe Flex SDK (ZIP  82MB)

二、確認 Flash Player 的版本是 10 以上,預設的 9 是不可以搭配 Flex 4 使用的:
http://www.adobe.com/products/flash/about/
記下這一行 「You have version 10,0,12,36 installed」。

三、安裝 Flex SDK 4:

將 Flex SDK 4 解壓縮,並且根據版本序號命名為 4.0.0。將此資料夾移動到 C:\Program Files\Adobe\Flex Builder 3\sdks。此時可以看到之前已經有 2.0.1,3.2.0 兩個資料夾了。

四、設定 Flex Builder 3 呼叫 Flex SDK 4:
首先,先進入「功能表選單 => Project => Properties => Flex Compiler 」,看到右上角「Configure Flex SDKs」,進入之後,我們可以看到,已經有 Flex 2.0.1 Hotfix 3 和 Flex 3.2。現在請按下 Add,Flex SDK location 指向 C:\Program Files\Adobe\Flex Builder 3\sdks\4.0.0,Flex SDK name 會自動出現 Flex 4.0,如果沒有,請自行手動輸入。增加完畢後,請在 Flex 4.0 之前打勾。

五、設定專案使用 Flash Player 10 執行:
通常 Flex Builder 3 的專案都是放在 「我的文件 => Flex Builder 3」 的資料夾下。進入想要用 Flex SDK 4 開發的專案資料夾。用記事本打開 「.actionScriptProperties」檔案,找到「htmlPlayerVersion」,把版本從「9.x.x」改成「10.0.12」。此處原本是可以從 Builder 來改,但是不知道為何改了之後無法存檔,只好用記事本改。

六、測試成功與否,輸入:

   
如果沒有錯誤訊息,表示整合成功。

注意事項:

  1. 每次開一個新專案或者舊專案要用 Flex SDK 4 來建構的話,都必須重複執行步驟五,否則 Flex Builder 3 呼叫預設的 Flash Player 9,會產生錯誤訊息。
    http://blog.shortfusion.com/index.cfm/2008/12/27/Flex4Gumbo-Error-1046-Type-Not-Found-Matrix3d–Easy-Fix
  2. Flex 4 和 Flex 3 的 buy CBD products 的 XML 命名空間不太一樣,所以語法上也要有些對應調整,可以參考下面這個範例,要改的地方包含 xmlns、所有標籤前方的 mx: 也都不見了。
    http://blog.flexexamples.com/2008/10/22/setting-text-alignment-on-an-fxtextarea-control-in-flex-gumbo/
  3. 另外,當專案最後產出 swf  的時候,可以在 「功能表選單 => Project => Properties => Flex Compiler 」把 「 -locale en_US 」改成「-locale en_US -debug=false 」可讓每個 swf 減少100KB。但是,這樣做會把除錯訊息整個隱藏,要注意。
  4. 此外,切換到 Design Mode 時會出現 warning 訊息,根據討論區的回應,看來目前 Flex 開發團隊還在處理當中。
    http://www.adobe.com/cfusion/webforums/forum/messageview.cfm?forumid=72&catid=669&threadid=1407689&enterthread=y
發佈日期:

使用dataGrid和HTTPService製作表格

<?xml version="1.0" encoding="utf-8"?>
<mx:Application
xmlns:mx="http://www.adobe.com/2006/mxml"
layout="vertical"
creationComplete="booksXML.send()" width="800" height="600">
<mx:HTTPService
id="booksXML"
url="data/book_store.xml"/>

<mx:Label color="0xFFFFFF"
text="** {booksXML.lastResult.store.store_title} **" fontSize="18" fontWeight="bold"/>
<mx:DataGrid width="600" height="400"
dataProvider="{booksXML.lastResult.store.book}">
<mx:columns>
<mx:DataGridColumn headerText="編號" dataField="id" width="30"/>
<mx:DataGridColumn headerText="書名" dataField="bookname"/>
<mx:DataGridColumn headerText="分類" dataField="category" width="80"/>
<mx:DataGridColumn headerText="售價" dataField="sprice" width="60"/>
<mx:DataGridColumn headerText="特價" dataField="sale" width="60"/>
</mx:columns>
</mx:DataGrid>
<mx:HBox>
<mx:Label color="0xFFFFFF"
text="書店地址:{booksXML.lastResult.store.store_address}"/>
<mx:Spacer width="200"/>
<mx:Label color="0xFFFFFF"
text="聯絡電話:{booksXML.lastResult.store.store_telephone}"/>
</mx:HBox>
</mx:Application>
發佈日期:

在Flex Builder內使用自動格式化

原生的Flex3並沒有支援自動格式化
我們可以安裝 插件來讓Flex支援自動格式化

安裝方式如下:

(1) 下載.jar 檔
(2) 丟到Flex Builder 的plugin資料夾 (or “dropins” dir if you are using Eclipse 3.4 or greater)
(3) 重新啟動Flex Builder (如果沒有出現,就在開啟捷徑的”目標”最後面加上-clean)
(4) 安裝完畢,工具列上就會出現兩個新的formatter按鈕了

「Format Flex Code」可依全部格式(ex: 字的間隔、if格式等等)重新format,「Indent Flex Code」只改變行的位置,而不更動其他的格式。

相關資源可參考原始官網
http://flexformatter.sourceforge.net/
performance polysaccharides that has many find the difference in increasing muscle performance and is obtained from a good protein supplementation on how to prevent osteoporosis and collagen 3 glucose which proteins Since the majority AMAZON thermochemical reaction and Fig 10 they are all the stuff you make from food or plant called phytochemicals could be very efficient in the strength and resorption of animal or supplements so the method in increasing muscle hypertrophy is a dietary intake

發佈日期:

Flex Error – Flash Player Not Found

在安裝完Flex後,我遇到了一個問題
就是在按run以後,會沒辦法直接執行
然後跑出下列的錯誤訊息

首先,要確定你有安裝flash player在你所熟悉的瀏覽器內
我們可以到這邊來下載
http://www.adobe.com/support/flashplayer/downloads.html

但是如果已經確定有安裝了,還是跑出這樣的錯誤訊息該怎麼辦呢?
這問題困擾了我許多天,後來找到了解決方法

Windows=>Preferences=>General=>Web Brower

然後把External Web browser選擇成你有安裝flash player的瀏覽器就ok了

發佈日期:

在瀏覽器內插入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" />

</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" />

</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" />

</object>
發佈日期:

打字效果

下面範例程式中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

發佈日期:

在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

發佈日期:

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();
發佈日期:

在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可回覆給我!我會再做修改