8-1 滑鼠與拖曳影片片段

一、 Mouse.show方法

語法:Mouse.show();

功能:SWF檔中,顯示滑鼠指標。

二、 Mouse.hide方法

語法:Mouse.hide();

功能:SWF檔中,隱藏滑鼠指標。

三、 startDrag函數

語法1startDrag(name_mc[,lock[,left, top, right, bottom]);

語法2name_mc.startDrag([,lock[,left, top, right, bottom]);

功能:設定name_mc影片片段實體可以被拖曳,以及可拖曳的範圍。

說明:

1. name_mc為影片片段實體。

2. lock:布林值,預設值為false

  true:滑鼠指標鎖定於影片片段實體的註冊點處。

  false:滑鼠指標鎖定在使用者第一次按下影片片段實體的位置。

3. left, top, right, bottom:限制影片片段可拖曳的範圍,省略,無範圍限制。

4. 一次只能拖曳一個影片片段實體。

四、 stopDrag函數

語法:stopDrag();

功能:停止影片片段被拖曳的動作。

 

 


        滑鼠移到圓球上,按下滑鼠左鍵不放,拖曳滑鼠,圓球隨著滑鼠移動。滑鼠指標停在第一次按下圓球的位置。放開滑鼠按鍵,此時移動滑鼠,圓球不會隨之移動。

 

 

 

 

 

 

 

 

 


circle_mc(圓球)影片片段程式

程式:

01

02

03

04

05

06

on (press) {

  this.startDrag();

}

on (release) {

  stopDrag();

}

解說:

0103:按下滑鼠左鍵不放,拖曳滑鼠,圓球隨著滑鼠移動。

02startDrag省略參數預設為false

0406:放開滑鼠按鍵,此時移動滑鼠,圓球不會隨之移動。

 

 


 滑鼠移到圓球上,按下滑鼠左鍵不放,拖曳滑鼠,圓球隨著滑鼠移動。滑鼠指標停在圓球的註冊點處位置。

 

 

 

 

 

 

 

 

 


circle_mc(圓球)影片片段實體上程式

程式:

01

02

03

on (press) {

  this.startDrag(true);

}

解說:

0103:按下滑鼠左鍵不放,拖曳滑鼠,圓球隨著滑鼠移動。圓球註冊點在圓球最左邊中間處

 

 

        隱藏滑鼠指標,移動滑鼠,圓球隨著滑鼠移動。

 

 

 

 

 

 

 

 

 


主場景影格1程式:

01

02

Mouse.hide();

circle_mc.startDrag(true);

解說:

0102:在SWF檔中滑鼠移動,圓球隨之移動,滑鼠指標不見了。