[英]Changing cursor to pointer on roll over in HTML5 canvas with Flash CC
我正在为FLASH CC中的HTML5画布文档中的某些按钮添加一些交互性。 该功能很好用,但是我无法弄清楚如何向其中添加JS以添加过渡,以便在将按钮翻转时出现手形光标/指针。
我知道如何通过buttonMode在AS3中做到这一点,但是我对JS完全不了解。
以下是我目前在HTMl5 canvas文档中按钮的代码,在此先感谢您的帮助!
var frequency = 1;
stage.enableMouseOver(frequency);
this.btn_yes.addEventListener("click", clickYes.bind(this));
this.btn_no.addEventListener("click", clickNo.bind(this));
this.btn_yes.addEventListener("mouseover", MouseOverYes);
this.btn_yes.addEventListener("mouseout", MouseOutYes);
this.btn_no.addEventListener("mouseover", MouseOverNo);
this.btn_no.addEventListener("mouseout", MouseOutNo);
function clickYes()
{
this.gotoAndPlay("chooseYes");
}
function clickNo()
{
this.gotoAndPlay("no");
}
function MouseOverYes()
{
this.btn_yes.style.cursor = 'pointer';
}
function MouseOutYes()
{
this.btn_yes.style.cursor = 'default';
}
function MouseOverNo()
{
this.btn_no.style.cursor = 'pointer';
}
function MouseOutNo()
{
this.btn_no.style.cursor = 'default';
}
也许试试这个。
stage.enableMouseOver();
var root = this;
root.theButtonName.cursor = "pointer";
stage.canvas.style.cursor =“默认”;
将鼠标光标设置为正常状态。
stage.canvas.style.cursor =“无”;
这将使鼠标光标消失,现在所有内容都严重缺乏文档。 试图找到一个很好的资源来在Flash canvas中进行编码。 如果您找到一个,请告诉我。
@ user3570797如果您使用的是FlashCC,则可以通过创建按钮符号轻松完成此操作。 尝试这样的事情: http : //grab.by/Ktw2
然后通过“ ExportRoot”对象按名称引用这些按钮,并将事件处理程序附加到这些按钮。
例:
function init() {
canvas = document.getElementById("canvas");
exportRoot = new lib.Button();
stage = new createjs.Stage(canvas);
stage.addChild(exportRoot);
stage.update();
stage.enableMouseOver();
var yesBtn = exportRoot.yesBtn;
var noBtn = exportRoot.noBtn;
yesBtn.addEventListener("click", handleClick);
noBtn.addEventListener("click", handleClick);
createjs.Ticker.setFPS(lib.properties.fps);
createjs.Ticker.addEventListener("tick", stage);
}
function handleClick(event) {
//doSomething...
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.