[FLASH 8] MC position's changing at first Zoom attempt

  • rtank
  • Newbie
  • Newbie
  • rtank
  • Posts: 6

Post 3+ Months Ago

Hi everybody.

I got an mc (named "img") on the stage. In order to zoom it, I'm using the following code:
Code: [ Select ]
///ZOOM///
myZoom = function (myDepth)
{
    if (myDepth == "deep")
    {
        myDepth = 4;
    }
    else if (myDepth == "medium")
    {
        myDepth = 8;
    }
    else if (myDepth == "light")
    {
        myDepth = 12;
    } // end else if

    img.onRelease = function()
    {
        if (k > 0)
        {
            return;
        } // end if
        zoom = true;
        dir == 1 ? (dir = -1) : (dir = 1);
        if (dir == 1)
        {
            pt = {x: img._xmouse, y: img._ymouse};
        } // end if
    };
    this.onEnterFrame = function ()
    {
        if (!zoom)
        {
            return;
        } // end if
        img._xscale = img._xscale + dir * k * 50 / myDepth;
        img._yscale = img._yscale + dir * k * 50 / myDepth;
        var pt2 = {x: pt.x, y: pt.y};
        img.localToGlobal(pt2);
        img._x = img._x - (pt2.x - pt.x);
        img._y = img._y - (pt2.y - pt.y);
        ++k;
        if (k == 8)
        {
            zoom = false;
            k = 0;
        } // end if
    };
};
myZoom("medium");
///END ZOOM///
  1. ///ZOOM///
  2. myZoom = function (myDepth)
  3. {
  4.     if (myDepth == "deep")
  5.     {
  6.         myDepth = 4;
  7.     }
  8.     else if (myDepth == "medium")
  9.     {
  10.         myDepth = 8;
  11.     }
  12.     else if (myDepth == "light")
  13.     {
  14.         myDepth = 12;
  15.     } // end else if
  16.     img.onRelease = function()
  17.     {
  18.         if (k > 0)
  19.         {
  20.             return;
  21.         } // end if
  22.         zoom = true;
  23.         dir == 1 ? (dir = -1) : (dir = 1);
  24.         if (dir == 1)
  25.         {
  26.             pt = {x: img._xmouse, y: img._ymouse};
  27.         } // end if
  28.     };
  29.     this.onEnterFrame = function ()
  30.     {
  31.         if (!zoom)
  32.         {
  33.             return;
  34.         } // end if
  35.         img._xscale = img._xscale + dir * k * 50 / myDepth;
  36.         img._yscale = img._yscale + dir * k * 50 / myDepth;
  37.         var pt2 = {x: pt.x, y: pt.y};
  38.         img.localToGlobal(pt2);
  39.         img._x = img._x - (pt2.x - pt.x);
  40.         img._y = img._y - (pt2.y - pt.y);
  41.         ++k;
  42.         if (k == 8)
  43.         {
  44.             zoom = false;
  45.             k = 0;
  46.         } // end if
  47.     };
  48. };
  49. myZoom("medium");
  50. ///END ZOOM///


Problem is, when I release on the mc it changes its original position to X=0,0 Y=0,0 as you can see HERE.
Obviously, I want it to keep its starting position on the stage and zooming IN and OUT from there.

Thanks to anyone who may help.
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • rtank
  • Newbie
  • Newbie
  • rtank
  • Posts: 6

Post 3+ Months Ago

Problem solved!

it was due to the mc's registration point.

Thanks anyway

Post Information

  • Total Posts in this topic: 2 posts
  • Users browsing this forum: No registered users and 17 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.