ExternalInterface
is the standard way of communicating between AS3 and JS (see documentation):
import flash.external.ExternalInterface;
function showAlert()
{
// Check ExternalInterface is available
if (ExternalInterface.available)
{
ExternalInterface.call("alert", "Please enter your User name");
}
}