Results 1 to 8 of 8

Hybrid View

  1. #1
    Member
    Join Date
    Jun 2007
    Location
    Durham
    Posts
    3

    Talking Thanks Alex.....

    I will keep an eye on it

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

    Find attached the Actionscript code from the file demoFlashSmall.fla.
    Note that it is not the complete source as the .fla file is a binary file (not a mxml file) so that the visual part is not included here:

    Code Actionscript:
    1. import flash.external.ExternalInterface;
    2. #include "lsjavascriptbridge.as"
    3. #include "format.as"
    4. _root.Message.text = "Lightstreamer Live Data";
    5.  
    6. var groupString = "item1 item2 item3 item4 item5 item6 item7 item8";
    7. var schemaString = "stock_name pct_change pct_change last_price time";
    8.  
    9. var bridge = new JavaScriptBridge("flashObject");
    10.  
    11. var myTable = new FlashTable(groupString,schemaString,"MERGE");
    12. myTable.setSnapshotRequired(true);
    13. myTable.setRequestedMaxFrequency(0.35);
    14. myTable.onItemUpdate = function (item, itemUpdate) {
    15.     if (itemUpdate.isValueChanged(1)) {
    16.         var newVal = itemUpdate.getNewValue(1);
    17.         newVal = cutName(newVal,item);
    18.         updateName(item,newVal);
    19.     }
    20.     if (itemUpdate.isValueChanged(2)) {
    21.         var newVal = itemUpdate.getNewValue(2);
    22.         newVal = formactDirection(newVal);
    23.         updateDirection(item,newVal);
    24.     }
    25.     if (itemUpdate.isValueChanged(3)) {
    26.         var newVal = itemUpdate.getNewValue(3);
    27.         newVal = formatDecimal(newVal, 2, true);
    28.         if(newVal > 0){
    29.             newVal  = "+" + newVal;
    30.         }
    31.         updatePerc(item,newVal);
    32.     }
    33.     if (itemUpdate.isValueChanged(4)) {
    34.         var newVal = itemUpdate.getNewValue(4);
    35.         newVal = formatDecimal(newVal, 2, true);
    36.         updateLastPrice(item, newVal);
    37.     }
    38.     if (itemUpdate.isValueChanged(5)) {
    39.         var newVal = itemUpdate.getNewValue(5);
    40.         newVal = formatTime(newVal);
    41.         updateLastTrade(item, newVal);
    42.     }
    43.    
    44. }
    45. myTable.onStart = function() {
    46.     for (var item = 1; item <= 8; item++) {
    47.         updateName(item,"");
    48.         updatePerc(item,"");
    49.         updateLastPrice(item, "");
    50.         updateLastTrade(item, "");
    51.     }
    52. }
    53. bridge.onStatusChange = function(newStatus) {
    54.     Message.text = "Status: " + newStatus;
    55. }
    56.  
    57. bridge.addTable(myTable,"FlashTable1");
    58.  
    59.  
    60. ///////////////////////////////////////////////////////////
    61.  
    62.  
    63.  
    64. onEnterFrame = function () {
    65.     dat = new Date();
    66.    
    67.  
    68.     gg = dat.getDate();
    69.     if(gg < 10){gg = "0" + gg}
    70.    
    71.     mm = (dat.getMonth() + 1);
    72.    
    73.  
    74.     if(mm == 1){mm = "Gen"}
    75.     else if(mm == 2){mm = "Feb"}
    76.     else if(mm == 3){mm = "Mar"}
    77.     else if(mm == 4){mm = "Apr"}
    78.     else if(mm == 5){mm = "May"}
    79.     else if(mm == 6){mm = "Jun"}
    80.     else if(mm == 7){mm = "Jul"}
    81.     else if(mm == 8){mm = "Aug"}
    82.     else if(mm == 9){mm = "Sep"}
    83.     else if(mm == 10){mm = "Oct"}
    84.     else if(mm == 11){mm = "Nov"}
    85.     else if(mm == 12){mm = "Dec"}
    86.    
    87.     aaaa = dat.getFullYear();
    88.    
    89.     _root.CurrentTime = gg + " " + mm + " " + aaaa;
    90. };
    91.  
    92.  
    93.  
    94. function updateInstrument(row) {
    95.     this["instrument"+row].gotoAndPlay(1);
    96. }
    97.  
    98. function updateName(row, newVal) {
    99.     this["instrument"+row].nomeinstrument = newVal;
    100.     this["instrument"+row].gotoAndPlay(1);
    101. }
    102.  
    103. function updateDirection(row, direction) {
    104.     if (direction == "up" and this["row"+row].direction.vardirection == "down") {
    105.         this["row"+row].direction.gotoAndPlay("goUp");
    106.     } else if (direction == "down" and this["row"+row].direction.vardirection == "up") {
    107.         this["row"+row].direction.gotoAndPlay("goDown");
    108.     }
    109.     updateInstrument(row);
    110. }
    111. function updatePerc(row, newVal) {
    112.     this["perc"+row] = newVal+"%";
    113.     this["row"+row].change.gotoAndPlay(1);
    114.     updateInstrument(row);
    115. }
    116. function updateLastPrice(row, newVal) {
    117.     this["lastPrice"+row] = newVal;
    118.     this["row"+row].price.gotoAndPlay(1);
    119.     updateInstrument(row);
    120. }
    121. function updateLastTrade(row, newVal) {
    122.     this["lastTrade"+row] = newVal;
    123.     this["row"+row].trade.gotoAndPlay(1);
    124.     updateInstrument(row);
    125. }
    126.  
    127.  
    128.  
    129. //notify the page that we are ready
    130. bridge.bind();

    Please substitute "& # 9 1 ;" with "[" as the Actionscript highlighting changed the code.

    Hope that helps.

 

 

Similar Threads

  1. GWT integration
    By hamroune in forum Client SDKs
    Replies: 1
    Last Post: January 3rd, 2012, 09:26 AM
  2. GWT integration
    By hamroune in forum General
    Replies: 1
    Last Post: January 3rd, 2012, 09:26 AM
  3. Drupal Integration ?
    By stockstreamtest1 in forum Client SDKs
    Replies: 2
    Last Post: September 19th, 2011, 10:48 AM
  4. GWT Integration
    By tvseshagiri in forum Client SDKs
    Replies: 1
    Last Post: June 7th, 2010, 11:11 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 10:42 AM.