Yi's profile从这刻起PhotosBlogLists Tools Help

从这刻起

Photo 1 of 196
October 28

flash.net.Socket的使用

Flex2 中flash.net包中新增了一个类:Socket,该类是支持原始的二进制数据的读取(支持Byte,Bytes,Double,Float, Int,Object,Short,UnsignedByte,UnsignedInt,UnsignedShort,UTF,UTFBytes,Boolean 的直接读写),可以直接实现基于TCP的底层的Socket的连接,就象其他语言中的Socket一样,我们可以使用该类,建立Socket连接,通过 Socket连接实现C/S模式的常用应用,如Ftp客户端、点到点网络传输,当然也通过他来连接如QQ、MSN、GTalk等聊天软件的连接。

以下我们将使用Socket类连接 time.nist.gov的time服务,time服务是一种获取互联网时间的服务,默认端口是13,XP的Internet时间同步就是通过连接远端服务器的TIME服务来实现时间同步的(time.window.com/time.nist.gov)。

首先我们构造一个Socket:

private socket=new Socket()

因为,连接远程服务器是需要一个过程,这是个异步的连接,所以我们需要为我们的Socket添加相应的监听器,flash.net.Socket支持七种事件,各自对应Socket连接的相应状态:

  • close,当网络连接关闭时触发。
  • complete,数据导入完成时触发。
  • connect,当网络连接建立时触发。
  • ioError,当发送或者接收数据出现I/O错误时触发。
  • progress,当正在导入数据时触发。
  • securityError, 当调用Socket.connect()方法时,连接的服务器超出了安全沙箱限制或者连接的端口小于1024时触发。注意FlashPlayer现在的安全设置,不允许与与swf源服务器以外的服务建立连接。所以下面的示例实际打开会报securityError错(下载本地可以正常运行),解决办法需要使用代理的方式连接外部服务器。当然您可以通过Security.loadPolicyFile( 'http://要连接的服务器/crossdomain.xml' );可以扩展sandbox改变安全设置,很不幸,目前大多数的服务器并没有该文件。关于这个问题,我将在下期的“Flex2发现之旅”中详细说明。
  • socketData,当Socket连接接收到数据时触发。

我们使用addEventListener(type:String, listener:Function)方法为我们刚才创建的socket添加相应事件的监听器:

socket.addEventListener("close", onClose);
socket.addEventListener("socketData", onDataReceived);
socket.addEventListener("close", onClose);
socket.addEventListener("connect", onConnect);
socket.addEventListener("socketData", onDataReceived);
socket.addEventListener("ioError", onIOError);
socket.addEventListener("progress", onProgress);
socket.addEventListener("securityError", onSecurityError);

然后调用Socket的connect(host:String, port:uint)方法与服务器建立Socket连接:

socket.connect("time.nist.gov",13);

Time服务的原理时服务器监听到13端口有新的连接,服务器会马上将本机的时间发送给连接的客户端并断开连接,所有当socket.connect()连接time服务的时候,首先会触发一个 connect事件,表示连接已经建立,然后马上就会接收到服务器返回的数据,触发socketData事件,最后由于服务器断开了连接,又会触发一个 close事件,告诉我们连接已断开,整个Socket连接完成。所有我们要获取远程返回的时间,就必须处理socketData事件,并读取数据:

private function onDataReceived(event:Event):Void {
var input:String="";
while ( socket.bytesAvailable > 0 )
{
var byte: uint = socket.readUnsignedByte();
input += String.fromCharCode( byte );
}
ti_time.text=input.substring(1,input.length-1);
traces("Client received: "+input);
}

读取数据时,我们循环检查 socket.bytesAvailable,bytesAvailable属性,存放的是尚未读取的数据堆栈的字节大小,而每执行一次 socket.readUnsignedByte(),就从数据堆栈中读取一个UnsignedByte数据,bytesAvailable就减1,一直到bytesAvailable为0的时候表示我们已经将数据堆栈中所有数据读取完成。

至于ti_time.text=input.substring(1,input.length-1)是将获取的数据赋值给TextInput组件,其中input.substring(1,input.length-1)是因为Time服务返回的数据会新起一行,起其返回的时间数据,起始第一个字节是一个换行符,所以用substring方法将其去处。

TimeClient.mxml完整的代码如下:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.macromedia.com/2005/mxml" xmlns="*">

<mx:Script>
<![CDATA[
import flash.net.*;
private var hostName:String = "localhost";
private var port:int = 8080;
private var socket:Socket;

public function SocketExample() {
hostName=ti_server.text;
port=int(ti_port.text);
bt_send.enabled=false;
traces('connecting ...');
socket = new Socket();
configureListeners(socket);
socket.connect(hostName, port);
}
private function configureListeners(dispatcher:IEventDispatcher):Void {
dispatcher.addEventListener("close", onClose);
dispatcher.addEventListener("connect", onConnect);
dispatcher.addEventListener("socketData", onDataReceived);
dispatcher.addEventListener("ioError", onIOError);
dispatcher.addEventListener("progress", onProgress);
dispatcher.addEventListener("securityError", onSecurityError);
}

private function onClose(event:Event):Void {
traces("onClose: " + event);
bt_send.enabled=true;
bt_close.enabled=false;
}

private function onConnect(event:Event):Void {
traces("onConnect: " + event);
bt_send.enabled=true;
bt_close.enabled=true;
}
private function onDataReceived(event:Event):Void {
traces("onDataReceived: " + event);
var input:String="";
while ( socket.bytesAvailable > 0 )
{
var byte: uint = socket.readUnsignedByte();
var next: uint;
input += String.fromCharCode( byte );
}
ti_time.text=input.substring(1,input.length-1);
traces("Client received: "+input);

}


private function onIOError(event:IOErrorEvent):Void {
traces("onIOError: " + event);
}

private function onProgress(event:ProgressEvent):Void {
traces("onProgress loaded:" + event.bytesLoaded + " total: " + event.bytesTotal);
}

private function onSecurityError(event:SecurityErrorEvent):Void {
traces("onSecurityError: " + event);
}
private function traces(msg:String):Void{
ta_debug.text=ta_debug.text+"\n"+msg;
}

private function close():Void{
socket.close();

}
]]>
</mx:Script>


<mx:Canvas width="100%" height="100%">
<mx:Label x="31" y="18" text="Server:"/>
<mx:TextInput x="79" y="18" id="ti_server" text="time.nist.gov"/>
<mx:Label x="44" y="51" text="Port:"/>
<mx:TextInput x="79" y="50" width="53" text="13" id="ti_port"/>
<mx:Label x="39" y="79" text="Time:"/>

<mx:TextInput x="79" y="80" id="ti_time" editable="false"/>

<mx:Button x="79" y="112" label="Get Time" id="bt_send" click="SocketExample();"/>
<mx:Button x="166" y="112" label="Close" id="bt_close" click="close();"/>

<mx:HRule x="35" y="139" height="20" width="408"/>

<mx:Label x="37" y="152" text="Debug Info:"/>
<mx:TextArea x="38" y="175" width="404" height="111" editable="false" id="ta_debug"/>


</mx:Canvas>

</mx:Application>

May 21

Flex 3 web conférence (client)

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="init()" width="1257" height="514">
    <mx:Script>
        <![CDATA[
            import flash.utils.Timer;
           
            import flash.events.TimerEvent;
            import flash.events.StatusEvent;
            import flash.events.MouseEvent;
            import flash.events.NetStatusEvent;
            import flash.events.SecurityErrorEvent;
            import flash.events.Event;
            import flash.events.SyncEvent;

            import flash.system.SecurityPanel;
            import flash.system.Security;

            import flash.net.NetConnection;
            import flash.net.NetStream;
            import flash.net.SharedObject;
           
            // streaming server
            private var fms_url:String = "rtmp://localhost/live/";
            private var streamName:String = "recording";

            private var so_url:String = "rtmp://localhost/SharedBall";
           
            // Netstream object
            private var play_ns:NetStream;
           
            // NetConnection object
            private var client_nc:NetConnection;
           
            // Shared object
            private var so:SharedObject;
           
            // sharedObject connection
            private var so_nc:NetConnection;
                   
            // page init
            private function init():void {
                // Add onBWDone() function of the NetConnection object
                NetConnection.prototype.onBWDone = handleBWDone;
               
                // Live NetConnection        
                client_nc = new NetConnection();
               
                //sharedObject NetConnection
                so_nc = new NetConnection();
               
                //share objects connection
                so_nc.connect(so_url);
                so_nc.addEventListener(NetStatusEvent.NET_STATUS, so_netStatusHandler);
           
            }
           
            // sharedObject status event function
            private function so_netStatusHandler(event:NetStatusEvent):void {
                        trace("connected is: " + so_nc.connected );
                        trace("event.info.level: " + event.info.level);
                        trace("event.info.code: " + event.info.code);
           
                        switch (event.info.code) {
                            case "NetConnection.Connect.Success" :
                                trace("Congratulations! you're connected");
                                so = SharedObject.getRemote("ballPosition", so_nc.uri, true);
                                so.connect(so_nc);
                                so.addEventListener(SyncEvent.SYNC, so_syncHandler);
                                break;
                            case "NetConnection.Connect.Rejected" :
                            case "NetConnection.Connect.Failed" :
                                trace("Oops! you weren't able to connect");
                                break;
                        }
            }
 
             // shared object synchro event function
            private function so_syncHandler(event:SyncEvent):void {
                        if (so.data.msg != undefined) {
                            MsgTxt_Server.text = so.data.msg;
                        }
                        if (so.data.status != undefined) {
                            if (so.data.status == "start") {
                                Connect_btn.enabled = true;
                            } else if (so.data.status == "stop") {
                                Connect_btn.enabled = false;
                            }
                        }
                        if (so.data.source != undefined) {
                            img.source = so.data.source;
                        }
            }       

            // fullscreen bouton click function
            private function fsBtnListener():void  {
                switch(stage.displayState) {
                            case "normal":
                                stage.displayState = "fullScreen";
                                break;
                            case "fullScreen":
                            default:
                                stage.displayState = "normal";
                                break;
                        }
           
            }

            // play bouton click function
            private function playBtnListener():void  {
                if (Play_btn.label == "Play") {
                    Play_btn.label = "Stop";
                    play_ns.play(streamName);
                } else {
                    play_ns.close();
                    Play_btn.label = "Play";
                }
            }


            // connect bouton click
            private function connectBtnListener():void  {
                if (Connect_btn.label == "Connect") {
                    client_nc.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
                    client_nc.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);
                    client_nc.connect(fms_url);               
                } else {
                    client_nc.close();
                    debug1_txt.text = "";
                }
            }
       
            private function handleBWDone():void{
                    trace("onBWDone : ");   
            }
            // NetConnection  & NetStream status function
            private function netStatusHandler(event:NetStatusEvent):void {
                        switch (event.info.code) {
                            case "NetConnection.Connect.Success":                               
                                BP.text = "The connection attempt succeeded.";
                                Connect_btn.label  = "Disconnect";
                                Play_btn.enabled = true;
                                Play_btn.label = "Play";
                                openStreams();
                                //connectStream();
                                break;
                            case "NetConnection.Connect.Failed":
                                trace("NetConnection.Connect.Failed");
                                BP.text = "The connection attempt failed.";
                                Connect_btn.label  = "Connect";
                                Play_btn.enabled = false;
                                Play_btn.label = "Play";
                                break;
                            case "NetConnection.Connect.Closed":
                                trace("NetConnection.Connect.Closed");
                                BP.text = "The connection was closed successfully.";
                                Connect_btn.label  = "Connect";
                                Play_btn.enabled = false;
                                Play_btn.label = "Play";                               
                                break;   
                            case "NetStream.Failed":
                                trace("NetConnection.Connect.Failed");
                                BP.text = " An error has occurred.";
                                Play_btn.label = "Play";                               
                                break;     
                            case "NetStream.Play.Start":
                                trace("NetStream.Play.Start");
                                BP.text = "Playback has started.";
                                Play_btn.label = "Stop";                               
                                break;       
                            case "NetStream.Play.Stop":
                                trace("NetStream.Play.Start");
                                BP.text = "Playback has stopped.";
                                Play_btn.label = "Play";                               
                                break;                               
                            case "NetStream.Play.Failed":
                                trace("NetStream.Play.Failed");
                                BP.text = "An error has occurred in playback.";
                                Play_btn.label = "Play";                               
                                break;       
                            case "NetStream.Play.StreamNotFound":
                                trace("NetStream.Play.Start");
                                BP.text = "The FLV passed to the play() method can't be found.";
                                Play_btn.label = "Play";
                                break;           
                            case "NetStream.Play.Reset":
                                trace("NetStream.Play.Start");
                                BP.text = "Caused by a play list reset.";
                                break;   
                            case "NetStream.Play.Reset":
                                trace("NetStream.Play.Start");
                                BP.text = "Caused by a play list reset.";
                                break;       
                            case "NetStream.Buffer.Empty":
                                trace("NetStream.Play.Start");
                                BP.text = "Data is not being received quickly enough to fill the buffer.";
                                break;       
                        }
            }

            private function securityErrorHandler(event:SecurityErrorEvent):void {
                    trace("securityErrorHandler: " + event);
            }

            private function asyncErrorHandler(event:AsyncErrorEvent):void {
                // ignore AsyncErrorEvent events.
            }

            private function openStreams():void {
                Play_btn.enabled = true;
                play_ns = new NetStream(client_nc);
                play_ns.play(streamName);
                play_ns.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
                play_ns.addEventListener(AsyncErrorEvent.ASYNC_ERROR, asyncErrorHandler);
            }   
     ]]>
    </mx:Script>
    <mx:VBox>
            <mx:Label text="" width="1098" id="MsgTxt_Server" height="18"/>
<mx:HBox>   
    <mx:VBox>
<mx:VideoDisplay id="Live_Video" width="640" height="480"/>
    </mx:VBox>
    <mx:VBox>
        <mx:Image id="img"
                maintainAspectRatio="true"
                horizontalAlign="center"
                width="580"
                height="100%" />
    <mx:Label x="20" y="538" text="" id="BP" width="416"/>
        <mx:HBox x="20" y="508">
            <mx:Button label="Connect" id="Connect_btn" width="80" click="connectBtnListener()"/>
            <mx:Button label="Publish" id="Play_btn" width="80"  click="playBtnListener()" enabled="false"/>
            <mx:Button label="FullScreen" id="FullScreen_btn" width="100"  click="fsBtnListener()"/>
            <mx:Label text="" width="176" id="debug1_txt" height="18"/>           
        </mx:HBox>
    </mx:VBox>               
</mx:HBox>   
</mx:VBox>
</mx:Application>


Flex 3 web conférence (serveur)

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" width="1291.7999" height="612"
creationComplete="init()" >
    <mx:Script>
        <![CDATA[
            import flash.media.Camera;
            import flash.media.Microphone;
           
            import flash.utils.Timer;
           
            import flash.events.TimerEvent;
            import flash.events.StatusEvent;
            import flash.events.MouseEvent;
            import flash.events.NetStatusEvent;
            import flash.events.SecurityErrorEvent;
            import flash.events.Event;
            import flash.events.SyncEvent;

            import flash.system.SecurityPanel;
            import flash.system.Security;

            import flash.net.NetConnection;
            import flash.net.NetStream;
            import flash.net.SharedObject;
           
            import mx.controls.Alert;
            import mx.collections.ArrayCollection;
            import mx.rpc.events.ResultEvent;
           
            [Bindable]
            private var arr:XMLList;
       
            private var client_cam:Camera;
            private var client_mic:Microphone;
           
            // streaming server address
            private var fms_url:String = "rtmp://localhost/live/";
           
            // sharedObject server address
            private var so_url:String = "rtmp://localhost/SharedBall";
            private var streamName:String = "recording";
   
            // NetConnection object
            private var client_nc:NetConnection;
           
            // Netstream object
            private var record_ns:NetStream;
           
            // sharedObject
            private var so:SharedObject;
           
            // sharedObject NetConnection
            private var so_nc:NetConnection;

            // page init
            private function init():void {
                // microphone object
                client_mic = Microphone.getMicrophone();
                Security.showSettings(SecurityPanel.MICROPHONE);
                client_mic.setLoopBack(true);
                                   
                if (client_mic != null) {
                    client_mic.setUseEchoSuppression(true);
                    //client_mic.setRate(sampleRate_array[4]);//44.1k Hz as2
                    //client_mic.rate(sampleRate_array[4]);
                }
               
                // camera object
                client_cam = flash.media.Camera.getCamera();
               
                // camera setting
                client_cam.setQuality(0,100);
                client_cam.setMode(640,480,30);
                client_cam.setKeyFrameInterval(48);
               
                // attacher video object   
                Live_Video.attachCamera(client_cam);

                // Add onBWDone() function of the NetConnection object
                NetConnection.prototype.onBWDone = handleBWDone;
               
                // Live NetConnection        
                client_nc = new NetConnection();
               
                //sharedObject NetConnection
                so_nc = new NetConnection();
               
                //share objects connection
                so_nc.connect(so_url);
                so_nc.addEventListener(NetStatusEvent.NET_STATUS, so_netStatusHandler);
            }
           
            // NetConnection onBWDone() function
            private function handleBWDone():void{
                    trace("onBWDone : ");   
            }
           
            // SharedObject NetConnection & NetStream event handle
            private function so_netStatusHandler(event:NetStatusEvent):void {
                        trace("connected is: " + so_nc.connected );
                        trace("event.info.level: " + event.info.level);
                        trace("event.info.code: " + event.info.code);
           
                        switch (event.info.code) {
                            case "NetConnection.Connect.Success" :
                                trace("Congratulations! you're connected");
                                so = SharedObject.getRemote("ballPosition", so_nc.uri, true);
                                so.connect(so_nc);
                                so.addEventListener(SyncEvent.SYNC, so_syncHandler);
                                break;
                            case "NetConnection.Connect.Rejected" :
                            case "NetConnection.Connect.Failed" :
                                trace("Oops! you weren't able to connect");
                                break;
                        }
            }
           
            //NetConnection & NetStream event handle
            private function netStatusHandler(event:NetStatusEvent):void {
                            switch (event.info.code) {
                                case "NetConnection.Connect.Success":
                                    Connect_btn.label  = "Disconnect";   
                                    Record_btn.enabled = true;
                                    Record_btn.label = "Publish";   
                                                              
                                    BP.text = "The connection attempt succeeded.";
                                    openStreams();
                                    break;
                                case "NetConnection.Connect.Failed":
                                    Connect_btn.label = "Connect";
                                    Record_btn.enabled = false;   
                                    Record_btn.label = "Publish";
                                    trace("NetConnection.Connect.Failed");
                                    BP.text = "The connection attempt failed.";
                                    break;
                                case "NetConnection.Connect.Closed":
                                    Connect_btn.label = "Connect";
                                    Record_btn.enabled = false;   
                                    Record_btn.label = "Publish";
                                    trace("NetConnection.Connect.Closed");
                                    if (so.data.status != undefined) so.setProperty("status", "stop");   
                                    BP.text = "The connection was closed successfully.";
                                    break;                           
                                case "NetStream.Publish.Start":
                                    BP.text = "Publish was successful.";
                                    Record_btn.label = "Stop";
                                    if (so.data.status != undefined) so.setProperty("status", "start");
                                    break;                   
                                case "NetStream.Publish.BadName":
                                    BP.text = "Attempt to publish a stream which is already being published by someone else";
                                    Record_btn.label = "Publish";
                                    break;   
                                case "NetStream.Publish.Idle":
                                    BP.text = "The publisher of the stream is idle and not transmitting data.";
                                    Record_btn.label = "Publish";
                                    break;   
                                case "NetStream.Unpublish.Success":
                                    BP.text = "The unpublish operation was successful.";
                                    Record_btn.label = "Publish";
                                    if (so.data.status != undefined) so.setProperty("status", "stop");                                   
                                    break;   
                            }
           }
          
            private function securityErrorHandler(event:SecurityErrorEvent):void {
                        trace("securityErrorHandler: " + event);
            }
           
            private function asyncErrorHandler(event:AsyncErrorEvent):void {
                        // ignore AsyncErrorEvent events.
            }
           
            //sharedObject sychro event
            private function so_syncHandler(event:SyncEvent):void {
                        if (so.data.msg != undefined) {
                            MsgTxt_Server.text = so.data.msg;
                        }
            }
           
            // Stream Connection
            private function openStreams():void {
                record_ns = new NetStream(client_nc);
                record_ns.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
                record_ns.addEventListener(AsyncErrorEvent.ASYNC_ERROR, asyncErrorHandler);
           
                record_ns.attachCamera(client_cam);
                record_ns.attachAudio(client_mic);
               
                var debug1_interval:Number = setInterval(debug1Thing, 100, record_ns);
            }
           
            // Connect bouton click event
            private function connectBtnListener():void  {
                if (Connect_btn.label == "Connect") {
                    client_nc.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
                    client_nc.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);
                    client_nc.connect(fms_url);               
                } else {
                    client_nc.close();
                }
            }
            // Publish bouton click
            private function recBtnListener():void  {
                if (Record_btn.label == "Publish") {
                    record_ns.publish(streamName,"live");
                    Record_btn.label = "Stop";
                } else {
                    record_ns.close();
                    Record_btn.label = "Publish";
                }
            }
            // FullScreen bouton click event function
            private function fsBtnListener():void  {
                switch(stage.displayState) {
                            case "normal":
                                stage.displayState = "fullScreen";
                                break;
                            case "fullScreen":
                            default:
                                stage.displayState = "normal";
                                break;
                        }
           
            }   
           
            // Message send Bouton click
            private function msgBtnListener():void  {
                if ( so != null ) {
                            so.setProperty("msg", MsgTxt.text);
                }
            }           
            // Show publish Timer
            private function debug1Thing(that_ns:NetStream):void {
                if (that_ns.time > 0) {
                    debug1_txt.text = "time: "+Math.floor(that_ns.time) + " s";
                }
            }
           
            //image click event
            private function showImages(e:ResultEvent):void {
                var result:XML =  e.result as XML;
                arr = result.diapo;
            }
           
            //image click event
            private function synchroDiapo():void {
                if ( so != null ) {
                            so.setProperty("source", img.source.toString());
                }
                //Alert.show(img.source.toString(),"image source", Alert.OK | Alert.CANCEL);
            }           
        ]]>
    </mx:Script>
    <mx:HTTPService id="imagesService" url="http://localhost/kadmin/flexProxy.php"
result="showImages(event)" resultFormat="e4x"/>
<mx:HBox>
    <mx:VBox><mx:Label text="" width="640" id="MsgTxt_Server"/>
        <mx:VideoDisplay id="Live_Video" width="640" height="480"/>
        <mx:Label x="20" y="538" text="" id="BP" width="433"/>
        <mx:HBox x="20" y="508">
            <mx:Button label="Setting" id="Setting_btn" width="80" click=""/>       
            <mx:Button label="Connect" id="Connect_btn" width="80" click="connectBtnListener()"/>
            <mx:Button label="Publish" id="Record_btn" width="80"  click="recBtnListener()" enabled="false"/>
            <mx:Button label="FullScreen" id="FullScreen_btn" width="100"  click="fsBtnListener()"/>
            <mx:Label text="" width="200" id="debug1_txt"/>           
        </mx:HBox>
        <mx:HBox>
        <mx:TextInput width="552" id="MsgTxt"/>
        <mx:Button label="Send"  id="Msg_btn" click="msgBtnListener()"/>
        </mx:HBox>
    </mx:VBox>
    <mx:VBox>
        <mx:Panel title="{horizontalList.selectedItem.@label}"
            height="100%"
            horizontalAlign="center">
    <mx:Image id="img"
                source="{horizontalList.selectedItem.@thumbnailImage}"
                maintainAspectRatio="true"
                horizontalAlign="center"
                width="440"
                height="330" />
        <mx:HorizontalList id="horizontalList"
                    labelField="thumbnailImage"
                    dataProvider="{arr}"
                    itemRenderer="CustomItemRenderer"
                    columnCount="4"
                    columnWidth="150"
                    rowCount="1"
                    rowHeight="110"
                    horizontalScrollPolicy="on" />
       <mx:HBox>
       <mx:Button label="Get diapos" click="imagesService.send()"/>
       <mx:Button label="Synchro diapo" click="synchroDiapo()"/>
       </mx:HBox> 
       </mx:Panel>                 
    </mx:VBox>
</mx:HBox>   
   
</mx:Application>
///////////////////////////////////////////////////////////////////////////
//////////    CustiomItemRenderer.mxml          /////////
///////////////////////////////////////////////////////////////////////////
<?xml version="1.0" encoding="utf-8"?>
<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml"
        horizontalAlign="center"
        verticalAlign="middle">
    <mx:Image source="{data.@thumbnailImage}" width="120" height="100%"/>
    <mx:Label text="{data.@label}" />
</mx:VBox>

May 14

我的祷告



耶 和 华 阿 , 求 你 不 要 在 怒 中 责 备 我 (们), 也 不 要 在 烈 怒 中 惩 罚 我(们) 。 (诗  6:1)   

主啊, 为什么有那么多, 持续不断的天灾人祸, 从百年不遇的雪灾, 西藏暴乱 到现在汶川大地震, 数以万计的生命一瞬那间消失, 有多少家庭破灭, 有多少亲人失去, 有多少人没了丈夫和妻子, 有多少人成为孤儿, 有多少白发人送黑发人, 有多少人在等待救援, 有多少受伤的人, 在失血, 在饥饿, 在黑夜和风雨中煎熬,

我 在 患 难 之 日 要 求 告 你 。 因 为 你 必 应 允 我(们)。 (诗 86:7)
难 道 我 们 从 神 手 里 得 福 , 不 也 受 祸 麽 (伯2:10 )  
赏 赐 的 是 耶 和 华 , 收 取 的 也 是 耶 和 华 。 耶 和 华 的 名 是 应 当 称 颂 的 。(伯1:21)

主啊, 你是创造宇宙万物的主, :你说 , 要 有 光 , 就 有 了 光, (创1)  

你 要 将 天 地 卷 起 来 , 像 一 件 外 衣 , 天 地 都 改 变 了 。 惟 有 你 永 不 改 变 , 你 的 年 数 没 有 穷 尽 。(希1:12)

主啊, 求你邦助在地震困境中的,
感谢你赐下的话语, 你说  压 伤 的 芦 苇 , 他 不 折 断 。 将 残 的 灯 火 , 他 不 吹 灭 。(以42:3)  
主啊,你又说   你(们)的 日 子 如 何 , 你(们) 的 力 量 也 必 如 何 。 (申33:25)

主啊, 求你让在这次地震中不幸死亡的人们特别是正在上课的中小学生们的灵魂进入天堂安息,    求你大能的手邦助在地震受伤 面临死亡, 忍受饥饿, 感到恐拒的人们, 求他们早日看到救援 , 获得治疗,  没了住所的人早日有安身之处, 中断的交通尽快通车,  失去亲人的得到安慰, 有能的人都伸岀邦助的手

耶 和 华 阿 , 人 算 什 么 , 你 竟 认 识 他 。 世 人 算 什 么 , 你 竟 顾 念 他 。 (伯7:17诗8:4 诗144:3 )

感谢主, 这次地震发生在白天, 而不是在人们的睡梦中, 发生在人口不多的山区, 而不是在工业重镇, 发生在国力不断增强的这二十年后的今天, 有亲自在抗灾第一线的总理, 有空投到灾区的人民解放军, 救灾工作还是相当迅速的, 也有网上这么多富有同情心的中国人

我 们 在 天 上 的 父 , 愿 人 都 尊 你 的 名 为 圣 。   
愿 你 的 国 降 临 , 愿 你 的 旨 意 行 在 地 上 , 如 同 行 在 天 上 。  
我 们 日 用 的 饮 食 , 今 日 赐 给 我 们 。  
免 我 们 的 债 , 如 同 我 们 免 了 人 的 债 。  
不 叫 我 们 遇 见 试 探 , 救 我 们 脱 离 凶 恶 , 因 为 国 度 , 权 柄 , 荣 耀 , 全 是 你 的 , 直 到 永 远 , 阿 们 。
(太6:9 -13)
January 29

看准婚姻晴雨表


  下面这些问题的目的是测验有些人婚姻为什么出问题,当你答复这些问题的时候,你或许会发现这些问题很值得一答。如果每个问题你的答复是的话,每题就可得10分。

  1问丈夫的问题

  (1)你是否还在追求你的太太?如偶尔送她一束花,记住她的生日和结婚纪念日,或出乎她意料的殷勤,非她所预期的体贴。

  (2)你是否注意永远不在他人面前批评她?

  (3)除了家庭开支以外,你是否还给她一些钱,让她随意使用?

  (4)你是否花时间去了解她各种女性方面的情绪问题,并帮助她度过疲倦、紧张不安的时期?

  (5)你是否至少空出你一半的娱乐时间,跟你太太共度?

  (6)除了可以显示她的长处,你是否机智地避免把你太太的烹调手艺和理家本领跟你母亲或某某人的太太相比较?

  (7)对于她的内心活动,她的俱乐部和社团,她所看的书。和她对地方行政的看法,你是否也有一定的兴趣?

  (8)你是否能够让她和其他男人跳舞,接受他们的友谊和照顾,而不会说些吃醋的话?

  (9)你是否经常注意找机会夸奖她,和你对她的赞赏?

  (10)关于她为你做的小事情,如缝纽扣、补袜子,把衣服送去洗,你是否会谢谢她?

  2问太太的问题

  (1)你是否让丈夫有处理公事上的完全自由,并避免批评他交往的人、他所选的秘书,或他所保留的自由时间?

  (2)你是否尽力使家庭有品味和有吸引力?

  (3)你是否常常改变口味,使他坐到桌上的时候还弄不清楚会吃什么?

  (4)对于你丈夫的事业,你是否有适当的了解,以便跟他做有益的讨论?

  (5)在金钱拮据的时候,你是否能勇敢地、愉快地面对这种情形,并不批评你丈夫的错处,或把他跟成功的人做不利于他的比较?

  (6)对于他的母亲或其他亲戚,你是否尽特别的努力,和他们融洽相处?

  (7)你选择衣着时,是否注意到他对颜色和样式上面的好恶?

  (8)为了家庭和睦,你是否牺牲一点自己的意见?

  (9)你是否尽力学学丈夫所喜爱的运动方式,以便和他共享休闲的时间?

  (10)你是否阅读当今的新闻、新书和新技术,以便在智慧兴趣方面,配合你的丈夫?

  婚姻是两人心灵的融洽,在融合中创意人生,才是最幸福的家庭。