带图像的自定义按钮
您好,我正在尝试在 actionscript 3 中创建一个按钮,该按钮将由自定义图像(来自我的 HDD 的 car.jpg )制作。是否可以使用 SimpleButton 类来做到这一点(我的意思是有没有办法加载图像并将其附加到按钮?)或者还有其他方法吗? 如果我想在按钮中也有动画,当我从按钮上滚动鼠标指针时,我该怎么办?
ps:我只想使用actionscript 3(我的意思是所有项目都是作为链接到Document类的.as文件完成的)。
Hi i'm trying to create a button in actionscript 3 that will be made by a custom image ( a car.jpg from my HDD ). Is it possible to do that with SimpleButton class ( i mean is there a way to load the image and attach it to the button ?) or is there another way?
If i would like to have animation also in the button when let's say i roll over the mouse pointer from the button what do i have to do?
ps: i would like to use only actionscript 3 ( i mean all the project is done as a .as file that is linked to Document class ).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尽管 George Profenza 已经在评论下指出了最佳解决方案,但如果您好奇如何实现 SimpleButton 类,您可能需要查看 as3 文档参考示例:
adobe livedocs - SimpleButton 示例
我还编写了一个简单的示例,仅在一个“复杂的按钮”,但使用 SimpleButton 类,因此您可以了解如何扩展该类,并为每个状态提供自己的图形。代码如下:
MySimpleButton.as
ButtonImgDisplayState.as
SimpleButton 的作用是让您无需设置侦听器,但您有义务绕过单独的 DisplayObjects 的状态,这使得您在处理状态之间的转换时按钮变得更加严格。
希望您觉得这很有用。
Although George Profenza already pointed the best solution under the comment if feel curious how you could implement the SimpleButton class you might want to take a look into th as3 document reference examples:
adobe livedocs - SimpleButton Example
I have also wrote a simple example that only makes a "simple button" in a "complicated button" but makes use of SimpleButton class, so you can take a look how you can extend the class, and give to each state it's own graphic. Here is the code:
MySimpleButton.as
ButtonImgDisplayState.as
The thing about the SimpleButton is to spare you to set listeners, but you are obligated to go around the states that are separated DisplayObjects making you button a more rigid thing when dealing with transitions between states.
Hope you find this useful.