将 ID 从主 swf 传递到子 swf
我有一个主影片剪辑,它根据按钮单击加载适当的 swf。按钮和相应的 swf 通过 XML 加载。我为实现此目的而采用的方法可以在这里找到: 示例代码
现在,这似乎工作得很好。但是,我的问题是,我不想为每次按钮单击调用单独的 SWF,而是想维护一个通用的 SWF 并仅更改适当的 XML 内容,使其更加动态。
这就是我被卡住的地方,我决定为xml上的每个按钮添加一个ID,并将其传递给Common SWF(子swf),这样根据ID,我可以加载相应的XML内容,而不是调用每次单击按钮都有单独的 swf。 XML 现在如下所示:
<?xml version="1.0" encoding="utf-8"?>
<menu>
<item>
<label>Gallery1</label>
<url><![CDATA[swf/gallery.swf]]></url>
<id>01</id>
</item>
<item>
<label>Gallery2</label>
<url><![CDATA[swf/gallery.swf]]></url>
<id>02</id>
</item>
</menu>
现在,我可以推送此 ID 并在主影片剪辑上跟踪它,但不知道如何将其传递给 Common/Child SWF。我不是 AS3 专家,但我每天都在学习它。因此,如果有人可以帮助我解决这个问题,我将非常感激。提前致谢。
I have a main movie clip that loads the appropriate swfs based on the button click. The buttons and the corresponding swfs are loaded through XML. The method I adapted to achieve this can be found here : Sample Code
Now, this seems to be working just fine. But, my problem is instead, of calling a separate SWF for each button click, I want to maintain a common SWF and change only the appropriate XML content, sort of make it more dynamic.
This is where I'm stuck, I decided to add an ID to each button on the xml and pass it to the Common SWF (child swf), so that based on the ID, I can load the corresponding XML content, rather than call separate swfs for each button click. The XML now looks like this:
<?xml version="1.0" encoding="utf-8"?>
<menu>
<item>
<label>Gallery1</label>
<url><![CDATA[swf/gallery.swf]]></url>
<id>01</id>
</item>
<item>
<label>Gallery2</label>
<url><![CDATA[swf/gallery.swf]]></url>
<id>02</id>
</item>
</menu>
Now, I'm able to push this ID and also have it traced on the main movie clip, but don't know how to pass it to the Common/Child SWF. I'm no expert in AS3 and I'm learning it everyday. So, if someone can help me with this, I would really appreciate it. Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
SWF-Button 必须实现 id 属性设置器的函数。该方法可以参考Loader-SWF方法,读取Clicks。
样本:
SWF-Button must implements function that is setter of id property. This method can have reference to Loader-SWF method taht reads Clicks.
sample: