AS3 中的按钮充当带有鼠标事件的滚动?
我是新来的,刚刚在谷歌上发现了这些论坛。
首先,如果有这样的主题,我想表示歉意,但我搜索了整个论坛,但没有找到任何可以解决我的问题的主题。
现在是重要的一件事。正如我在主题标题中所述,我需要一个执行此操作的 AS3 代码。这就是我想要的 完成。我的屏幕中央有一个 MC(图像),有两个按钮,一个在右边,一个在左边 那个MC的一边。我想在鼠标事件上向左或向右滚动(图像就像一个菜单),向下或向上滚动。 所以,我只想在按住鼠标按钮或将鼠标悬停在按钮上时更改 MC 的 X 值。 我已经设法做到了这一点,但它仅移动了我在鼠标事件后输入的一个值。 这是我做的一段代码。
buttonL1_btn.addEventListener(MouseEvent.MOUSE_OVER, buttonL1Pressed);
function buttonL1Pressed(event:MouseEvent):void{
var temp:int = 0;
var temp1:int = 0;
temp = paleta1_mc.x;
temp1 = temp - 5;
paleta1_mc.x = temp1;
trace(temp1);
}
我希望你能理解我,并知道如何帮助我解决这个问题。
预先非常感谢您!
干杯, 伊万
I'm new here, just found these forums on Google.
First of all, I want to appologise if there is some topics like this, but I searched whole forums and didn't find any that finishes my problem.
Now the important one. As I stated in topic title, I need an AS3 code that's doing the thing. This is what I want to
accomplish. I have a MC(image) in the center of my screen, and have two buttons, one on right and one on left
side of that MC. I want to scroll (image is like a menu) that MC left or right on mouse events, down or over.
So, I just want to change MCs X value while holding mouse button on buttons or just hovering over them.
I have managed to do that, but it's only moving by one value I have entered after a mouse event.
Here's a piece of code I did.
buttonL1_btn.addEventListener(MouseEvent.MOUSE_OVER, buttonL1Pressed);
function buttonL1Pressed(event:MouseEvent):void{
var temp:int = 0;
var temp1:int = 0;
temp = paleta1_mc.x;
temp1 = temp - 5;
paleta1_mc.x = temp1;
trace(temp1);
}
I hope you understood me, and have a clue how to help me with this.
Thank you very much in advance!
Cheers,
Ivan
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
试试这个:
Try this:
您似乎将事件侦听器附加到
MOUSE_OVER
事件而不是MOUSE_DOWN
?由于您的处理函数名为buttonL1Pressed
,我假设您希望在用户单击按钮时而不是在鼠标光标位于按钮上时触发该事件。抱歉,我不太清楚你在问什么,但是当我阅读你的代码时,我突然意识到了这一点。
如果您能提供更多详细信息,我很乐意提供帮助。
It looks like you're attaching the event listener to the
MOUSE_OVER
event instead ofMOUSE_DOWN
? Since your handler function is calledbuttonL1Pressed
, I assume you want the event to fire when the user clicks the button instead of when the mouse cursor is over it.Sorry, I'm not entirely clear what you're asking, but that jumped out at me as I was reading your code.
If you can provide a little more detail, I'd be happy to help if I can.