0 Replies Latest reply on May 22, 2006 2:38 AM by green11

    zoom and drag help

      Hi everyone

      I am making a page turning book much like this example http://www.merc-clothing.com/newspaper.asp
      Ok a lot like this example, the size of my double page spread is
      1095 by 777 and the top left position is X-550 Y-457
      I have almost completed it but the one problem is when I zoom in and drag the page around there is no script to tell it not to let the page be dragged of the screen I hope this makes sense.
      Also when you zoom back out the page doesn’t return to the position it was before
      would anyone know where and what to add to this script to stop my mc being dragged so far the next set of page are revealed underneath and so when you zoom back out it returns to its original position

      I am a complete idiot regarding actionscript so please be gentle
      Thanks for your time

      this is the script im using now to zoom in and drag

      zoom_drag_zoom(newsMC, 100);

      function zoom_drag_zoom(myMC, myScale)
      // 1st param = the MovieClip you want to allpy this functionality to.
      // 2nd param = the amount you want it scaled down by when zoomed out
      // if no amount is give it will default to 50%

      // Deak's zoom, drag, zoom. 2006
      // allows you to zoom in to an MC
      // onPress, drag MC onMouseDown
      // and zoom out onRelease

      // sets the scale to 50% if no scale is given.
      myScale = (!myScale) ? 50 : myScale ;


      //var myMC:MovieClip = newsMC;

      //initially reduce the size of the mc
      myMC._xscale = myScale;
      myMC._yscale = myScale;

      // set variables to false
      var zoomedIn:Boolean = false;
      var dragging:Boolean = false;

      // onPress is triggered as the mouse is clicked
      myMC.onPress = function()
      // checks to see if the MC is zoomed in (not zoomed).
      if (!zoomedIn) {
      // if the MC is not zoomed then increase scale to 100%
      myMC._xscale = 200;
      myMC._yscale = 200;
      // set variable to true, to be used later
      zoomedIn = true;
      dragging = true;

      // onMouseDown is also triggered as the mouse is clicked
      // N.B. even if the onMouseDown appears after the onPress it will be triggered first
      myMC.onMouseDown = function()
      // checks to see if the MC is zoomed in (is zoomed).
      if (zoomedIn) {
      // add a mouse listener
      // Mouse listener is triggered when the mouse is down and only if the MC has been zoomed in.
      var mouseListener bject = new Object();
      mouseListener.onMouseMove = function ()
      // starts the drag of the MC
      // set variable to true
      dragging = true;
      // the MC is now draggable so we can remove the lsitener.

      // onMouseUp is trigger when the mouse button is released, this will always proceed an onRelease.
      myMC.onMouseUp = function()
      // This removes the listener and stops the drag, called here so if you click the MC but do not move the mouse it will not prevoke the startDrag


      // onMouseUp is trigger when the mouse button is released
      myMC.onRelease = function()
      // condition: if MC is zoomed and you are NOT dragging the MC
      if ( (zoomedIn) && (!dragging) ) {
      // reduce scale
      myMC._xscale = myScale;
      myMC._yscale = myScale;
      // reset the variables
      zoomedIn = false;
      dragging = false;

      // this is placed here at the end of the onRelease to set the dragging variable to false.
      // if this was placed in the onMouseUp then the MC would get zoomed out as "dragging" would be false.
      dragging = false;