I have a page flipper that has no control of skipping ahead pages…like a table of contents. I’ve been looking at this AS for two days now and cant figure out how I would jump to a page? Maybe one of you experts can take a crack at it.
I am sure it will have something to do with the automovepage functin about halfway down.
br.onPress=function(){
if(((rightpage._totalframes-1)>rightpage._currentframe)&&(!changingpage)){
startchangingpage("right");
}
}
bl.onPress=function(){
if(((leftpage._currentframe-1)>0)&&(!changingpage)){
startchangingpage("left");
}
}
function startchangingpage(corner){
changingpage=corner;
if(changingpage=="right"){
this.attachMovie("pagechange", "pagechange", this.getNextHighestDepth(), {_x:booksize._width, _y:booksize._height});
if((rightpage._currentframe)<(rightpage._totalframes-2)){
pagechange.castshadowmask._y=-(booksize._height);
pagechange.castshadowmask._height=booksize._height;
pagechange.castshadowmask._x=-(booksize._width);
pagechange.castshadowmask._width=booksize._width;
pagechange.castshadow._alpha=100;
}else{
pagechange.castshadow._alpha=0;
}
pagechange.glare._alpha=100;
pagechange.bottompage.gotoAndStop(rightpage._currentframe);
pagechange.bottompage._x=-(booksize._width/2);
pagechange.bottompage._y=-(booksize._height);
pagechange.toppage.gotoAndStop(rightpage._currentframe+1);
rightpage.gotoAndStop(rightpage._currentframe+2);
}else if(changingpage=="left"){
this.attachMovie("pagechange", "pagechange", this.getNextHighestDepth(), {_x:booksize._width, _y:booksize._height});
if((leftpage._currentframe)>3){
pagechange.castshadowmask._y=-(booksize._height);
pagechange.castshadowmask._height=booksize._height;
pagechange.castshadowmask._x=-(booksize._width);
pagechange.castshadowmask._width=booksize._width;
pagechange.castshadow._alpha=100;
}else{
pagechange.castshadow._alpha=0;
}
pagechange.glare._alpha=100;
pagechange.bottompage.gotoAndStop(leftpage._currentframe);
pagechange.bottompage._x=-(booksize._width);
pagechange.bottompage._y=-(booksize._height);
pagechange.toppage.gotoAndStop(leftpage._currentframe-1);
leftpage.gotoAndStop(leftpage._currentframe-2);
}
}
onEnterFrame=function(){
if(automoving){
automovepage();
}
else if(changingpage){
cornerx=_xmouse;
cornery=_ymouse;
if(_ymouse<=booksize._height){
cornerradius=Math.sqrt(Math.pow(_xmouse-(booksize._width/2),2)+Math.pow(_ymouse-booksize._height,2));
if(cornerradius>booksize._width/2){
cornerx=(booksize._width/2)+((booksize._width/2)/cornerradius)*(_xmouse-(booksize._width/2));
cornery=booksize._height+((booksize._width/2)/cornerradius)*(_ymouse-booksize._height);
}
}else{
cornerradius=Math.sqrt(Math.pow(_xmouse-(booksize._width/2),2)+Math.pow(_ymouse-booksize._y,2));
circleradius=Math.sqrt(Math.pow((booksize._width/2),2)+Math.pow((booksize._height),2));
pageangle=-Math.atan((_ymouse-(booksize._y))/(_xmouse-(booksize._width/2)))*radianstodegrees;
if(pageangle>0){pageangle=pageangle-180};
if(cornerradius>circleradius){
cornerx=(booksize._width/2)+Math.sin((pageangle+90)*degreestoradians)*circleradius;
cornery=Math.cos((pageangle+90)*degreestoradians)*circleradius;
if(cornerx<=booksize._x){
cornerx=booksize._x;
cornery=booksize._height;
}else if(cornerx>=booksize._width){
cornerx=booksize._width;
cornery=booksize._height;
}
}
}
drawflippingpage();
}
}
br.onReleaseOutside=function(){
if(changingpage){
automoving=1;
}
}
br.onRelease=function(){
if(changingpage){
automoving=1;
}
}
bl.onReleaseOutside=function(){
if(changingpage){
automoving=1;
}
}
bl.onRelease=function(){
if(changingpage){
automoving=1;
}
}
function automovepage(){
if(changingpage=="right"){
totaldistance=Math.abs(cornery-booksize._height)+Math.abs(booksize._x-cornerx);
if(totaldistance!=0){
cornerx+=automoverate*(booksize._x-cornerx)/totaldistance;
cornery+=automoverate*(booksize._height-cornery)/totaldistance;
}
}else{
totaldistance=Math.abs(cornery-booksize._height)+Math.abs(booksize._width-cornerx);
if(totaldistance!=0){
cornerx+=automoverate*(booksize._width-cornerx)/totaldistance;
cornery+=automoverate*(booksize._height-cornery)/totaldistance;
}
}
drawflippingpage();
if((totaldistance<=automoverate)){
automoving=0;
pagechange.removeMovieClip();
if(cornerx>booksize._width/2){
rightpage.gotoAndStop(rightpage._currentframe-2);
}else if(cornerx<booksize._width/2){
leftpage.gotoAndStop(leftpage._currentframe+2);
}
if(leftpage._currentframe==1){
bl._visible=false;
}else{bl._visible=true;}
if(rightpage._currentframe>=rightpage._totalframes-1){
br._visible=false;
}else{br._visible=true;}
changingpage=0;
}
}
function drawflippingpage(){
if(changingpage=="left"){
maskrotation=Math.atan((cornery-booksize._height)/(cornerx-booksize._x))*radianstodegrees;
pagechange.pagechangemask._rotation=180;
pagechange.pagechangemask._x=(cornerx-booksize._x)/2-booksize._width;
pagechange.pagechangemask._y=(cornery-booksize._height)/2;
pagechange.castshadow._x=pagechange.pagechangemask._x;
pagechange.castshadow._y=pagechange.pagechangemask._y;
pagechange.glare._x=pagechange.pagechangemask._x;
pagechange.glare._y=pagechange.pagechangemask._y;
pagechange.pagechangemask._rotation=maskrotation+pagechange.pagechangemask._rotation;
pagechange.castshadow._rotation=pagechange.pagechangemask._rotation;
pagechange.glare._rotation=pagechange.pagechangemask._rotation;
pagechange.toppage._rotation=maskrotation*2;
pagechange.toppage._x=(cornerx-booksize._width)+(Math.sin(pagechange.toppage._rotation*degreestoradians)*booksize._height)-(Math.cos(pagechange.toppage._rotation*degreestoradians)*booksize._width/2);
pagechange.toppage._y=(cornery-booksize._height)-(Math.cos(pagechange.toppage._rotation*degreestoradians)*booksize._height)-(Math.sin(pagechange.toppage._rotation*degreestoradians)*booksize._width/2);
pagechange.glaremask._rotation=pagechange.toppage._rotation;
pagechange.glaremask._x=pagechange.toppage._x;
pagechange.glaremask._y=pagechange.toppage._y;
if((-pagechange.pagechangemask._x)==booksize._width){
pagechange.toppage._x=booksize._width*booksize._height;
pagechange.glaremask._x=pagechange.toppage._x;
}
if((cornerx-booksize._width*.85)>=0){
if(leftpage._currentframe>2){
pagechange.castshadow._alpha=100-((cornerx-booksize._width*.85)/(booksize._width*.15))*100;
}
pagechange.glare._alpha=100-((cornerx-booksize._width*.8)/(booksize._width*.2))*100;
}
}else if(changingpage=="right"){
maskrotation=Math.atan((cornery-booksize._height)/(cornerx-booksize._width))*radianstodegrees;
pagechange.pagechangemask._rotation=maskrotation;
pagechange.pagechangemask._x=(cornerx-booksize._width)/2;
pagechange.pagechangemask._y=(cornery-booksize._height)/2;
pagechange.castshadow._x=pagechange.pagechangemask._x;
pagechange.castshadow._y=pagechange.pagechangemask._y;
pagechange.glare._x=pagechange.pagechangemask._x;
pagechange.glare._y=pagechange.pagechangemask._y;
pagechange.toppage._rotation=maskrotation*2;
pagechange.castshadow._rotation=pagechange.pagechangemask._rotation;
pagechange.glare._rotation=pagechange.pagechangemask._rotation;
pagechange.toppage._x=(cornerx-booksize._width)+(Math.sin(pagechange.toppage._rotation*degreestoradians)*booksize._height);
pagechange.toppage._y=(cornery-booksize._height)-(Math.cos(pagechange.toppage._rotation*degreestoradians)*booksize._height);
pagechange.glaremask._rotation=pagechange.toppage._rotation;
pagechange.glaremask._x=pagechange.toppage._x;
pagechange.glaremask._y=pagechange.toppage._y;
if(cornerx<=booksize._width*.15){
if((leftpage._currentframe)<(leftpage._totalframes-3)){
pagechange.castshadow._alpha=((cornerx)/(booksize._width*.15))*100;
}
pagechange.glare._alpha=((cornerx)/(booksize._width*.15))*100;
}
}
}