3 Replies Latest reply on May 29, 2006 2:53 PM by kglad

    LoadVars' sendAndLoad is altering buttons behaviour

    Level 7
      hi, i'm having a weird problem with a rather simple movie:

      1. it loads images from the server using the loadMovie method from
      different folders
      2. the folder can be choosen from a combo box component
      3. LoadVars sendAndLoad method send the folder name to a PHP script wich
      returns images names in that folder as a string

      the problem is that when you change the folder, i.e., a second
      sendAndLoad method is issued, buttons to navigate to previous/next image
      begin to behave odd: you need to move the cursor over them before
      clicking or the actions aren't executed!?

      you can take a look here. note that initially the buttons work fine, the
      problem appears when you change the folder

      http://www.master.esdi.es/interactius06/msocarras/2006/exercises/pint/load_img_web_2.htm

      here is the code (1 frame movie);

      var imagesArr:Array = new Array();

      var lv:LoadVars = new LoadVars();
      lv.dir = cbDir.selectedItem.label;

      lv.sendAndLoad("read_folder_2.php", lv, "POST");

      lv.onLoad = function(success) {
      if (success) {
      stringToArray(this.str);
      } else {
      counter.text = "Error:"+this.str;
      }
      }

      var cbListener bject = new Object();
      cbListener.change = function(eventObject bject) {
      lv.dir = _root.cbDir.selectedItem.label;
      lv.sendAndLoad("read_folder_2.php", lv, "POST");
      };
      cbDir.addEventListener("change", cbListener)

      function stringToArray(str) {
      imagesArr = str.split("|");
      initialize();
      }

      function initialize() {
      total = imagesArr.length;
      i = 0;
      loadImg(0);
      }

      previous.onRelease = function() {
      if (i > 0) {
      loadImg(-1);
      }
      }

      next.onRelease = function() {
      if (i < total-1) {
      loadImg(1);
      }
      }

      function loadImg(incr) {
      i = i + incr;
      container.loadMovie(lv.dir+"/"+imagesArr );
      counter.text = i+1+"/"+total;
      }