フォーカス移動・マウスカーソル変化を無効に

 画像やテキストをボタンにすると、Tabキーを押したときにフォーカスが移動して黄色い枠が表示されたり、ボタン領域内にマウスカーソルを移動するとマウスカーソルの形状が変化してしまうのを、無効にするための方法。方法2の方が簡単。
 自分が思いつかないだけで他の方法もあるかも。



 
 スプライトにボタンにする画像(またはテキスト)を入れて、インスタンス名をmcにして_rootに配置。

★方法1(ジャンプ先が_rootにあるラベルaの場合)
 「ボタンにする」でボタンを作らない
 _rootのフレームアクションで
mc.onMouseDown=function(){
  if(this.hitTest(_root._xmouse,_root._ymouse,true)){
    this.pressflg=true;
  }
};
mc.onMouseUp=function(){
  if(this.pressflg==true && this.hitTest(_root._xmouse,_root._ymouse,true)){
    this._parent.gotoAndPlay("a"); //ボタンを押したときの処理
  }
  this.pressflg=false;
};

 あるいはクリップアクションで
on(MouseDown){
  if(this.hitTest(_root._xmouse,_root._ymouse,true)){
    this.pressflg=true;
  }
}
-
on(MouseUp){
  if(this.pressflg==true && this.hitTest(_root._xmouse,_root._ymouse,true)){
    this._parent.gotoAndPlay("a"); //ボタンを押したときの処理
  }
  this.pressflg=false;
}



★方法2
 スプライト内の画像(またはテキスト)を「ボタンにする」でボタンを作る
 _rootのフレームアクションで
for (test in this.mc) {
  this.mc[test].tabEnabled=false;
  this.mc[test].useHandCursor=false;
}

あるいは_root.mcのフレームアクションで
for (test in this) {
  this[test].tabEnabled=false;
  this[test].useHandCursor=false;
}


トップに戻る