AS3 如何让按钮切换功能?
单击“button1”时,光标变为“movieclip” 我希望这个影片剪辑光标切换回常规光标 当再次点击button1时,切换该功能的打开和关闭。
我向您提出的问题是,这里是否可能使用某种布尔值来打开和关闭该功能,或者我是否走错了方向? 提前致谢!
button1.addEventListener(MouseEvent.CLICK,wipe);
function wipe(e:Event):void
{
Mouse.hide();
stage.addEventListener(MouseEvent.MOUSE_MOVE,follow);
function follow(evt:MouseEvent)
{
cursor.x = mouseX;
cursor.y = mouseY;
}
}
When button1 is clicked, the cursor changes into a 'movieclip'
I want this movieclip cursor to switch back into a regular cursor
when button1 is clicked again, so toggle the function on and off.
My question to you is, is it likely to use some kind of boolean here to toggle the function on and off or am I in the wrong direction?
Thanks in advance!
button1.addEventListener(MouseEvent.CLICK,wipe);
function wipe(e:Event):void
{
Mouse.hide();
stage.addEventListener(MouseEvent.MOUSE_MOVE,follow);
function follow(evt:MouseEvent)
{
cursor.x = mouseX;
cursor.y = mouseY;
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试
将跟随的定义移出擦除。这还有效吗?
如果您需要直接在舞台上有其他 MOUSE_MOVE 侦听器,那么您可能想要使用更像以下的内容:
注意:我假设您要将代码放入文档类中,因为我总是假设如果您如果您足够细心,可以在 Stack Overflow 等地方询问,那么您会希望采用良好的做法。
Try
I'd move the definition of follow out of wipe. Does that even work?
If you need to have other listeners for MOUSE_MOVE directly on the stage then you might want to go with something more like:
Note: I've assumed you're going to put your code into a document Class, since I always assume that if you care enough to ask on a place like Stack Overflow, you'd like to use good practice.
希望这有帮助。
Hope this helps.