2 Replies Latest reply on Nov 13, 2006 12:57 AM by Glazer

    Why isnt my background resizing?

    fanmap81 Level 1
      Can anyone tell me what it is im doing wrong here? Im trying to get my background to size to stay consistent with the stage no matter how wide the screen is. I want to know whats wrong with my code that this isnt happening all of a sudden because it worked in a previous project i was working on. Here is the code:

      stop();
      id1 = setInterval(preloader, 100);

      function preloader()
      {
      var gbt = getBytesTotal();
      if(gbt < 100)
      return;
      var gbl = getBytesLoaded();
      if(gbl >= gbt)
      {
      clearInterval(id1);
      initialize();
      }
      }



      function initialize()
      {
      startingSizeX = Stage.width; // get these values before setting noScale
      startingSizeY = Stage.height;
      Stage.scaleMode = "noScale"; // prevent menus from resizing
      backdrop._width = Stage.width;
      backdrop._height = Stage.height;


      ContentoriginalX = 58;
      ContentoriginalY = 158;


      positionMenus(); // adjust menu position

      // watch for resizing. When it occurs, resize the background picture
      // to match the stage size.
      // All the other objects remain the same size but we reposition
      // the objects by the amount needed.
      listener = new Object();
      listener.onResize = function ()
      {
      // keep the background picture the same size as the stage
      backdrop._width = Stage.width;
      backdrop._height = Stage.height;
      positionMenus(); // reposition the menus as needed
      };
      Stage.addListener(listener);
      }

      function positionMenus()
      {
      // how much difference is stage size now compared to the original size?
      var diffSizeX = startingSizeX - Stage.width;
      var diffSizeY = startingSizeY - Stage.height;

      // add half the difference to the menu position
      Content._x = ContentoriginalX + (diffSizeX / 2);
      Content._y = ContentoriginalY + (diffSizeY / 2);

      }

      Any and all help is appreciated. Thanks