# Page flip help

**URL:** <https://forum.kirupa.com/t/page-flip-help/297629>\
**Category:** flash\
**Created:** [October 6, 2009, 8:17am UTC](https://forum.kirupa.com/t/page-flip-help/297629 "2009-10-06T08:17:00Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![tomto](https://avatars.discourse-cdn.com/v4/letter/t/a183cd/32.png) [@tomto](https://forum.kirupa.com/u/tomto)\
**Post date:** [October 6, 2009, 8:17am UTC](https://forum.kirupa.com/t/page-flip-help/297629/1 "2009-10-06T08:17:00Z")

</div>

Hiya  
I’m modifying pixelwits pageflip component ([http://www.pixelwit.com/flip/PageFlip.html](http://www.pixelwit.com/flip/PageFlip.html)) for a project that i’m doing however there is one little function that I would like to add.

I would like the flip to action when the corner is pressed - instead of having to drag it across. How could I go about adding this in replacement of the code that is already there. To clarify I don’t want it to drag, just to move on click of the corner.

This is the code that controls the flip at present (draggable)

```auto
// __________________ F L I P P I N G F U N C T I O N S
// 
// How to adjust position of flipping page
// based on a value between 0 and 1
function flip(curVal) {
    var rot = dir*45*curVal;
    FBPageMask._rotation = FTPageMask._rotation=-rot;
    FBPage._rotation = FShadowMask._rotation=(dir*90)-rot*2;
    FShadow._rotation = SShadow._rotation=(dir*45)-rot;
}
// 
// 
// how to determine position of flipping page
// returns a value between 0 and 1
// zero being no-flip and one being full-flip
function getPageRatio() {
    if (dragging) {
        // if dragging page position is determined by mouse position
        // the 20 helps advance the turning page when the button is pressed
        pageRatio = -dir*(_xmouse-startX-dir*20)/(2*pageWi);
    } else {
        // if not dragging; auto increment page towards final position
        pageRatio>2/3 ? pageRatio += autoStep : pageRatio -= autoStep;
    }
    // if out of bounds
    if (pageRatio<=0) {
        pageRatio = 0;
        if (!dragging) {
            flipDone();
        }
    } else if (pageRatio>=1) {
        pageRatio = 1;
        if (!dragging) {
            flipDone();
        }
    }
    return (pageRatio);
    trace(pageRatio);
}

// _____________ C O N T R O L I N G F U N C T I O N S
// What to do when you press a page flipping button
function startFlip(dir) {
    pageInit(curPage+dir, dir);
    startX = dir*pageWi;
    dragging = true;
    RButton._alpha = 0;
    this.onEnterFrame = function() {
        flip(getPageRatio());
    };
}
// 
// 
// what to do when page is released
function flipRelease() {
    dragging = false;
    if (pageRatio>2/3) {
        curPage += 2*dir;
    }
}
// 
// 
// What to do when pages are done flipping
function flipDone() {
    this.onEnterFrame = null;
    RButton._alpha = 100;
    if (curPage != .5) {
        LButton._visible = 1;
    }
    if (curPage != maxPages+.5) {
        RButton._visible = 1;
    }
    // Delete hidden pages to save resources
    if (pageRatio == 0) {
        FShadow.removeMovieClip();
        FShadowMask.removeMovieClip();
        SShadow.removeMovieClip();
        SShadowMask.removeMovieClip();
        FBPage.removeMovieClip();
        FBPageMask.removeMovieClip();
        if (dir == 1) {
            SRPage.removeMovieClip();
        } else {
            SLPage.removeMovieClip();
        }
    } else {
        FTPage.removeMovieClip();
        if (dir == -1) {
            SRPage.removeMovieClip();
        } else {
            SLPage.removeMovieClip();
        }
    }
    FTPageMask.removeMovieClip();
}

// assign functions to button events
RButton.onPress = function() {
    startFlip(1);
};
RButton.onReleaseOutside = function() {
    flipRelease();
};
RButton.onRelease = function() {
    flipRelease();
};

```

Any help with this would be much appreciated.

Thanks  
Tom
