So.. I'm gonna go directly to the topic: I am making a book page flip effect in flash.. Imagine a thin book page and yourself opening that - Well that's what I have to recreate. I found 2 or 3 examples, and just picked the one I liked the most. The problem is that it's in AS1(the oldest version of flash's programming language), and I need to make it in AS3(for a reason of course). Anyway, I used the AS1 code as much as I could, but now it seems I have to go on on my own.. Enough history, let's get to the problem.
So, the current problem: Imagine 2 pages... 2 rectangles next to each other. Then imagine a 3rd one lying next to them... I better give you an example of what I'm trying to say.
There: Just did it fast on paint :P
That basically shows how should the 3rd rectangle move. The red circle at the top of the image shows where the registration point of the
3rd rectangle is. In case you are wondering what a registration point is - Well, it's the point around which a specific object rotates, and which specifies the object's X and Y coordinates(Z too, but that's totally unnecessary in this case).
And something important I almost forgot to say: The top left corner of the 1st rectangle is the place where X and Y are both 0.
Also, in Flash the Y axis
(or w.e word I had to use) is kind of inverted. -100 means 100pixels up for example, and, obviously, +100 means 100px down. The X axis is normal. -100 means 100px to the left and +100: 100px to the right.
And here's what I came up with so far(and obviously this is AS3):
<?php
function flip(currVal):void
{
//currVal returns the progress of the animation(0 to 1)
var rot = transDirection * 45 * currVal;
/*var posY = imagesHeight - imagesHeight*(currVal);
if (FBPage.rotation < 0)
{
posY = 0;
}
rect3.y = posY;/**/
rect3.rotation = (transDirection*90)-(rot*2);
var posX = (imagesWidth*2 - ((currVal)*imagesWidth*2))*transDirection;
if (posX >= imagesWidth)
{
rect3.y = imagesHeight - (imagesHeight/1.5*currVal);
}
else
{
rect3.y = imagesHeight - ((imagesHeight/1.5) - imagesHeight/1.5*currVal);
}
rect3.x = posX;
}
?>
transDirection is either +1 or -1, specifying which direction are we animating in. I'm not taking it in mind for this animation currently. I'm testing with +1 always... I'm going to fix the code up when I actually have progress on this. So, if you like to, you can just ignore it, like it isn't there. Other variables are self-explanatory I hope. rect3 is obviously the 3rd rectangle.
I'd be really grateful if I get any help on this, since I'm gonna be at school almost the whole day and I have to get it done by tomorrow evening, and yeah... Tomorrow I do have school again, and again - almost the whole day.
Going to ask my math teacher about it too.
[E] Here's the AS1 example, that I'm using:
http://www.pixelwit.com/blog/w ... 7/09/pageflip_notypos.zip
Thanks.