5 Replies Latest reply on Feb 23, 2008 6:01 AM by Greg Dove

    Actionscript bug problem loading in Firefox

    ungabo
      Please Help.

      I'm working on a page at http://localhost/skitterskatter/gerilance/D4D/index4.html

      The page works fine in Internet Explorer on a PC. In Firefox and some mac browsers when you click on a thumbnail, the image does not display (an image is supposed to expand out from the thumbnail into the upper right of the screen). After a page refresh often the thumbnail actions work.

      It seems that the image has to load into the cache before it can move. I can't figure out how to get this to work. Here is the actionscript:


      var finalWidth = 435; // width for furniture piece
      var finalHeight = 295; // height for furniture piece

      var initWidth = 10; // initial width and height for furniture piece that explodes from thumbnail
      var initHeight = 10;
      var finalX = 570; // Destination X and Y positions for furniture piece
      var finalY = 50;
      var stoploop = 0; // counter to determine when furniture piece is in place
      var numberOfCalls = 40; // the number of times a function is called to reach the final position
      var intervalID;
      var initX = 0;
      var initY = 0;

      function startLoading(image, button) {
      clearInterval(intervalID);
      _root.infoField._visible = true;

      myData = new LoadVars();
      myData.onLoad = function() {
      _root.descr.text = this.theText;
      };
      myData.load("./descr/"+image+".txt");

      myData = new LoadVars();
      myData.onLoad = function() {
      _root.nameOfPiece.text = this.theText;
      };
      myData.load("./names/n_"+image+".txt");

      _root.perice._width = 10;
      _root.perice._height = 10;


      var whichImage = "./pieces/"+image+".jpg";
      loadMovie(whichImage, "_root.perice");

      _root.onEnterFrame = function() {
      var infoLoaded = _root.perice.getBytesLoaded();

      var infoTotal = _root.perice.getBytesTotal();
      var percentage = Math.floor(infoLoaded/infoTotal*100);
      _root.infoField.text = "loading... "+percentage+"% InfoLoaded: "+infoLoaded+" InfoTotal: ";

      if (percentage>=100) {

      var material = "./materials/mat_"+image+".jpg";
      var titleimage = "./titles/title_"+image+".jpg";
      var design = "./designs/design_"+image+".jpg";
      loadMovie(material, "_root.material");
      loadMovie(titleimage, "_root.titleimage");

      loadMovie(design, "_root.design");
      initX = _root._xmouse;
      initY = _root._ymouse;
      stoploop = 0;


      _root.perice._x = initX;
      _root.perice._y = initY;


      intervalID = setInterval( moveperice, 50 );

      delete this.onEnterFrame;

      }
      // gotoAndPlay(1);
      };
      _root.startagain();
      }

      function moveperice() {

      _root.perice._x += (finalX-initX)/numberOfCalls;
      _root.perice._y += (finalY-initY)/numberOfCalls;


      _root.perice._width += (finalWidth-initWidth)/numberOfCalls;
      _root.perice._height += (finalHeight-initHeight)/numberOfCalls;


      stoploop += 1;

      if (stoploop >= numberOfCalls) {
      ;
      clearInterval(intervalID);
      }
      }
      slidebar.button1.onRelease = function () {
      startLoading("albert", this, initX, initY);
      }

      slidebar.button2.onRelease = function () {
      startLoading("amy", this, initX, initY);
      }

      slidebar.button3.onRelease = function () {
      startLoading("david", this);
      }


      etc with the rest of the buttons.

      Please help.