//AS代码改变鼠标指针样
Mouse.cursor=
"hand"
;
//手掌型样式。
Mouse.cursor=
"ibeam"
;
//文本选择型样式。
Mouse.cursor=
"button"
;
//按钮手指型样式。
Mouse.cursor=
"auto"
;
//默认样式。
Mouse.cursor=
"arrow"
;
//箭头样式。
import flash.events.MouseEvent;
import flash.events.TimerEvent;
var doubleClick:Boolean = false;
stage.addEventListener(MouseEvent.CLICK, mClick);
function mClick(e:MouseEvent):void
{
if (doubleClick)
{
doubleClick = false;
return;
}
doubleClick = true;
var timer:Timer = new Timer(260, 1);
timer.addEventListener(TimerEvent.TIMER, onTimer);
timer.start();
function onTimer(e:TimerEvent):void
{
if(doubleClick){
trace("在这里处理单击事件")
} else {
trace("在这里处理双击事件")
}
timer.removeEventListener(TimerEvent.TIMER, onTimer);
doubleClick = false;
}
}
【方法二】mc.doubleClickEnabled=true
mc.addEventListener(MouseEvent.CLICK,chick)
mc.addEventListener(MouseEvent.DOUBLE_CLICK,double)
var sta=false
function double(e){
sta=true
}
function chick(e){
sta=false
var time=new Timer(260,1)
time.start()
time.addEventListener(TimerEvent.TIMER,func)
}
function func(e){
if(sta){
trace("双击")
}else{
trace("单击")
}
}
import flash.display.Sprite;
import flash.events.*;
import flash.utils.Timer;
public class MyButton extends Sprite
{
public var double:Boolean;
public function MyButton() {
super();
init();
}
public function init():void {
addEventListener( MouseEvent.CLICK , onClickHandler );
addEventListener( MouseEvent.DOUBLE_CLICK , onDoubleClickHandler );
}
public function onClickHandler( e:MouseEvent ):void {
double = false;
var timer:Timer = new Timer(260,1);
timer.addEventListener( TimerEvent.TIMER , checkClick );
timer.start();
}
public function onDoubleClickHandler( e:MouseEvent ):void {
double = true;
}
public function checkClick( e:TimerEvent ):void {
if( double ){
//监听这两个自定义事件即可
dispatchEvent( new Event( "mouseDoubleClick" , true ) );
}else{
dispatchEvent( new Event( "mouseSingleClick" , true ) );
}
}
}