0 Replies Latest reply on Aug 5, 2009 6:19 PM by kyser777

    Problem, change the language with dynamic text

    kyser777

      I am looking for a way to change simply the language of my flash animation

      I work with flash cs4

       

      of course I got Mylocale.as:

       

       

       

      import mx.lang.Locale;
      class MyLocale extends mx.lang.Locale {
      static function start():Void {  
      var langCode:String = xmlLang;
      currentXMLMapIndex = 0;
      xmlDoc.load(xmlMap[langCode][0]);
      }

       

      static function setXMLLang(langCode:String):Void {
      xmlLang = langCode;
      }

       


      }

       

       

       

      and different xml files in the same folder than my swf file

       

      in string , I ticked : "replace  strings automatically during the execution"

       

        with a default language (I am wondering if the problem is not from there)

       

        if I tick: "replace strings manually using the scene language " or "replace strings via actionscript"

       

      my code does not work.

       

        then I kept: "replace strings automatically during the execution"

       

       

       

      in my flash animation I have several scenes (pages)

       

      p1, p2, p3, p4

       

      in p1

       

      I created a language bar

       

      then 2 layers inside

       

      Layer--action:

       

      langListener = new Object();

       

       

       

      langListener.change = function(eventObj) {
      var target = eventObj.target;
      var newLang = target.selectedItem.data;
      MyLocale.setXMLLang(newLang);
      MyLocale.start();
      }
      lang_cb.addEventListener("change", langListener);

       

       

       

      // Force Japanese
      lang_cb.selectedIndex = 1;
      lang_cb.dispatchEvent({type:"change"});

       


      Layer--language ex Fr:

       


      // Forces combobox to have the correct value
      on (release) {
      var component = _parent.lang_cb;
      for (var i=0; i< component.length; i++) {
      var item = component.getItemAt(i);
      if (item.data == "fr") {
      component.setSelectedIndex(i);
      component.dispatchEvent({type:"change"});
      break;
      }
      }
      }

       


      ex Ja :

       

      // Forces combobox to have the correct value
      on (release) {
      var component = _parent.lang_cb;
      for (var i=0; i< component.length; i++) {
      var item = component.getItemAt(i);
      if (item.data == "ja") {
      component.setSelectedIndex(i);
      component.dispatchEvent({type:"change"});
      break;
      }
      }
      }

       


      When I change the language in p1 , the language is also modified in p2, p3 and p4

       

       

      however , after a navigation in p2, p3 and p4 , once I come back in p1 , the default language is back automatically although I did not touch the language bar!!

       

       

       

       

      I don't know how to solve the problem

       

      to my mind , the script reset itself each time I come back on p1

       

       

      is there a way to keep the saved settings even when I am back on p1 until I modify manually again the language bar

       

      thanks a lot