Difference between revisions of "E-book comb.as"
m |
m |
||
Line 4: | Line 4: | ||
speed = 8; | speed = 8; | ||
//main clip | //main clip | ||
− | createEmptyMovieClip("book", | + | createEmptyMovieClip("book",10); |
createEmptyMovieClip("right_next",2); | createEmptyMovieClip("right_next",2); | ||
Line 12: | Line 12: | ||
createEmptyMovieClip("pg4",6); | createEmptyMovieClip("pg4",6); | ||
//create following page | //create following page | ||
− | right_next.createTextField('content',0,0,0, | + | pg1.createEmptyMovieClip("RightFill",1); |
+ | right_next.createTextField('content',0,0,0,100,50); | ||
with (right_next.content) { | with (right_next.content) { | ||
autosize = 'left'; | autosize = 'left'; | ||
Line 21: | Line 22: | ||
wordWrap = false; | wordWrap = false; | ||
html = true; | html = true; | ||
− | + | // embedFonts = true; | |
htmlText = '<font color="#ff0000">Hello right world!</font>'; | htmlText = '<font color="#ff0000">Hello right world!</font>'; | ||
} | } | ||
− | pg1.loadMovie(" | + | //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) | ||
Line 49: | Line 50: | ||
v = 609-i; | v = 609-i; | ||
} | } | ||
+ | //x = 40; | ||
x = (v-ox)*Tx; | x = (v-ox)*Tx; | ||
y = 50; | y = 50; | ||
Line 70: | Line 72: | ||
Py = 0; | Py = 0; | ||
Qx = w; | Qx = w; | ||
− | + | ||
if (dy*dy<1) { a = 0; Qx = x; Qy = Ry = h; Rx = (x+w)/2; } | if (dy*dy<1) { a = 0; Qx = x; Qy = Ry = h; Rx = (x+w)/2; } | ||
else { | else { | ||
Line 88: | Line 90: | ||
//draw lines | //draw lines | ||
clear(); | clear(); | ||
− | lineStyle( | + | lineStyle(1,0); |
moveTo(ox,oy); | moveTo(ox,oy); | ||
lineTo(ox,oy-h*Ty); | lineTo(ox,oy-h*Ty); | ||
Line 98: | Line 100: | ||
lineTo(ox-w*Tx,oy); | lineTo(ox-w*Tx,oy); | ||
//draw fold | //draw fold | ||
− | beginFill( | + | beginFill(0xcccccc,100); |
moveTo(ox+x*Tx,oy-y*Ty); | moveTo(ox+x*Tx,oy-y*Ty); | ||
lineTo(ox+Px*Tx,oy-Py*Ty); | lineTo(ox+Px*Tx,oy-Py*Ty); | ||
Line 105: | Line 107: | ||
lineTo(ox+x*Tx,oy-y*Ty); | lineTo(ox+x*Tx,oy-y*Ty); | ||
endFill(); | 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(); | ||
+ | //this.loadMovie("1.jpg"); | ||
+ | } | ||
+ | |||
// orient right_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; | ||
− | pg1._x = ox + x; | + | //_root.right_next._x = ox+Rx*Tx; |
− | pg1._y = oy + y; | + | //_root.right_next._y = oy-Ry*Ty; |
− | pg1._rotation = a*57.29578; | + | |
+ | //pg1._x = ox + x; | ||
+ | //pg1._y = oy + y; | ||
+ | //pg1._rotation = a*57.29578; | ||
+ | System.security.allowDomain("http://www.jack.co.nz"); | ||
+ | |||
+ | |||
+ | } | ||
+ | var mclListener = new Object(); | ||
+ | mclListener.onLoadInit = function(target_mc) { | ||
+ | target_mc.setMask(pg1.RightFill); | ||
+ | //pg1.RightFill._x = "50"; | ||
+ | //pg1.RightFill._y = "50"; | ||
} | } | ||
+ | var my_mcl = new MovieClipLoader(); | ||
+ | my_mcl.addListener(mclListener); | ||
+ | my_mcl.loadClip("http://www.jack.co.nz/six.jpg", book); | ||
//iterate over frames | //iterate over frames | ||
Line 121: | Line 153: | ||
// 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 148: | Line 181: | ||
//if (_ymouse > 250) coords.bar = 1; | //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; |
}; | }; | ||
mouseListener.onMouseUp = function(){ | mouseListener.onMouseUp = function(){ | ||
− | i= | + | i=600; |
}; | }; | ||
Mouse.addListener(mouseListener); | Mouse.addListener(mouseListener); |
Revision as of 11:24, 3 January 2007
// Compile and run in [[Bookclick]] margin = 50; i = 0; speed = 8; //main clip createEmptyMovieClip("book",10);
createEmptyMovieClip("right_next",2); createEmptyMovieClip("pg1",3); createEmptyMovieClip("pg2",4); createEmptyMovieClip("pg3",5); createEmptyMovieClip("pg4",6); //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!'; } //pg1.loadMovie("1.jpg");
// 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(); //this.loadMovie("1.jpg");
}
// orient right_next page
_root.right_next._x = ox+x; _root.right_next._y = oy+y; //_root.right_next._x = ox+Rx*Tx; //_root.right_next._y = oy-Ry*Ty;
//pg1._x = ox + x; //pg1._y = oy + y; //pg1._rotation = a*57.29578; System.security.allowDomain("http://www.jack.co.nz");
}
var mclListener = new Object();
mclListener.onLoadInit = function(target_mc) {
target_mc.setMask(pg1.RightFill);
//pg1.RightFill._x = "50"; //pg1.RightFill._y = "50"; } 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(); //Tx = coords.j = 0; //Ty = coords.k = 0; 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 <= 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; };
mouseListener.onMouseUp = function(){
i=600;
};
Mouse.addListener(mouseListener);