|
|
Line 1: |
Line 1: |
− | margin = 50;
| + | a = Math.atan2(y,x); |
− | w = (Stage.width-margin*2)/2;
| + | r = Math.sqrt(x*x+y*y); |
− | h = Stage.height-margin*2;
| + | if (r>w) r=w; |
− | i = 0;
| + | x = Math.cos(a)*r; |
− | speed = 8;
| + | y = Math.sin(a)*r; |
| | | |
− | createEmptyMovieClip("book",1);
| + | // Calculate point Z and dy,dx of line C |
| + | dx = w-x; |
| + | dy = y; |
| + | Zx = x+dx/2; |
| + | Zy = y-dy/2; |
| | | |
− | createEmptyMovieClip("right_next",2);
| + | // Calculate line D |
| + | Px = Zx-Zy*dy/dx; |
| + | Py = 0; |
| + | Qx = w; |
| | | |
− | right_next.createTextField('content',0,0,0,50,50);
| + | if (dy*dy<1) { a = 0; Qx = x; Qy = Ry = h; Rx = (x+w)/2; } |
− | with (right_next.content) {
| + | else { |
− | autosize = 'left';
| + | Qy = Zy+(w-Zx)*dx/dy; |
− | selectable = false;
| + | if (Qy>h || Qy<0) { |
− | _quality = 'BEST';
| + | a = Math.atan2(Qy-y,Qx-x); |
− | border = false;
| + | if (Qy<0) a += Math.PI; |
− | multiline = true;
| + | Qx = x+Math.cos(a)*h; |
− | wordWrap = false;
| + | Qy = y+Math.sin(a)*h; |
− | html = true;
| + | Rx = Qx+(Qy-h)/(y-Py)*(Px-x); |
− | embedFonts = true;
| + | Ry = h; |
− | htmlText = '<font color="#ff0000">Hello right world!</font>';
| + | } |
− | } | + | else { Rx = Qx; Ry = Qy; } |
− | | + | if (Qy==0) Rx = w-Qx; |
− | function topRight(i,j) {
| + | if (Rx<0) return; |
− | ox = margin+w;
| + | } |
− | oy = margin;
| |
− | if (j == 1) {
| |
− | | |
− | x= _xmouse-ox;
| |
− | y= _ymouse-oy;trace(y);
| |
− |
| |
− | if (i) {
| |
− | x = i-ox;
| |
− | y = 40;
| |
− | if (x <= -253) y = 0;
| |
− | }
| |
− | | |
− | calculate();
| |
− | // Draw page
| |
− | clear();
| |
− | lineStyle(1,0);
| |
− | moveTo(ox,oy);
| |
− | lineTo(ox,oy+h);
| |
− | lineTo(ox+w,oy+h);
| |
− | lineTo(ox+w,oy);
| |
− | lineTo(ox,oy);
| |
− | moveTo(ox-w,oy);
| |
− | lineTo(ox+Px,oy+Py);
| |
− | lineTo(ox+Rx,oy+Ry);
| |
− | lineTo(ox+Rx,oy+h);
| |
− | lineTo(ox-w,oy+h);
| |
− | lineTo(ox-w,oy);
| |
− | // Draw fold
| |
− | beginFill(0xeeeeee,100);
| |
− | moveTo(ox+x,oy+y);
| |
− | lineTo(ox+Px,oy);
| |
− | lineTo(ox+Rx,oy+Ry);
| |
− | lineTo(ox+Qx,oy+Qy);
| |
− | lineTo(ox+x,oy+y);
| |
− | endFill();
| |
− | // orient right_next page
| |
− | _root.right_next._x = x;
| |
− | _root.right_next._y = y;
| |
− | _root.right_next._rotation = a*57.29578;
| |
− | }
| |
− |
| |
− | if (j == -1) {
| |
− | | |
− | x = ox-_xmouse;
| |
− | y = _ymouse-oy;
| |
− |
| |
− | if (i) {
| |
− | x = ox-i;
| |
− | y = 40;
| |
− | if (x < -253) y = 0;
| |
− | }
| |
− |
| |
− | calculate ();
| |
− | // Draw page
| |
− | clear();
| |
− | lineStyle(1,0);
| |
− | moveTo(ox,oy);
| |
− | lineTo(ox,oy+h);
| |
− | lineTo(ox-w,oy+h);
| |
− | lineTo(ox-w,oy);
| |
− | lineTo(ox,oy);
| |
− | moveTo(ox+w,oy);
| |
− | lineTo(ox-Px,oy+Py);
| |
− | lineTo(ox-Rx,oy+Ry);
| |
− | lineTo(ox-Rx,oy+h);
| |
− | lineTo(ox+w,oy+h);
| |
− | lineTo(ox+w,oy);
| |
− | // Draw fold
| |
− | beginFill(0xdddddd,100);
| |
− | moveTo(ox-x,oy+y);
| |
− | lineTo(ox-Px,oy+Py);
| |
− | lineTo(ox-Rx,oy+Ry);
| |
− | lineTo(ox-Qx,oy+Qy);
| |
− | lineTo(ox-x,oy+y);
| |
− | endFill();
| |
− | // orient right_next page
| |
− | _root.left_next._x = ox-x;
| |
− | _root.left_next._y = oy+y;
| |
− | _root.left_next._rotation = -a*57.29578;
| |
− | }
| |
− |
| |
− | function calculate() {
| |
− | // constrain mouse to radius W
| |
− | a = Math.atan2(y,x);
| |
− | r = Math.sqrt(x*x+y*y);
| |
− | if (r>w) r=w;
| |
− | x = Math.cos(a)*r;
| |
− | y = Math.sin(a)*r;
| |
− | // Calculate point Z and dy,dx of line C
| |
− | dx = w-x;
| |
− | dy = y;
| |
− | Zx = x+dx/2;
| |
− | Zy = y-dy/2;
| |
− | // Calculate line D
| |
− | Px = Zx-Zy*dy/dx;
| |
− | Py = 0;
| |
− | Qx = w;
| |
− |
| |
− | if (dy*dy<1) { a = 0; Qx = x; Qy = Ry = h; Rx = (x+w)/2; }
| |
− | else {
| |
− | Qy = Zy+(w-Zx)*dx/dy;
| |
− | if (Qy>h || Qy<0) {
| |
− | a = Math.atan2(Qy-y,Qx-x);
| |
− | if (Qy<0) a += Math.PI;
| |
− | Qx = x+Math.cos(a)*h;
| |
− | Qy = y+Math.sin(a)*h;
| |
− | Rx = Qx+(Qy-h)/(y-Py)*(Px-x);
| |
− | Ry = h;
| |
− | }
| |
− | else { Rx = Qx; Ry = Qy; }
| |
− | if (Qy==0) Rx = w-Qx;
| |
− | if (Rx<0) return;
| |
− | }
| |
− | }
| |
− | }
| |
− | | |
− | function reduce() {
| |
− | if (i) topRight (i-=speed,j,k);
| |
− | }
| |
− |
| |
− | var coords = new Object();
| |
− | coords.u = 0;
| |
− | coords.v = 0;
| |
− | j = coords.u;
| |
− | k = coords.v;
| |
− | | |
− | var mouseListener = new Object();
| |
− | | |
− | mouseListener.onMouseMove = function(){
| |
− | if (_xmouse >=305) {
| |
− | coords.u = 1;
| |
− | }
| |
− | if (_xmouse < 305) {
| |
− | coords.u = -1;
| |
− | }
| |
− | j = coords.u;
| |
− | k = coords.v;
| |
− | topRight(0,j,k);
| |
− | };
| |
− | | |
− | mouseListener.onMouseUp = function(){
| |
− | if (_xmouse >=305) {
| |
− | coords.u = 1;
| |
− | i=559;
| |
− | }
| |
− | if (_xmouse < 305) {
| |
− | coords.u = -1;
| |
− | i=50;
| |
− | speed = -speed;
| |
− | }
| |
− | if (_ymouse <= 150) coords.v = -1;
| |
− | if (_ymouse > 150 && _ymouse <= 250) coords.v = 0;
| |
− | if (_ymouse > 250) coords.v = 1;
| |
− | }; | |
− | | |
− | Mouse.addListener(mouseListener);
| |
a = Math.atan2(y,x);
r = Math.sqrt(x*x+y*y);
if (r>w) r=w;
x = Math.cos(a)*r;
y = Math.sin(a)*r;
// Calculate point Z and dy,dx of line C
dx = w-x;
dy = y;
Zx = x+dx/2;
Zy = y-dy/2;
// Calculate line D
Px = Zx-Zy*dy/dx;
Py = 0;
Qx = w;
if (dy*dy<1) { a = 0; Qx = x; Qy = Ry = h; Rx = (x+w)/2; }
else {
Qy = Zy+(w-Zx)*dx/dy;
if (Qy>h || Qy<0) {
a = Math.atan2(Qy-y,Qx-x);
if (Qy<0) a += Math.PI;
Qx = x+Math.cos(a)*h;
Qy = y+Math.sin(a)*h;
Rx = Qx+(Qy-h)/(y-Py)*(Px-x);
Ry = h;
}
else { Rx = Qx; Ry = Qy; }
if (Qy==0) Rx = w-Qx;
if (Rx<0) return;
}