Difference between revisions of "E-book comb.as"

From Organic Design wiki
m
m
Line 1: Line 1:
// Compile and run in [[[[Bookclick]]]]
+
// Compile and run in [[[[E-book_comb]]]]
 
margin = 50;
 
margin = 50;
 
i = 0;
 
i = 0;
Line 8: Line 8:
 
createEmptyMovieClip("right_next",2);
 
createEmptyMovieClip("right_next",2);
 
createEmptyMovieClip("pg1",3);
 
createEmptyMovieClip("pg1",3);
createEmptyMovieClip("pg2",4);
 
createEmptyMovieClip("pg3",5);
 
createEmptyMovieClip("pg4",6);
 
 
//create following page
 
//create following page
 
pg1.createEmptyMovieClip("RightFill",1);
 
pg1.createEmptyMovieClip("RightFill",1);
right_next.createTextField('content',0,0,0,100,50);
+
right_next.createTextField('content',0,0,0,100,50);
with (right_next.content) {
+
with (right_next.content) {
autosize = 'left';
+
autosize = 'left';
selectable = false;
+
selectable = false;
_quality = 'BEST';
+
_quality = 'BEST';
border = false;
+
border = false;
multiline = true;
+
multiline = true;
wordWrap = false;
+
wordWrap = false;
html = true;
+
html = true;
//  embedFonts = true;
+
//  embedFonts = true;
htmlText = '<font color="#ff0000">Hello right world!</font>';
+
htmlText = '<font color="#ff0000">Hello right world!</font>';
}
+
}
//pg1.loadMovie("1.jpg");
 
 
 
 
// main function takes three parameters (an iterator and x and y mouse)
 
// main function takes three parameters (an iterator and x and y mouse)
 
function pageTurn(i,Tx,Ty) {
 
function pageTurn(i,Tx,Ty) {
Line 115: Line 110:
 
lineTo (ox+Px*Tx,oy);
 
lineTo (ox+Px*Tx,oy);
 
lineTo(ox+Rx*Tx,oy-Ry*Ty);
 
lineTo(ox+Rx*Tx,oy-Ry*Ty);
 
 
lineTo (ox+w*Tx,oy-h*Ty);
 
lineTo (ox+w*Tx,oy-h*Ty);
 
lineTo (ox+w*Tx,oy);
 
lineTo (ox+w*Tx,oy);
 
endFill();
 
endFill();
//this.loadMovie("1.jpg");
 
 
 
}
 
}
+
// orient next page
// orient right_next page
 
 
 
 
_root.right_next._x = ox+x;
 
_root.right_next._x = ox+x;
 
_root.right_next._y = oy+y;
 
_root.right_next._y = oy+y;
//_root.right_next._x = ox+Rx*Tx;
+
//_root.right_next._rotation = a*57.29578;
//_root.right_next._y = oy-Ry*Ty;
 
 
//pg1._x = ox + x;
 
//pg1._y = oy + y;
 
//pg1._rotation = a*57.29578;
 
 
 
 +
}
  
 +
var mclListener = new Object();
  
}
 
var mclListener = new Object();
 
 
mclListener.onLoadInit = function(target_mc) {
 
mclListener.onLoadInit = function(target_mc) {
 
     target_mc.setMask(pg1.RightFill);
 
     target_mc.setMask(pg1.RightFill);
//pg1.RightFill._x = "50";
 
//pg1.RightFill._y = "50";
 
 
}
 
}
//System.security.allowDomain("http://www.jack.co.nz");
+
 
 +
System.security.allowDomain("http://www.jack.co.nz");
 +
 
 
var my_mcl = new MovieClipLoader();
 
var my_mcl = new MovieClipLoader();
 
my_mcl.addListener(mclListener);
 
my_mcl.addListener(mclListener);
Line 154: Line 139:
 
// for multiple parameters in main function
 
// for multiple parameters in main function
 
var coords = new Object();
 
var coords = new Object();
//Tx = coords.j = 0;
+
 
//Ty = coords.k = 0;
 
 
var mouseListener = new Object();
 
var mouseListener = new Object();
  
Line 178: Line 162:
 
  Tx = coords.j = -1;
 
  Tx = coords.j = -1;
 
  }
 
  }
//if (_ymouse <= 150) coords.bar = -1;
 
//if (_ymouse > 150 && _ymouse <= 250) coords.bar = 0;
 
//if (_ymouse > 250) coords.bar = 1;
 
 
if (_ymouse <= 200) Ty = coords.k = -1;
 
if (_ymouse <= 200) Ty = coords.k = -1;
 
if (_ymouse > 200) Ty = coords.k = 1;
 
if (_ymouse > 200) Ty = coords.k = 1;

Revision as of 11:44, 3 January 2007

// Compile and run in [[E-book_comb]] margin = 50; i = 0; speed = 8; //main clip createEmptyMovieClip("book",10);

createEmptyMovieClip("right_next",2); createEmptyMovieClip("pg1",3); //create following page pg1.createEmptyMovieClip("RightFill",1); right_next.createTextField('content',0,0,0,100,50); with (right_next.content) { autosize = 'left'; selectable = false; _quality = 'BEST'; border = false; multiline = true; wordWrap = false; html = true; // embedFonts = true; htmlText = 'Hello right world!'; } // main function takes three parameters (an iterator and x and y mouse) function pageTurn(i,Tx,Ty) {

w = (Stage.width-margin*2)/2; h = Stage.height-margin*2; ox = margin+w; oy = margin; //mousemove if (!i) { x= _xmouse-ox; y= _ymouse-oy; x=x*Tx; if (Ty == 1) { oy = margin + h; y= oy-_ymouse; } } //onclick if (i) { v = i; if (Tx == -1) { v = 609-i; } //x = 40; x = (v-ox)*Tx; y = 50; if (Ty == 1) { oy = margin + h; } } //calculate fold 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; } //draw lines clear(); lineStyle(1,0); moveTo(ox,oy); lineTo(ox,oy-h*Ty); moveTo(ox-w*Tx,oy); lineTo(ox+Px*Tx,oy-Py*Ty); lineTo(ox+Rx*Tx,oy-Ry*Ty); lineTo(ox+Rx*Tx,oy-h*Ty); lineTo(ox-w*Tx,oy-h*Ty); lineTo(ox-w*Tx,oy); //draw fold beginFill(0xcccccc,100); moveTo(ox+x*Tx,oy-y*Ty); lineTo(ox+Px*Tx,oy-Py*Ty); lineTo(ox+Rx*Tx,oy-Ry*Ty); lineTo(ox+Qx*Tx,oy-Qy*Ty); lineTo(ox+x*Tx,oy-y*Ty); endFill();

with (pg1.RightFill) { clear(); lineStyle(1,0); beginFill(0xffffff,100); moveTo (ox+w*Tx,oy);; lineTo (ox+Px*Tx,oy); lineTo(ox+Rx*Tx,oy-Ry*Ty); lineTo (ox+w*Tx,oy-h*Ty); lineTo (ox+w*Tx,oy); endFill(); } // orient next page _root.right_next._x = ox+x; _root.right_next._y = oy+y; //_root.right_next._rotation = a*57.29578;

}

var mclListener = new Object();

mclListener.onLoadInit = function(target_mc) {

   target_mc.setMask(pg1.RightFill);

}

System.security.allowDomain("http://www.jack.co.nz");

var my_mcl = new MovieClipLoader(); my_mcl.addListener(mclListener); my_mcl.loadClip("http://www.jack.co.nz/six.jpg", book);

//iterate over frames function reduce() {

   if (i) pageTurn(i-=speed,Tx,Ty);

} // for multiple parameters in main function var coords = new Object();

var mouseListener = new Object();

mouseListener.onMouseMove = function(){ if (_xmouse >=305) { Tx = coords.j = 1; } if (_xmouse < 305) { Tx = coords.j = -1; } if (_ymouse <= 200) Ty = coords.k = -1; if (_ymouse > 200) Ty = coords.k = 1;

pageTurn(0,Tx,Ty); };

mouseListener.onMouseDown = function(){

	if (_xmouse >=305) {

Tx = coords.j = 1; }

  	if (_xmouse < 305) {

Tx = coords.j = -1; } if (_ymouse <= 200) Ty = coords.k = -1; if (_ymouse > 200) Ty = coords.k = 1; };

mouseListener.onMouseUp = function(){

	i=600;

};

Mouse.addListener(mouseListener);