简体   繁体   English

使用Flash CC在HTML5画布中将光标更改为鼠标悬停时的指针

[英]Changing cursor to pointer on roll over in HTML5 canvas with Flash CC

I'm working on adding some interactivity to some buttons in an HTML5 canvas document in FLASH CC. 我正在为FLASH CC中的HTML5画布文档中的某些按钮添加一些交互性。 The functionality works great, but I can't figure out how to add the JS to it for adding a rollover so that the handcursor/pointer appears when the buttons are rolled over. 该功能很好用,但是我无法弄清楚如何向其中添加JS以添加过渡,以便在将按钮翻转时出现手形光标/指针。

I know how to do this in AS3 through the buttonMode, but I'm a total noob to JS. 我知道如何通过buttonMode在AS3中做到这一点,但是我对JS完全不了解。

Below is the code that I have currently for the buttons in the HTMl5 canvas doc, Thanks in advance for any help! 以下是我目前在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';
     }

Maybe try this one. 也许试试这个。

stage.enableMouseOver();
var root = this;
root.theButtonName.cursor = "pointer";

stage.canvas.style.cursor = "default"; stage.canvas.style.cursor =“默认”;

will set the mouse cursor to it's normal state. 将鼠标光标设置为正常状态。

stage.canvas.style.cursor = "none"; stage.canvas.style.cursor =“无”;

This will make the mouse cursor disappear, there's a serious lack of documentation on everything right now. 这将使鼠标光标消失,现在所有内容都严重缺乏文档。 Trying to find a good resource for coding in flash canvas as well. 试图找到一个很好的资源来在Flash canvas中进行编码。 if you find one please let me know. 如果您找到一个,请告诉我。

@user3570797 If you are using FlashCC, this can be done easily by creating button symbols. @ user3570797如果您使用的是FlashCC,则可以通过创建按钮符号轻松完成此操作。 Try something like this: http://grab.by/Ktw2 尝试这样的事情: http : //grab.by/Ktw2

Then reference these buttons by name via the 'ExportRoot' object and attach event handlers to those buttons. 然后通过“ ExportRoot”对象按名称引用这些按钮,并将事件处理程序附加到这些按钮。

Example: 例:

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM