搜尋部落格文章

2012年5月11日 星期五

替換滑鼠游標,游標會不停閃爍

很久以前就碰到過這樣子的問題,
 首先,
我要自訂一個圖案在MOSUE_OVER某物件時,去取代原生的滑鼠指標並跟隨移動,
但若自訂圖案擋住了原本滑鼠的位置時,圖案則會不停的切換。
Mouse.hide();
↓
Mouse.show();
↓
Mouse.hide();
↓
Mouse.show();
↓
xN次
這根本就是陷入了無窮盡的迴圈啊~~~

為了確保父輩實體能夠當作滑鼠事件的目標物件來運作,
可以將父輩實體的 mouseChildren 屬性設為 false,
因為子系物件會也會觸發滑鼠事件而去影響到父輩實體。

// Ignores all sub movie clips and treats them as the parent
//      — otherwise events will be triggered on the child
//      movieclips and not our main clip
自訂圖案.mouseChildren   = false;
滑入物件.mouseChildren = false;
若自訂圖案重疊壓在要滑入的物件上方,會不斷觸發MOSUE_OUT事件,
接著我們要忽略自訂圖案的所有滑鼠事件,避免這個問題。
// Ignore all the mouse events for the cursor
//      — otherwise MOUSE_OUT will trigger since mouse is
//      now on target_mc instead of boundary_mc
自訂圖案.mouseEnabled = false;

沒有留言:

張貼留言