如何在Flash中点击另一个按钮后隐藏一个按钮?
我正在使用 Actionscript 3 制作点击游戏。在第 1 帧上有两个按钮,按钮 1 和 2。在第 3 帧上有两个按钮,按钮 A 和 B。
我希望在单击第 1 帧上的按钮 1 后,第 3 帧上的按钮 A 将被隐藏,或者当我单击第 1 帧上的按钮 2,第 3 帧上的按钮 B 将被隐藏。当您单击隐藏的按钮时,它们不会执行任何操作。
提前致谢
I am using actionscript 3 to make a point and click game. On frame 1 there are two buttons, button 1 and 2. On frame 3 there are two buttons, button A and B.
I want it so that after I click button 1 on frame 1, button A on frame 3 will be hidden or when I click button 2 on frame 1, button B on frame 3 will be hidden. The buttons that are hidden do not do anything when you click them.
thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您尝试删除不在显示列表中的内容,Flash 将抛出错误。我想这里最好的解决方案是设置一个时间线变量来跟踪您按下的按钮。像这样:
在第 1 帧上
在第 3 帧上
If you try to remove something that is not in the display list yet Flash will thrown an error. I guess the best solution here is setting up a timeline variable to keep track of which button you have pressed. Something like this:
on frame 1
on frame 3
有多种方法可以从显示列表中删除对象,或以其他方式将其隐藏在视图中。例如:
您还可以将目标按钮的“可见性”属性设置为 false。
非常非常简单,您应该能够根据需要修改此代码片段。
说到另一个话题。
我总是敦促人们不要在时间表上进行互动。它只是让事情变得混乱,特别是当您在 AS3 中拥有如此强大的面向对象工具时......
无论哪种方式 - 干杯,祝你好运。
当然可以 - 尽管这是一个相当深刻的问题,具体取决于您的经验。主要的事情是参与 AS3 的面向对象功能,并仅通过代码驱动大部分应用程序。
项目看起来像这样:Fla 主要用作资产容器(如果您使用嵌入,则甚至不是),具有单个空时间线框架。然后,主文档类负责启动和构建项目的所有方面 - 从数据的加载和控制到显示列表对象的创建和添加,再到建立和控制用户交互。经典包/类设计用于创建可能的数十或数百个单独的 .AS 文件。时间线仍然用于创建复杂的动画,但很少涉及任何代码(在这里或那里保存一个 stop(); )。
当我刚刚学习这个时 - 我得到了一本好书,并经常在谷歌上搜索,以找出AS3 的要点,就从那里开始。做一些简单的项目,你就能看到你能有多深入,而且速度有多快。
这样工作的好处怎么强调都不为过。
如果您还有任何疑问,请告诉我。祝你好运!
There are many ways to remove an object from the display list, or otherwise hide it from view. For example:
You could also set the target buttons "visibility" property to false.
Very very simple, and you should be able to modify this snippet as needed.
On another topic.
I always urge people away from developing interactions on the timeline. It just confuses things, especially when you have such potent object oriented tools available in AS3...
Either way - Cheers and good luck.
Sure thing - although its a fairly deep question, depending on your experience. The main thing is getting involved with AS3's Object Oriented features, and driving the majority of your application via code alone.
Projects look like this: the Fla functions mostly as a container for assets (and if you utilize embeds, not even that), with a single, empty timeline frame. The main document class is then responsible for initiating and constructing all aspects of the project - everything from the load and control of data to the creation and addition of display list objects to establishing and controlling user interactions. Classic Package / Class design is used to create, potentially, dozens or hundreds of individual .AS files. The timeline is still used to create complex animations, but rarely involve any code (save a stop(); here or there).
When I was just learning this - I got a good book, and hit the googles a lot, to figure out the essentials of AS3, and just kind of went from there. Make a few simple projects, and you can see how indepth you can get, and quickly.
The benefit from working like this can not be overstated.
Let me know if you have any further questions. Good luck!