如何使用 flashvars 更改 SWF 中动态文本的语言?

发布于 2024-08-31 20:30:20 字数 1607 浏览 5 评论 0原文

我有一个 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!

Files for this question available here...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

儭儭莪哋寶赑 2024-09-07 20:30:20

我不确定您是否在询问如何访问 flashvars 或如何处理多种语言,但假设是前者,您可以像这样访问 flashvars:

protected function init():void
{
    var flashvars:Object = LoaderInfo(root.loaderInfo).parameters;
    var myDataLoader:URLLoader = new URLLoader();
    myDataLoader.addEventListener(Event.COMPLETE, onDataLoadComplete);
    myDataLoader.load(new URLRequest(flashvars.projecttext));
}

protected function onDataLoadComplete(e:Event):void
{
    var myDataLoader:URLLoader = URLLoader(e.target);
    var myData:Object = myDataLoader.data;
    // now you can do whatever you want with the contents of the file (i.e. myData)
}

== 编辑 ==

您需要添加一个将触发的事件侦听器当负载完成时。我已经编辑了上面的伪代码作为示例......

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:

protected function init():void
{
    var flashvars:Object = LoaderInfo(root.loaderInfo).parameters;
    var myDataLoader:URLLoader = new URLLoader();
    myDataLoader.addEventListener(Event.COMPLETE, onDataLoadComplete);
    myDataLoader.load(new URLRequest(flashvars.projecttext));
}

protected function onDataLoadComplete(e:Event):void
{
    var myDataLoader:URLLoader = URLLoader(e.target);
    var myData:Object = myDataLoader.data;
    // now you can do whatever you want with the contents of the file (i.e. myData)
}

== 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...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文