3 Replies Latest reply on Apr 17, 2007 11:15 AM by Newsgroup_User

    Can I... Dynamic Switch case

    BobbyP57
      Hi All, I am loading an external XML and I have a for loop and that works great. Now I want to build a dynamic switch case but flash keeps deleteing my case statement in my j for loop. If I hard code the switch all is fine but not what I want

      Any help would be great

      Thanks
      Bobby

      stop ();
      ////////////////////////////////////////////////////////////////////////////////
      ResponseObject666 = new xmlObject ();
      var xml_file:String = "FileLoader.xml";
      ResponseObject666.Open (xml_file);
      ResponseObject666.ignoreWhite = true;
      ResponseObject666.onLoad = function (success:Boolean) {
      //trace ("Success Loader");
      var nr = this.GetNumRows ();
      //trace (nr);
      Response666 = {};
      Response666.GTitle = [];
      Response666.GFile = [];
      ///////////////////////////////////////////////////////////////////////////
      for (i = 0; i < nr; i++) {
      Response666.GTitle = this.GetResult ("Game_Title");
      Response666.GFile
      = this.GetResult ("Game_File");
      fredName = Response666.GTitle ;
      fredFileName = Response666.GFile
      ;
      //trace (Response666.GFile );
      systems_list.addItem ({label:fredName, data:i});
      this.MoveNext ();
      /////////////////////////////////////////////////////////////////////
      }
      var listHandler:Object = new Object ();
      listHandler.change = function (evt:Object) {
      fader_mc.play ();
      switch (evt.target.selectedItem.data) {
      //////////////////////
      //for (j = 0; j < nr; j++) {
      // case j ://<----- case j : //
      // file2load = Response666.GFile[j];
      // play ();
      // break;
      //}
      /////////////////////

      case 0 :
      file2load = Response666.GFile[0];
      play ();
      break;
      case 1 :
      file2load = Response666.GFile[1];
      play ();
      break;
      ECT...
      default :
      trace ("unhandled event: " + evt.target.selectedItem.data);
      break;
      }
      };
      systems_list.addEventListener ("change", listHandler);
      };