что то всем в последнее время всем эти книжки подовай)) я так и не понял как оно работает, скрипт сильно замутный какойто:
Код:
function reset()
{
* *for (i = 0; i < 4; i++)
* *{
* * * *setPage(i, pw, ph);
* *} // end of for
* *pages.pgrad._visible = pages.mask._visible = pages.flip._visible = false;
* *pages.flip.p3mask._width = pages.pgmask._width = pw * 2;
* *pages.flip.p3mask._height = pages.pgmask._height = ph;
* *pages.flip.fmask.page.pf._width = pw;
* *pages.flip.fmask.page.pf._height = ph;
} // End of the function
function setPage(i, w, h)
{
* *var item = eval("pages.p" + (i + 1));
* *if (i == 1 || i == 2)
* *{
* * * *item = eval("pages.flip.p" + (i + 1));
* *} // end if
* *item.page._x = -w;
* *item._x = i % 2 == 0 ? (0) : (w);
} // End of the function
function hittest()
{
* *var x = pages._xmouse;
* *var y = pages._ymouse;
* *var pmh = ph / 2;
* *if (y <= pmh && y >= -pmh && x <= pw && x >= -pw)
* *{
* * * *var r = Math.sqrt(x * x + y * y);
* * * *var a = Math.asin(y / r);
* * * *var y = Math.tan(a) * pw;
* * * *if (y > 0 && y > ph / 2)
* * * *{
* * * * * *y = ph / 2;
* * * *} // end if
* * * *if (y < 0 && y < -ph / 2)
* * * *{
* * * * * *y = -ph / 2;
* * * *} // end if
* * * *oy = sy = y;
* * * *r0 = Math.sqrt((sy + ph / 2) * (sy + ph / 2) + pw * pw);
* * * *r1 = Math.sqrt((ph / 2 - sy) * (ph / 2 - sy) + pw * pw);
* * * *pageN = pages.flip.p2.page;
* * * *pageO = pages.flip.p3;
* * * *offs = -pw;
* * * *pages.flip.fmask._x = pw;
* * * *if (x < 0 && page > 0)
* * * *{
* * * * * *pages.flip.p3._x = 0;
* * * * * *setPages(page - 2, page - 1, page, page + 1);
* * * * * *return(-1);
* * * *} // end if
* * * *if (x > 0 && page < maxpage)
* * * *{
* * * * * *pages.flip.p3._x = pw;
* * * * * *setPages(page, page + 2, page + 1, page + 3);
* * * * * *return(1);
* * * *} // end if
* *}
* *else
* *{
* * * *return(0);
* *} // end if
} // End of the function
function calc(x, y)
{
* *var _l1 = x;
* *var _l2 = y;
* *var rr0 = Math.sqrt((_l2 + ph / 2) * (_l2 + ph / 2) + _l1 * _l1);
* *var rr1 = Math.sqrt((ph / 2 - _l2) * (ph / 2 - _l2) + _l1 * _l1);
* *if (rr0 > r0 || rr1 > r1)
* *{
* * * *if (_l2 < sy)
* * * *{
* * * * * *var a = Math.asin((ph / 2 - _l2) / rr1);
* * * * * *_l2 = ph / 2 - Math.sin(a) * r1;
* * * * * *_l1 = _l1 < 0 ? (-Math.cos(a) * r1) : (Math.cos(a) * r1);
* * * * * *if (_l2 > sy)
* * * * * *{
* * * * * * * *if (sx * _l1 > 0)
* * * * * * * *{
* * * * * * * * * *_l2 = sy;
* * * * * * * * * *_l1 = sx;
* * * * * * * *}
* * * * * * * *else
* * * * * * * *{
* * * * * * * * * *_l2 = sy;
* * * * * * * * * *_l1 = -sx;
* * * * * * * *} // end if
* * * * * *} // end if
* * * *}
* * * *else
* * * *{
* * * * * *var a = Math.asin((_l2 + ph / 2) / rr0);
* * * * * *_l2 = Math.sin(a) * r0 - ph / 2;
* * * * * *_l1 = _l1 < 0 ? (-Math.cos(a) * r0) : (Math.cos(a) * r0);
* * * * * *if (_l2 < sy)
* * * * * *{
* * * * * * * *if (sx * _l1 > 0)
* * * * * * * *{
* * * * * * * * * *_l2 = sy;
* * * * * * * * * *_l1 = sx;
* * * * * * * *}
* * * * * * * *else
* * * * * * * *{
* * * * * * * * * *_l2 = sy;
* * * * * * * * * *_l1 = -sx;
* * * * * * * *} // end if
* * * * * *} // end if
* * * *} // end if
* *} // end if
* *if (sx < 0 && _l1 - sx < 10 || sx > 0 && sx - _l1 < 10)
* *{
* * * *if (sx < 0)
* * * *{
* * * * * *_l1 = -pw + 10;
* * * *} // end if
* * * *if (sx > 0)
* * * *{
* * * * * *_l1 = pw - 10;
* * * *} // end if
* *} // end if
* *pages.pgrad._visible = pages.flip._visible = true;
* *var vx = _l1 - sx;
* *var vy = _l2 - sy;
* *var a1 = vy / vx;
* *var a2 = -vy / vx;
* *cx = sx + vx / 2;
* *cy = sy + vy / 2;
* *var _l3 = Math.sqrt((sx - _l1) * (sx - _l1) + (sy - _l2) * (sy - _l2));
* *var a = Math.asin((sy - _l2) / _l3);
* *if (sx < 0)
* *{
* * * *a = -a;
* *} // end if
* *ad = a * 57.295780;
* *pageN._rotation = ad * 2;
* *_l3 = Math.sqrt((sx - _l1) * (sx - _l1) + (sy - _l2) * (sy - _l2));
* *rl = pw * 2;
* *if (sx > 0)
* *{
* * * *pages.mask._xscale = 100;
* * * *nx = cx - Math.tan(a) * (ph / 2 - cy);
* * * *ny = ph / 2;
* * * *if (nx > pw)
* * * *{
* * * * * *nx = pw;
* * * * * *ny = cy + Math.tan(1.570796 + a) * (pw - cx);
* * * *} // end if
* * * *pageN.pf._x = -(pw - nx);
* * * *pages.flip.fgrad._xscale = _l3 / rl / 2 * pw;
* * * *pages.pgrad._xscale = -_l3 / rl / 2 * pw;
* * * *pages.flip.p3shadow._xscale = _l3 / rl / 2 * pw;
* *}
* *else
* *{
* * * *pages.mask._xscale = -100;
* * * *nx = cx - Math.tan(a) * (ph / 2 - cy);
* * * *ny = ph / 2;
* * * *if (nx < -pw)
* * * *{
* * * * * *nx = -pw;
* * * * * *ny = cy + Math.tan(1.570796 + a) * (-pw - cx);
* * * *} // end if
* * * *pageN.pf._x = -(pw - (pw + nx));
* * * *pages.flip.fgrad._xscale = -_l3 / rl / 2 * pw;
* * * *pages.pgrad._xscale = _l3 / rl / 2 * pw;
* * * *pages.flip.p3shadow._xscale = -_l3 / rl / 2 * pw;
* *} // end if
* *pages.mask._x = cx;
* *pages.mask._y = cy;
* *pages.mask._rotation = ad;
* *pageN.pf._y = -ny;
* *pageN._x = nx + offs;
* *pageN._y = ny;
* *pages.flip.fgrad._x = cx;
* *pages.flip.fgrad._y = cy;
* *pages.flip.fgrad._rotation = ad;
* *pages.flip.fgrad._alpha = _l3 > rl - 50 ? (100 - (_l3 - (rl - 50)) * 2) : (100);
* *pages.flip.p3shadow._x = cx;
* *pages.flip.p3shadow._y = cy;
* *pages.flip.p3shadow._rotation = ad;
* *pages.flip.p3shadow._alpha = _l3 > rl - 50 ? (100 - (_l3 - (rl - 50)) * 2) : (100);
* *pages.pgrad._x = cx;
* *pages.pgrad._y = cy;
* *pages.pgrad._rotation = ad + 180;
* *pages.pgrad._alpha = _l3 > rl - 100 ? (100 - (_l3 - (rl - 100))) : (100);
* *pages.flip.fmask.page._x = pageN._x;
* *pages.flip.fmask.page._y = pageN._y;
* *pages.flip.fmask.page.pf._x = pageN.pf._x;
* *pages.flip.fmask.page.pf._y = pageN.pf._y;
* *pages.flip.fmask.page._rotation = pageN._rotation;
} // End of the function
function setPages(p1, p2, p3, p4)
{
* *var _l1 = p4;
* *var _l2 = p3;
* *var _l3 = p2;
* *if (p1 < 0)
* *{
* * * *p1 = 0;
* *} // end if
* *if (_l3 < 0)
* *{
* * * *_l3 = 0;
* *} // end if
* *if (_l2 < 0)
* *{
* * * *_l2 = 0;
* *} // end if
* *if (_l1 < 0)
* *{
* * * *_l1 = 0;
* *} // end if
* *pages.p1.page.pf.ph.attachMovie("page" + p1, "pic", 0);
* *pages.flip.p2.page.pf.ph.attachMovie("page" + _l3, "pic", 0);
* *pages.flip.p3.page.pf.ph.attachMovie("page" + _l2, "pic", 0);
* *pages.p4.page.pf.ph.attachMovie("page" + _l1, "pic", 0);
} // End of the function
function resetPages()
{
* *setPages(page, 0, 0, page + 1);
} // End of the function
pw = 381;
ph = 502;
page = 2;
maxpage = 20;
resetPages();
reset();
flip = false;
flipOff = false;
flipOK = false;
sx = sy = 0;
mx = pages._xmouse;
my = pages._ymouse;
mousecontroll = new Object();
mousecontroll.onMouseDown = function ()
{
* *clickCount++;
* *if (clickCount > 1)
* *{
* * * *if (flipOff)
* * * *{
* * * * * *flipOff = false;
* * * * * *flip = true;
* * * *}
* * * *else
* * * *{
* * * * * *var _l1 = hittest();
* * * * * *if (_l1)
* * * * * *{
* * * * * * * *anim._visible = false;
* * * * * * * *flip = true;
* * * * * * * *flipOff = false;
* * * * * * * *ox = sx = _l1 * pw;
* * * * * * * *pages.flip.setMask(pages.mask);
* * * * * *} // end if
* * * *} // end if
* *} // end if
};
mousecontroll.onMouseUp = function ()
{
* *if (flip)
* *{
* * * *flipOK = false;
* * * *if (sx < 0 && pages._xmouse > 0)
* * * *{
* * * * * *flipOK = true;
* * * *} // end if
* * * *if (sx > 0 && pages._xmouse < 0)
* * * *{
* * * * * *flipOK = true;
* * * *} // end if
* * * *flipOff = true;
* * * *flip = false;
* *} // end if
};
Mouse.addListener(mousecontroll);
onEnterFrame = function ()
{
* *var _l1 = pages._xmouse;
* *var _l2 = pages._ymouse;
* *if (flip)
* *{
* * * *_l1 = ox = ox + (_l1 - ox) / 5;
* * * *_l2 = oy = oy + (_l2 - oy) / 5;
* * * *calc(_l1, _l2);
* *} // end if
* *if (flipOff)
* *{
* * * *if (flipOK)
* * * *{
* * * * * *_l1 = ox = ox + (-sx - ox) / 3;
* * * * * *_l2 = oy = oy + (sy - oy) / 3;
* * * * * *calc(_l1, _l2);
* * * * * *if (_l1 / -sx > 0.990000)
* * * * * *{
* * * * * * * *flip = false;
* * * * * * * *flipOK = flipOff = false;
* * * * * * * *pages.pgrad._visible = pages.flip._visible = false;
* * * * * * * *page = page + (sx < 0 ? (-2) : (2));
* * * * * * * *setPages(page, 0, 0, page + 1);
* * * * * *} // end if
* * * *}
* * * *else
* * * *{
* * * * * *_l1 = ox = ox + (sx - ox) / 3;
* * * * * *_l2 = oy = oy + (sy - oy) / 3;
* * * * * *calc(_l1, _l2);
* * * * * *if (_l1 / sx > 0.990000)
* * * * * *{
* * * * * * * *flip = false;
* * * * * * * *flipOff = false;
* * * * * * * *pages.pgrad._visible = pages.flip._visible = false;
* * * * * * * *setPages(page, 0, 0, page + 1);
* * * * * *} // end if
* * * *} // end if
* *} // end if
};
могу исходник странички [Только зарегистрированные пользователи могут видеть ссылки. ] выслать если надо)