Antoniosp 2 Denunciar post Postado Janeiro 31, 2007 E aí darkogan, É só seguir a dica do arquivo: 47. hcover = true; //hard cover on/offAí é só trocar pra false. :) Compartilhar este post Link para o post Compartilhar em outros sites
darkogan 0 Denunciar post Postado Fevereiro 1, 2007 Aew Antonio ....brigado cara adianto muito o meu lado .... eu tava tao preocupado com a programação toda que nao percebi esse detalhe ....Tks Compartilhar este post Link para o post Compartilhar em outros sites
João A. Zonta 0 Denunciar post Postado Fevereiro 6, 2007 Já vi essa pergunta 2 vezes no fórum e ainda não vi a resposta .. então ai vai.Quando você adiciona mais páginas no PageFlip2 e a página fica transparente, na verdade ela não está transparente, simplesmente ela não está ali. É pq o script não achou a página pq não tem o caminho certo, vai na biblioteca clica com o botão direito em cima do movieclip com o nome da página que fica "transparente" no filme, vai em propriedades, clica em Advanced e no item linkage você seleciona Export for ActionScript, em Identifier você coloca o nome referente a página, exemplo: página 17 no Identifier você coloca page17.Espero ter ajudado.T+ Compartilhar este post Link para o post Compartilhar em outros sites
aitadaniel 0 Denunciar post Postado Fevereiro 6, 2007 Olá pessoal, comecei a fazer uma revista em efeito page flip, mas me deparei com jm problema eu importava todas as imagens para a biblioteca e quando finalizei a revista o arquivo ficou muito pesado, sei que tem como fazer loadMovie, ja estudei sobre isso, só que não estou conseguindo isso... Será que alguem poderia me ajudar nessa parte ou me indicar algo para eu estudar...Desde já agradeço a atenção Compartilhar este post Link para o post Compartilhar em outros sites
Taci Bianchini 0 Denunciar post Postado Fevereiro 15, 2007 http://forum.imasters.com.br/public/style_emoticons/default/upset.gif Olá! Estou usando o page flip versão 2.1.3, que é dinâmico, e bem, eu coloquei uma animação na primeira pagina(capa), e eu queria que esta animação começasse de novo toda a vez que o usuario voltasse até a Capa. Fiz diversas tentativas, mas não consegui nada ainda, sei que não deve ser algo muito dificil de fazer. Minha primeira tentativa foi: No primeiro frame do primeiro layer coloquei o seguinte codigo: stop(); function onVisible() { gotoAndPlay(2); //trace("************************ VISIBLE **************************"); } function onInvisible() { gotoAndStop(1); //trace("************************ INVISIBLE **************************"); } E no ultimo frame do primeiro layer: gotoAndPlay(2) Mas com isso a imagem fica rodando em loop sem parar, eu quero que a animação aconteça e pare, e depois, quando a pessoa retornasse a primeira pagina ela pudesse ver novamente a animação! Compartilhar este post Link para o post Compartilhar em outros sites
André Coutinho 0 Denunciar post Postado Fevereiro 19, 2007 Pessoal,Sei que este código é meio antigo, mas eu preciso fazê-lo abrir em uma determinada página...já consegui fazer abrir na página 2 e 3, porém p/ abrir na página antes do fim dá um pau.Alguém pode ajudar?Att,André Compartilhar este post Link para o post Compartilhar em outros sites
annodam 0 Denunciar post Postado Abril 9, 2007 Olá!! gente eu li tudo neste tópico e num encontrei ninguém com dúvida pior que a minha!! hauahuahauhau... é o seguinte... minha animação ta prontinha (usei a verão 2.2), o problema é qdo acabam as páginas, que vira a página "capa de fundo do livro" do outro lado ainda fik aparecendo a anterior... e qdo começa a animação fica certinho, a capa da frente sozinha e do outro lado branco... mas se eu virar a capa e depois volta pra ela, a pagina 2 fica do lado dela ¬¬... eu num to sabendo como fazer pra fica só a capa da frente com o outro lado sem nda e a capa de fundo tbm... alguém pode me ajuda? E outra coisa tbm, vi umas pessoas falando que estão usando uma versão que da pra carrega imagem externa... a v.2.2 eu sei que num da pra fazer isso... alguém poderia postar essa versão que da pra fazer isso por favor? T+ Compartilhar este post Link para o post Compartilhar em outros sites
Antoniosp 2 Denunciar post Postado Abril 9, 2007 Bom, veja se a sua definição de páginas está ok. Ex: addPage("start"); //começa com startaddPage("page1");addPage("page2");addPage("page3");addPage("page4");addPage("page5");addPage("page6"); //não tenho certeza, mas acho que tem que ser um número par a última página.addPage("end"); //termina com end Flw Compartilhar este post Link para o post Compartilhar em outros sites
annodam 0 Denunciar post Postado Abril 9, 2007 Bom, veja se a sua definição de páginas está ok. Ex: addPage("start"); //começa com startaddPage("page1");addPage("page2");addPage("page3");addPage("page4");addPage("page5");addPage("page6"); //não tenho certeza, mas acho que tem que ser um número par a última página.addPage("end"); //termina com endFlw=/ minha última página é número 24...acho q ta faltando algum código, sei lá.... Compartilhar este post Link para o post Compartilhar em outros sites
Antoniosp 2 Denunciar post Postado Abril 10, 2007 Tenta pegar ela zeradinha e copia os mcs feitos seus pra nova.. Compartilhar este post Link para o post Compartilhar em outros sites
annodam 0 Denunciar post Postado Abril 10, 2007 Tenta pegar ela zeradinha e copia os mcs feitos seus pra nova..num deu certo tbm... eu fiz assim, deletei todas as páginas e fui duplicando akelas duas de modelozeradas pra cada lado e renomeando tdo certinho... mas continua dando o msm erro... eu acho que é alguma action q eu devo ter q por em alguma página pra sumir as outras qdo vira a página... mas num sei o q q é =( Compartilhar este post Link para o post Compartilhar em outros sites
annodam 0 Denunciar post Postado Abril 10, 2007 deu certo agora u.u eu tinha apagado sem querer a página em branco... e tinha q dexa ela no palco tbm... (ela é tão visivel né...) mas tdo bem... mto obrigado pela ajuda =) Compartilhar este post Link para o post Compartilhar em outros sites
Antoniosp 2 Denunciar post Postado Abril 10, 2007 Haha, ainda bem que foi só isso. :PABraço Compartilhar este post Link para o post Compartilhar em outros sites
Herege 0 Denunciar post Postado Abril 15, 2007 Hey pessoal... Estou montando um site que utiliza estas actions e estava tentando adicionar botões simples de voltar e avançar. Alguma idéia? Compartilhar este post Link para o post Compartilhar em outros sites
Camargalo 0 Denunciar post Postado Abril 30, 2007 Vi um pessoal perguntando sobre como alterar o tamanho das páginas...mas não achei respostas.....!! Alguém pode nos ajudar?? Valeu! Compartilhar este post Link para o post Compartilhar em outros sites
Dieguinhu Web 0 Denunciar post Postado Maio 8, 2007 GaleraTo com o pageflip aí que tem na rede só que ele é 300X400E eu vo fazer uma revista digital,portanto nessa dimensão o usuário não vai consiguir ler a revista como mudo as proporções da pagina,aonde tá page1,page2,page3 se eu tirar lá a pagina e colocar outra com o tamanho que preciso ela funcionará corretamente?AbraçoMe dêm dicas que to desenvolvendo para um siteObrigado Compartilhar este post Link para o post Compartilhar em outros sites
Dieguinhu Web 0 Denunciar post Postado Maio 8, 2007 Opa consegui jáqualquer outra duvida do um grito rsrsrsrrsrsabraço Compartilhar este post Link para o post Compartilhar em outros sites
Dieguinhu Web 0 Denunciar post Postado Maio 15, 2007 Bom tenhu esse codigo como ficaria com 68 paginas? //pageflip version 2.13 (200504272050)////0427: - removeML() function added, see details at frame 15// - new page definition system, hope it is easier to use!// - no need to adjust the mask size!//0418: now it is AS2/FLash7 Compatible (The bug was the variable flipOff/flipoff)//skip page option added to gotoPage function //(for the latest version, always check at [url="http://www.iparigrafika.hu/pageflip)"]http://www.iparigrafika.hu/pageflip)[/url]////this code is written by Macc 2004.11.01//abel@iparigrafika.hu////sound added by Triqui - www.triquitips.com (great job Macc!!!)////this code is opensource////free use!//but a small credit would be nice:)//these values can be changed: -------------------------------------------------------------------------pw = 449; //page width in pixelph = 600; //page height in pixel //pages in the library must have the same size, the script will not resize them!//page data... (export names/tearing flag)addPage("start"); //Always start with "start"!!!addPage("page1");addPage("page2");addPage("page3");addPage("page4");addPage("page5");addPage("page6");addPage("page7");addPage("page8");addPage("page9");addPage("page10");addPage("page11",true); //second argument defines page tearing.addPage("page12",true);addPage("page13");addPage("page14");addPage("page15");addPage("page16");addPage("page17");addPage("page18");addPage("page19");addPage("page20");addPage("page21");addPage("page22");addPage("page23");addPage("page24");addPage("page25");addPage("page26");addPage("page27");addPage("page28");addPage("page29");addPage("page30");addPage("page31");addPage("page32");addPage("page33");addPage("page34");addPage("page35");addPage("page36");addPage("page37");addPage("page38");addPage("page39");addPage("page40");addPage("page41");addPage("page42");addPage("page43");addPage("page44");addPage("page45");addPage("page46");addPage("page47");addPage("page48");addPage("page49");addPage("page50");addPage("page51");addPage("page52");addPage("page53");addPage("page54");addPage("page55");addPage("page56");addPage("page57");addPage("page58");addPage("page59");addPage("page60");addPage("page61");addPage("page62");addPage("page63");addPage("page64");addPage("page65");addPage("page66");addPage("page67");addPage("page68");addPage("end"); //always end with "end"!!!page=0; //first page (normally it is 0 = the page before the cover = blank page)hcover = true; //hard cover on/offpage_sound = true; //sound on/offclickarea = 64; //pixel width of the click sensitive area at the edges..afa = 56; //width of the autoflip starter square.gs = 2; //goto page flip speedps = 5; //mouse pursuit speedes = 3; //flip speed after mouse btn releasecanflip = true; //page flipping enabled//do not change these values: ---------------------------------------------------------------------------------------------------------------------_global.mcnt = 0; //counter (used on a page where is an animation)gpage = 0; //gotoPage Nogflip = false; //gotoPage flipgdir = 0; //goto direction...gskip = false; //skip pages ***gtarget = 0; //target when skippingaflip = false; //auto flipflip = false; //pageflipflipOff = false; //terminateflipflipOK = false; //good fliphflip = false; //hardflip (the cover of the book)rotz = -30; //hardflip max y differencepreflip = false; //corner flip statusctear = false; //actual page statustear = false;teard = 0;tlimit = 80;removedPages = new Array(); //list of removed pages!mpx = 0, mpy = 0; //mousepos at clicksx = sy = 0; //startpoint when flippingx = 0; //mouse x,yy = 0;ax = 0; //auto x,yay = 0;acnt = 0;aadd = 0;aamp = 0;AM = Math.PI/180;//pageflip code by Macc ---------------------------------------------------------------------------------------------------------------------------function addPage(ename,tear) { //defining pages... ------------------------------------------------------------------------------------------- if(ename=="start") { pageOrder = new Array(); pageCanTear = new Array(); page=0; ename="blankpage"; } if(ename=="end") { maxpage = page-1; ename="blankpage"; } tear = tear==undefined? false: tear; pageOrder = ename; pageCanTear = tear; page++}function reset() { //initializing pages... --------------------------------------------------------------------------------------- pages.p0.page._x = -pw; pages.p0._x = 0; pages.p1.page._x = -pw; pages.p1._x = 0; pages.flip.p2.page._x = -pw; pages.flip.p2._x = pw; pages.flip.p3.page._x = -pw; pages.flip.p3._x = 0; pages.p4.page._x = -pw; pages.p4._x = pw; pages.p5.page._x = -pw; pages.p5._x = pw; pages.pgrad._visible = pages.mask._visible = pages.flip._visible = false; pages.flip.p3mask._width = pages.pgmask._width = pw*2; pages.center._height = pages.flip.p3mask._height = pages.pgmask._height = ph; pages.flip.fmask.page.pf._width = pw; pages.center._width = 6; pages.flip.fmask.page.pf._height = ph; pages.mask._height = pages.pgrad._height = pages.flip.p3shadow._height = pages.flip.flipgrad._height = 2*Math.sqrt(ph*ph+pw*pw); pageNumber = new Array(); for(i=0;i<=(maxpage+1);i++) pageNumber[i] = i;}mousecontroll = new Object(); //initializing mouse click handler ---------------------------------------------------------------------------mousecontroll.onMouseDown = function() { if(flip && !aflip) {// && !preflip) { flipOK = false; if(sx<0 && pages._xmouse>0) flipOK = true; if(sx>0 && pages._xmouse<0) flipOK = true; flipOff = true; flip = false; } else if((flipOff || aflip || !canflip) && !preflip) { trace("donothing"); } else { var oox = ox; var ooy = oy; var osx = sx; var osy = sy; var hit = hittest(); //hittest if(hit) { anim._visible = false; flip = true; flipOff = false; tear = false; //not tearing yet... ox = sx = hit*pw; if(preflip) { aflip = preflip = false; ox = oox, oy = ooy; sx = osx, sy = osy; } pages.flip.setMask(pages.mask); mpx = pages._xmouse, mpy = pages._ymouse; //_quality = "MEDIUM"; //it is the place to degrade image quality while turning pages if the performance is too low. } }}mousecontroll.onMouseUp = function() { if(flip && !tear) { if((Math.abs(pages._xmouse)>(pw-afa) && Math.abs(pages._ymouse)>(ph/2-afa) && Math.abs(pages._xmouse-mpx)<afa) || preflip) { flip = false; preflip = false; autoflip(); } else if(!preflip) { preflip = false; flipOK = false; if(sx<0 && pages._xmouse>0) flipOK = true; if(sx>0 && pages._xmouse<0) flipOK = true; flipOff = true; flip = false; } }}function hittest() { //hittest at mouse clicks, if click is over the book -> determining turning direction ------------------------------------ var x=pages._xmouse; var y=pages._ymouse; var pmh = ph/2; if(y<=pmh && y>=-pmh && x<=pw && x>=-pw) { //ha a megadott intervallumban klikkelunk, akkor lapozhatunk 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; if(y<0 && y<-ph/2) y = - ph/2; 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 = eval("pages.flip.p2.page"); pageO = eval("pages.flip.p3"); offs = -pw; pages.flip.fmask._x = pw; if(x<-(pw-clickarea) && page>0) { //>-----> flip backward pages.flip.p3._x = 0; hflip = checkCover(page,-1); setPages(page-2,page-1,page,page+1); ctear = pageCanTear[page-1]; return -1; } if(x>(pw-clickarea) && page<maxpage) { //<-----< flip forward pages.flip.p3._x = pw; hflip = checkCover(page,1); setPages(page,page+2,page+1,page+3); ctear = pageCanTear[page+2]; return 1; } } else return 0; //wrong click}function checkCover(p,dir) { if(hcover) { if(dir>0) { if(p==(maxpage-2) || p==0) return true; } else { if(p==maxpage || p==2) return true; } } return false; }function corner() { var x = Math.abs(pages._xmouse); var y = Math.abs(pages._ymouse); if(x>(pw-afa) && x<pw && y>(ph/2-afa) && y<(ph/2)) { return true; } return false;}function oef() { _global.mcnt++; //main counter incrase (need for some page effect); if(!flip && corner()) { //corner mouseover preflip = true; if(!autoflip()) preflip = false; } if(preflip && !corner()) { preflip = false; flip = false; flipOK = false; flipOff = true; } getm(); if(aflip && !preflip) { y = (ay += (sy-ay)/(gflip? gs: ps )); acnt += aadd; ax -= aadd; if(Math.abs(acnt)>pw) { flipOK = true; flipOff = true; flip = false; aflip = false; } } if(flip) { //page turning is in progress... if(tear) { if (page_sound){ if (page_effect <> 1){ triquisound = new Sound(this); triquisound.attachSound("pagetear"); triquisound.start(0, 1); page_effect = 1; } } x = tox; y = (toy += teard); teard *= 1.2; if(Math.abs(teard)>1200) { flipOff = true; flip = false; } } else { x = (ox += (x-ox)/(gflip? gs: ps )); y = (oy += (y-oy)/(gflip? gs: ps )); } calc(x,y); //positioning pages and shadows } if(flipOff) { //terminating page turning effect... (comlplete turning... dropped on the other side) if(flipOK || tear) { if (page_sound){ if (page_effect <> 1){ triquisound = new Sound(this); triquisound.attachSound("pageflip"); triquisound.start(0, 1); page_effect = 1; } } x = (ox += (-sx-ox)/(gflip? gs: es )); y = (oy += (sy-oy)/(gflip? gs: es )); calc(x,y); if(x/-sx > 0.99 || tear) { //we are done with turning, so stop all turning issue... flip = false; page_effect = 0; flipOK = flipOff = false; pages.pgrad._visible = pages.flip._visible = false; //_quality = "BEST"; //if quality is decrased during turning effect, you must reset its default value! if(tear) { //if tear: remove page!!! removePage((sx<0)? page: page+1); page += (sx<0)? -2: 0; } else { page += (sx<0)? -2: 2; //and tourning pages at pagenumber level... } if(gskip) page = gtarget; setPages(page,0,0,page+1); tear = false; if(gpage>0 && !gskip) { //gotoflip active -> is there another flipping left? gpage--; autoflip(); } else gflip = gskip = false; } } else { //terminating page turning effect... (incomlplete turning... dropped on the dragged side) x = (ox += (sx-ox)/3); y = (oy += (sy-oy)/3); calc(x,y); if(x/sx > 0.99) { //we are done with turning, so stop all turning issue... flip = false; flipOff = false; aflip = false; pages.pgrad._visible = pages.flip._visible = false; //_quality = "HIGH"; //if quality is decrased during turning effect, you must reset its default value! setPages(page,0,0,page+1); //no change at pagenumbers.. } } }}function calc(x,y) { //positioning pages and shadows by x,y reference points -------------------------------------------------- if(hflip) { //hardflip... var xp = (sx<0)? -x: x; if(xp>0) { sp2._visible = false; sp3._visible = true; scalc(sp3,x); } else { sp3._visible = false; sp2._visible = true; scalc(sp2,x); } pages.flip.setMask(null); pages.flip._visible = true; pages.flip.fgrad._visible = false; pages.flip.p2._visible = pages.flip.p3._visible = false; return; } else pages.flip.fgrad._visible = true; //normal flipping process--------------------------------------------------------------------- var rr0 = Math.sqrt((y+ph/2)*(y+ph/2)+x*x); var rr1 = Math.sqrt((ph/2-y)*(ph/2-y)+x*x); if((rr0>r0 || rr1>r1) && !tear) { // we can tear off pages now:) // so reference points must be recalculated! if(y<sy) { // k1-gyel kell osszehasonlitani! var a = Math.asin((ph/2-y)/rr1); y = (ph/2-Math.sin(a)*r1); x = (x<0)? -Math.cos(a)*r1: Math.cos(a)*r1; if(y>sy) { if((sx*x)>0) y = sy, x = sx; else y = sy, x = -sx; } if((rr1-r1)>tlimit && ctear) { teard = -5; tear = true; tox = ox = x; toy = oy = y; } } else { // k0-val kell osszehasonlitani! var a = Math.asin((y+ph/2)/rr0); y = Math.sin(a)*r0-ph/2; x = (x<0)? -Math.cos(a)*r0: Math.cos(a)*r0; if(y<sy) { if((sx*x)>0) y = sy, x = sx; else y = sy, x = -sx; } if((rr0-r0)>tlimit && ctear) { teard = 5; tear = true; tox = ox = x; toy = oy = y; } } } if((sx<0 && (x-sx)<10) || (sx>0 && (sx-x)<10)) { if(sx<0) x = -pw+10; if(sx>0) x = pw-10; } //calculating flipping process pages.flip._visible = true; pages.flip.p3shadow._visible = pages.pgrad._visible = !tear; pages.flip.p2._visible = pages.flip.p3._visible = true; //equation of the line var vx = x-sx; var vy = y-sy; var a1 = vy/vx; var a2 = -vy/vx; cx = sx+(vx/2); cy = sy+(vy/2); //trigonometriai szamitasok //calculating rotation of the page, and the masks var r = Math.sqrt((sx-x)*(sx-x)+(sy-y)*(sy-y)); var a = Math.asin((sy-y)/r); if(sx<0) a = -a; ad = a/AM; //in degree pageN._rotation = ad*2; r = Math.sqrt((sx-x)*(sx-x)+(sy-y)*(sy-y)); rl = (pw*2); if(sx>0) { //flip forward pages.mask._xscale = 100; nx = cx-Math.tan(a)*(ph/2-cy); ny = ph/2; if(nx>pw) { nx = pw; ny = cy+Math.tan(Math.PI/2+a)*(pw-cx); } pageN.pf._x = -(pw-nx); pages.flip.fgrad._xscale = (r/rl/2)*pw; pages.pgrad._xscale = -(r/rl/2)*pw; pages.flip.p3shadow._xscale = (r/rl/2)*pw; } else { //flip backward pages.mask._xscale = -100; nx = cx-Math.tan(a)*(ph/2-cy); ny = ph/2; if(nx<-pw) { nx = -pw; ny = cy+Math.tan(Math.PI/2+a)*(-pw-cx); } pageN.pf._x = -(pw-(pw+nx)); pages.flip.fgrad._xscale = -(r/rl/2)*pw; pages.pgrad._xscale = (r/rl/2)*pw; pages.flip.p3shadow._xscale = -(r/rl/2)*pw; } 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 = (r>(rl-50))? 100-(r-(rl-50))*2: 100; pages.flip.p3shadow._x = cx; pages.flip.p3shadow._y = cy; pages.flip.p3shadow._rotation = ad; pages.flip.p3shadow._alpha = (r>(rl-50))? 100-(r-(rl-50))*2: 100; pages.pgrad._x = cx; pages.pgrad._y = cy; pages.pgrad._rotation = ad+180; pages.pgrad._alpha = (r>(rl-100))? 100-(r-(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;}function scalc(obj,x) { //hardflip calc if(x<-pw) x=-pw; if(x>pw) x=pw; var a = Math.asin( x/pw ); var rot = a/AM/2; var xs = 100; var ss = 100*Math.sin( rotz*AM ); x = x/2; var y = Math.cos(a)*(pw/2)*(ss/100); placeImg(obj, rot, ss, x, y) pages.pgrad._visible = pages.flip._visible = true; pages.pgrad._xscale = x; pages.pgrad._alpha = pages.flip.p3shadow._alpha = 100; pages.flip.p3shadow._xscale = -x; pages.flip.p3shadow._x = 0; pages.flip.p3shadow._y = 0; pages.flip.p3shadow._rotation = 0; pages.pgrad._x = 0; pages.pgrad._y = 0; pages.pgrad._rotation = 0;}function placeImg(j, rot, ss, x, y) { var m = Math.tan( rot*AM ); var f = Math.SQRT2/Math.sqrt(m*m+1); var phxs = 100*m; var phRot = -rot;; var xs = 100*f; var ys = 100*f; j.ph.pic._rotation = 45; j.ph.pic._xscale = (phxs<0)? - xs: xs; j.ph.pic._yscale = ys*(100/ss); j.ph._rotation = phRot; j.ph._xscale = phxs; j._yscale = ss; j._x = x; j._y = y; j._visible = true;}function setPages(p1,p2,p3,p4) { //attach the right page "image" at the right place:) p0 = p1-2; //pages for transparency... p5 = p4+2; if(p0<0) p0=0; if(p5>maxpage) p5=0; if(p1<0) p1=0; //visible pages if(p2<0) p2=0; if(p3<0) p3=0; if(p4<0) p4=0; trace("setpages ->"+p1+","+p2+","+p3+","+p4); pleft = pages.p1.page.pf.ph.attachMovie(pageOrder[p1],"pic",0); pages.p1.page.pf.ph._y = -ph/2; pleftb = pages.p0.page.pf.ph.attachMovie(pageOrder[p0],"pic",0); pages.p0.page.pf.ph._y = -ph/2; if(hflip) { //hardflip pages are specials!!! var tm = pages.flip.hfliph.attachMovie("sph","sp2",0); sp2 = tm.ph.pic.attachMovie(pageOrder[p2],"pic",0); sp2._y = -ph/2, sp2._x = -pw/2; sp2 = eval("pages.flip.hfliph.sp2"); var tm = pages.flip.hfliph.attachMovie("sph","sp3",1); sp3 = tm.ph.pic.attachMovie(pageOrder[p3],"pic",0); sp3._y = -ph/2, sp3._x = -pw/2; sp3 = eval("pages.flip.hfliph.sp3"); } else { pages.flip.hfliph.sp2.removeMovieClip(); pages.flip.hfliph.sp3.removeMovieClip(); sp2 = pages.flip.p2.page.pf.ph.attachMovie(pageOrder[p2],"pic",0); pages.flip.p2.page.pf.ph._y = -ph/2; sp3 = pages.flip.p3.page.pf.ph.attachMovie(pageOrder[p3],"pic",0); pages.flip.p3.page.pf.ph._y = -ph/2; } pright = pages.p4.page.pf.ph.attachMovie(pageOrder[p4],"pic",0); pages.p4.page.pf.ph._y = -ph/2; prightb = pages.p5.page.pf.ph.attachMovie(pageOrder[p5],"pic",0); pages.p5.page.pf.ph._y = -ph/2;}function resetPages() { setPages(page,0,0,page+1);} function autoflip() { //start auto flip! if(!aflip && !flip && !flipOff && canflip) { //only when all conditions fits our needs... acnt = 0 aamp = Math.random()*(ph/2)-(ph/4); var x= gflip? (gdir*pw)/2: ((pages._xmouse<0)? -pw/2: pw/2); //var y= Math.random()*ph-(ph/2); //random starty var y = Math.random()*(ph/2)-(ph/4); var pmh = ph/2; var r = Math.sqrt(x*x+y*y); var a = Math.asin(y/r); var yy = Math.tan(a)*pw; if(y>0 && y>ph/2) y = ph/2; if(y<0 && y<-ph/2) y = - ph/2; oy = sy = yy; ax = (pages._xmouse<0)? -pw/2: pw/2; var l = ((ph/2)-y); ay = y+((Math.random()*2*l)-l)/2; //page turnig style randomizing trace("autoflip from "+ax+","+ay); offs = -pw; var hit = 0; if(x<0 && page>0) { pages.flip.p3._x = 0; hflip = (hcover && gskip)? gtarget==0: checkCover(page,-1); if(!(preflip && hflip)) { if(gskip) setPages(gtarget,gtarget+1,page,page+1); else setPages(page-2,page-1,page,page+1); } hit = -1; } if(x>0 && page<maxpage) { pages.flip.p3._x = pw; hflip = (hcover && gskip)? gtarget==maxpage: checkCover(page,1); if(!(preflip && hflip)) { if(gskip) setPages(page,gtarget,page+1,gtarget+1); else setPages(page,page+2,page+1,page+3); } hit = 1; } if(hflip && preflip) { hit = 0; preflip = false; return false; } if(hit) { anim._visible = false; flip = true; flipOff = false; ox = sx = hit*pw; pages.flip.setMask(pages.mask); aadd = hit*(pw/(gflip? 5:10 )); //autoflip takes 10 frames to be done!!! aflip = true; pages.flip.fmask._x = pw; if(preflip) { oy = sy = (pages._ymouse<0)? -(ph/2): (ph/2); } r0 = Math.sqrt((sy+ph/2)*(sy+ph/2)+pw*pw); r1 = Math.sqrt((ph/2-sy)*(ph/2-sy)+pw*pw); pageN = eval("pages.flip.p2.page"); pageO = eval("pages.flip.p3"); oef(); return true; } } else return false;}function getm() { //get x,y reference points depending of turning style: manual/auto if(aflip && !preflip) { x = ax; y = ay; } else { x = pages._xmouse; y = pages._ymouse; }}function gotoPage(i,skip) { //quickjump to the page number i i = getPN(i); //i = target page gskip = (skip==undefined)? false: skip; //skip pages if(i<0) return false; var p = int(page/2); var d = int(i/2); if(p!=d && canflip && !gflip) { //target!=current page if(p<d) { //go forward gdir = 1; gpage = d-p-1; } else { //go backward gdir = -1 gpage = p-d-1; } gflip = true; if(gskip) gtarget = d*2, gpage = 0; autoflip(); } else gskip = false;}function getPN(i) { //get the right page number var find = false; for(j=1;j<=maxpage;j++) { if(i==pageNumber[j]) { i=j; find = true; break; } } if(find) return i; else return -1;}function removePage(i) { trace("remove page "+i); i = (Math.floor((i-1)/2)*2)+1; removedPages.push(pageNumber[i], pageNumber[i+1]); for(j=(i+2);j<=(maxPage+1);j++) { pageOrder[j-2]=pageOrder[j]; pageCanTear[j-2]=pageCanTear[j]; pageNumber[j-2]=pageNumber[j]; } trace("removed pages "+i+","+(i+1)); trace(removedPages.join(", ")); maxPage -= 2;}//------------------------------------------------------------------------------------------------ PUT YOUR CODE HERE --------------/* you can use these functions: gotoPage( destinationPageNo, skip ); //quick jump to the page number: destinationPageNo; values = 0-maxpages; skip: boolean; if true, pages will be skipped to the destination! autoflip(); //start autoflip (direction is calculated from _xmouse) canflip //it's a variable. setting its value to false disables flipping other functions of page turning is automatic; WARNING!!! if you want to unload/reload tha pageflip, before unloading call function: removeML(); to remove mouse listener!*/)[/url]////this code is written by Macc 2004.11.01//abel@iparigrafika.hu////sound added by Triqui - www.triquitips.com (great job Macc!!!)////this code is opensource////free use!//but a small credit would be nice:)//these values can be changed: -------------------------------------------------------------------------pw = 449; //page width in pixelph = 600; //page height in pixel //pages in the library must have the same size, the script will not resize them!//page data... (export names/tearing flag)addPage("start"); //Always start with "start"!!!addPage("page1");addPage("page2");addPage("page3");addPage("page4");addPage("page5");addPage("page6");addPage("page7");addPage("page8");addPage("page9");addPage("page10");addPage("page11",true); //second argument defines page tearing.addPage("page12",true);addPage("page13");addPage("page14");addPage("page15");addPage("page16");addPage("page17");addPage("page18");addPage("page19");addPage("page20");addPage("page21");addPage("page22");addPage("page23");addPage("page24");addPage("page25");addPage("page26");addPage("page27");addPage("page28");addPage("page29");addPage("page30");addPage("page31");addPage("page32");addPage("page33");addPage("page34");addPage("page35");addPage("page36");addPage("page37");addPage("page38");addPage("page39");addPage("page40");addPage("page41");addPage("page42");addPage("page43");addPage("page44");addPage("page45");addPage("page46");addPage("page47");addPage("page48");addPage("page49");addPage("page50");addPage("page51");addPage("page52");addPage("page53");addPage("page54");addPage("page55");addPage("page56");addPage("page57");addPage("page58");addPage("page59");addPage("page60");addPage("page61");addPage("page62");addPage("page63");addPage("page64");addPage("page65");addPage("page66");addPage("page67");addPage("page68");addPage("end"); //always end with "end"!!!page=0; //first page (normally it is 0 = the page before the cover = blank page)hcover = true; //hard cover on/offpage_sound = true; //sound on/offclickarea = 64; //pixel width of the click sensitive area at the edges..afa = 56; //width of the autoflip starter square.gs = 2; //goto page flip speedps = 5; //mouse pursuit speedes = 3; //flip speed after mouse btn releasecanflip = true; //page flipping enabled//do not change these values: ---------------------------------------------------------------------------------------------------------------------_global.mcnt = 0; //counter (used on a page where is an animation)gpage = 0; //gotoPage Nogflip = false; //gotoPage flipgdir = 0; //goto direction...gskip = false; //skip pages ***gtarget = 0; //target when skippingaflip = false; //auto flipflip = false; //pageflipflipOff = false; //terminateflipflipOK = false; //good fliphflip = false; //hardflip (the cover of the book)rotz = -30; //hardflip max y differencepreflip = false; //corner flip statusctear = false; //actual page statustear = false;teard = 0;tlimit = 80;removedPages = new Array(); //list of removed pages!mpx = 0, mpy = 0; //mousepos at clicksx = sy = 0; //startpoint when flippingx = 0; //mouse x,yy = 0;ax = 0; //auto x,yay = 0;acnt = 0;aadd = 0;aamp = 0;AM = Math.PI/180;//pageflip code by Macc ---------------------------------------------------------------------------------------------------------------------------function addPage(ename,tear) { //defining pages... ------------------------------------------------------------------------------------------- if(ename=="start") { pageOrder = new Array(); pageCanTear = new Array(); page=0; ename="blankpage"; } if(ename=="end") { maxpage = page-1; ename="blankpage"; } tear = tear==undefined? false: tear; pageOrder = ename; pageCanTear = tear; page++}function reset() { //initializing pages... --------------------------------------------------------------------------------------- pages.p0.page._x = -pw; pages.p0._x = 0; pages.p1.page._x = -pw; pages.p1._x = 0; pages.flip.p2.page._x = -pw; pages.flip.p2._x = pw; pages.flip.p3.page._x = -pw; pages.flip.p3._x = 0; pages.p4.page._x = -pw; pages.p4._x = pw; pages.p5.page._x = -pw; pages.p5._x = pw; pages.pgrad._visible = pages.mask._visible = pages.flip._visible = false; pages.flip.p3mask._width = pages.pgmask._width = pw*2; pages.center._height = pages.flip.p3mask._height = pages.pgmask._height = ph; pages.flip.fmask.page.pf._width = pw; pages.center._width = 6; pages.flip.fmask.page.pf._height = ph; pages.mask._height = pages.pgrad._height = pages.flip.p3shadow._height = pages.flip.flipgrad._height = 2*Math.sqrt(ph*ph+pw*pw); pageNumber = new Array(); for(i=0;i<=(maxpage+1);i++) pageNumber[i] = i;}mousecontroll = new Object(); //initializing mouse click handler ---------------------------------------------------------------------------mousecontroll.onMouseDown = function() { if(flip && !aflip) {// && !preflip) { flipOK = false; if(sx<0 && pages._xmouse>0) flipOK = true; if(sx>0 && pages._xmouse<0) flipOK = true; flipOff = true; flip = false; } else if((flipOff || aflip || !canflip) && !preflip) { trace("donothing"); } else { var oox = ox; var ooy = oy; var osx = sx; var osy = sy; var hit = hittest(); //hittest if(hit) { anim._visible = false; flip = true; flipOff = false; tear = false; //not tearing yet... ox = sx = hit*pw; if(preflip) { aflip = preflip = false; ox = oox, oy = ooy; sx = osx, sy = osy; } pages.flip.setMask(pages.mask); mpx = pages._xmouse, mpy = pages._ymouse; //_quality = "MEDIUM"; //it is the place to degrade image quality while turning pages if the performance is too low. } }}mousecontroll.onMouseUp = function() { if(flip && !tear) { if((Math.abs(pages._xmouse)>(pw-afa) && Math.abs(pages._ymouse)>(ph/2-afa) && Math.abs(pages._xmouse-mpx)<afa) || preflip) { flip = false; preflip = false; autoflip(); } else if(!preflip) { preflip = false; flipOK = false; if(sx<0 && pages._xmouse>0) flipOK = true; if(sx>0 && pages._xmouse<0) flipOK = true; flipOff = true; flip = false; } }}function hittest() { //hittest at mouse clicks, if click is over the book -> determining turning direction ------------------------------------ var x=pages._xmouse; var y=pages._ymouse; var pmh = ph/2; if(y<=pmh && y>=-pmh && x<=pw && x>=-pw) { //ha a megadott intervallumban klikkelunk, akkor lapozhatunk 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; if(y<0 && y<-ph/2) y = - ph/2; 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 = eval("pages.flip.p2.page"); pageO = eval("pages.flip.p3"); offs = -pw; pages.flip.fmask._x = pw; if(x<-(pw-clickarea) && page>0) { //>-----> flip backward pages.flip.p3._x = 0; hflip = checkCover(page,-1); setPages(page-2,page-1,page,page+1); ctear = pageCanTear[page-1]; return -1; } if(x>(pw-clickarea) && page<maxpage) { //<-----< flip forward pages.flip.p3._x = pw; hflip = checkCover(page,1); setPages(page,page+2,page+1,page+3); ctear = pageCanTear[page+2]; return 1; } } else return 0; //wrong click}function checkCover(p,dir) { if(hcover) { if(dir>0) { if(p==(maxpage-2) || p==0) return true; } else { if(p==maxpage || p==2) return true; } } return false; }function corner() { var x = Math.abs(pages._xmouse); var y = Math.abs(pages._ymouse); if(x>(pw-afa) && x<pw && y>(ph/2-afa) && y<(ph/2)) { return true; } return false;}function oef() { _global.mcnt++; //main counter incrase (need for some page effect); if(!flip && corner()) { //corner mouseover preflip = true; if(!autoflip()) preflip = false; } if(preflip && !corner()) { preflip = false; flip = false; flipOK = false; flipOff = true; } getm(); if(aflip && !preflip) { y = (ay += (sy-ay)/(gflip? gs: ps )); acnt += aadd; ax -= aadd; if(Math.abs(acnt)>pw) { flipOK = true; flipOff = true; flip = false; aflip = false; } } if(flip) { //page turning is in progress... if(tear) { if (page_sound){ if (page_effect <> 1){ triquisound = new Sound(this); triquisound.attachSound("pagetear"); triquisound.start(0, 1); page_effect = 1; } } x = tox; y = (toy += teard); teard *= 1.2; if(Math.abs(teard)>1200) { flipOff = true; flip = false; } } else { x = (ox += (x-ox)/(gflip? gs: ps )); y = (oy += (y-oy)/(gflip? gs: ps )); } calc(x,y); //positioning pages and shadows } if(flipOff) { //terminating page turning effect... (comlplete turning... dropped on the other side) if(flipOK || tear) { if (page_sound){ if (page_effect <> 1){ triquisound = new Sound(this); triquisound.attachSound("pageflip"); triquisound.start(0, 1); page_effect = 1; } } x = (ox += (-sx-ox)/(gflip? gs: es )); y = (oy += (sy-oy)/(gflip? gs: es )); calc(x,y); if(x/-sx > 0.99 || tear) { //we are done with turning, so stop all turning issue... flip = false; page_effect = 0; flipOK = flipOff = false; pages.pgrad._visible = pages.flip._visible = false; //_quality = "BEST"; //if quality is decrased during turning effect, you must reset its default value! if(tear) { //if tear: remove page!!! removePage((sx<0)? page: page+1); page += (sx<0)? -2: 0; } else { page += (sx<0)? -2: 2; //and tourning pages at pagenumber level... } if(gskip) page = gtarget; setPages(page,0,0,page+1); tear = false; if(gpage>0 && !gskip) { //gotoflip active -> is there another flipping left? gpage--; autoflip(); } else gflip = gskip = false; } } else { //terminating page turning effect... (incomlplete turning... dropped on the dragged side) x = (ox += (sx-ox)/3); y = (oy += (sy-oy)/3); calc(x,y); if(x/sx > 0.99) { //we are done with turning, so stop all turning issue... flip = false; flipOff = false; aflip = false; pages.pgrad._visible = pages.flip._visible = false; //_quality = "HIGH"; //if quality is decrased during turning effect, you must reset its default value! setPages(page,0,0,page+1); //no change at pagenumbers.. } } }}function calc(x,y) { //positioning pages and shadows by x,y reference points -------------------------------------------------- if(hflip) { //hardflip... var xp = (sx<0)? -x: x; if(xp>0) { sp2._visible = false; sp3._visible = true; scalc(sp3,x); } else { sp3._visible = false; sp2._visible = true; scalc(sp2,x); } pages.flip.setMask(null); pages.flip._visible = true; pages.flip.fgrad._visible = false; pages.flip.p2._visible = pages.flip.p3._visible = false; return; } else pages.flip.fgrad._visible = true; //normal flipping process--------------------------------------------------------------------- var rr0 = Math.sqrt((y+ph/2)*(y+ph/2)+x*x); var rr1 = Math.sqrt((ph/2-y)*(ph/2-y)+x*x); if((rr0>r0 || rr1>r1) && !tear) { // we can tear off pages now:) // so reference points must be recalculated! if(y<sy) { // k1-gyel kell osszehasonlitani! var a = Math.asin((ph/2-y)/rr1); y = (ph/2-Math.sin(a)*r1); x = (x<0)? -Math.cos(a)*r1: Math.cos(a)*r1; if(y>sy) { if((sx*x)>0) y = sy, x = sx; else y = sy, x = -sx; } if((rr1-r1)>tlimit && ctear) { teard = -5; tear = true; tox = ox = x; toy = oy = y; } } else { // k0-val kell osszehasonlitani! var a = Math.asin((y+ph/2)/rr0); y = Math.sin(a)*r0-ph/2; x = (x<0)? -Math.cos(a)*r0: Math.cos(a)*r0; if(y<sy) { if((sx*x)>0) y = sy, x = sx; else y = sy, x = -sx; } if((rr0-r0)>tlimit && ctear) { teard = 5; tear = true; tox = ox = x; toy = oy = y; } } } if((sx<0 && (x-sx)<10) || (sx>0 && (sx-x)<10)) { if(sx<0) x = -pw+10; if(sx>0) x = pw-10; } //calculating flipping process pages.flip._visible = true; pages.flip.p3shadow._visible = pages.pgrad._visible = !tear; pages.flip.p2._visible = pages.flip.p3._visible = true; //equation of the line var vx = x-sx; var vy = y-sy; var a1 = vy/vx; var a2 = -vy/vx; cx = sx+(vx/2); cy = sy+(vy/2); //trigonometriai szamitasok //calculating rotation of the page, and the masks var r = Math.sqrt((sx-x)*(sx-x)+(sy-y)*(sy-y)); var a = Math.asin((sy-y)/r); if(sx<0) a = -a; ad = a/AM; //in degree pageN._rotation = ad*2; r = Math.sqrt((sx-x)*(sx-x)+(sy-y)*(sy-y)); rl = (pw*2); if(sx>0) { //flip forward pages.mask._xscale = 100; nx = cx-Math.tan(a)*(ph/2-cy); ny = ph/2; if(nx>pw) { nx = pw; ny = cy+Math.tan(Math.PI/2+a)*(pw-cx); } pageN.pf._x = -(pw-nx); pages.flip.fgrad._xscale = (r/rl/2)*pw; pages.pgrad._xscale = -(r/rl/2)*pw; pages.flip.p3shadow._xscale = (r/rl/2)*pw; } else { //flip backward pages.mask._xscale = -100; nx = cx-Math.tan(a)*(ph/2-cy); ny = ph/2; if(nx<-pw) { nx = -pw; ny = cy+Math.tan(Math.PI/2+a)*(-pw-cx); } pageN.pf._x = -(pw-(pw+nx)); pages.flip.fgrad._xscale = -(r/rl/2)*pw; pages.pgrad._xscale = (r/rl/2)*pw; pages.flip.p3shadow._xscale = -(r/rl/2)*pw; } 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 = (r>(rl-50))? 100-(r-(rl-50))*2: 100; pages.flip.p3shadow._x = cx; pages.flip.p3shadow._y = cy; pages.flip.p3shadow._rotation = ad; pages.flip.p3shadow._alpha = (r>(rl-50))? 100-(r-(rl-50))*2: 100; pages.pgrad._x = cx; pages.pgrad._y = cy; pages.pgrad._rotation = ad+180; pages.pgrad._alpha = (r>(rl-100))? 100-(r-(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;}function scalc(obj,x) { //hardflip calc if(x<-pw) x=-pw; if(x>pw) x=pw; var a = Math.asin( x/pw ); var rot = a/AM/2; var xs = 100; var ss = 100*Math.sin( rotz*AM ); x = x/2; var y = Math.cos(a)*(pw/2)*(ss/100); placeImg(obj, rot, ss, x, y) pages.pgrad._visible = pages.flip._visible = true; pages.pgrad._xscale = x; pages.pgrad._alpha = pages.flip.p3shadow._alpha = 100; pages.flip.p3shadow._xscale = -x; pages.flip.p3shadow._x = 0; pages.flip.p3shadow._y = 0; pages.flip.p3shadow._rotation = 0; pages.pgrad._x = 0; pages.pgrad._y = 0; pages.pgrad._rotation = 0;}function placeImg(j, rot, ss, x, y) { var m = Math.tan( rot*AM ); var f = Math.SQRT2/Math.sqrt(m*m+1); var phxs = 100*m; var phRot = -rot;; var xs = 100*f; var ys = 100*f; j.ph.pic._rotation = 45; j.ph.pic._xscale = (phxs<0)? - xs: xs; j.ph.pic._yscale = ys*(100/ss); j.ph._rotation = phRot; j.ph._xscale = phxs; j._yscale = ss; j._x = x; j._y = y; j._visible = true;}function setPages(p1,p2,p3,p4) { //attach the right page "image" at the right place:) p0 = p1-2; //pages for transparency... p5 = p4+2; if(p0<0) p0=0; if(p5>maxpage) p5=0; if(p1<0) p1=0; //visible pages if(p2<0) p2=0; if(p3<0) p3=0; if(p4<0) p4=0; trace("setpages ->"+p1+","+p2+","+p3+","+p4); pleft = pages.p1.page.pf.ph.attachMovie(pageOrder[p1],"pic",0); pages.p1.page.pf.ph._y = -ph/2; pleftb = pages.p0.page.pf.ph.attachMovie(pageOrder[p0],"pic",0); pages.p0.page.pf.ph._y = -ph/2; if(hflip) { //hardflip pages are specials!!! var tm = pages.flip.hfliph.attachMovie("sph","sp2",0); sp2 = tm.ph.pic.attachMovie(pageOrder[p2],"pic",0); sp2._y = -ph/2, sp2._x = -pw/2; sp2 = eval("pages.flip.hfliph.sp2"); var tm = pages.flip.hfliph.attachMovie("sph","sp3",1); sp3 = tm.ph.pic.attachMovie(pageOrder[p3],"pic",0); sp3._y = -ph/2, sp3._x = -pw/2; sp3 = eval("pages.flip.hfliph.sp3"); } else { pages.flip.hfliph.sp2.removeMovieClip(); pages.flip.hfliph.sp3.removeMovieClip(); sp2 = pages.flip.p2.page.pf.ph.attachMovie(pageOrder[p2],"pic",0); pages.flip.p2.page.pf.ph._y = -ph/2; sp3 = pages.flip.p3.page.pf.ph.attachMovie(pageOrder[p3],"pic",0); pages.flip.p3.page.pf.ph._y = -ph/2; } pright = pages.p4.page.pf.ph.attachMovie(pageOrder[p4],"pic",0); pages.p4.page.pf.ph._y = -ph/2; prightb = pages.p5.page.pf.ph.attachMovie(pageOrder[p5],"pic",0); pages.p5.page.pf.ph._y = -ph/2;}function resetPages() { setPages(page,0,0,page+1);} function autoflip() { //start auto flip! if(!aflip && !flip && !flipOff && canflip) { //only when all conditions fits our needs... acnt = 0 aamp = Math.random()*(ph/2)-(ph/4); var x= gflip? (gdir*pw)/2: ((pages._xmouse<0)? -pw/2: pw/2); //var y= Math.random()*ph-(ph/2); //random starty var y = Math.random()*(ph/2)-(ph/4); var pmh = ph/2; var r = Math.sqrt(x*x+y*y); var a = Math.asin(y/r); var yy = Math.tan(a)*pw; if(y>0 && y>ph/2) y = ph/2; if(y<0 && y<-ph/2) y = - ph/2; oy = sy = yy; ax = (pages._xmouse<0)? -pw/2: pw/2; var l = ((ph/2)-y); ay = y+((Math.random()*2*l)-l)/2; //page turnig style randomizing trace("autoflip from "+ax+","+ay); offs = -pw; var hit = 0; if(x<0 && page>0) { pages.flip.p3._x = 0; hflip = (hcover && gskip)? gtarget==0: checkCover(page,-1); if(!(preflip && hflip)) { if(gskip) setPages(gtarget,gtarget+1,page,page+1); else setPages(page-2,page-1,page,page+1); } hit = -1; } if(x>0 && page<maxpage) { pages.flip.p3._x = pw; hflip = (hcover && gskip)? gtarget==maxpage: checkCover(page,1); if(!(preflip && hflip)) { if(gskip) setPages(page,gtarget,page+1,gtarget+1); else setPages(page,page+2,page+1,page+3); } hit = 1; } if(hflip && preflip) { hit = 0; preflip = false; return false; } if(hit) { anim._visible = false; flip = true; flipOff = false; ox = sx = hit*pw; pages.flip.setMask(pages.mask); aadd = hit*(pw/(gflip? 5:10 )); //autoflip takes 10 frames to be done!!! aflip = true; pages.flip.fmask._x = pw; if(preflip) { oy = sy = (pages._ymouse<0)? -(ph/2): (ph/2); } r0 = Math.sqrt((sy+ph/2)*(sy+ph/2)+pw*pw); r1 = Math.sqrt((ph/2-sy)*(ph/2-sy)+pw*pw); pageN = eval("pages.flip.p2.page"); pageO = eval("pages.flip.p3"); oef(); return true; } } else return false;}function getm() { //get x,y reference points depending of turning style: manual/auto if(aflip && !preflip) { x = ax; y = ay; } else { x = pages._xmouse; y = pages._ymouse; }}function gotoPage(i,skip) { //quickjump to the page number i i = getPN(i); //i = target page gskip = (skip==undefined)? false: skip; //skip pages if(i<0) return false; var p = int(page/2); var d = int(i/2); if(p!=d && canflip && !gflip) { //target!=current page if(p<d) { //go forward gdir = 1; gpage = d-p-1; } else { //go backward gdir = -1 gpage = p-d-1; } gflip = true; if(gskip) gtarget = d*2, gpage = 0; autoflip(); } else gskip = false;}function getPN(i) { //get the right page number var find = false; for(j=1;j<=maxpage;j++) { if(i==pageNumber[j]) { i=j; find = true; break; } } if(find) return i; else return -1;}function removePage(i) { trace("remove page "+i); i = (Math.floor((i-1)/2)*2)+1; removedPages.push(pageNumber[i], pageNumber[i+1]); for(j=(i+2);j<=(maxPage+1);j++) { pageOrder[j-2]=pageOrder[j]; pageCanTear[j-2]=pageCanTear[j]; pageNumber[j-2]=pageNumber[j]; } trace("removed pages "+i+","+(i+1)); trace(removedPages.join(", ")); maxPage -= 2;}//------------------------------------------------------------------------------------------------ PUT YOUR CODE HERE --------------/* you can use these functions: gotoPage( destinationPageNo, skip ); //quick jump to the page number: destinationPageNo; values = 0-maxpages; skip: boolean; if true, pages will be skipped to the destination! autoflip(); //start autoflip (direction is calculated from _xmouse) canflip //it's a variable. setting its value to false disables flipping other functions of page turning is automatic; WARNING!!! if you want to unload/reload tha pageflip, before unloading call function: removeML(); to remove mouse listener!*/)[/url]////this code is written by Macc 2004.11.01//abel@iparigrafika.hu////sound added by Triqui - www.triquitips.com (great job Macc!!!)////this code is opensource////free use!//but a small credit would be nice:)//these values can be changed: -------------------------------------------------------------------------pw = 449; //page width in pixelph = 600; //page height in pixel //pages in the library must have the same size, the script will not resize them!//page data... (export names/tearing flag)addPage("start"); //Always start with "start"!!!addPage("page1");addPage("page2");addPage("page3");addPage("page4");addPage("page5");addPage("page6");addPage("page7");addPage("page8");addPage("page9");addPage("page10");addPage("page11",true); //second argument defines page tearing.addPage("page12",true);addPage("page13");addPage("page14");addPage("page15");addPage("page16");addPage("page17");addPage("page18");addPage("page19");addPage("page20");addPage("page21");addPage("page22");addPage("page23");addPage("page24");addPage("page25");addPage("page26");addPage("page27");addPage("page28");addPage("page29");addPage("page30");addPage("page31");addPage("page32");addPage("page33");addPage("page34");addPage("page35");addPage("page36");addPage("page37");addPage("page38");addPage("page39");addPage("page40");addPage("page41");addPage("page42");addPage("page43");addPage("page44");addPage("page45");addPage("page46");addPage("page47");addPage("page48");addPage("page49");addPage("page50");addPage("page51");addPage("page52");addPage("page53");addPage("page54");addPage("page55");addPage("page56");addPage("page57");addPage("page58");addPage("page59");addPage("page60");addPage("page61");addPage("page62");addPage("page63");addPage("page64");addPage("page65");addPage("page66");addPage("page67");addPage("page68");addPage("end"); //always end with "end"!!!page=0; //first page (normally it is 0 = the page before the cover = blank page)hcover = true; //hard cover on/offpage_sound = true; //sound on/offclickarea = 64; //pixel width of the click sensitive area at the edges..afa = 56; //width of the autoflip starter square.gs = 2; //goto page flip speedps = 5; //mouse pursuit speedes = 3; //flip speed after mouse btn releasecanflip = true; //page flipping enabled//do not change these values: ---------------------------------------------------------------------------------------------------------------------_global.mcnt = 0; //counter (used on a page where is an animation)gpage = 0; //gotoPage Nogflip = false; //gotoPage flipgdir = 0; //goto direction...gskip = false; //skip pages ***gtarget = 0; //target when skippingaflip = false; //auto flipflip = false; //pageflipflipOff = false; //terminateflipflipOK = false; //good fliphflip = false; //hardflip (the cover of the book)rotz = -30; //hardflip max y differencepreflip = false; //corner flip statusctear = false; //actual page statustear = false;teard = 0;tlimit = 80;removedPages = new Array(); //list of removed pages!mpx = 0, mpy = 0; //mousepos at clicksx = sy = 0; //startpoint when flippingx = 0; //mouse x,yy = 0;ax = 0; //auto x,yay = 0;acnt = 0;aadd = 0;aamp = 0;AM = Math.PI/180;//pageflip code by Macc ---------------------------------------------------------------------------------------------------------------------------function addPage(ename,tear) { //defining pages... ------------------------------------------------------------------------------------------- if(ename=="start") { pageOrder = new Array(); pageCanTear = new Array(); page=0; ename="blankpage"; } if(ename=="end") { maxpage = page-1; ename="blankpage"; } tear = tear==undefined? false: tear; pageOrder = ename; pageCanTear = tear; page++}function reset() { //initializing pages... --------------------------------------------------------------------------------------- pages.p0.page._x = -pw; pages.p0._x = 0; pages.p1.page._x = -pw; pages.p1._x = 0; pages.flip.p2.page._x = -pw; pages.flip.p2._x = pw; pages.flip.p3.page._x = -pw; pages.flip.p3._x = 0; pages.p4.page._x = -pw; pages.p4._x = pw; pages.p5.page._x = -pw; pages.p5._x = pw; pages.pgrad._visible = pages.mask._visible = pages.flip._visible = false; pages.flip.p3mask._width = pages.pgmask._width = pw*2; pages.center._height = pages.flip.p3mask._height = pages.pgmask._height = ph; pages.flip.fmask.page.pf._width = pw; pages.center._width = 6; pages.flip.fmask.page.pf._height = ph; pages.mask._height = pages.pgrad._height = pages.flip.p3shadow._height = pages.flip.flipgrad._height = 2*Math.sqrt(ph*ph+pw*pw); pageNumber = new Array(); for(i=0;i<=(maxpage+1);i++) pageNumber[i] = i;}mousecontroll = new Object(); //initializing mouse click handler ---------------------------------------------------------------------------mousecontroll.onMouseDown = function() { if(flip && !aflip) {// && !preflip) { flipOK = false; if(sx<0 && pages._xmouse>0) flipOK = true; if(sx>0 && pages._xmouse<0) flipOK = true; flipOff = true; flip = false; } else if((flipOff || aflip || !canflip) && !preflip) { trace("donothing"); } else { var oox = ox; var ooy = oy; var osx = sx; var osy = sy; var hit = hittest(); //hittest if(hit) { anim._visible = false; flip = true; flipOff = false; tear = false; //not tearing yet... ox = sx = hit*pw; if(preflip) { aflip = preflip = false; ox = oox, oy = ooy; sx = osx, sy = osy; } pages.flip.setMask(pages.mask); mpx = pages._xmouse, mpy = pages._ymouse; //_quality = "MEDIUM"; //it is the place to degrade image quality while turning pages if the performance is too low. } }}mousecontroll.onMouseUp = function() { if(flip && !tear) { if((Math.abs(pages._xmouse)>(pw-afa) && Math.abs(pages._ymouse)>(ph/2-afa) && Math.abs(pages._xmouse-mpx)<afa) || preflip) { flip = false; preflip = false; autoflip(); } else if(!preflip) { preflip = false; flipOK = false; if(sx<0 && pages._xmouse>0) flipOK = true; if(sx>0 && pages._xmouse<0) flipOK = true; flipOff = true; flip = false; } }}function hittest() { //hittest at mouse clicks, if click is over the book -> determining turning direction ------------------------------------ var x=pages._xmouse; var y=pages._ymouse; var pmh = ph/2; if(y<=pmh && y>=-pmh && x<=pw && x>=-pw) { //ha a megadott intervallumban klikkelunk, akkor lapozhatunk 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; if(y<0 && y<-ph/2) y = - ph/2; 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 = eval("pages.flip.p2.page"); pageO = eval("pages.flip.p3"); offs = -pw; pages.flip.fmask._x = pw; if(x<-(pw-clickarea) && page>0) { //>-----> flip backward pages.flip.p3._x = 0; hflip = checkCover(page,-1); setPages(page-2,page-1,page,page+1); ctear = pageCanTear[page-1]; return -1; } if(x>(pw-clickarea) && page<maxpage) { //<-----< flip forward pages.flip.p3._x = pw; hflip = checkCover(page,1); setPages(page,page+2,page+1,page+3); ctear = pageCanTear[page+2]; return 1; } } else return 0; //wrong click}function checkCover(p,dir) { if(hcover) { if(dir>0) { if(p==(maxpage-2) || p==0) return true; } else { if(p==maxpage || p==2) return true; } } return false; }function corner() { var x = Math.abs(pages._xmouse); var y = Math.abs(pages._ymouse); if(x>(pw-afa) && x<pw && y>(ph/2-afa) && y<(ph/2)) { return true; } return false;}function oef() { _global.mcnt++; //main counter incrase (need for some page effect); if(!flip && corner()) { //corner mouseover preflip = true; if(!autoflip()) preflip = false; } if(preflip && !corner()) { preflip = false; flip = false; flipOK = false; flipOff = true; } getm(); if(aflip && !preflip) { y = (ay += (sy-ay)/(gflip? gs: ps )); acnt += aadd; ax -= aadd; if(Math.abs(acnt)>pw) { flipOK = true; flipOff = true; flip = false; aflip = false; } } if(flip) { //page turning is in progress... if(tear) { if (page_sound){ if (page_effect <> 1){ triquisound = new Sound(this); triquisound.attachSound("pagetear"); triquisound.start(0, 1); page_effect = 1; } } x = tox; y = (toy += teard); teard *= 1.2; if(Math.abs(teard)>1200) { flipOff = true; flip = false; } } else { x = (ox += (x-ox)/(gflip? gs: ps )); y = (oy += (y-oy)/(gflip? gs: ps )); } calc(x,y); //positioning pages and shadows } if(flipOff) { //terminating page turning effect... (comlplete turning... dropped on the other side) if(flipOK || tear) { if (page_sound){ if (page_effect <> 1){ triquisound = new Sound(this); triquisound.attachSound("pageflip"); triquisound.start(0, 1); page_effect = 1; } } x = (ox += (-sx-ox)/(gflip? gs: es )); y = (oy += (sy-oy)/(gflip? gs: es )); calc(x,y); if(x/-sx > 0.99 || tear) { //we are done with turning, so stop all turning issue... flip = false; page_effect = 0; flipOK = flipOff = false; pages.pgrad._visible = pages.flip._visible = false; //_quality = "BEST"; //if quality is decrased during turning effect, you must reset its default value! if(tear) { //if tear: remove page!!! removePage((sx<0)? page: page+1); page += (sx<0)? -2: 0; } else { page += (sx<0)? -2: 2; //and tourning pages at pagenumber level... } if(gskip) page = gtarget; setPages(page,0,0,page+1); tear = false; if(gpage>0 && !gskip) { //gotoflip active -> is there another flipping left? gpage--; autoflip(); } else gflip = gskip = false; } } else { //terminating page turning effect... (incomlplete turning... dropped on the dragged side) x = (ox += (sx-ox)/3); y = (oy += (sy-oy)/3); calc(x,y); if(x/sx > 0.99) { //we are done with turning, so stop all turning issue... flip = false; flipOff = false; aflip = false; pages.pgrad._visible = pages.flip._visible = false; //_quality = "HIGH"; //if quality is decrased during turning effect, you must reset its default value! setPages(page,0,0,page+1); //no change at pagenumbers.. } } }}function calc(x,y) { //positioning pages and shadows by x,y reference points -------------------------------------------------- if(hflip) { //hardflip... var xp = (sx<0)? -x: x; if(xp>0) { sp2._visible = false; sp3._visible = true; scalc(sp3,x); } else { sp3._visible = false; sp2._visible = true; scalc(sp2,x); } pages.flip.setMask(null); pages.flip._visible = true; pages.flip.fgrad._visible = false; pages.flip.p2._visible = pages.flip.p3._visible = false; return; } else pages.flip.fgrad._visible = true; //normal flipping process--------------------------------------------------------------------- var rr0 = Math.sqrt((y+ph/2)*(y+ph/2)+x*x); var rr1 = Math.sqrt((ph/2-y)*(ph/2-y)+x*x); if((rr0>r0 || rr1>r1) && !tear) { // we can tear off pages now:) // so reference points must be recalculated! if(y<sy) { // k1-gyel kell osszehasonlitani! var a = Math.asin((ph/2-y)/rr1); y = (ph/2-Math.sin(a)*r1); x = (x<0)? -Math.cos(a)*r1: Math.cos(a)*r1; if(y>sy) { if((sx*x)>0) y = sy, x = sx; else y = sy, x = -sx; } if((rr1-r1)>tlimit && ctear) { teard = -5; tear = true; tox = ox = x; toy = oy = y; } } else { // k0-val kell osszehasonlitani! var a = Math.asin((y+ph/2)/rr0); y = Math.sin(a)*r0-ph/2; x = (x<0)? -Math.cos(a)*r0: Math.cos(a)*r0; if(y<sy) { if((sx*x)>0) y = sy, x = sx; else y = sy, x = -sx; } if((rr0-r0)>tlimit && ctear) { teard = 5; tear = true; tox = ox = x; toy = oy = y; } } } if((sx<0 && (x-sx)<10) || (sx>0 && (sx-x)<10)) { if(sx<0) x = -pw+10; if(sx>0) x = pw-10; } //calculating flipping process pages.flip._visible = true; pages.flip.p3shadow._visible = pages.pgrad._visible = !tear; pages.flip.p2._visible = pages.flip.p3._visible = true; //equation of the line var vx = x-sx; var vy = y-sy; var a1 = vy/vx; var a2 = -vy/vx; cx = sx+(vx/2); cy = sy+(vy/2); //trigonometriai szamitasok //calculating rotation of the page, and the masks var r = Math.sqrt((sx-x)*(sx-x)+(sy-y)*(sy-y)); var a = Math.asin((sy-y)/r); if(sx<0) a = -a; ad = a/AM; //in degree pageN._rotation = ad*2; r = Math.sqrt((sx-x)*(sx-x)+(sy-y)*(sy-y)); rl = (pw*2); if(sx>0) { //flip forward pages.mask._xscale = 100; nx = cx-Math.tan(a)*(ph/2-cy); ny = ph/2; if(nx>pw) { nx = pw; ny = cy+Math.tan(Math.PI/2+a)*(pw-cx); } pageN.pf._x = -(pw-nx); pages.flip.fgrad._xscale = (r/rl/2)*pw; pages.pgrad._xscale = -(r/rl/2)*pw; pages.flip.p3shadow._xscale = (r/rl/2)*pw; } else { //flip backward pages.mask._xscale = -100; nx = cx-Math.tan(a)*(ph/2-cy); ny = ph/2; if(nx<-pw) { nx = -pw; ny = cy+Math.tan(Math.PI/2+a)*(-pw-cx); } pageN.pf._x = -(pw-(pw+nx)); pages.flip.fgrad._xscale = -(r/rl/2)*pw; pages.pgrad._xscale = (r/rl/2)*pw; pages.flip.p3shadow._xscale = -(r/rl/2)*pw; } 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 = (r>(rl-50))? 100-(r-(rl-50))*2: 100; pages.flip.p3shadow._x = cx; pages.flip.p3shadow._y = cy; pages.flip.p3shadow._rotation = ad; pages.flip.p3shadow._alpha = (r>(rl-50))? 100-(r-(rl-50))*2: 100; pages.pgrad._x = cx; pages.pgrad._y = cy; pages.pgrad._rotation = ad+180; pages.pgrad._alpha = (r>(rl-100))? 100-(r-(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;}function scalc(obj,x) { //hardflip calc if(x<-pw) x=-pw; if(x>pw) x=pw; var a = Math.asin( x/pw ); var rot = a/AM/2; var xs = 100; var ss = 100*Math.sin( rotz*AM ); x = x/2; var y = Math.cos(a)*(pw/2)*(ss/100); placeImg(obj, rot, ss, x, y) pages.pgrad._visible = pages.flip._visible = true; pages.pgrad._xscale = x; pages.pgrad._alpha = pages.flip.p3shadow._alpha = 100; pages.flip.p3shadow._xscale = -x; pages.flip.p3shadow._x = 0; pages.flip.p3shadow._y = 0; pages.flip.p3shadow._rotation = 0; pages.pgrad._x = 0; pages.pgrad._y = 0; pages.pgrad._rotation = 0;}function placeImg(j, rot, ss, x, y) { var m = Math.tan( rot*AM ); var f = Math.SQRT2/Math.sqrt(m*m+1); var phxs = 100*m; var phRot = -rot;; var xs = 100*f; var ys = 100*f; j.ph.pic._rotation = 45; j.ph.pic._xscale = (phxs<0)? - xs: xs; j.ph.pic._yscale = ys*(100/ss); j.ph._rotation = phRot; j.ph._xscale = phxs; j._yscale = ss; j._x = x; j._y = y; j._visible = true;}function setPages(p1,p2,p3,p4) { //attach the right page "image" at the right place:) p0 = p1-2; //pages for transparency... p5 = p4+2; if(p0<0) p0=0; if(p5>maxpage) p5=0; if(p1<0) p1=0; //visible pages if(p2<0) p2=0; if(p3<0) p3=0; if(p4<0) p4=0; trace("setpages ->"+p1+","+p2+","+p3+","+p4); pleft = pages.p1.page.pf.ph.attachMovie(pageOrder[p1],"pic",0); pages.p1.page.pf.ph._y = -ph/2; pleftb = pages.p0.page.pf.ph.attachMovie(pageOrder[p0],"pic",0); pages.p0.page.pf.ph._y = -ph/2; if(hflip) { //hardflip pages are specials!!! var tm = pages.flip.hfliph.attachMovie("sph","sp2",0); sp2 = tm.ph.pic.attachMovie(pageOrder[p2],"pic",0); sp2._y = -ph/2, sp2._x = -pw/2; sp2 = eval("pages.flip.hfliph.sp2"); var tm = pages.flip.hfliph.attachMovie("sph","sp3",1); sp3 = tm.ph.pic.attachMovie(pageOrder[p3],"pic",0); sp3._y = -ph/2, sp3._x = -pw/2; sp3 = eval("pages.flip.hfliph.sp3"); } else { pages.flip.hfliph.sp2.removeMovieClip(); pages.flip.hfliph.sp3.removeMovieClip(); sp2 = pages.flip.p2.page.pf.ph.attachMovie(pageOrder[p2],"pic",0); pages.flip.p2.page.pf.ph._y = -ph/2; sp3 = pages.flip.p3.page.pf.ph.attachMovie(pageOrder[p3],"pic",0); pages.flip.p3.page.pf.ph._y = -ph/2; } pright = pages.p4.page.pf.ph.attachMovie(pageOrder[p4],"pic",0); pages.p4.page.pf.ph._y = -ph/2; prightb = pages.p5.page.pf.ph.attachMovie(pageOrder[p5],"pic",0); pages.p5.page.pf.ph._y = -ph/2;}function resetPages() { setPages(page,0,0,page+1);} function autoflip() { //start auto flip! if(!aflip && !flip && !flipOff && canflip) { //only when all conditions fits our needs... acnt = 0 aamp = Math.random()*(ph/2)-(ph/4); var x= gflip? (gdir*pw)/2: ((pages._xmouse<0)? -pw/2: pw/2); //var y= Math.random()*ph-(ph/2); //random starty var y = Math.random()*(ph/2)-(ph/4); var pmh = ph/2; var r = Math.sqrt(x*x+y*y); var a = Math.asin(y/r); var yy = Math.tan(a)*pw; if(y>0 && y>ph/2) y = ph/2; if(y<0 && y<-ph/2) y = - ph/2; oy = sy = yy; ax = (pages._xmouse<0)? -pw/2: pw/2; var l = ((ph/2)-y); ay = y+((Math.random()*2*l)-l)/2; //page turnig style randomizing trace("autoflip from "+ax+","+ay); offs = -pw; var hit = 0; if(x<0 && page>0) { pages.flip.p3._x = 0; hflip = (hcover && gskip)? gtarget==0: checkCover(page,-1); if(!(preflip && hflip)) { if(gskip) setPages(gtarget,gtarget+1,page,page+1); else setPages(page-2,page-1,page,page+1); } hit = -1; } if(x>0 && page<maxpage) { pages.flip.p3._x = pw; hflip = (hcover && gskip)? gtarget==maxpage: checkCover(page,1); if(!(preflip && hflip)) { if(gskip) setPages(page,gtarget,page+1,gtarget+1); else setPages(page,page+2,page+1,page+3); } hit = 1; } if(hflip && preflip) { hit = 0; preflip = false; return false; } if(hit) { anim._visible = false; flip = true; flipOff = false; ox = sx = hit*pw; pages.flip.setMask(pages.mask); aadd = hit*(pw/(gflip? 5:10 )); //autoflip takes 10 frames to be done!!! aflip = true; pages.flip.fmask._x = pw; if(preflip) { oy = sy = (pages._ymouse<0)? -(ph/2): (ph/2); } r0 = Math.sqrt((sy+ph/2)*(sy+ph/2)+pw*pw); r1 = Math.sqrt((ph/2-sy)*(ph/2-sy)+pw*pw); pageN = eval("pages.flip.p2.page"); pageO = eval("pages.flip.p3"); oef(); return true; } } else return false;}function getm() { //get x,y reference points depending of turning style: manual/auto if(aflip && !preflip) { x = ax; y = ay; } else { x = pages._xmouse; y = pages._ymouse; }}function gotoPage(i,skip) { //quickjump to the page number i i = getPN(i); //i = target page gskip = (skip==undefined)? false: skip; //skip pages if(i<0) return false; var p = int(page/2); var d = int(i/2); if(p!=d && canflip && !gflip) { //target!=current page if(p<d) { //go forward gdir = 1; gpage = d-p-1; } else { //go backward gdir = -1 gpage = p-d-1; } gflip = true; if(gskip) gtarget = d*2, gpage = 0; autoflip(); } else gskip = false;}function getPN(i) { //get the right page number var find = false; for(j=1;j<=maxpage;j++) { if(i==pageNumber[j]) { i=j; find = true; break; } } if(find) return i; else return -1;}function removePage(i) { trace("remove page "+i); i = (Math.floor((i-1)/2)*2)+1; removedPages.push(pageNumber[i], pageNumber[i+1]); for(j=(i+2);j<=(maxPage+1);j++) { pageOrder[j-2]=pageOrder[j]; pageCanTear[j-2]=pageCanTear[j]; pageNumber[j-2]=pageNumber[j]; } trace("removed pages "+i+","+(i+1)); trace(removedPages.join(", ")); maxPage -= 2;}//------------------------------------------------------------------------------------------------ PUT YOUR CODE HERE --------------/* you can use these functions: gotoPage( destinationPageNo, skip ); //quick jump to the page number: destinationPageNo; values = 0-maxpages; skip: boolean; if true, pages will be skipped to the destination! autoflip(); //start autoflip (direction is calculated from _xmouse) canflip //it's a variable. setting its value to false disables flipping other functions of page turning is automatic; WARNING!!! if you want to unload/reload tha pageflip, before unloading call function: removeML(); to remove mouse listener!*/)[/url]////this code is written by Macc 2004.11.01//abel@iparigrafika.hu////sound added by Triqui - www.triquitips.com (great job Macc!!!)////this code is opensource////free use!//but a small credit would be nice:)//these values can be changed: -------------------------------------------------------------------------pw = 449; //page width in pixelph = 600; //page height in pixel //pages in the library must have the same size, the script will not resize them!//page data... (export names/tearing flag)addPage("start"); //Always start with "start"!!!addPage("page1");addPage("page2");addPage("page3");addPage("page4");addPage("page5");addPage("page6");addPage("page7");addPage("page8");addPage("page9");addPage("page10");addPage("page11",true); //second argument defines page tearing.addPage("page12",true);addPage("page13");addPage("page14");addPage("page15");addPage("page16");addPage("page17");addPage("page18");addPage("page19");addPage("page20");addPage("page21");addPage("page22");addPage("page23");addPage("page24");addPage("page25");addPage("page26");addPage("page27");addPage("page28");addPage("page29");addPage("page30");addPage("page31");addPage("page32");addPage("page33");addPage("page34");addPage("page35");addPage("page36");addPage("page37");addPage("page38");addPage("page39");addPage("page40");addPage("page41");addPage("page42");addPage("page43");addPage("page44");addPage("page45");addPage("page46");addPage("page47");addPage("page48");addPage("page49");addPage("page50");addPage("page51");addPage("page52");addPage("page53");addPage("page54");addPage("page55");addPage("page56");addPage("page57");addPage("page58");addPage("page59");addPage("page60");addPage("page61");addPage("page62");addPage("page63");addPage("page64");addPage("page65");addPage("page66");addPage("page67");addPage("page68");addPage("end"); //always end with "end"!!!page=0; //first page (normally it is 0 = the page before the cover = blank page)hcover = true; //hard cover on/offpage_sound = true; //sound on/offclickarea = 64; //pixel width of the click sensitive area at the edges..afa = 56; //width of the autoflip starter square.gs = 2; //goto page flip speedps = 5; //mouse pursuit speedes = 3; //flip speed after mouse btn releasecanflip = true; //page flipping enabled//do not change these values: ---------------------------------------------------------------------------------------------------------------------_global.mcnt = 0; //counter (used on a page where is an animation)gpage = 0; //gotoPage Nogflip = false; //gotoPage flipgdir = 0; //goto direction...gskip = false; //skip pages ***gtarget = 0; //target when skippingaflip = false; //auto flipflip = false; //pageflipflipOff = false; //terminateflipflipOK = false; //good fliphflip = false; //hardflip (the cover of the book)rotz = -30; //hardflip max y differencepreflip = false; //corner flip statusctear = false; //actual page statustear = false;teard = 0;tlimit = 80;removedPages = new Array(); //list of removed pages!mpx = 0, mpy = 0; //mousepos at clicksx = sy = 0; //startpoint when flippingx = 0; //mouse x,yy = 0;ax = 0; //auto x,yay = 0;acnt = 0;aadd = 0;aamp = 0;AM = Math.PI/180;//pageflip code by Macc ---------------------------------------------------------------------------------------------------------------------------function addPage(ename,tear) { //defining pages... ------------------------------------------------------------------------------------------- if(ename=="start") { pageOrder = new Array(); pageCanTear = new Array(); page=0; ename="blankpage"; } if(ename=="end") { maxpage = page-1; ename="blankpage"; } tear = tear==undefined? false: tear; pageOrder = ename; pageCanTear = tear; page++}function reset() { //initializing pages... --------------------------------------------------------------------------------------- pages.p0.page._x = -pw; pages.p0._x = 0; pages.p1.page._x = -pw; pages.p1._x = 0; pages.flip.p2.page._x = -pw; pages.flip.p2._x = pw; pages.flip.p3.page._x = -pw; pages.flip.p3._x = 0; pages.p4.page._x = -pw; pages.p4._x = pw; pages.p5.page._x = -pw; pages.p5._x = pw; pages.pgrad._visible = pages.mask._visible = pages.flip._visible = false; pages.flip.p3mask._width = pages.pgmask._width = pw*2; pages.center._height = pages.flip.p3mask._height = pages.pgmask._height = ph; pages.flip.fmask.page.pf._width = pw; pages.center._width = 6; pages.flip.fmask.page.pf._height = ph; pages.mask._height = pages.pgrad._height = pages.flip.p3shadow._height = pages.flip.flipgrad._height = 2*Math.sqrt(ph*ph+pw*pw); pageNumber = new Array(); for(i=0;i<=(maxpage+1);i++) pageNumber[i] = i;}mousecontroll = new Object(); //initializing mouse click handler ---------------------------------------------------------------------------mousecontroll.onMouseDown = function() { if(flip && !aflip) {// && !preflip) { flipOK = false; if(sx<0 && pages._xmouse>0) flipOK = true; if(sx>0 && pages._xmouse<0) flipOK = true; flipOff = true; flip = false; } else if((flipOff || aflip || !canflip) && !preflip) { trace("donothing"); } else { var oox = ox; var ooy = oy; var osx = sx; var osy = sy; var hit = hittest(); //hittest if(hit) { anim._visible = false; flip = true; flipOff = false; tear = false; //not tearing yet... ox = sx = hit*pw; if(preflip) { aflip = preflip = false; ox = oox, oy = ooy; sx = osx, sy = osy; } pages.flip.setMask(pages.mask); mpx = pages._xmouse, mpy = pages._ymouse; //_quality = "MEDIUM"; //it is the place to degrade image quality while turning pages if the performance is too low. } }}mousecontroll.onMouseUp = function() { if(flip && !tear) { if((Math.abs(pages._xmouse)>(pw-afa) && Math.abs(pages._ymouse)>(ph/2-afa) && Math.abs(pages._xmouse-mpx)<afa) || preflip) { flip = false; preflip = false; autoflip(); } else if(!preflip) { preflip = false; flipOK = false; if(sx<0 && pages._xmouse>0) flipOK = true; if(sx>0 && pages._xmouse<0) flipOK = true; flipOff = true; flip = false; } }}function hittest() { //hittest at mouse clicks, if click is over the book -> determining turning direction ------------------------------------ var x=pages._xmouse; var y=pages._ymouse; var pmh = ph/2; if(y<=pmh && y>=-pmh && x<=pw && x>=-pw) { //ha a megadott intervallumban klikkelunk, akkor lapozhatunk 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; if(y<0 && y<-ph/2) y = - ph/2; 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 = eval("pages.flip.p2.page"); pageO = eval("pages.flip.p3"); offs = -pw; pages.flip.fmask._x = pw; if(x<-(pw-clickarea) && page>0) { //>-----> flip backward pages.flip.p3._x = 0; hflip = checkCover(page,-1); setPages(page-2,page-1,page,page+1); ctear = pageCanTear[page-1]; return -1; } if(x>(pw-clickarea) && page<maxpage) { //<-----< flip forward pages.flip.p3._x = pw; hflip = checkCover(page,1); setPages(page,page+2,page+1,page+3); ctear = pageCanTear[page+2]; return 1; } } else return 0; //wrong click}function checkCover(p,dir) { if(hcover) { if(dir>0) { if(p==(maxpage-2) || p==0) return true; } else { if(p==maxpage || p==2) return true; } } return false; }function corner() { var x = Math.abs(pages._xmouse); var y = Math.abs(pages._ymouse); if(x>(pw-afa) && x<pw && y>(ph/2-afa) && y<(ph/2)) { return true; } return false;}function oef() { _global.mcnt++; //main counter incrase (need for some page effect); if(!flip && corner()) { //corner mouseover preflip = true; if(!autoflip()) preflip = false; } if(preflip && !corner()) { preflip = false; flip = false; flipOK = false; flipOff = true; } getm(); if(aflip && !preflip) { y = (ay += (sy-ay)/(gflip? gs: ps )); acnt += aadd; ax -= aadd; if(Math.abs(acnt)>pw) { flipOK = true; flipOff = true; flip = false; aflip = false; } } if(flip) { //page turning is in progress... if(tear) { if (page_sound){ if (page_effect <> 1){ triquisound = new Sound(this); triquisound.attachSound("pagetear"); triquisound.start(0, 1); page_effect = 1; } } x = tox; y = (toy += teard); teard *= 1.2; if(Math.abs(teard)>1200) { flipOff = true; flip = false; } } else { x = (ox += (x-ox)/(gflip? gs: ps )); y = (oy += (y-oy)/(gflip? gs: ps )); } calc(x,y); //positioning pages and shadows } if(flipOff) { //terminating page turning effect... (comlplete turning... dropped on the other side) if(flipOK || tear) { if (page_sound){ if (page_effect <> 1){ triquisound = new Sound(this); triquisound.attachSound("pageflip"); triquisound.start(0, 1); page_effect = 1; } } x = (ox += (-sx-ox)/(gflip? gs: es )); y = (oy += (sy-oy)/(gflip? gs: es )); calc(x,y); if(x/-sx > 0.99 || tear) { //we are done with turning, so stop all turning issue... flip = false; page_effect = 0; flipOK = flipOff = false; pages.pgrad._visible = pages.flip._visible = false; //_quality = "BEST"; //if quality is decrased during turning effect, you must reset its default value! if(tear) { //if tear: remove page!!! removePage((sx<0)? page: page+1); page += (sx<0)? -2: 0; } else { page += (sx<0)? -2: 2; //and tourning pages at pagenumber level... } if(gskip) page = gtarget; setPages(page,0,0,page+1); tear = false; if(gpage>0 && !gskip) { //gotoflip active -> is there another flipping left? gpage--; autoflip(); } else gflip = gskip = false; } } else { //terminating page turning effect... (incomlplete turning... dropped on the dragged side) x = (ox += (sx-ox)/3); y = (oy += (sy-oy)/3); calc(x,y); if(x/sx > 0.99) { //we are done with turning, so stop all turning issue... flip = false; flipOff = false; aflip = false; pages.pgrad._visible = pages.flip._visible = false; //_quality = "HIGH"; //if quality is decrased during turning effect, you must reset its default value! setPages(page,0,0,page+1); //no change at pagenumbers.. } } }}function calc(x,y) { //positioning pages and shadows by x,y reference points -------------------------------------------------- if(hflip) { //hardflip... var xp = (sx<0)? -x: x; if(xp>0) { sp2._visible = false; sp3._visible = true; scalc(sp3,x); } else { sp3._visible = false; sp2._visible = true; scalc(sp2,x); } pages.flip.setMask(null); pages.flip._visible = true; pages.flip.fgrad._visible = false; pages.flip.p2._visible = pages.flip.p3._visible = false; return; } else pages.flip.fgrad._visible = true; //normal flipping process--------------------------------------------------------------------- var rr0 = Math.sqrt((y+ph/2)*(y+ph/2)+x*x); var rr1 = Math.sqrt((ph/2-y)*(ph/2-y)+x*x); if((rr0>r0 || rr1>r1) && !tear) { // we can tear off pages now:) // so reference points must be recalculated! if(y<sy) { // k1-gyel kell osszehasonlitani! var a = Math.asin((ph/2-y)/rr1); y = (ph/2-Math.sin(a)*r1); x = (x<0)? -Math.cos(a)*r1: Math.cos(a)*r1; if(y>sy) { if((sx*x)>0) y = sy, x = sx; else y = sy, x = -sx; } if((rr1-r1)>tlimit && ctear) { teard = -5; tear = true; tox = ox = x; toy = oy = y; } } else { // k0-val kell osszehasonlitani! var a = Math.asin((y+ph/2)/rr0); y = Math.sin(a)*r0-ph/2; x = (x<0)? -Math.cos(a)*r0: Math.cos(a)*r0; if(y<sy) { if((sx*x)>0) y = sy, x = sx; else y = sy, x = -sx; } if((rr0-r0)>tlimit && ctear) { teard = 5; tear = true; tox = ox = x; toy = oy = y; } } } if((sx<0 && (x-sx)<10) || (sx>0 && (sx-x)<10)) { if(sx<0) x = -pw+10; if(sx>0) x = pw-10; } //calculating flipping process pages.flip._visible = true; pages.flip.p3shadow._visible = pages.pgrad._visible = !tear; pages.flip.p2._visible = pages.flip.p3._visible = true; //equation of the line var vx = x-sx; var vy = y-sy; var a1 = vy/vx; var a2 = -vy/vx; cx = sx+(vx/2); cy = sy+(vy/2); //trigonometriai szamitasok //calculating rotation of the page, and the masks var r = Math.sqrt((sx-x)*(sx-x)+(sy-y)*(sy-y)); var a = Math.asin((sy-y)/r); if(sx<0) a = -a; ad = a/AM; //in degree pageN._rotation = ad*2; r = Math.sqrt((sx-x)*(sx-x)+(sy-y)*(sy-y)); rl = (pw*2); if(sx>0) { //flip forward pages.mask._xscale = 100; nx = cx-Math.tan(a)*(ph/2-cy); ny = ph/2; if(nx>pw) { nx = pw; ny = cy+Math.tan(Math.PI/2+a)*(pw-cx); } pageN.pf._x = -(pw-nx); pages.flip.fgrad._xscale = (r/rl/2)*pw; pages.pgrad._xscale = -(r/rl/2)*pw; pages.flip.p3shadow._xscale = (r/rl/2)*pw; } else { //flip backward pages.mask._xscale = -100; nx = cx-Math.tan(a)*(ph/2-cy); ny = ph/2; if(nx<-pw) { nx = -pw; ny = cy+Math.tan(Math.PI/2+a)*(-pw-cx); } pageN.pf._x = -(pw-(pw+nx)); pages.flip.fgrad._xscale = -(r/rl/2)*pw; pages.pgrad._xscale = (r/rl/2)*pw; pages.flip.p3shadow._xscale = -(r/rl/2)*pw; } 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 = (r>(rl-50))? 100-(r-(rl-50))*2: 100; pages.flip.p3shadow._x = cx; pages.flip.p3shadow._y = cy; pages.flip.p3shadow._rotation = ad; pages.flip.p3shadow._alpha = (r>(rl-50))? 100-(r-(rl-50))*2: 100; pages.pgrad._x = cx; pages.pgrad._y = cy; pages.pgrad._rotation = ad+180; pages.pgrad._alpha = (r>(rl-100))? 100-(r-(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;}function scalc(obj,x) { //hardflip calc if(x<-pw) x=-pw; if(x>pw) x=pw; var a = Math.asin( x/pw ); var rot = a/AM/2; var xs = 100; var ss = 100*Math.sin( rotz*AM ); x = x/2; var y = Math.cos(a)*(pw/2)*(ss/100); placeImg(obj, rot, ss, x, y) pages.pgrad._visible = pages.flip._visible = true; pages.pgrad._xscale = x; pages.pgrad._alpha = pages.flip.p3shadow._alpha = 100; pages.flip.p3shadow._xscale = -x; pages.flip.p3shadow._x = 0; pages.flip.p3shadow._y = 0; pages.flip.p3shadow._rotation = 0; pages.pgrad._x = 0; pages.pgrad._y = 0; pages.pgrad._rotation = 0;}function placeImg(j, rot, ss, x, y) { var m = Math.tan( rot*AM ); var f = Math.SQRT2/Math.sqrt(m*m+1); var phxs = 100*m; var phRot = -rot;; var xs = 100*f; var ys = 100*f; j.ph.pic._rotation = 45; j.ph.pic._xscale = (phxs<0)? - xs: xs; j.ph.pic._yscale = ys*(100/ss); j.ph._rotation = phRot; j.ph._xscale = phxs; j._yscale = ss; j._x = x; j._y = y; j._visible = true;}function setPages(p1,p2,p3,p4) { //attach the right page "image" at the right place:) p0 = p1-2; //pages for transparency... p5 = p4+2; if(p0<0) p0=0; if(p5>maxpage) p5=0; if(p1<0) p1=0; //visible pages if(p2<0) p2=0; if(p3<0) p3=0; if(p4<0) p4=0; trace("setpages ->"+p1+","+p2+","+p3+","+p4); pleft = pages.p1.page.pf.ph.attachMovie(pageOrder[p1],"pic",0); pages.p1.page.pf.ph._y = -ph/2; pleftb = pages.p0.page.pf.ph.attachMovie(pageOrder[p0],"pic",0); pages.p0.page.pf.ph._y = -ph/2; if(hflip) { //hardflip pages are specials!!! var tm = pages.flip.hfliph.attachMovie("sph","sp2",0); sp2 = tm.ph.pic.attachMovie(pageOrder[p2],"pic",0); sp2._y = -ph/2, sp2._x = -pw/2; sp2 = eval("pages.flip.hfliph.sp2"); var tm = pages.flip.hfliph.attachMovie("sph","sp3",1); sp3 = tm.ph.pic.attachMovie(pageOrder[p3],"pic",0); sp3._y = -ph/2, sp3._x = -pw/2; sp3 = eval("pages.flip.hfliph.sp3"); } else { pages.flip.hfliph.sp2.removeMovieClip(); pages.flip.hfliph.sp3.removeMovieClip(); sp2 = pages.flip.p2.page.pf.ph.attachMovie(pageOrder[p2],"pic",0); pages.flip.p2.page.pf.ph._y = -ph/2; sp3 = pages.flip.p3.page.pf.ph.attachMovie(pageOrder[p3],"pic",0); pages.flip.p3.page.pf.ph._y = -ph/2; } pright = pages.p4.page.pf.ph.attachMovie(pageOrder[p4],"pic",0); pages.p4.page.pf.ph._y = -ph/2; prightb = pages.p5.page.pf.ph.attachMovie(pageOrder[p5],"pic",0); pages.p5.page.pf.ph._y = -ph/2;}function resetPages() { setPages(page,0,0,page+1);} function autoflip() { //start auto flip! if(!aflip && !flip && !flipOff && canflip) { //only when all conditions fits our needs... acnt = 0 aamp = Math.random()*(ph/2)-(ph/4); var x= gflip? (gdir*pw)/2: ((pages._xmouse<0)? -pw/2: pw/2); //var y= Math.random()*ph-(ph/2); //random starty var y = Math.random()*(ph/2)-(ph/4); var pmh = ph/2; var r = Math.sqrt(x*x+y*y); var a = Math.asin(y/r); var yy = Math.tan(a)*pw; if(y>0 && y>ph/2) y = ph/2; if(y<0 && y<-ph/2) y = - ph/2; oy = sy = yy; ax = (pages._xmouse<0)? -pw/2: pw/2; var l = ((ph/2)-y); ay = y+((Math.random()*2*l)-l)/2; //page turnig style randomizing trace("autoflip from "+ax+","+ay); offs = -pw; var hit = 0; if(x<0 && page>0) { pages.flip.p3._x = 0; hflip = (hcover && gskip)? gtarget==0: checkCover(page,-1); if(!(preflip && hflip)) { if(gskip) setPages(gtarget,gtarget+1,page,page+1); else setPages(page-2,page-1,page,page+1); } hit = -1; } if(x>0 && page<maxpage) { pages.flip.p3._x = pw; hflip = (hcover && gskip)? gtarget==maxpage: checkCover(page,1); if(!(preflip && hflip)) { if(gskip) setPages(page,gtarget,page+1,gtarget+1); else setPages(page,page+2,page+1,page+3); } hit = 1; } if(hflip && preflip) { hit = 0; preflip = false; return false; } if(hit) { anim._visible = false; flip = true; flipOff = false; ox = sx = hit*pw; pages.flip.setMask(pages.mask); aadd = hit*(pw/(gflip? 5:10 )); //autoflip takes 10 frames to be done!!! aflip = true; pages.flip.fmask._x = pw; if(preflip) { oy = sy = (pages._ymouse<0)? -(ph/2): (ph/2); } r0 = Math.sqrt((sy+ph/2)*(sy+ph/2)+pw*pw); r1 = Math.sqrt((ph/2-sy)*(ph/2-sy)+pw*pw); pageN = eval("pages.flip.p2.page"); pageO = eval("pages.flip.p3"); oef(); return true; } } else return false;}function getm() { //get x,y reference points depending of turning style: manual/auto if(aflip && !preflip) { x = ax; y = ay; } else { x = pages._xmouse; y = pages._ymouse; }}function gotoPage(i,skip) { //quickjump to the page number i i = getPN(i); //i = target page gskip = (skip==undefined)? false: skip; //skip pages if(i<0) return false; var p = int(page/2); var d = int(i/2); if(p!=d && canflip && !gflip) { //target!=current page if(p<d) { //go forward gdir = 1; gpage = d-p-1; } else { //go backward gdir = -1 gpage = p-d-1; } gflip = true; if(gskip) gtarget = d*2, gpage = 0; autoflip(); } else gskip = false;}function getPN(i) { //get the right page number var find = false; for(j=1;j<=maxpage;j++) { if(i==pageNumber[j]) { i=j; find = true; break; } } if(find) return i; else return -1;}function removePage(i) { trace("remove page "+i); i = (Math.floor((i-1)/2)*2)+1; removedPages.push(pageNumber[i], pageNumber[i+1]); for(j=(i+2);j<=(maxPage+1);j++) { pageOrder[j-2]=pageOrder[j]; pageCanTear[j-2]=pageCanTear[j]; pageNumber[j-2]=pageNumber[j]; } trace("removed pages "+i+","+(i+1)); trace(removedPages.join(", ")); maxPage -= 2;}//------------------------------------------------------------------------------------------------ PUT YOUR CODE HERE --------------/* you can use these functions: gotoPage( destinationPageNo, skip ); //quick jump to the page number: destinationPageNo; values = 0-maxpages; skip: boolean; if true, pages will be skipped to the destination! autoflip(); //start autoflip (direction is calculated from _xmouse) canflip //it's a variable. setting its value to false disables flipping other functions of page turning is automatic; WARNING!!! if you want to unload/reload tha pageflip, before unloading call function: removeML(); to remove mouse listener!*/)[/url]////this code is written by Macc 2004.11.01//abel@iparigrafika.hu////sound added by Triqui - www.triquitips.com (great job Macc!!!)////this code is opensource////free use!//but a small credit would be nice:)//these values can be changed: -------------------------------------------------------------------------pw = 449; //page width in pixelph = 600; //page height in pixel //pages in the library must have the same size, the script will not resize them!//page data... (export names/tearing flag)addPage("start"); //Always start with "start"!!!addPage("page1");addPage("page2");addPage("page3");addPage("page4");addPage("page5");addPage("page6");addPage("page7");addPage("page8");addPage("page9");addPage("page10");addPage("page11",true); //second argument defines page tearing.addPage("page12",true);addPage("page13");addPage("page14");addPage("page15");addPage("page16");addPage("page17");addPage("page18");addPage("page19");addPage("page20");addPage("page21");addPage("page22");addPage("page23");addPage("page24");addPage("page25");addPage("page26");addPage("page27");addPage("page28");addPage("page29");addPage("page30");addPage("page31");addPage("page32");addPage("page33");addPage("page34");addPage("page35");addPage("page36");addPage("page37");addPage("page38");addPage("page39");addPage("page40");addPage("page41");addPage("page42");addPage("page43");addPage("page44");addPage("page45");addPage("page46");addPage("page47");addPage("page48");addPage("page49");addPage("page50");addPage("page51");addPage("page52");addPage("page53");addPage("page54");addPage("page55");addPage("page56");addPage("page57");addPage("page58");addPage("page59");addPage("page60");addPage("page61");addPage("page62");addPage("page63");addPage("page64");addPage("page65");addPage("page66");addPage("page67");addPage("page68");addPage("end"); //always end with "end"!!!page=0; //first page (normally it is 0 = the page before the cover = blank page)hcover = true; //hard cover on/offpage_sound = true; //sound on/offclickarea = 64; //pixel width of the click sensitive area at the edges..afa = 56; //width of the autoflip starter square.gs = 2; //goto page flip speedps = 5; //mouse pursuit speedes = 3; //flip speed after mouse btn releasecanflip = true; //page flipping enabled//do not change these values: ---------------------------------------------------------------------------------------------------------------------_global.mcnt = 0; //counter (used on a page where is an animation)gpage = 0; //gotoPage Nogflip = false; //gotoPage flipgdir = 0; //goto direction...gskip = false; //skip pages ***gtarget = 0; //target when skippingaflip = false; //auto flipflip = false; //pageflipflipOff = false; //terminateflipflipOK = false; //good fliphflip = false; //hardflip (the cover of the book)rotz = -30; //hardflip max y differencepreflip = false; //corner flip statusctear = false; //actual page statustear = false;teard = 0;tlimit = 80;removedPages = new Array(); //list of removed pages!mpx = 0, mpy = 0; //mousepos at clicksx = sy = 0; //startpoint when flippingx = 0; //mouse x,yy = 0;ax = 0; //auto x,yay = 0;acnt = 0;aadd = 0;aamp = 0;AM = Math.PI/180;//pageflip code by Macc ---------------------------------------------------------------------------------------------------------------------------function addPage(ename,tear) { //defining pages... ------------------------------------------------------------------------------------------- if(ename=="start") { pageOrder = new Array(); pageCanTear = new Array(); page=0; ename="blankpage"; } if(ename=="end") { maxpage = page-1; ename="blankpage"; } tear = tear==undefined? false: tear; pageOrder = ename; pageCanTear = tear; page++}function reset() { //initializing pages... --------------------------------------------------------------------------------------- pages.p0.page._x = -pw; pages.p0._x = 0; pages.p1.page._x = -pw; pages.p1._x = 0; pages.flip.p2.page._x = -pw; pages.flip.p2._x = pw; pages.flip.p3.page._x = -pw; pages.flip.p3._x = 0; pages.p4.page._x = -pw; pages.p4._x = pw; pages.p5.page._x = -pw; pages.p5._x = pw; pages.pgrad._visible = pages.mask._visible = pages.flip._visible = false; pages.flip.p3mask._width = pages.pgmask._width = pw*2; pages.center._height = pages.flip.p3mask._height = pages.pgmask._height = ph; pages.flip.fmask.page.pf._width = pw; pages.center._width = 6; pages.flip.fmask.page.pf._height = ph; pages.mask._height = pages.pgrad._height = pages.flip.p3shadow._height = pages.flip.flipgrad._height = 2*Math.sqrt(ph*ph+pw*pw); pageNumber = new Array(); for(i=0;i<=(maxpage+1);i++) pageNumber[i] = i;}mousecontroll = new Object(); //initializing mouse click handler ---------------------------------------------------------------------------mousecontroll.onMouseDown = function() { if(flip && !aflip) {// && !preflip) { flipOK = false; if(sx<0 && pages._xmouse>0) flipOK = true; if(sx>0 && pages._xmouse<0) flipOK = true; flipOff = true; flip = false; } else if((flipOff || aflip || !canflip) && !preflip) { trace("donothing"); } else { var oox = ox; var ooy = oy; var osx = sx; var osy = sy; var hit = hittest(); //hittest if(hit) { anim._visible = false; flip = true; flipOff = false; tear = false; //not tearing yet... ox = sx = hit*pw; if(preflip) { aflip = preflip = false; ox = oox, oy = ooy; sx = osx, sy = osy; } pages.flip.setMask(pages.mask); mpx = pages._xmouse, mpy = pages._ymouse; //_quality = "MEDIUM"; //it is the place to degrade image quality while turning pages if the performance is too low. } }}mousecontroll.onMouseUp = function() { if(flip && !tear) { if((Math.abs(pages._xmouse)>(pw-afa) && Math.abs(pages._ymouse)>(ph/2-afa) && Math.abs(pages._xmouse-mpx)<afa) || preflip) { flip = false; preflip = false; autoflip(); } else if(!preflip) { preflip = false; flipOK = false; if(sx<0 && pages._xmouse>0) flipOK = true; if(sx>0 && pages._xmouse<0) flipOK = true; flipOff = true; flip = false; } }}function hittest() { //hittest at mouse clicks, if click is over the book -> determining turning direction ------------------------------------ var x=pages._xmouse; var y=pages._ymouse; var pmh = ph/2; if(y<=pmh && y>=-pmh && x<=pw && x>=-pw) { //ha a megadott intervallumban klikkelunk, akkor lapozhatunk 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; if(y<0 && y<-ph/2) y = - ph/2; 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 = eval("pages.flip.p2.page"); pageO = eval("pages.flip.p3"); offs = -pw; pages.flip.fmask._x = pw; if(x<-(pw-clickarea) && page>0) { //>-----> flip backward pages.flip.p3._x = 0; hflip = checkCover(page,-1); setPages(page-2,page-1,page,page+1); ctear = pageCanTear[page-1]; return -1; } if(x>(pw-clickarea) && page<maxpage) { //<-----< flip forward pages.flip.p3._x = pw; hflip = checkCover(page,1); setPages(page,page+2,page+1,page+3); ctear = pageCanTear[page+2]; return 1; } } else return 0; //wrong click}function checkCover(p,dir) { if(hcover) { if(dir>0) { if(p==(maxpage-2) || p==0) return true; } else { if(p==maxpage || p==2) return true; } } return false; }function corner() { var x = Math.abs(pages._xmouse); var y = Math.abs(pages._ymouse); if(x>(pw-afa) && x<pw && y>(ph/2-afa) && y<(ph/2)) { return true; } return false;}function oef() { _global.mcnt++; //main counter incrase (need for some page effect); if(!flip && corner()) { //corner mouseover preflip = true; if(!autoflip()) preflip = false; } if(preflip && !corner()) { preflip = false; flip = false; flipOK = false; flipOff = true; } getm(); if(aflip && !preflip) { y = (ay += (sy-ay)/(gflip? gs: ps )); acnt += aadd; ax -= aadd; if(Math.abs(acnt)>pw) { flipOK = true; flipOff = true; flip = false; aflip = false; } } if(flip) { //page turning is in progress... if(tear) { if (page_sound){ if (page_effect <> 1){ triquisound = new Sound(this); triquisound.attachSound("pagetear"); triquisound.start(0, 1); page_effect = 1; } } x = tox; y = (toy += teard); teard *= 1.2; if(Math.abs(teard)>1200) { flipOff = true; flip = false; } } else { x = (ox += (x-ox)/(gflip? gs: ps )); y = (oy += (y-oy)/(gflip? gs: ps )); } calc(x,y); //positioning pages and shadows } if(flipOff) { //terminating page turning effect... (comlplete turning... dropped on the other side) if(flipOK || tear) { if (page_sound){ if (page_effect <> 1){ triquisound = new Sound(this); triquisound.attachSound("pageflip"); triquisound.start(0, 1); page_effect = 1; } } x = (ox += (-sx-ox)/(gflip? gs: es )); y = (oy += (sy-oy)/(gflip? gs: es )); calc(x,y); if(x/-sx > 0.99 || tear) { //we are done with turning, so stop all turning issue... flip = false; page_effect = 0; flipOK = flipOff = false; pages.pgrad._visible = pages.flip._visible = false; //_quality = "BEST"; //if quality is decrased during turning effect, you must reset its default value! if(tear) { //if tear: remove page!!! removePage((sx<0)? page: page+1); page += (sx<0)? -2: 0; } else { page += (sx<0)? -2: 2; //and tourning pages at pagenumber level... } if(gskip) page = gtarget; setPages(page,0,0,page+1); tear = false; if(gpage>0 && !gskip) { //gotoflip active -> is there another flipping left? gpage--; autoflip(); } else gflip = gskip = false; } } else { //terminating page turning effect... (incomlplete turning... dropped on the dragged side) x = (ox += (sx-ox)/3); y = (oy += (sy-oy)/3); calc(x,y); if(x/sx > 0.99) { //we are done with turning, so stop all turning issue... flip = false; flipOff = false; aflip = false; pages.pgrad._visible = pages.flip._visible = false; //_quality = "HIGH"; //if quality is decrased during turning effect, you must reset its default value! setPages(page,0,0,page+1); //no change at pagenumbers.. } } }}function calc(x,y) { //positioning pages and shadows by x,y reference points -------------------------------------------------- if(hflip) { //hardflip... var xp = (sx<0)? -x: x; if(xp>0) { sp2._visible = false; sp3._visible = true; scalc(sp3,x); } else { sp3._visible = false; sp2._visible = true; scalc(sp2,x); } pages.flip.setMask(null); pages.flip._visible = true; pages.flip.fgrad._visible = false; pages.flip.p2._visible = pages.flip.p3._visible = false; return; } else pages.flip.fgrad._visible = true; //normal flipping process--------------------------------------------------------------------- var rr0 = Math.sqrt((y+ph/2)*(y+ph/2)+x*x); var rr1 = Math.sqrt((ph/2-y)*(ph/2-y)+x*x); if((rr0>r0 || rr1>r1) && !tear) { // we can tear off pages now:) // so reference points must be recalculated! if(y<sy) { // k1-gyel kell osszehasonlitani! var a = Math.asin((ph/2-y)/rr1); y = (ph/2-Math.sin(a)*r1); x = (x<0)? -Math.cos(a)*r1: Math.cos(a)*r1; if(y>sy) { if((sx*x)>0) y = sy, x = sx; else y = sy, x = -sx; } if((rr1-r1)>tlimit && ctear) { teard = -5; tear = true; tox = ox = x; toy = oy = y; } } else { // k0-val kell osszehasonlitani! var a = Math.asin((y+ph/2)/rr0); y = Math.sin(a)*r0-ph/2; x = (x<0)? -Math.cos(a)*r0: Math.cos(a)*r0; if(y<sy) { if((sx*x)>0) y = sy, x = sx; else y = sy, x = -sx; } if((rr0-r0)>tlimit && ctear) { teard = 5; tear = true; tox = ox = x; toy = oy = y; } } } if((sx<0 && (x-sx)<10) || (sx>0 && (sx-x)<10)) { if(sx<0) x = -pw+10; if(sx>0) x = pw-10; } //calculating flipping process pages.flip._visible = true; pages.flip.p3shadow._visible = pages.pgrad._visible = !tear; pages.flip.p2._visible = pages.flip.p3._visible = true; //equation of the line var vx = x-sx; var vy = y-sy; var a1 = vy/vx; var a2 = -vy/vx; cx = sx+(vx/2); cy = sy+(vy/2); //trigonometriai szamitasok //calculating rotation of the page, and the masks var r = Math.sqrt((sx-x)*(sx-x)+(sy-y)*(sy-y)); var a = Math.asin((sy-y)/r); if(sx<0) a = -a; ad = a/AM; //in degree pageN._rotation = ad*2; r = Math.sqrt((sx-x)*(sx-x)+(sy-y)*(sy-y)); rl = (pw*2); if(sx>0) { //flip forward pages.mask._xscale = 100; nx = cx-Math.tan(a)*(ph/2-cy); ny = ph/2; if(nx>pw) { nx = pw; ny = cy+Math.tan(Math.PI/2+a)*(pw-cx); } pageN.pf._x = -(pw-nx); pages.flip.fgrad._xscale = (r/rl/2)*pw; pages.pgrad._xscale = -(r/rl/2)*pw; pages.flip.p3shadow._xscale = (r/rl/2)*pw; } else { //flip backward pages.mask._xscale = -100; nx = cx-Math.tan(a)*(ph/2-cy); ny = ph/2; if(nx<-pw) { nx = -pw; ny = cy+Math.tan(Math.PI/2+a)*(-pw-cx); } pageN.pf._x = -(pw-(pw+nx)); pages.flip.fgrad._xscale = -(r/rl/2)*pw; pages.pgrad._xscale = (r/rl/2)*pw; pages.flip.p3shadow._xscale = -(r/rl/2)*pw; } 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 = (r>(rl-50))? 100-(r-(rl-50))*2: 100; pages.flip.p3shadow._x = cx; pages.flip.p3shadow._y = cy; pages.flip.p3shadow._rotation = ad; pages.flip.p3shadow._alpha = (r>(rl-50))? 100-(r-(rl-50))*2: 100; pages.pgrad._x = cx; pages.pgrad._y = cy; pages.pgrad._rotation = ad+180; pages.pgrad._alpha = (r>(rl-100))? 100-(r-(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;}function scalc(obj,x) { //hardflip calc if(x<-pw) x=-pw; if(x>pw) x=pw; var a = Math.asin( x/pw ); var rot = a/AM/2; var xs = 100; var ss = 100*Math.sin( rotz*AM ); x = x/2; var y = Math.cos(a)*(pw/2)*(ss/100); placeImg(obj, rot, ss, x, y) pages.pgrad._visible = pages.flip._visible = true; pages.pgrad._xscale = x; pages.pgrad._alpha = pages.flip.p3shadow._alpha = 100; pages.flip.p3shadow._xscale = -x; pages.flip.p3shadow._x = 0; pages.flip.p3shadow._y = 0; pages.flip.p3shadow._rotation = 0; pages.pgrad._x = 0; pages.pgrad._y = 0; pages.pgrad._rotation = 0;}function placeImg(j, rot, ss, x, y) { var m = Math.tan( rot*AM ); var f = Math.SQRT2/Math.sqrt(m*m+1); var phxs = 100*m; var phRot = -rot;; var xs = 100*f; var ys = 100*f; j.ph.pic._rotation = 45; j.ph.pic._xscale = (phxs<0)? - xs: xs; j.ph.pic._yscale = ys*(100/ss); j.ph._rotation = phRot; j.ph._xscale = phxs; j._yscale = ss; j._x = x; j._y = y; j._visible = true;}function setPages(p1,p2,p3,p4) { //attach the right page "image" at the right place:) p0 = p1-2; //pages for transparency... p5 = p4+2; if(p0<0) p0=0; if(p5>maxpage) p5=0; if(p1<0) p1=0; //visible pages if(p2<0) p2=0; if(p3<0) p3=0; if(p4<0) p4=0; trace("setpages ->"+p1+","+p2+","+p3+","+p4); pleft = pages.p1.page.pf.ph.attachMovie(pageOrder[p1],"pic",0); pages.p1.page.pf.ph._y = -ph/2; pleftb = pages.p0.page.pf.ph.attachMovie(pageOrder[p0],"pic",0); pages.p0.page.pf.ph._y = -ph/2; if(hflip) { //hardflip pages are specials!!! var tm = pages.flip.hfliph.attachMovie("sph","sp2",0); sp2 = tm.ph.pic.attachMovie(pageOrder[p2],"pic",0); sp2._y = -ph/2, sp2._x = -pw/2; sp2 = eval("pages.flip.hfliph.sp2"); var tm = pages.flip.hfliph.attachMovie("sph","sp3",1); sp3 = tm.ph.pic.attachMovie(pageOrder[p3],"pic",0); sp3._y = -ph/2, sp3._x = -pw/2; sp3 = eval("pages.flip.hfliph.sp3"); } else { pages.flip.hfliph.sp2.removeMovieClip(); pages.flip.hfliph.sp3.removeMovieClip(); sp2 = pages.flip.p2.page.pf.ph.attachMovie(pageOrder[p2],"pic",0); pages.flip.p2.page.pf.ph._y = -ph/2; sp3 = pages.flip.p3.page.pf.ph.attachMovie(pageOrder[p3],"pic",0); pages.flip.p3.page.pf.ph._y = -ph/2; } pright = pages.p4.page.pf.ph.attachMovie(pageOrder[p4],"pic",0); pages.p4.page.pf.ph._y = -ph/2; prightb = pages.p5.page.pf.ph.attachMovie(pageOrder[p5],"pic",0); pages.p5.page.pf.ph._y = -ph/2;}function resetPages() { setPages(page,0,0,page+1);} function autoflip() { //start auto flip! if(!aflip && !flip && !flipOff && canflip) { //only when all conditions fits our needs... acnt = 0 aamp = Math.random()*(ph/2)-(ph/4); var x= gflip? (gdir*pw)/2: ((pages._xmouse<0)? -pw/2: pw/2); //var y= Math.random()*ph-(ph/2); //random starty var y = Math.random()*(ph/2)-(ph/4); var pmh = ph/2; var r = Math.sqrt(x*x+y*y); var a = Math.asin(y/r); var yy = Math.tan(a)*pw; if(y>0 && y>ph/2) y = ph/2; if(y<0 && y<-ph/2) y = - ph/2; oy = sy = yy; ax = (pages._xmouse<0)? -pw/2: pw/2; var l = ((ph/2)-y); ay = y+((Math.random()*2*l)-l)/2; //page turnig style randomizing trace("autoflip from "+ax+","+ay); offs = -pw; var hit = 0; if(x<0 && page>0) { pages.flip.p3._x = 0; hflip = (hcover && gskip)? gtarget==0: checkCover(page,-1); if(!(preflip && hflip)) { if(gskip) setPages(gtarget,gtarget+1,page,page+1); else setPages(page-2,page-1,page,page+1); } hit = -1; } if(x>0 && page<maxpage) { pages.flip.p3._x = pw; hflip = (hcover && gskip)? gtarget==maxpage: checkCover(page,1); if(!(preflip && hflip)) { if(gskip) setPages(page,gtarget,page+1,gtarget+1); else setPages(page,page+2,page+1,page+3); } hit = 1; } if(hflip && preflip) { hit = 0; preflip = false; return false; } if(hit) { anim._visible = false; flip = true; flipOff = false; ox = sx = hit*pw; pages.flip.setMask(pages.mask); aadd = hit*(pw/(gflip? 5:10 )); //autoflip takes 10 frames to be done!!! aflip = true; pages.flip.fmask._x = pw; if(preflip) { oy = sy = (pages._ymouse<0)? -(ph/2): (ph/2); } r0 = Math.sqrt((sy+ph/2)*(sy+ph/2)+pw*pw); r1 = Math.sqrt((ph/2-sy)*(ph/2-sy)+pw*pw); pageN = eval("pages.flip.p2.page"); pageO = eval("pages.flip.p3"); oef(); return true; } } else return false;}function getm() { //get x,y reference points depending of turning style: manual/auto if(aflip && !preflip) { x = ax; y = ay; } else { x = pages._xmouse; y = pages._ymouse; }}function gotoPage(i,skip) { //quickjump to the page number i i = getPN(i); //i = target page gskip = (skip==undefined)? false: skip; //skip pages if(i<0) return false; var p = int(page/2); var d = int(i/2); if(p!=d && canflip && !gflip) { //target!=current page if(p<d) { //go forward gdir = 1; gpage = d-p-1; } else { //go backward gdir = -1 gpage = p-d-1; } gflip = true; if(gskip) gtarget = d*2, gpage = 0; autoflip(); } else gskip = false;}function getPN(i) { //get the right page number var find = false; for(j=1;j<=maxpage;j++) { if(i==pageNumber[j]) { i=j; find = true; break; } } if(find) return i; else return -1;}function removePage(i) { trace("remove page "+i); i = (Math.floor((i-1)/2)*2)+1; removedPages.push(pageNumber[i], pageNumber[i+1]); for(j=(i+2);j<=(maxPage+1);j++) { pageOrder[j-2]=pageOrder[j]; pageCanTear[j-2]=pageCanTear[j]; pageNumber[j-2]=pageNumber[j]; } trace("removed pages "+i+","+(i+1)); trace(removedPages.join(", ")); maxPage -= 2;}//------------------------------------------------------------------------------------------------ PUT YOUR CODE HERE --------------/* you can use these functions: gotoPage( destinationPageNo, skip ); //quick jump to the page number: destinationPageNo; values = 0-maxpages; skip: boolean; if true, pages will be skipped to the destination! autoflip(); //start autoflip (direction is calculated from _xmouse) canflip //it's a variable. setting its value to false disables flipping other functions of page turning is automatic; WARNING!!! if you want to unload/reload tha pageflip, before unloading call function: removeML(); to remove mouse listener!*/)[/url]////this code is written by Macc 2004.11.01//abel@iparigrafika.hu////sound added by Triqui - www.triquitips.com (great job Macc!!!)////this code is opensource////free use!//but a small credit would be nice:)//these values can be changed: -------------------------------------------------------------------------pw = 449; //page width in pixelph = 600; //page height in pixel //pages in the library must have the same size, the script will not resize them!//page data... (export names/tearing flag)addPage("start"); //Always start with "start"!!!addPage("page1");addPage("page2");addPage("page3");addPage("page4");addPage("page5");addPage("page6");addPage("page7");addPage("page8");addPage("page9");addPage("page10");addPage("page11",true); //second argument defines page tearing.addPage("page12",true);addPage("page13");addPage("page14");addPage("page15");addPage("page16");addPage("page17");addPage("page18");addPage("page19");addPage("page20");addPage("page21");addPage("page22");addPage("page23");addPage("page24");addPage("page25");addPage("page26");addPage("page27");addPage("page28");addPage("page29");addPage("page30");addPage("page31");addPage("page32");addPage("page33");addPage("page34");addPage("page35");addPage("page36");addPage("page37");addPage("page38");addPage("page39");addPage("page40");addPage("page41");addPage("page42");addPage("page43");addPage("page44");addPage("page45");addPage("page46");addPage("page47");addPage("page48");addPage("page49");addPage("page50");addPage("page51");addPage("page52");addPage("page53");addPage("page54");addPage("page55");addPage("page56");addPage("page57");addPage("page58");addPage("page59");addPage("page60");addPage("page61");addPage("page62");addPage("page63");addPage("page64");addPage("page65");addPage("page66");addPage("page67");addPage("page68");addPage("end"); //always end with "end"!!!page=0; //first page (normally it is 0 = the page before the cover = blank page)hcover = true; //hard cover on/offpage_sound = true; //sound on/offclickarea = 64; //pixel width of the click sensitive area at the edges..afa = 56; //width of the autoflip starter square.gs = 2; //goto page flip speedps = 5; //mouse pursuit speedes = 3; //flip speed after mouse btn releasecanflip = true; //page flipping enabled//do not change these values: ---------------------------------------------------------------------------------------------------------------------_global.mcnt = 0; //counter (used on a page where is an animation)gpage = 0; //gotoPage Nogflip = false; //gotoPage flipgdir = 0; //goto direction...gskip = false; //skip pages ***gtarget = 0; //target when skippingaflip = false; //auto flipflip = false; //pageflipflipOff = false; //terminateflipflipOK = false; //good fliphflip = false; //hardflip (the cover of the book)rotz = -30; //hardflip max y differencepreflip = false; //corner flip statusctear = false; //actual page statustear = false;teard = 0;tlimit = 80;removedPages = new Array(); //list of removed pages!mpx = 0, mpy = 0; //mousepos at clicksx = sy = 0; //startpoint when flippingx = 0; //mouse x,yy = 0;ax = 0; //auto x,yay = 0;acnt = 0;aadd = 0;aamp = 0;AM = Math.PI/180;//pageflip code by Macc ---------------------------------------------------------------------------------------------------------------------------function addPage(ename,tear) { //defining pages... ------------------------------------------------------------------------------------------- if(ename=="start") { pageOrder = new Array(); pageCanTear = new Array(); page=0; ename="blankpage"; } if(ename=="end") { maxpage = page-1; ename="blankpage"; } tear = tear==undefined? false: tear; pageOrder = ename; pageCanTear = tear; page++}function reset() { //initializing pages... --------------------------------------------------------------------------------------- pages.p0.page._x = -pw; pages.p0._x = 0; pages.p1.page._x = -pw; pages.p1._x = 0; pages.flip.p2.page._x = -pw; pages.flip.p2._x = pw; pages.flip.p3.page._x = -pw; pages.flip.p3._x = 0; pages.p4.page._x = -pw; pages.p4._x = pw; pages.p5.page._x = -pw; pages.p5._x = pw; pages.pgrad._visible = pages.mask._visible = pages.flip._visible = false; pages.flip.p3mask._width = pages.pgmask._width = pw*2; pages.center._height = pages.flip.p3mask._height = pages.pgmask._height = ph; pages.flip.fmask.page.pf._width = pw; pages.center._width = 6; pages.flip.fmask.page.pf._height = ph; pages.mask._height = pages.pgrad._height = pages.flip.p3shadow._height = pages.flip.flipgrad._height = 2*Math.sqrt(ph*ph+pw*pw); pageNumber = new Array(); for(i=0;i<=(maxpage+1);i++) pageNumber[i] = i;}mousecontroll = new Object(); //initializing mouse click handler ---------------------------------------------------------------------------mousecontroll.onMouseDown = function() { if(flip && !aflip) {// && !preflip) { flipOK = false; if(sx<0 && pages._xmouse>0) flipOK = true; if(sx>0 && pages._xmouse<0) flipOK = true; flipOff = true; flip = false; } else if((flipOff || aflip || !canflip) && !preflip) { trace("donothing"); } else { var oox = ox; var ooy = oy; var osx = sx; var osy = sy; var hit = hittest(); //hittest if(hit) { anim._visible = false; flip = true; flipOff = false; tear = false; //not tearing yet... ox = sx = hit*pw; if(preflip) { aflip = preflip = false; ox = oox, oy = ooy; sx = osx, sy = osy; } pages.flip.setMask(pages.mask); mpx = pages._xmouse, mpy = pages._ymouse; //_quality = "MEDIUM"; //it is the place to degrade image quality while turning pages if the performance is too low. } }}mousecontroll.onMouseUp = function() { if(flip && !tear) { if((Math.abs(pages._xmouse)>(pw-afa) && Math.abs(pages._ymouse)>(ph/2-afa) && Math.abs(pages._xmouse-mpx)<afa) || preflip) { flip = false; preflip = false; autoflip(); } else if(!preflip) { preflip = false; flipOK = false; if(sx<0 && pages._xmouse>0) flipOK = true; if(sx>0 && pages._xmouse<0) flipOK = true; flipOff = true; flip = false; } }}function hittest() { //hittest at mouse clicks, if click is over the book -> determining turning direction ------------------------------------ var x=pages._xmouse; var y=pages._ymouse; var pmh = ph/2; if(y<=pmh && y>=-pmh && x<=pw && x>=-pw) { //ha a megadott intervallumban klikkelunk, akkor lapozhatunk 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; if(y<0 && y<-ph/2) y = - ph/2; 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 = eval("pages.flip.p2.page"); pageO = eval("pages.flip.p3"); offs = -pw; pages.flip.fmask._x = pw; if(x<-(pw-clickarea) && page>0) { //>-----> flip backward pages.flip.p3._x = 0; hflip = checkCover(page,-1); setPages(page-2,page-1,page,page+1); ctear = pageCanTear[page-1]; return -1; } if(x>(pw-clickarea) && page<maxpage) { //<-----< flip forward pages.flip.p3._x = pw; hflip = checkCover(page,1); setPages(page,page+2,page+1,page+3); ctear = pageCanTear[page+2]; return 1; } } else return 0; //wrong click}function checkCover(p,dir) { if(hcover) { if(dir>0) { if(p==(maxpage-2) || p==0) return true; } else { if(p==maxpage || p==2) return true; } } return false; }function corner() { var x = Math.abs(pages._xmouse); var y = Math.abs(pages._ymouse); if(x>(pw-afa) && x<pw && y>(ph/2-afa) && y<(ph/2)) { return true; } return false;}function oef() { _global.mcnt++; //main counter incrase (need for some page effect); if(!flip && corner()) { //corner mouseover preflip = true; if(!autoflip()) preflip = false; } if(preflip && !corner()) { preflip = false; flip = false; flipOK = false; flipOff = true; } getm(); if(aflip && !preflip) { y = (ay += (sy-ay)/(gflip? gs: ps )); acnt += aadd; ax -= aadd; if(Math.abs(acnt)>pw) { flipOK = true; flipOff = true; flip = false; aflip = false; } } if(flip) { //page turning is in progress... if(tear) { if (page_sound){ if (page_effect <> 1){ triquisound = new Sound(this); triquisound.attachSound("pagetear"); triquisound.start(0, 1); page_effect = 1; } } x = tox; y = (toy += teard); teard *= 1.2; if(Math.abs(teard)>1200) { flipOff = true; flip = false; } } else { x = (ox += (x-ox)/(gflip? gs: ps )); y = (oy += (y-oy)/(gflip? gs: ps )); } calc(x,y); //positioning pages and shadows } if(flipOff) { //terminating page turning effect... (comlplete turning... dropped on the other side) if(flipOK || tear) { if (page_sound){ if (page_effect <> 1){ triquisound = new Sound(this); triquisound.attachSound("pageflip"); triquisound.start(0, 1); page_effect = 1; } } x = (ox += (-sx-ox)/(gflip? gs: es )); y = (oy += (sy-oy)/(gflip? gs: es )); calc(x,y); if(x/-sx > 0.99 || tear) { //we are done with turning, so stop all turning issue... flip = false; page_effect = 0; flipOK = flipOff = false; pages.pgrad._visible = pages.flip._visible = false; //_quality = "BEST"; //if quality is decrased during turning effect, you must reset its default value! if(tear) { //if tear: remove page!!! removePage((sx<0)? page: page+1); page += (sx<0)? -2: 0; } else { page += (sx<0)? -2: 2; //and tourning pages at pagenumber level... } if(gskip) page = gtarget; setPages(page,0,0,page+1); tear = false; if(gpage>0 && !gskip) { //gotoflip active -> is there another flipping left? gpage--; autoflip(); } else gflip = gskip = false; } } else { //terminating page turning effect... (incomlplete turning... dropped on the dragged side) x = (ox += (sx-ox)/3); y = (oy += (sy-oy)/3); calc(x,y); if(x/sx > 0.99) { //we are done with turning, so stop all turning issue... flip = false; flipOff = false; aflip = false; pages.pgrad._visible = pages.flip._visible = false; //_quality = "HIGH"; //if quality is decrased during turning effect, you must reset its default value! setPages(page,0,0,page+1); //no change at pagenumbers.. } } }}function calc(x,y) { //positioning pages and shadows by x,y reference points -------------------------------------------------- if(hflip) { //hardflip... var xp = (sx<0)? -x: x; if(xp>0) { sp2._visible = false; sp3._visible = true; scalc(sp3,x); } else { sp3._visible = false; sp2._visible = true; scalc(sp2,x); } pages.flip.setMask(null); pages.flip._visible = true; pages.flip.fgrad._visible = false; pages.flip.p2._visible = pages.flip.p3._visible = false; return; } else pages.flip.fgrad._visible = true; //normal flipping process--------------------------------------------------------------------- var rr0 = Math.sqrt((y+ph/2)*(y+ph/2)+x*x); var rr1 = Math.sqrt((ph/2-y)*(ph/2-y)+x*x); if((rr0>r0 || rr1>r1) && !tear) { // we can tear off pages now:) // so reference points must be recalculated! if(y<sy) { // k1-gyel kell osszehasonlitani! var a = Math.asin((ph/2-y)/rr1); y = (ph/2-Math.sin(a)*r1); x = (x<0)? -Math.cos(a)*r1: Math.cos(a)*r1; if(y>sy) { if((sx*x)>0) y = sy, x = sx; else y = sy, x = -sx; } if((rr1-r1)>tlimit && ctear) { teard = -5; tear = true; tox = ox = x; toy = oy = y; } } else { // k0-val kell osszehasonlitani! var a = Math.asin((y+ph/2)/rr0); y = Math.sin(a)*r0-ph/2; x = (x<0)? -Math.cos(a)*r0: Math.cos(a)*r0; if(y<sy) { if((sx*x)>0) y = sy, x = sx; else y = sy, x = -sx; } if((rr0-r0)>tlimit && ctear) { teard = 5; tear = true; tox = ox = x; toy = oy = y; } } } if((sx<0 && (x-sx)<10) || (sx>0 && (sx-x)<10)) { if(sx<0) x = -pw+10; if(sx>0) x = pw-10; } //calculating flipping process pages.flip._visible = true; pages.flip.p3shadow._visible = pages.pgrad._visible = !tear; pages.flip.p2._visible = pages.flip.p3._visible = true; //equation of the line var vx = x-sx; var vy = y-sy; var a1 = vy/vx; var a2 = -vy/vx; cx = sx+(vx/2); cy = sy+(vy/2); //trigonometriai szamitasok //calculating rotation of the page, and the masks var r = Math.sqrt((sx-x)*(sx-x)+(sy-y)*(sy-y)); var a = Math.asin((sy-y)/r); if(sx<0) a = -a; ad = a/AM; //in degree pageN._rotation = ad*2; r = Math.sqrt((sx-x)*(sx-x)+(sy-y)*(sy-y)); rl = (pw*2); if(sx>0) { //flip forward pages.mask._xscale = 100; nx = cx-Math.tan(a)*(ph/2-cy); ny = ph/2; if(nx>pw) { nx = pw; ny = cy+Math.tan(Math.PI/2+a)*(pw-cx); } pageN.pf._x = -(pw-nx); pages.flip.fgrad._xscale = (r/rl/2)*pw; pages.pgrad._xscale = -(r/rl/2)*pw; pages.flip.p3shadow._xscale = (r/rl/2)*pw; } else { //flip backward pages.mask._xscale = -100; nx = cx-Math.tan(a)*(ph/2-cy); ny = ph/2; if(nx<-pw) { nx = -pw; ny = cy+Math.tan(Math.PI/2+a)*(-pw-cx); } pageN.pf._x = -(pw-(pw+nx)); pages.flip.fgrad._xscale = -(r/rl/2)*pw; pages.pgrad._xscale = (r/rl/2)*pw; pages.flip.p3shadow._xscale = -(r/rl/2)*pw; } 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 = (r>(rl-50))? 100-(r-(rl-50))*2: 100; pages.flip.p3shadow._x = cx; pages.flip.p3shadow._y = cy; pages.flip.p3shadow._rotation = ad; pages.flip.p3shadow._alpha = (r>(rl-50))? 100-(r-(rl-50))*2: 100; pages.pgrad._x = cx; pages.pgrad._y = cy; pages.pgrad._rotation = ad+180; pages.pgrad._alpha = (r>(rl-100))? 100-(r-(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;}function scalc(obj,x) { //hardflip calc if(x<-pw) x=-pw; if(x>pw) x=pw; var a = Math.asin( x/pw ); var rot = a/AM/2; var xs = 100; var ss = 100*Math.sin( rotz*AM ); x = x/2; var y = Math.cos(a)*(pw/2)*(ss/100); placeImg(obj, rot, ss, x, y) pages.pgrad._visible = pages.flip._visible = true; pages.pgrad._xscale = x; pages.pgrad._alpha = pages.flip.p3shadow._alpha = 100; pages.flip.p3shadow._xscale = -x; pages.flip.p3shadow._x = 0; pages.flip.p3shadow._y = 0; pages.flip.p3shadow._rotation = 0; pages.pgrad._x = 0; pages.pgrad._y = 0; pages.pgrad._rotation = 0;}function placeImg(j, rot, ss, x, y) { var m = Math.tan( rot*AM ); var f = Math.SQRT2/Math.sqrt(m*m+1); var phxs = 100*m; var phRot = -rot;; var xs = 100*f; var ys = 100*f; j.ph.pic._rotation = 45; j.ph.pic._xscale = (phxs<0)? - xs: xs; j.ph.pic._yscale = ys*(100/ss); j.ph._rotation = phRot; j.ph._xscale = phxs; j._yscale = ss; j._x = x; j._y = y; j._visible = true;}function setPages(p1,p2,p3,p4) { //attach the right page "image" at the right place:) p0 = p1-2; //pages for transparency... p5 = p4+2; if(p0<0) p0=0; if(p5>maxpage) p5=0; if(p1<0) p1=0; //visible pages if(p2<0) p2=0; if(p3<0) p3=0; if(p4<0) p4=0; trace("setpages ->"+p1+","+p2+","+p3+","+p4); pleft = pages.p1.page.pf.ph.attachMovie(pageOrder[p1],"pic",0); pages.p1.page.pf.ph._y = -ph/2; pleftb = pages.p0.page.pf.ph.attachMovie(pageOrder[p0],"pic",0); pages.p0.page.pf.ph._y = -ph/2; if(hflip) { //hardflip pages are specials!!! var tm = pages.flip.hfliph.attachMovie("sph","sp2",0); sp2 = tm.ph.pic.attachMovie(pageOrder[p2],"pic",0); sp2._y = -ph/2, sp2._x = -pw/2; sp2 = eval("pages.flip.hfliph.sp2"); var tm = pages.flip.hfliph.attachMovie("sph","sp3",1); sp3 = tm.ph.pic.attachMovie(pageOrder[p3],"pic",0); sp3._y = -ph/2, sp3._x = -pw/2; sp3 = eval("pages.flip.hfliph.sp3"); } else { pages.flip.hfliph.sp2.removeMovieClip(); pages.flip.hfliph.sp3.removeMovieClip(); sp2 = pages.flip.p2.page.pf.ph.attachMovie(pageOrder[p2],"pic",0); pages.flip.p2.page.pf.ph._y = -ph/2; sp3 = pages.flip.p3.page.pf.ph.attachMovie(pageOrder[p3],"pic",0); pages.flip.p3.page.pf.ph._y = -ph/2; } pright = pages.p4.page.pf.ph.attachMovie(pageOrder[p4],"pic",0); pages.p4.page.pf.ph._y = -ph/2; prightb = pages.p5.page.pf.ph.attachMovie(pageOrder[p5],"pic",0); pages.p5.page.pf.ph._y = -ph/2;}function resetPages() { setPages(page,0,0,page+1);} function autoflip() { //start auto flip! if(!aflip && !flip && !flipOff && canflip) { //only when all conditions fits our needs... acnt = 0 aamp = Math.random()*(ph/2)-(ph/4); var x= gflip? (gdir*pw)/2: ((pages._xmouse<0)? -pw/2: pw/2); //var y= Math.random()*ph-(ph/2); //random starty var y = Math.random()*(ph/2)-(ph/4); var pmh = ph/2; var r = Math.sqrt(x*x+y*y); var a = Math.asin(y/r); var yy = Math.tan(a)*pw; if(y>0 && y>ph/2) y = ph/2; if(y<0 && y<-ph/2) y = - ph/2; oy = sy = yy; ax = (pages._xmouse<0)? -pw/2: pw/2; var l = ((ph/2)-y); ay = y+((Math.random()*2*l)-l)/2; //page turnig style randomizing trace("autoflip from "+ax+","+ay); offs = -pw; var hit = 0; if(x<0 && page>0) { pages.flip.p3._x = 0; hflip = (hcover && gskip)? gtarget==0: checkCover(page,-1); if(!(preflip && hflip)) { if(gskip) setPages(gtarget,gtarget+1,page,page+1); else setPages(page-2,page-1,page,page+1); } hit = -1; } if(x>0 && page<maxpage) { pages.flip.p3._x = pw; hflip = (hcover && gskip)? gtarget==maxpage: checkCover(page,1); if(!(preflip && hflip)) { if(gskip) setPages(page,gtarget,page+1,gtarget+1); else setPages(page,page+2,page+1,page+3); } hit = 1; } if(hflip && preflip) { hit = 0; preflip = false; return false; } if(hit) { anim._visible = false; flip = true; flipOff = false; ox = sx = hit*pw; pages.flip.setMask(pages.mask); aadd = hit*(pw/(gflip? 5:10 )); //autoflip takes 10 frames to be done!!! aflip = true; pages.flip.fmask._x = pw; if(preflip) { oy = sy = (pages._ymouse<0)? -(ph/2): (ph/2); } r0 = Math.sqrt((sy+ph/2)*(sy+ph/2)+pw*pw); r1 = Math.sqrt((ph/2-sy)*(ph/2-sy)+pw*pw); pageN = eval("pages.flip.p2.page"); pageO = eval("pages.flip.p3"); oef(); return true; } } else return false;}function getm() { //get x,y reference points depending of turning style: manual/auto if(aflip && !preflip) { x = ax; y = ay; } else { x = pages._xmouse; y = pages._ymouse; }}function gotoPage(i,skip) { //quickjump to the page number i i = getPN(i); //i = target page gskip = (skip==undefined)? false: skip; //skip pages if(i<0) return false; var p = int(page/2); var d = int(i/2); if(p!=d && canflip && !gflip) { //target!=current page if(p<d) { //go forward gdir = 1; gpage = d-p-1; } else { //go backward gdir = -1 gpage = p-d-1; } gflip = true; if(gskip) gtarget = d*2, gpage = 0; autoflip(); } else gskip = false;}function getPN(i) { //get the right page number var find = false; for(j=1;j<=maxpage;j++) { if(i==pageNumber[j]) { i=j; find = true; break; } } if(find) return i; else return -1;}function removePage(i) { trace("remove page "+i); i = (Math.floor((i-1)/2)*2)+1; removedPages.push(pageNumber[i], pageNumber[i+1]); for(j=(i+2);j<=(maxPage+1);j++) { pageOrder[j-2]=pageOrder[j]; pageCanTear[j-2]=pageCanTear[j]; pageNumber[j-2]=pageNumber[j]; } trace("removed pages "+i+","+(i+1)); trace(removedPages.join(", ")); maxPage -= 2;}//------------------------------------------------------------------------------------------------ PUT YOUR CODE HERE --------------/* you can use these functions: gotoPage( destinationPageNo, skip ); //quick jump to the page number: destinationPageNo; values = 0-maxpages; skip: boolean; if true, pages will be skipped to the destination! autoflip(); //start autoflip (direction is calculated from _xmouse) canflip //it's a variable. setting its value to false disables flipping other functions of page turning is automatic; WARNING!!! if you want to unload/reload tha pageflip, before unloading call function: removeML(); to remove mouse listener!*/)[/url]////this code is written by Macc 2004.11.01//abel@iparigrafika.hu////sound added by Triqui - www.triquitips.com (great job Macc!!!)////this code is opensource////free use!//but a small credit would be nice:)//these values can be changed: -------------------------------------------------------------------------pw = 449; //page width in pixelph = 600; //page height in pixel //pages in the library must have the same size, the script will not resize them!//page data... (export names/tearing flag)addPage("start"); //Always start with "start"!!!addPage("page1");addPage("page2");addPage("page3");addPage("page4");addPage("page5");addPage("page6");addPage("page7");addPage("page8");addPage("page9");addPage("page10");addPage("page11",true); //second argument defines page tearing.addPage("page12",true);addPage("page13");addPage("page14");addPage("page15");addPage("page16");addPage("page17");addPage("page18");addPage("page19");addPage("page20");addPage("page21");addPage("page22");addPage("page23");addPage("page24");addPage("page25");addPage("page26");addPage("page27");addPage("page28");addPage("page29");addPage("page30");addPage("page31");addPage("page32");addPage("page33");addPage("page34");addPage("page35");addPage("page36");addPage("page37");addPage("page38");addPage("page39");addPage("page40");addPage("page41");addPage("page42");addPage("page43");addPage("page44");addPage("page45");addPage("page46");addPage("page47");addPage("page48");addPage("page49");addPage("page50");addPage("page51");addPage("page52");addPage("page53");addPage("page54");addPage("page55");addPage("page56");addPage("page57");addPage("page58");addPage("page59");addPage("page60");addPage("page61");addPage("page62");addPage("page63");addPage("page64");addPage("page65");addPage("page66");addPage("page67");addPage("page68");addPage("end"); //always end with "end"!!!page=0; //first page (normally it is 0 = the page before the cover = blank page)hcover = true; //hard cover on/offpage_sound = true; //sound on/offclickarea = 64; //pixel width of the click sensitive area at the edges..afa = 56; //width of the autoflip starter square.gs = 2; //goto page flip speedps = 5; //mouse pursuit speedes = 3; //flip speed after mouse btn releasecanflip = true; //page flipping enabled//do not change these values: ---------------------------------------------------------------------------------------------------------------------_global.mcnt = 0; //counter (used on a page where is an animation)gpage = 0; //gotoPage Nogflip = false; //gotoPage flipgdir = 0; //goto direction...gskip = false; //skip pages ***gtarget = 0; //target when skippingaflip = false; //auto flipflip = false; //pageflipflipOff = false; //terminateflipflipOK = false; //good fliphflip = false; //hardflip (the cover of the book)rotz = -30; //hardflip max y differencepreflip = false; //corner flip statusctear = false; //actual page statustear = false;teard = 0;tlimit = 80;removedPages = new Array(); //list of removed pages!mpx = 0, mpy = 0; //mousepos at clicksx = sy = 0; //startpoint when flippingx = 0; //mouse x,yy = 0;ax = 0; //auto x,yay = 0;acnt = 0;aadd = 0;aamp = 0;AM = Math.PI/180;//pageflip code by Macc ---------------------------------------------------------------------------------------------------------------------------function addPage(ename,tear) { //defining pages... ------------------------------------------------------------------------------------------- if(ename=="start") { pageOrder = new Array(); pageCanTear = new Array(); page=0; ename="blankpage"; } if(ename=="end") { maxpage = page-1; ename="blankpage"; } tear = tear==undefined? false: tear; pageOrder = ename; pageCanTear = tear; page++}function reset() { //initializing pages... --------------------------------------------------------------------------------------- pages.p0.page._x = -pw; pages.p0._x = 0; pages.p1.page._x = -pw; pages.p1._x = 0; pages.flip.p2.page._x = -pw; pages.flip.p2._x = pw; pages.flip.p3.page._x = -pw; pages.flip.p3._x = 0; pages.p4.page._x = -pw; pages.p4._x = pw; pages.p5.page._x = -pw; pages.p5._x = pw; pages.pgrad._visible = pages.mask._visible = pages.flip._visible = false; pages.flip.p3mask._width = pages.pgmask._width = pw*2; pages.center._height = pages.flip.p3mask._height = pages.pgmask._height = ph; pages.flip.fmask.page.pf._width = pw; pages.center._width = 6; pages.flip.fmask.page.pf._height = ph; pages.mask._height = pages.pgrad._height = pages.flip.p3shadow._height = pages.flip.flipgrad._height = 2*Math.sqrt(ph*ph+pw*pw); pageNumber = new Array(); for(i=0;i<=(maxpage+1);i++) pageNumber[i] = i;}mousecontroll = new Object(); //initializing mouse click handler ---------------------------------------------------------------------------mousecontroll.onMouseDown = function() { if(flip && !aflip) {// && !preflip) { flipOK = false; if(sx<0 && pages._xmouse>0) flipOK = true; if(sx>0 && pages._xmouse<0) flipOK = true; flipOff = true; flip = false; } else if((flipOff || aflip || !canflip) && !preflip) { trace("donothing"); } else { var oox = ox; var ooy = oy; var osx = sx; var osy = sy; var hit = hittest(); //hittest if(hit) { anim._visible = false; flip = true; flipOff = false; tear = false; //not tearing yet... ox = sx = hit*pw; if(preflip) { aflip = preflip = false; ox = oox, oy = ooy; sx = osx, sy = osy; } pages.flip.setMask(pages.mask); mpx = pages._xmouse, mpy = pages._ymouse; //_quality = "MEDIUM"; //it is the place to degrade image quality while turning pages if the performance is too low. } }}mousecontroll.onMouseUp = function() { if(flip && !tear) { if((Math.abs(pages._xmouse)>(pw-afa) && Math.abs(pages._ymouse)>(ph/2-afa) && Math.abs(pages._xmouse-mpx)<afa) || preflip) { flip = false; preflip = false; autoflip(); } else if(!preflip) { preflip = false; flipOK = false; if(sx<0 && pages._xmouse>0) flipOK = true; if(sx>0 && pages._xmouse<0) flipOK = true; flipOff = true; flip = false; } }}function hittest() { //hittest at mouse clicks, if click is over the book -> determining turning direction ------------------------------------ var x=pages._xmouse; var y=pages._ymouse; var pmh = ph/2; if(y<=pmh && y>=-pmh && x<=pw && x>=-pw) { //ha a megadott intervallumban klikkelunk, akkor lapozhatunk 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; if(y<0 && y<-ph/2) y = - ph/2; 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 = eval("pages.flip.p2.page"); pageO = eval("pages.flip.p3"); offs = -pw; pages.flip.fmask._x = pw; if(x<-(pw-clickarea) && page>0) { //>-----> flip backward pages.flip.p3._x = 0; hflip = checkCover(page,-1); setPages(page-2,page-1,page,page+1); ctear = pageCanTear[page-1]; return -1; } if(x>(pw-clickarea) && page<maxpage) { //<-----< flip forward pages.flip.p3._x = pw; hflip = checkCover(page,1); setPages(page,page+2,page+1,page+3); ctear = pageCanTear[page+2]; return 1; } } else return 0; //wrong click}function checkCover(p,dir) { if(hcover) { if(dir>0) { if(p==(maxpage-2) || p==0) return true; } else { if(p==maxpage || p==2) return true; } } return false; }function corner() { var x = Math.abs(pages._xmouse); var y = Math.abs(pages._ymouse); if(x>(pw-afa) && x<pw && y>(ph/2-afa) && y<(ph/2)) { return true; } return false;}function oef() { _global.mcnt++; //main counter incrase (need for some page effect); if(!flip && corner()) { //corner mouseover preflip = true; if(!autoflip()) preflip = false; } if(preflip && !corner()) { preflip = false; flip = false; flipOK = false; flipOff = true; } getm(); if(aflip && !preflip) { y = (ay += (sy-ay)/(gflip? gs: ps )); acnt += aadd; ax -= aadd; if(Math.abs(acnt)>pw) { flipOK = true; flipOff = true; flip = false; aflip = false; } } if(flip) { //page turning is in progress... if(tear) { if (page_sound){ if (page_effect <> 1){ triquisound = new Sound(this); triquisound.attachSound("pagetear"); triquisound.start(0, 1); page_effect = 1; } } x = tox; y = (toy += teard); teard *= 1.2; if(Math.abs(teard)>1200) { flipOff = true; flip = false; } } else { x = (ox += (x-ox)/(gflip? gs: ps )); y = (oy += (y-oy)/(gflip? gs: ps )); } calc(x,y); //positioning pages and shadows } if(flipOff) { //terminating page turning effect... (comlplete turning... dropped on the other side) if(flipOK || tear) { if (page_sound){ if (page_effect <> 1){ triquisound = new Sound(this); triquisound.attachSound("pageflip"); triquisound.start(0, 1); page_effect = 1; } } x = (ox += (-sx-ox)/(gflip? gs: es )); y = (oy += (sy-oy)/(gflip? gs: es )); calc(x,y); if(x/-sx > 0.99 || tear) { //we are done with turning, so stop all turning issue... flip = false; page_effect = 0; flipOK = flipOff = false; pages.pgrad._visible = pages.flip._visible = false; //_quality = "BEST"; //if quality is decrased during turning effect, you must reset its default value! if(tear) { //if tear: remove page!!! removePage((sx<0)? page: page+1); page += (sx<0)? -2: 0; } else { page += (sx<0)? -2: 2; //and tourning pages at pagenumber level... } if(gskip) page = gtarget; setPages(page,0,0,page+1); tear = false; if(gpage>0 && !gskip) { //gotoflip active -> is there another flipping left? gpage--; autoflip(); } else gflip = gskip = false; } } else { //terminating page turning effect... (incomlplete turning... dropped on the dragged side) x = (ox += (sx-ox)/3); y = (oy += (sy-oy)/3); calc(x,y); if(x/sx > 0.99) { //we are done with turning, so stop all turning issue... flip = false; flipOff = false; aflip = false; pages.pgrad._visible = pages.flip._visible = false; //_quality = "HIGH"; //if quality is decrased during turning effect, you must reset its default value! setPages(page,0,0,page+1); //no change at pagenumbers.. } } }}function calc(x,y) { //positioning pages and shadows by x,y reference points -------------------------------------------------- if(hflip) { //hardflip... var xp = (sx<0)? -x: x; if(xp>0) { sp2._visible = false; sp3._visible = true; scalc(sp3,x); } else { sp3._visible = false; sp2._visible = true; scalc(sp2,x); } pages.flip.setMask(null); pages.flip._visible = true; pages.flip.fgrad._visible = false; pages.flip.p2._visible = pages.flip.p3._visible = false; return; } else pages.flip.fgrad._visible = true; //normal flipping process--------------------------------------------------------------------- var rr0 = Math.sqrt((y+ph/2)*(y+ph/2)+x*x); var rr1 = Math.sqrt((ph/2-y)*(ph/2-y)+x*x); if((rr0>r0 || rr1>r1) && !tear) { // we can tear off pages now:) // so reference points must be recalculated! if(y<sy) { // k1-gyel kell osszehasonlitani! var a = Math.asin((ph/2-y)/rr1); y = (ph/2-Math.sin(a)*r1); x = (x<0)? -Math.cos(a)*r1: Math.cos(a)*r1; if(y>sy) { if((sx*x)>0) y = sy, x = sx; else y = sy, x = -sx; } if((rr1-r1)>tlimit && ctear) { teard = -5; tear = true; tox = ox = x; toy = oy = y; } } else { // k0-val kell osszehasonlitani! var a = Math.asin((y+ph/2)/rr0); y = Math.sin(a)*r0-ph/2; x = (x<0)? -Math.cos(a)*r0: Math.cos(a)*r0; if(y<sy) { if((sx*x)>0) y = sy, x = sx; else y = sy, x = -sx; } if((rr0-r0)>tlimit && ctear) { teard = 5; tear = true; tox = ox = x; toy = oy = y; } } } if((sx<0 && (x-sx)<10) || (sx>0 && (sx-x)<10)) { if(sx<0) x = -pw+10; if(sx>0) x = pw-10; } //calculating flipping process pages.flip._visible = true; pages.flip.p3shadow._visible = pages.pgrad._visible = !tear; pages.flip.p2._visible = pages.flip.p3._visible = true; //equation of the line var vx = x-sx; var vy = y-sy; var a1 = vy/vx; var a2 = -vy/vx; cx = sx+(vx/2); cy = sy+(vy/2); //trigonometriai szamitasok //calculating rotation of the page, and the masks var r = Math.sqrt((sx-x)*(sx-x)+(sy-y)*(sy-y)); var a = Math.asin((sy-y)/r); if(sx<0) a = -a; ad = a/AM; //in degree pageN._rotation = ad*2; r = Math.sqrt((sx-x)*(sx-x)+(sy-y)*(sy-y)); rl = (pw*2); if(sx>0) { //flip forward pages.mask._xscale = 100; nx = cx-Math.tan(a)*(ph/2-cy); ny = ph/2; if(nx>pw) { nx = pw; ny = cy+Math.tan(Math.PI/2+a)*(pw-cx); } pageN.pf._x = -(pw-nx); pages.flip.fgrad._xscale = (r/rl/2)*pw; pages.pgrad._xscale = -(r/rl/2)*pw; pages.flip.p3shadow._xscale = (r/rl/2)*pw; } else { //flip backward pages.mask._xscale = -100; nx = cx-Math.tan(a)*(ph/2-cy); ny = ph/2; if(nx<-pw) { nx = -pw; ny = cy+Math.tan(Math.PI/2+a)*(-pw-cx); } pageN.pf._x = -(pw-(pw+nx)); pages.flip.fgrad._xscale = -(r/rl/2)*pw; pages.pgrad._xscale = (r/rl/2)*pw; pages.flip.p3shadow._xscale = -(r/rl/2)*pw; } 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 = (r>(rl-50))? 100-(r-(rl-50))*2: 100; pages.flip.p3shadow._x = cx; pages.flip.p3shadow._y = cy; pages.flip.p3shadow._rotation = ad; pages.flip.p3shadow._alpha = (r>(rl-50))? 100-(r-(rl-50))*2: 100; pages.pgrad._x = cx; pages.pgrad._y = cy; pages.pgrad._rotation = ad+180; pages.pgrad._alpha = (r>(rl-100))? 100-(r-(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;}function scalc(obj,x) { //hardflip calc if(x<-pw) x=-pw; if(x>pw) x=pw; var a = Math.asin( x/pw ); var rot = a/AM/2; var xs = 100; var ss = 100*Math.sin( rotz*AM ); x = x/2; var y = Math.cos(a)*(pw/2)*(ss/100); placeImg(obj, rot, ss, x, y) pages.pgrad._visible = pages.flip._visible = true; pages.pgrad._xscale = x; pages.pgrad._alpha = pages.flip.p3shadow._alpha = 100; pages.flip.p3shadow._xscale = -x; pages.flip.p3shadow._x = 0; pages.flip.p3shadow._y = 0; pages.flip.p3shadow._rotation = 0; pages.pgrad._x = 0; pages.pgrad._y = 0; pages.pgrad._rotation = 0;}function placeImg(j, rot, ss, x, y) { var m = Math.tan( rot*AM ); var f = Math.SQRT2/Math.sqrt(m*m+1); var phxs = 100*m; var phRot = -rot;; var xs = 100*f; var ys = 100*f; j.ph.pic._rotation = 45; j.ph.pic._xscale = (phxs<0)? - xs: xs; j.ph.pic._yscale = ys*(100/ss); j.ph._rotation = phRot; j.ph._xscale = phxs; j._yscale = ss; j._x = x; j._y = y; j._visible = true;}function setPages(p1,p2,p3,p4) { //attach the right page "image" at the right place:) p0 = p1-2; //pages for transparency... p5 = p4+2; if(p0<0) p0=0; if(p5>maxpage) p5=0; if(p1<0) p1=0; //visible pages if(p2<0) p2=0; if(p3<0) p3=0; if(p4<0) p4=0; trace("setpages ->"+p1+","+p2+","+p3+","+p4); pleft = pages.p1.page.pf.ph.attachMovie(pageOrder[p1],"pic",0); pages.p1.page.pf.ph._y = -ph/2; pleftb = pages.p0.page.pf.ph.attachMovie(pageOrder[p0],"pic",0); pages.p0.page.pf.ph._y = -ph/2; if(hflip) { //hardflip pages are specials!!! var tm = pages.flip.hfliph.attachMovie("sph","sp2",0); sp2 = tm.ph.pic.attachMovie(pageOrder[p2],"pic",0); sp2._y = -ph/2, sp2._x = -pw/2; sp2 = eval("pages.flip.hfliph.sp2"); var tm = pages.flip.hfliph.attachMovie("sph","sp3",1); sp3 = tm.ph.pic.attachMovie(pageOrder[p3],"pic",0); sp3._y = -ph/2, sp3._x = -pw/2; sp3 = eval("pages.flip.hfliph.sp3"); } else { pages.flip.hfliph.sp2.removeMovieClip(); pages.flip.hfliph.sp3.removeMovieClip(); sp2 = pages.flip.p2.page.pf.ph.attachMovie(pageOrder[p2],"pic",0); pages.flip.p2.page.pf.ph._y = -ph/2; sp3 = pages.flip.p3.page.pf.ph.attachMovie(pageOrder[p3],"pic",0); pages.flip.p3.page.pf.ph._y = -ph/2; } pright = pages.p4.page.pf.ph.attachMovie(pageOrder[p4],"pic",0); pages.p4.page.pf.ph._y = -ph/2; prightb = pages.p5.page.pf.ph.attachMovie(pageOrder[p5],"pic",0); pages.p5.page.pf.ph._y = -ph/2;}function resetPages() { setPages(page,0,0,page+1);} function autoflip() { //start auto flip! if(!aflip && !flip && !flipOff && canflip) { //only when all conditions fits our needs... acnt = 0 aamp = Math.random()*(ph/2)-(ph/4); var x= gflip? (gdir*pw)/2: ((pages._xmouse<0)? -pw/2: pw/2); //var y= Math.random()*ph-(ph/2); //random starty var y = Math.random()*(ph/2)-(ph/4); var pmh = ph/2; var r = Math.sqrt(x*x+y*y); var a = Math.asin(y/r); var yy = Math.tan(a)*pw; if(y>0 && y>ph/2) y = ph/2; if(y<0 && y<-ph/2) y = - ph/2; oy = sy = yy; ax = (pages._xmouse<0)? -pw/2: pw/2; var l = ((ph/2)-y); ay = y+((Math.random()*2*l)-l)/2; //page turnig style randomizing trace("autoflip from "+ax+","+ay); offs = -pw; var hit = 0; if(x<0 && page>0) { pages.flip.p3._x = 0; hflip = (hcover && gskip)? gtarget==0: checkCover(page,-1); if(!(preflip && hflip)) { if(gskip) setPages(gtarget,gtarget+1,page,page+1); else setPages(page-2,page-1,page,page+1); } hit = -1; } if(x>0 && page<maxpage) { pages.flip.p3._x = pw; hflip = (hcover && gskip)? gtarget==maxpage: checkCover(page,1); if(!(preflip && hflip)) { if(gskip) setPages(page,gtarget,page+1,gtarget+1); else setPages(page,page+2,page+1,page+3); } hit = 1; } if(hflip && preflip) { hit = 0; preflip = false; return false; } if(hit) { anim._visible = false; flip = true; flipOff = false; ox = sx = hit*pw; pages.flip.setMask(pages.mask); aadd = hit*(pw/(gflip? 5:10 )); //autoflip takes 10 frames to be done!!! aflip = true; pages.flip.fmask._x = pw; if(preflip) { oy = sy = (pages._ymouse<0)? -(ph/2): (ph/2); } r0 = Math.sqrt((sy+ph/2)*(sy+ph/2)+pw*pw); r1 = Math.sqrt((ph/2-sy)*(ph/2-sy)+pw*pw); pageN = eval("pages.flip.p2.page"); pageO = eval("pages.flip.p3"); oef(); return true; } } else return false;}function getm() { //get x,y reference points depending of turning style: manual/auto if(aflip && !preflip) { x = ax; y = ay; } else { x = pages._xmouse; y = pages._ymouse; }}function gotoPage(i,skip) { //quickjump to the page number i i = getPN(i); //i = target page gskip = (skip==undefined)? false: skip; //skip pages if(i<0) return false; var p = int(page/2); var d = int(i/2); if(p!=d && canflip && !gflip) { //target!=current page if(p<d) { //go forward gdir = 1; gpage = d-p-1; } else { //go backward gdir = -1 gpage = p-d-1; } gflip = true; if(gskip) gtarget = d*2, gpage = 0; autoflip(); } else gskip = false;}function getPN(i) { //get the right page number var find = false; for(j=1;j<=maxpage;j++) { if(i==pageNumber[j]) { i=j; find = true; break; } } if(find) return i; else return -1;}function removePage(i) { trace("remove page "+i); i = (Math.floor((i-1)/2)*2)+1; removedPages.push(pageNumber[i], pageNumber[i+1]); for(j=(i+2);j<=(maxPage+1);j++) { pageOrder[j-2]=pageOrder[j]; pageCanTear[j-2]=pageCanTear[j]; pageNumber[j-2]=pageNumber[j]; } trace("removed pages "+i+","+(i+1)); trace(removedPages.join(", ")); maxPage -= 2;}//------------------------------------------------------------------------------------------------ PUT YOUR CODE HERE --------------/* you can use these functions: gotoPage( destinationPageNo, skip ); //quick jump to the page number: destinationPageNo; values = 0-maxpages; skip: boolean; if true, pages will be skipped to the destination! autoflip(); //start autoflip (direction is calculated from _xmouse) canflip //it's a variable. setting its value to false disables flipping other functions of page turning is automatic; WARNING!!! if you want to unload/reload tha pageflip, before unloading call function: removeML(); to remove mouse listener!*/ queria adicionar mais como faço so´colocar addpage e 17 18 19 e assim por adiante,se eu ir duplicando as paginas e instanciando com nome diferente ja funciona?? Nao ta funcionando aki ta ficando tudo em branco as paginas... Compartilhar este post Link para o post Compartilhar em outros sites
Dieguinhu Web 0 Denunciar post Postado Maio 15, 2007 Gente o pageflip q tenho vai ate 0 17 quando chega nessa pagina o livro fica transparente e não ta aparecendo a imagem já criei os MC page18 19 etc etc,só que ja alterei a opção do blankpage pra page68 eas ultimas folhas se repetem Não estou conseguindo acrescentar mais paginas? O que deve estar errado? Abraço Deem uma olhada ta publicado http://www.galeriaviponline.com/livro/livro.swf Compartilhar este post Link para o post Compartilhar em outros sites
Eder Fortunato 15 Denunciar post Postado Maio 15, 2007 teve um cara que respondeu isso lá atras, dá uma lida no tópico pow ninguém respondeu..só agora estou com tempo pra dar uma ajudaeu dei uma fuçada no pageflip2 e ficou bem mais fácil adicionar páginas, criar efeitos...para adicionar uma página abra a Library (CTRL+L)expande a pasta "PageElements"é nessa pasta que você tem os MV das páginas.no último objeto "page17_blankpage" clique com o botão direito e clique em "propriedades"altere o nome de "page17_blankpage" para "page_fim_blankpage"no parâmetro "Identifier" altere para "page_fim"clique em okagora abre o painel de actions para ver os scripts do primeiro framena linha 23 tem um array()pageOrder = new Array("page0","page1","page2","page3","page4","page5","page6","page7","page8","page9","page10","page11","page12","page13","page14","page15","page16","page17");o último valor é "page17", troque por "page_fim"esses valores são os identificadores dos MV que estão na libraryna verdade não precisava ter feito isso, mas para organizar e entender melhor é bom fazer.Agora faça um teste adicionando 2 páginasna linha 23 adicione dois valorres antes do último, assim:pageOrder = new Array("page0","page1","page2","page3","page4","page5","page6","page7","page8","page9","page10","page11","page12","page13","page14","page15","page16","page17","page18","page_fim");na linha 24 tem um array que define se a página pode ser arrancada do livro. é um efeito bem interessante. coloque true para ativar ou false para desativaradicione mais 2 "false" antes do último:pageCanTear = new Array(false, false, false, false, false, false, false, false, false, false, false, true, true, false, false, false, false, false, false, false);repare que as páginas 12 e 13 estão como true, ao executar o swf faça um teste arrancando a página com o mouse.na linha 28você encontrará isso:maxpage=16; //last page (back cover, should be even number)é o número de páginas, como adicionamos mais 2 então altere para 18maxpage=18; //last page (back cover, should be even number)beleza!!agora é preciso criar as páginas.volte à library (CTRL+L) e na pasta "PageElements" vai lá no "page16"clique com o botão direito do mouse e escolha "Duplicate"coloque o nome "page17"em "Linkage" selecione o primeiro "Export for ActionScript"ao clicar uma quarta caixa aparecerá já marcada, deixe-a marcada. O nome do identificador mantenha como está e clique em OKrepita esse procedimento para ir criando suas páginasmas não se esqueça das linhas 23, 24 e 28qualquer dúvida poste aquidesculpe o tutorial mal feito, estou com um pouco de pressat+ Compartilhar este post Link para o post Compartilhar em outros sites