Show
Ignore:
Timestamp:
01/19/08 05:07:35 (6 years ago)
Author:
tasuku
Message:

set dekita

Location:
lang/actionscript/memcached-client/trunk
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • lang/actionscript/memcached-client/trunk/MemcachedClient.as

    r4650 r4918  
    1 // Memcached client on ActionScript 3 
     1// Memcached client on ActionScript3 
    22// Tasuku SUENAGA a.k.a. gunyarakun(not gunyaraway) 
    33// BSD License or meshi-ogoru license 
     4 
     5// はらへった。 
    46 
    57package { 
     
    2022    public function MemcachedClient() { 
    2123      make_label(); 
    22       set_label('initialize instance'); 
    2324      if (ExternalInterface.available) { 
    2425        try { 
     
    5960    // set 
    6061    public function set(key:String, value:String, exptime:uint = 0, flags:uint = 0):void { 
    61       this.send_storage_cmd('set', key, flags, exptime, value); 
     62      send_storage_cmd('set', key, flags, exptime, value); 
    6263    } 
    6364    // get 
     
    7071    // FIXME: cas_unique:Number 
    7172    private function send_storage_cmd(command_name:String, key:String, flags:uint, 
    72                                       exptime:uint, bytes:String) { 
    73       var command = new Array(command_name, key, flags, exptime, bytes.length).join(' '); 
     73                                      exptime:uint, bytes:String):void { 
     74      var command:String = new Array(command_name, key, flags, exptime, bytes.length).join(' '); 
    7475      recv_mode = 'storage'; 
    7576      send_line(command); 
     
    7778    } 
    7879 
    79     private function send_retrieval_cmd(command_name:String, key:String) { 
    80       var command = new Array(command_name, key).join(' '); 
     80    private function send_retrieval_cmd(command_name:String, key:String):void { 
     81      var command:String = new Array(command_name, key).join(' '); 
    8182      recv_mode = 'retrieval'; 
    8283      send_line(command); 
    8384    } 
    8485 
    85     private function send_line(data:String) { 
     86    private function send_line(data:String):void { 
    8687      if (!socket || !socket.connected) return; 
    8788      socket.writeUTFBytes(data); 
     
    9091    } 
    9192 
    92     private function on_line(line) { 
     93    private function on_line(line:String):Boolean { 
    9394      switch(recv_mode) { 
    9495        case 'storage': 
     
    110111          // TODO: 
    111112      } 
     113      return true; 
    112114    } 
    113115 
     
    124126    private function on_data(evt:Event):void { 
    125127      recv_buf += socket.readUTFBytes(socket.bytesAvailable); 
    126       var e; 
     128      var e:int; 
    127129      while ((e = recv_buf.indexOf('\n')) != -1) { 
    128         var line = recv_buf.substring(0, e); 
     130        var line:String = recv_buf.substring(0, e); 
    129131        if (on_line(line)) { 
    130132          recv_buf = recv_buf.substring(e + 1); 
     
    148150      label.autoSize = TextFieldAutoSize.LEFT; 
    149151      label.selectable = true; 
    150       label.text = ''; 
    151152      label.x = 0; 
    152153      label.y = 0; 
     154      var fm:TextFormat = new TextFormat(); 
     155      fm.size = 12; 
     156      fm.color = 0x000000; 
     157      label.border = true; 
     158      label.width=300; 
     159      label.setTextFormat(fm); 
    153160      addChild(label); 
    154161    } 
  • lang/actionscript/memcached-client/trunk/memcached.html

    r4650 r4918  
    88} 
    99</style> 
    10 <script type="text/javascript" src="./json.js"></script> 
    1110<script language="JavaScript"> 
    1211  // TODO: refactoring 
     
    2221    } 
    2322  } 
    24   function connect(host, port) { 
     23   function connect(host, port) { 
    2524    var m = thisMovie('MemcachedClient'); 
    2625    m.connect(host, port, 'OnConnect', 'OnClose', 'OnGet', 'OnError'); 
    2726  } 
    2827  function set(key, value) { 
    29     var socket = thisMovie("MemcachedClient"); 
     28    var m = thisMovie('MemcachedClient'); 
    3029    m.set(key, value); 
    3130  } 
    3231  function get(key) { 
    33     var socket = thisMovie("MemcachedClient"); 
     32    var m = thisMovie('MemcachedClient'); 
    3433    m.get(key); 
    3534  } 
     
    4847  } 
    4948  function OnError(msg) { 
    50    print('socket error! ' + msg); 
     49    print('socket error! ' + msg); 
    5150  } 
    5251</script> 
     
    5655    <input type="button" value="接続" onClick="connect('localhost', 11211);"> 
    5756  </p> 
    58   <textarea style="width:80%;height:16em;background-color:#ddd;" id="output" name="output"> 
     57  <p> 
     58    <input type="text" id="set_key" size="16"> 
     59    <input type="text" id="set_value" size="32"> 
     60    <input type="button" value="set" onClick="set(document.getElementById('set_key').value, document.getElementById('set_value').value);"> 
     61  </p> 
     62  <textarea style="width:80%;height:8em;background-color:#ddd;" id="output" name="output"> 
    5963  </textarea> 
    6064  <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" 
     
    6872    <param name="allowNetworking" value="all" /> 
    6973    <embed src="./MemcachedClient.swf" quality="high" bgcolor="#ffffff" 
    70      width="1" height="1" name="MemcachedClient" align="middle" 
     74     width="200" height="100" name="MemcachedClient" align="middle" 
    7175     play="true" loop="false" quality="high" allowScriptAccess="always" 
    7276     allowNetworking="all" type="application/x-shockwave-flash"