如何使用 flashvars 更改 SWF 中动态文本的语言?
我有一个 SWF,其中嵌入了来自外部 .txt 文件的文本。有没有办法根据语言通过嵌入代码(swfObject)将不同的文件用作文本源?
这是我当前的动作脚本:
myData = new LoadVars();
myData.onLoad = function() {
text_clips.project_title.text = this.projecttitle1;
};
myData.load("translatetext.txt");
var loader:MovieClipLoader = new MovieClipLoader();
loader.loadClip(_level0.projectimage1,pic1.image_holder);
这是translatetext.txt的内容:
projecttitle1=This is my translatable text
这是我正在使用的嵌入代码:
<div>
<object width="960" height="275" id="rvFlashcontent">
<param name="movie" value="lang_test_3.swf" />
<param name="wmode" value="transparent" />
<param name="flashvars" value="projectimage1=flashimages/testimage.jpg" />
<!--[if !IE]>-->
<object type="application/x-shockwave-flash" data="lang_test_3.swf" width="960" height="275">
<param name="wmode" value="transparent" />
<param name="flashvars" value="projectimage1=flashimages/testimage.jpg" />
<!--<![endif]-->
<h1>Alt Content</h1>
<!--[if !IE]>-->
</object>
<!--<![endif]-->
</object>
</div>
我想要什么要做的就是添加一个 Flashvars 参数来命名要加载的文件,这样我就可以更改语言:
<param name="flashvars" value="projectimage1=flashimages/image.jpg&projecttext=textfrench.txt" />
到目前为止需要四种语言,但这会增长,因此它需要足够灵活,以便开发人员可以添加语言而无需获取新的 SWF每次。预先感谢大家!
I have a SWF with text embedded from an external .txt file. Is there a way I can have a different file used as the text source through the embedcode (swfObject) depending on the language?
Here is my current actionscript:
myData = new LoadVars();
myData.onLoad = function() {
text_clips.project_title.text = this.projecttitle1;
};
myData.load("translatetext.txt");
var loader:MovieClipLoader = new MovieClipLoader();
loader.loadClip(_level0.projectimage1,pic1.image_holder);
This is the content of translatetext.txt:
projecttitle1=This is my translatable text
This is the embed code I'm using:
<div>
<object width="960" height="275" id="rvFlashcontent">
<param name="movie" value="lang_test_3.swf" />
<param name="wmode" value="transparent" />
<param name="flashvars" value="projectimage1=flashimages/testimage.jpg" />
<!--[if !IE]>-->
<object type="application/x-shockwave-flash" data="lang_test_3.swf" width="960" height="275">
<param name="wmode" value="transparent" />
<param name="flashvars" value="projectimage1=flashimages/testimage.jpg" />
<!--<![endif]-->
<h1>Alt Content</h1>
<!--[if !IE]>-->
</object>
<!--<![endif]-->
</object>
</div>
What I want to do is add a Flashvars parameter to name the file to load, so I can change the language:
<param name="flashvars" value="projectimage1=flashimages/image.jpg&projecttext=textfrench.txt" />
There are four languages needed so far, but this will grow so it needs to be flexible enough to let the developers add languages without getting a new SWF each time. Thanks in advance all!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不确定您是否在询问如何访问 flashvars 或如何处理多种语言,但假设是前者,您可以像这样访问 flashvars:
== 编辑 ==
您需要添加一个将触发的事件侦听器当负载完成时。我已经编辑了上面的伪代码作为示例......
I'm not sure if you're asking how to access flashvars or how to handle multiple languages, but assuming it's the former, you can get at flashvars like so:
== Edit ==
You need to add an event listener that will fire when the load is complete. I've edited my pseudo code above as an example...