AS3 Collision Help

OK could do with some help with this wee problem. 

Got 3 classes Game.as, Player.as and Floor.as. I would like to get Player to collide with floor.

I have no errors pop up in Flash but the trace("Hit") doesn't show??? Not sure what I am doing wrong.

Here is what I have so far.

//Game.as - https://dl-web.dropbox.com/get/Photos/Game.txt?w=a4e63240

//Player.as - https://dl-web.dropbox.com/get/Photos/Player.txt?w=301fb046

//Floor.as - https://dl-web.dropbox.com/get/Photos/Floor.txt?w=42dc6501

 

 

Any Help is welcome Thank you..

 

I can't open those files, and I also don't know actionscript, but I'll give it a go

When you say "collide with the floor" I assume you mean "how to add colision detection". It's usually a good idea to make an entire function handle all the collision detection. Did you add gravity to the game? If you did, it's as checking to see if the player is below or equals to the floor. if(player.y<=floor.y). That's if you have one single floor across the whole game. If you have multiple floors and platforms, again I don't know anything about actiionscript, but it's a better idea not to actually program the level details into the game.

AS3 has several built in methods for handling collision detection. Check out the documentation for the hitTestObect and hitTestPoint methods. It'll do all the math for you.

If you're just trying to learn the concepts by yourself, Arijan's method is the way to go.

To break it down a little more, create a variable called yVelocity that will control how far up or down your player will travel each frame. If your collision detection results return true, then set that velocity variable to 0. That's how I usually handle stuff like that.