从外部 swf 中的按钮加载外部 swf 并卸载自身?
我是闪存 AS3 的超级新手。我无意听起来像个白痴,但说实话,我花了很长时间才弄清楚如何加载外部 .swf 到我的主文件中!现在我的朋友问我是否可以在外部 .swf 中添加一个按钮,该按钮将自行卸载并在其位置加载新的按钮...
我已经在论坛中寻找答案有一段时间了,我相信现在是我崩溃、承认失败并寻求帮助的时候了。
有人可以告诉我这并不那么困难吗..?当然有可能......
预先感谢您提供任何建议!我期待我可以在这里发表回复!
I am an uber n00b to flash AS3. And it is not my intention to sound like a complete moron, but honestly, I have had a hard enough time figuring out just how to load an external .swf into my main file! And now my friend is asking me if I could please add a button within the external .swf which will unload itself and load a new on in its place...
I have looked around in the forums for an answer for a while now and I believe it is time for me to break down, admit defeat, and ask for help.
Can someone please tell me it's not that difficult..? Surely it is possible...
Thank you in advance for any advice at all! I am looking forward to the time when I can post a response here!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我有解决办法!而这才过去了24小时。我统治!
我遇到了 dispatchEvent 并解决了它!
...如果将来有人看到此页面来寻求这个看似不可能完成的任务的答案,那么他们现在就会得到答案!如果我在引用我所做的事情时没有正确的术语,请原谅我。开始了...
在我的外部 .swf 中,我需要为我的按钮(位于我的外部 swf 中)设置一个侦听器事件。然后在我的按钮的函数中包含一个dispatchEvent。我在参数中加入了“true”,以将事件“冒泡”回主时间线。他是我的一个按钮的例子。
好的,但这只是实现这一目标的一半代码。所以现在,在我加载外部 swf 的主 swf 中,我需要做几件事:
1)。从内存中卸载当前的 swf,以便它停止播放声音
2)。在我的外部 swf 中为dispatchEvent 设置一个侦听器(它将冒泡)
3)。加载新的外部 swf
就是这样!老实说,我没想到我会这么快在这里发布回复!
I have the solution! And it's only been 24 hours. I rule!
I came across dispatchEvent and that solved it!
...In case someone comes across this page seeking the answer to this seemingly-impossible-task-for-a-n00bie in the future, then they will have the answer right now! Please forgive me if I don't have the correct terminology in referencing what I did. Here we go...
In my external .swf I needed to set a listener event to my buttons (which are in my external swf). Then include a dispatchEvent within the function for my buttons . I included "true" in the arguments to 'bubble' the event back up to the main timeline. He's an example of one of my buttons.
Ok, but that's only half of the code to make it happen. So now, in my main swf, in which I load the external swfs into, I needed to do several things:
1). Unload the current swf from memory so that it will stop playing sounds
2). Set a listener for the dispatchEvent in my external swf (which will bubble up)
3). Load the new external swf
And there it is! I honestly didn't think that I'd be posting a response on here THAT quickly!