http://www.fastswf.com/J4oIStE (A & D to move left/right, SPACE to jump)
Something like this? I know you can get stuck in the platform but im sure you can figure out how to solve this :).
So, here is my MovingPlatform class; http://pastebin.com/FqvcnRAS
So here you can see I keep track of a dX and dY which are public variables. I simply add the platform to my level (Im sure you know how to do this), and then this is my Player class code, specifically, the update() code;
super.update();
var iX:int = 0;
if (Input.check(Key.A)) iX--; if (Input.check(Key.D)) iX++;
//
_dX = 200 * FP.elapsed * iX; //Horizontal movement
//
// solid is just static Grid mask, movingSolid is any MovingPlatform class type
var colliders:Entity = collideTypes(["solid", "movingSolid"], x, y + 1);
if (colliders)
{
_dY = 0; //Set our dY to 0 because we are on ground
if (colliders is MovingPlatform) //But, if we are on a MovingPlatform
{
_dX += MovingPlatform(colliders).dX; //Lets add the platforms dX to our players
}
if (Input.pressed(Key.SPACE))
{
_dY = -10; //Jump code (v. basic)
}
}
else
{
_dY += 30 * FP.elapsed; //If we are not on ground, increase our dY
}
moveBy(_dX, _dY, ["solid", "movingSolid"]); //FP's magical moveBy function is useful!
Apologies if I have not explained this well, I can upload the source files if you wish to look.
NOTES: I know the code is messy and not ideal, but it shows how the basic idea works. It can easily be improved. I also know there are a few var’s in there I never use, thats because I was testing!
EDIT: Uploaded the FlashDevelop project for anyone interested (Again, the code is messy & buggy! Maybe try improve it?) - FP-Platformer.zip(277.3 KB)