Edge detection for platformers?

Has anyone tried to implement edge detection? In other words, detecting when your character/player sprite is sitting on the edge of a platform? The way I was taught to implement this in other engines is that you have two raycasts pointing down the y-axis on the left and right of your character. These raycasts get the coordinates of the tiles your character is standing on.

Then you check and see if the tile coordinates returned by the raycasts on the right or the left are lower on the y axis than the tile coordinates returned by the other raycast.

[So far I can see how this would be implemented in Haxeflixel easily, save for the last part here.]

The final step is you compute the width of the player, the width of the tile the player is standing on, and at what point along the x-axis of the tile the player is standing (usually by referencing the raycast that is still detecting the tile that the player is standing on.)

the reason you do this last step is because you don't want to have a callback for an edge detection if, say, the player's bounding box is only 1 pixel over the edge of the platform. You only want this callback to fire just as the player is about to fall off the platform, this way you can load a sprite animation that shows the player struggling to maintain their balance. You could even have a function that pushes them off the edge if they remain in this position for too long.