如何通过 XMLUI 从 JSFL 中的 Flash 创作获取值?
我想从 flash 文件设置一个变量,以便我可以在命令中从 JSFL 访问 if 。
我正在 JSFL 的 XMLUI 中使用一个元素: 这是 JSFL:
fl.getDocumentDOM().xmlPanel(fl.configURI + 'Commands/ATest.xml');
fl.trace(fl.xmlui.get('secretword'));//this traces undefined
XMLUI:
<dialog buttons="accept,cancel">
<textbox id="display_tb" size="24" />
<flash id="trace_fl" width ="150" height="100" src="ATest.swf">
<property id="secretword" />
</flash>
<button id="trace_btn" label="trace Flash" oncommand="fl.xmlui.set('display_tb','the secret word is ' + fl.xmlui.get('secretword'));" />
</dialog>
ATest.swf 内的操作脚本:
MMExecute("fl.trace('Hello From Flash XMLUI');");
XMLUI.setProperty('secretword','duck');
注意,如果我使用
MMExecute("fl.xml.ui.set('secretword','duck')");
而不是
XMLUI.setProperty('secretword','duck');
我会收到错误。
在 XMLUI 中正确设置了 Secretword:
- 我可以使用 fl.xmlui.get('secretword') 并在 'display_tb' 文本框中设置值
- 我可以从 ActionScript 打印该值(使用 fl.trace()),
但我得到了未定义当我打开面板后在 JSFL 中使用 trace fl.xmlui.get('secretword') 时。
从某种程度上来说,这是有道理的,如果 xmlui 变量在 xmlui 对话框显示期间就一直存在,并且一旦用户单击接受或取消。 有人可以确认是这样吗?
解决方法是通过 JSFL 从 xmlui 将“secretword”保存在文本文件中,尽管仅将值从 xmlui 节点传递到 JSFL 会更简单。 除了将文件写入磁盘之外,还有“更干净”的方法吗?
I want to set a variable from a flash file so that I can access if from JSFL in a Command.
I am using a element in JSFL's XMLUI:
Here's the JSFL:
fl.getDocumentDOM().xmlPanel(fl.configURI + 'Commands/ATest.xml');
fl.trace(fl.xmlui.get('secretword'));//this traces undefined
The XMLUI:
<dialog buttons="accept,cancel">
<textbox id="display_tb" size="24" />
<flash id="trace_fl" width ="150" height="100" src="ATest.swf">
<property id="secretword" />
</flash>
<button id="trace_btn" label="trace Flash" oncommand="fl.xmlui.set('display_tb','the secret word is ' + fl.xmlui.get('secretword'));" />
</dialog>
The actionscript inside ATest.swf:
MMExecute("fl.trace('Hello From Flash XMLUI');");
XMLUI.setProperty('secretword','duck');
Note that if I use
MMExecute("fl.xml.ui.set('secretword','duck')");
instead of
XMLUI.setProperty('secretword','duck');
I get an error.
The secretword is set properly in XMLUI:
- I can use fl.xmlui.get('secretword') and set the value in the 'display_tb' textbox
- I can print the value from actionscript (with fl.trace())
but I get undefined when I use trace fl.xmlui.get('secretword') in JSFL after opening the panel.
In a way it kind of makes sense, if the xmlui variables live as long as the xmlui dialog is display, and they become undefined as soon as the user click either accept or cancel.
Can someone confirm is this is the case ?
Aworkaround would be saving the 'secretword' in a text file through JSFL from xmlui, although just passing values from a xmlui node to JSFL would be simpler.
Is there a 'cleaner' way of doing this, other than writing a file to disk ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,我也这么认为。
为什么不将此密码应用于 XMLUI 的根元素?
Yes, I think so too.
Why not to apply this secretword to root element of your XMLUI?