Difference between revisions of "SWF e-book.as"
m |
m |
||
| Line 60: | Line 60: | ||
// Draw fold | // Draw fold | ||
| − | beginFill( | + | beginFill(0xff00,100); |
moveTo(ox+Px,oy); | moveTo(ox+Px,oy); | ||
lineTo(ox+x,oy+y); | lineTo(ox+x,oy+y); | ||
Revision as of 02:59, 22 November 2006
// Code for [[SWF e-book]] margin = 20;
// bg defines the hitArea which raises mouse events // - this is used so that the book symbol doesn't need to have a filled background createEmptyMovieClip("bg",1); bg._visible = false; bg.beginFill(0,100); bg.moveTo(margin,margin); bg.lineTo(width-margin,margin); bg.lineTo(width-margin,height-margin); bg.lineTo(margin,height-margin); bg.lineTo(margin,margin); bg.endFill();
// This initialises the book page lines createEmptyMovieClip("book",2); book.hitArea = bg;
// Draws page lines and folde line based on mouse position book.onMouseMove = function() {
w = (width-margin*2)/2; h = height-margin*2; ox = margin+w; oy = margin;
// Get mouse coords relative to book middle x = _xmouse-margin-w; y = _ymouse-margin;
// 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; Qy = Zy+(w-Zx)*dx/dy;
// Draw page clear(); lineStyle(3,0); moveTo(ox-w,oy); lineTo(ox+Px,oy); lineTo(ox+w,oy+Qy); lineTo(ox+w,oy+h); lineTo(ox-w,oy+h); lineTo(ox-w,oy); moveTo(ox,oy); lineTo(ox,oy+h);
// Draw fold beginFill(0xff00,100); moveTo(ox+Px,oy); lineTo(ox+x,oy+y); lineTo(ox+w,oy+Qy); endFill();
};



