How can I change the language of dynamic text in a SWF using flashvars?
Posted
by Cormac
on Stack Overflow
See other posts from Stack Overflow
or by Cormac
Published on 2010-05-07T10:05:13Z
Indexed on
2010/05/07
10:08 UTC
Read the original article
Hit count: 198
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!
© Stack Overflow or respective owner