I would like to share some knowledge that I have done for XMPP client in Flex with ActionScript 3.
For ActionScript 3, you must download XIFF API 3.0 from http://www.igniterealtime.org.
Here is the sample code that you can follow to create XMPP client in Flex with ActionScript 3.
For run this sample code, you must have account in XMPP Server like OpenFire or Ejabberd.

Create account name “sinal” and one more “lee” in XMPP Server.

MXML:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="initApp()">
	
<mx:Script>
<!&#91;CDATA&#91;
	import mx.controls.Alert;
	private var xmpp:XMPPSocket = new XMPPSocket();
	public function initApp():void
	{
		btnConnect.addEventListener(MouseEvent.CLICK, connectEvent);
		btnConnect.addEventListener(KeyboardEvent.KEY_DOWN, connectEvent);	
		txtMsg.addEventListener(KeyboardEvent.KEY_UP, keyUp);		
	}
	
	public function connectEvent(event:Event):void
	{
		xmpp.onCreationComplete();		
	}
	
	public function messageSend():void
	{
		var msg:String = txtMsg.text; 
		var jid:String = "lee@seven-pc";
		xmpp.sendMessage(jid, msg);
		txtMsg.text = "";
	}
	
	public function keyUp(event:KeyboardEvent):void
        {        	
            switch(event.keyCode)
            {
                case Keyboard.ENTER :
                    messageSend();
                    break;
            }
        }
&#93;&#93;>
</mx:Script>

<mx:states>
	<mx:State name="ConnectedState">		
		<mx:AddChild relativeTo="{form1}" position="lastChild">
			<mx:VBox width="422" height="179" id="vbox1">
			<mx:TextArea width="422" height="145" id="textTalk">						
				</mx:TextArea>
				<mx:HBox>
					<mx:Label text="Message:"/>
					<mx:TextInput width="289" id="txtMsg" keyUp="keyUp(event)"/>
					<mx:Button label="Send" id="btnSend" click="messageSend()"/>
				</mx:HBox>
			</mx:VBox>
		</mx:AddChild>
		<mx:SetProperty target="{formitem1}" name="label" value="Status:"/>
		<mx:RemoveChild target="{formitem1}"/>
		<mx:AddChild relativeTo="{vbox1}" position="before" target="{formitem1}"/>
		<mx:RemoveChild target="{btnConnect}"/>
		<mx:AddChild relativeTo="{form1}" position="lastChild" target="{btnConnect}"/>
	</mx:State>
</mx:states>


<mx:Form width="455" height="263" id="form1" horizontalCenter="-28" verticalCenter="-29">
	<mx:FormItem label="Status:" id="formitem1">
		<mx:Text id="textStatus" text="Offline"/>
	</mx:FormItem>
	<mx:Button label="Connect" id="btnConnect"/>
</mx:Form>

</mx:Application>

ActionScript :

package
{
import flash.events.TimerEvent;
import flash.utils.Timer;
import flash.xml.XMLDocument;

import mx.core.Application;

import org.jivesoftware.xiff.conference.Room;
import org.jivesoftware.xiff.core.JID;
import org.jivesoftware.xiff.core.XMPPSocketConnection;
import org.jivesoftware.xiff.data.Message;
import org.jivesoftware.xiff.data.Presence;
import org.jivesoftware.xiff.events.IncomingDataEvent;
import org.jivesoftware.xiff.events.LoginEvent;
import org.jivesoftware.xiff.events.MessageEvent;
import org.jivesoftware.xiff.events.RoomEvent;
import org.jivesoftware.xiff.events.XIFFErrorEvent;

public class XMPPSocket{
	private var connection:XMPPSocketConnection;
	private var keepAlive:Timer;
	
	private var username:String = "sinal";
	private var password:String = "123456";
	private var server:String = "seven-pc";
	//private var textDisplay:TextArea = Application.application.textTalk;
	
	
	public function onCreationComplete():Boolean
	{
		connection = new XMPPSocketConnection();
		connection.username = username;
		connection.password = password;
		connection.server = server;
		connection.port = 5222;				
	
		connection.addEventListener(LoginEvent.LOGIN, onLogin);
	    connection.addEventListener(XIFFErrorEvent.XIFF_ERROR, onError);
	    connection.addEventListener(IncomingDataEvent.INCOMING_DATA, onIncomingData);
	    connection.addEventListener(MessageEvent.MESSAGE, onMessage);
	    
	    keepAlive = new Timer(2 * 60 * 1000);
        keepAlive.addEventListener(TimerEvent.TIMER, onKeepAliveLoop);
				
		return connection.connect("standard");
		
	}
	
	public function onIncomingData(event:IncomingDataEvent):void
    {
           var xml:XMLDocument = event.data;
           //Application.application.textTalk.text = Application.application.textTalk.text + "\n" + String(xml);		         
    }
	
	private function onLogin(e:LoginEvent):void
	{			
		if(connection.isLoggedIn()){			
			Application.application.textStatus.text = "Online";
			Application.application.btnConnect.enabled = false;
			Application.application.btnConnect.visible = false;
			Application.application.currentState = 'ConnectedState';
		}
		
		trace("onLogin. " + e.toString());	

        keepAlive.start();
       
        var presence:Presence = new Presence(null, connection.jid, Presence.SHOW_CHAT, null, null, 1);        
        connection.send(presence);
        
		/*var room:Room = new Room(connection);
		room.roomJID = new JID("lee@conference.seven-pc");
		room.addEventListener(RoomEvent.ROOM_JOIN, onRoomJoin);
		room.join();*/
	}
	
	
	
	private function onRoomJoin(e:RoomEvent):void
	{
		Room(e.target).sendMessage("im here");
	}
	
	private function onError(e:XIFFErrorEvent):void
	{
		trace(e.errorMessage);
	}
	
	private function onKeepAliveLoop(event:TimerEvent):void
    {
            connection.sendKeepAlive();
    }
    
    
    public function sendMessage(jid:String, contentMsg:String):void
    {   	
    	var chattingWith:JID = new JID(jid);
    	var msg:Message = new Message(chattingWith, null, contentMsg, null, Message.CHAT_TYPE);
        if (connection.isLoggedIn())
        {
            connection.send(msg);
            addMessage(connection.jid, contentMsg);
        }       
    }
    
    private function onMessage(event:MessageEvent):void
    {
        trace("onMessage. " + event.toString());
        addMessage(event.data.from, event.data.body);
    }
    
    private function addMessage(from:JID, msg:String):void
    {
        var date:Date = new Date();
        Application.application.textTalk.text = Application.application.textTalk.text + "\n" + ("[" + date.getHours() + ":" + date.getMinutes() + " |  " + from.node + " ] " + msg);
    }
    
}
}