How to check a network connection status by flash?

how to check a network connection status with flash?
i found this data in help

If XMLSocket.connect returns a value of true, the initial stage of the connection process is successful; later, the XMLSocket.onConnect method is invoked to determine whether the final connection succeeded or failed. If XMLSocket.connect returns false, a connection could not be established.

Example

The following example uses XMLSocket.connect to connect to the host where the movie resides, and uses trace to display the return value indicating the success or failure of the connection.

function myOnConnect(success) {
if (success) {
trace (“Connection succeeded!”)
} else {
trace (“Connection failed!”)
}
}
socket = new XMLSocket()
socket.onConnect = myOnConnect
if (!socket.connect(null, 2000)) {
trace (“Connection failed!”)
}


isthis is what i need?
ONLY WHAT I WANT IS TO DRAW OUR NETWORK AS BUTTONS AND FLASH CHECKS EVERY DEVICE IS IT CONNECTED WELL OR NOT
AND ACCORDING TO THAT THE BUTTON COLOR CHANGES
IS IT POSSIBLE AND EASY WITH FLASH OR NOT???