3 Replies Latest reply on Dec 5, 2012 2:49 PM by kglad

    Timer not clearing

    Jim Wiley

      Hi All,

      I am having issues with a Strings Panel XML (mx.lang.locale) loading XML language files access code not clearing the Success timer.

      Do I need to create a Global timer??? AS2 CS5 Player 8

       

       

      import mx.lang.Locale;
      stop();
      //Prepare for importing language variable from  Director
      var Lang:String = new String();
      //Test for missing variable - default to Strings Panel default, usually English
      onEnterFrame=function(){
      Locale.setLoadCallback(localeCallback);
      if (Lang == null) {
        Lang = Locale.getDefaultLang();
        trace(Lang);
      } else {
        var temp:Boolean = new Boolean();
        temp = false;
        for (var i=0; i<Locale.languageCodeArray.length; i++){
         if (Lang==Locale.languageCodeArray[i]){
          temp = true
          break;
         }
        }
        if (!temp){
        trace("Not a supported language or missing Strings Panel setting for XML file for - " + Lang);
         Lang = Locale.getDefaultLang();
        }
        setLangXML();
      }
          delete this.onEnterFrame;
      CBActivate();
      }  
      function setLangXML():Void{
      Locale.loadLanguageXML(Lang);
      var locale_int:Number = setInterval(checkLocaleStatus, 10);
      }
      function checkLocaleStatus():Void {
          if (Locale.checkXMLStatus()) {
              clearInterval(locale_int);
              trace("clearing interval @ " + getTimer() + " ms");
          }
      }
      // callback function for Locale.setLoadCallback()
      function localeCallback(success:Boolean):Void {
      success=false;
      txt0.text = Locale.loadStringEx("IDS_GT8-LD-001", Lang);
      }
      //Language Selector ComboBox
      function CBActivate():Void{
      Menu1.dataProvider = Locale.languageCodeArray.sort();
      var myListener:Object = new Object();
      Menu1.addEventListener("change",myListener);
      for (var i=0; i<Menu1.length;i++){
        if (Menu1.getItemAt(i)==Locale.getDefaultLang()){
         Menu1.selectedIndex=i;
         break;
        }
      }
      myListener.change = function (){
        Lang = Menu1.value;
        trace("Set to " + Lang);
        setLangXML();
      }
      }