Results 1 to 8 of 8
  1. #1
    Member
    Join Date
    Mar 2010
    Location
    Ho Chi Minh
    Posts
    5

    Chat Demo in Flash???

    I'm a newbie, I have run the ChatDemo and the Flash_StockListDemo. But now I want to run the ChatDemo use Flash, like the ChatDemo in normal HTML, can you help me? Because when I use ChatDemo in normal HTML, I have DynaScrollTable class to scroll, with 2 methods: setAutoScroll and setUpwardScroll. But in Flash, I only have the FlashTable class, and it don't have 2 above methods.

  2. #2
    Power Member
    Join Date
    Jul 2006
    Location
    Cesano Maderno, Italy
    Posts
    784
    hi,

    I'm sorry but we don't have visual tables for the flash bridge, so you have to handle the visualization of the received updates.

    You may use the flex library (sdk_client_flash_flex(native_as)) instead of using the flash bridge (sdk_client_flash_flex(js_bridge)) and exploit the VisualTable class binded to a flex DataGrid, but such flex library is not available in the moderato version of Lightstreamer. Let me know if you want me to expand on this.

  3. #3
    Member
    Join Date
    Mar 2010
    Location
    Ho Chi Minh
    Posts
    5
    I have a simple example chat demo use Flash like:
    The index.html:
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <!--
      LIGHTSTREAMER - www.lightstreamer.com
      Flash Bridge Stock-List Demo
    -->
    
    <html>
    
    <head>
      <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
      <title>Lightstreamer :: Flash Bridge :: Chat Demo</title>
      <link rel="stylesheet" type="text/css" href="css/chat.css" />
      <!-- load Lightstreamer libraries -->
      <script src="../commons/lightstreamer/lscommons.js" type="text/javascript"></script>
      <script src="../commons/lightstreamer/lspushpage.js" type="text/javascript"></script>
    
      <!-- load Lightstreamer Flash Bridge -->
      <script src="bridge/lsflashbridge.js" type="text/javascript"></script>
    
      <!-- load some code, shared among most of these demo applications, used for
           creating or seeking the Master Push-Page and the Engine.
           Please study carefully the source code of misc.js to learn how it works
           and to change it at your convenience -->
      <script src="../commons/custom/misc.js" type="text/javascript"></script>
    </head>
    <body>
    	<!-- Flash object -->
    	<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="400" height="300" id="flashObject" style="margin-left: 12px;">
    		<param name="allowScriptAccess" value="sameDomain" />
    		<param name="movie" value="demoFlashChat.swf" />
    		<param name="quality" value="high" />
    		<param name="bgcolor" value="#ffffff" />
    		<embed src="demoFlashChat.swf" quality="high" bgcolor="#ffffff" width="400" height="300" name="flashObject" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
    	</object>
    <!-- message submission form -->
      <form onSubmit="submitForm(); return false;" class="formPanel">
        <div class="sendTitle">Send a message:</div>
        <div class="formElements">
          <input id="user_message" type="text" size="70" />
          <input id="mex_button" type="submit" value="Send" />
        </div>
      </form>
    
    <!-- JavaScript code specific of this application -->  
    <script type="text/javascript">
      function submitForm() {
        var textField = document.getElementById("user_message");
        if (window.engineRef && textField) {
          var text = textField.value;
          textField.value = "";
          if (!text) {
            alert("Can't send an empty message");
          } else {
            var mex = "CHAT|" + text;
            engineRef.sendMessage(mex, "Chats", null, 5000);
          }
        }
      }
    
      //////////////// JavaScript code that extends some functions defined in misc.js
    
      // remember the current engine reference, if any
      var engineRef = null;
    
      // define an extension to the onEngineReady callback defined in misc.js
      function onEngineReady(lsEngine) {
        // store the engine reference
        engineRef = lsEngine;
      }
      // define an extension to the onEngineLost callback defined in misc.js
      function onEngineLost() {
        engineRef = null;
      }
      // these two functions are defined in misc.js
      var pushPage = initializeDemoPushPage("../commons/custom/", true, onEngineReady, onEngineLost);
      initializeDemoEngine(pushPage, "../commons/lightstreamer/", null);
      
    //////////////// Flash Bridge Configuration
    	var flashHandler = new FlashBridge("flashObject");
    
    </script>
    
    </body>
    
    </html>
    And the demoFlashChat.fla with 2 input text: text1 and statusField,with as code like:
    Code:
    import flash.external.ExternalInterface;
    #include "..\lib\lsjavascriptbridge.as"
    
    _root.text1.text = "";
    _root.statusField.text = "WAITING";
    
    function bridgeIsReady() {
    	_root.statusField.text = "Bridge ready";
    }
    
    function statusChange(newStatus) {
    	_root.statusField.text = newStatus;
    }
    
    function myOnStart() {
    	_root.text1.text = "";
    }
    function myOnItemUpdate(itemPos,itemObj,itemName) {
    	if (itemPos == 1) {
    		if (itemObj.isValueChanged(1) == true) {
    			_root.text1.text = itemObj.getNewValue(1);
    		}
    	}
    }
    
    var bridge = new JavaScriptBridge("flashObject");
    bridge.onReady = bridgeIsReady;
    bridge.onStatusChange = statusChange;
    var myTable = new FlashTable("chat_room", null, "DISTINCT");
    myTable.setDataAdapter("CHAT_ROOM");
    myTable.setSnapshotRequired(true);
    
    myTable.onItemUpdate = myOnItemUpdate;
    myTable.onStart = myOnStart;
    bridge.addTable(myTable,"FlashTable1");
    
    bridge.bind();
    2 above code file are combined from 2 your demo: ChatDemo and Flash_StockListDemo_Basic. But it can't run.I don't know. The problem maybe in callback function: myOnItemUpdate,because when I try put a code line as:_root.text1.text = "test" in this function(I'm so sorry, because now I only know debug like that in Flash), it don't display, but in your example(Flash_StockListDemo_Basic), a same line will display.
    The above example only make a simple work: when user type a text line on HTML form, it transmit to LS server, then back to text1 variable in Flash, and display.
    Thanks for your help!

  4. #4
    Administrator
    Join Date
    Jul 2006
    Location
    Milan
    Posts
    1,093
    You supply a null argument for the schema in your FlashTable constructor.
    This is not supported by the library; using null is only supported by the javascript library, which looks for fields mentioned in the cells declared within the page.

    You should explicitly supply an array containing the names of the available fields, namely "timestamp", "IP", "nick" and "message".

  5. #5
    Member
    Join Date
    Mar 2010
    Location
    Ho Chi Minh
    Posts
    5
    Quote Originally Posted by DarioCrivelli
    You supply a null argument for the schema in your FlashTable constructor.
    This is not supported by the library; using null is only supported by the javascript library, which looks for fields mentioned in the cells declared within the page.

    You should explicitly supply an array containing the names of the available fields, namely "timestamp", "IP", "nick" and "message".
    Thanks!I have just fixed. And I have another question as:in Flash/Flex client,does the method look like the sendMessage()(lsengine.js->LightstreamerEngine) ??? I want to send a text message in Flash application to the Server but I don't know the way.

  6. #6
    Power Member
    Join Date
    Jul 2006
    Location
    Cesano Maderno, Italy
    Posts
    784
    hi,

    the flash bridge does not have its own sendMessage method, so, you must rely on the web client's sendMessage method.

  7. #7
    Hi there! I am also quite new in this topic, but I am very interested in having a chat installed on my website like you, what happens is that I think I already tried everything they have recommended in this forum and I still do not see the effects, that is , the chat on my page still doesn't work. I tried to put the code in different sections of the page, I tried to give it all the necessary permissions and correct the commands as they said here, but nothing happens. I don't know if any of you can help me.

  8. #8
    Administrator
    Join Date
    Jul 2006
    Location
    Milan, Italy
    Posts
    521
    Can you please expand on your issue?

    Quote Originally Posted by Monicamlivechat View Post
    Hi there! I am also quite new in this topic, but I am very interested in having a chat installed on my website like you, what happens is that I think I already tried everything they have recommended in this forum and I still do not see the effects, that is , the chat on my page still doesn't work. I tried to put the code in different sections of the page, I tried to give it all the necessary permissions and correct the commands as they said here, but nothing happens. I don't know if any of you can help me.

 

 

Similar Threads

  1. chat and private message
    By ernivan in forum Client SDKs
    Replies: 1
    Last Post: March 11th, 2011, 09:26 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT +1. The time now is 03:22 PM.
Lightstreamer Logo