Posted By

daisuke103 on 02/11/08


Tagged

php textmate send load vars as2 mdn bbs


Versions (?)

AS2 MdN PHPと連携して掲示板 AS側


 / Published in: Other
 

  1. /*
  2. ステージにupBtn,downBtn(表示フレームのスクロール)
  3. sendBtnを配置
  4. 送信側
  5. */
  6.  
  7. //送信用LoadVras
  8. var sendObj:LoadVars = new LoadVars();
  9. //受信用LoadVras
  10. var receiveObj:LoadVars = new LoadVars();
  11. //アクセスするPHPファイルへのパス
  12. var connectURL:String = "p046.php";
  13.  
  14. //はじめにデータを受け取る
  15. sendObj.startup = "true";
  16. sendObj.sendAndLoad(connectURL,receiveObj,"POST");
  17. displayTF.text = "Now Loading ...";
  18.  
  19. //<2>
  20. receiveObj.onLoad = function(success){
  21. if(success){
  22. if(receiveObj.error != undefined){
  23. displayTF.text = receiveObj.error;
  24. }else{
  25. trace("total : "+receiveObj.total+"¥n");
  26. //一度displayTFを初期化
  27. displayTF.text = "";
  28. //総コメント数
  29. var total:Number = new Number(receiveObj.total);
  30. //<3>
  31. for(var i = 0 ; i < total ; i++){
  32. displayTF.text += "No."+i+"¥n";
  33. //<4>
  34. displayTF.text += receiveObj["comment"+i]+"¥n";
  35. displayTF.text += receiveObj["date"+i]+"¥n";
  36.  
  37. displayTF.text += "-¥n¥n";
  38. }
  39. //一番下までスクロール
  40. displayTF.scroll = displayTF.maxscroll;
  41. }
  42. }else{
  43. trace("Error connecting to server.");
  44. }
  45. };
  46. //<1>
  47. sendBtn.onRelease = function(){
  48. sendObj.startup = "false";
  49. sendObj.comment = inputTF.text;
  50. //テキストフィールドを初期化
  51. inputTF.text = "";
  52. sendObj.sendAndLoad(connectURL,receiveObj,"POST");
  53. }
  54.  
  55. upBtn.onPress = function(){
  56. if(displayTF.scroll > 1){
  57. displayTF.scroll--;
  58. }
  59. }
  60. downBtn.onPress = function(){
  61. if(displayTF.scroll < displayTF.maxscroll){
  62. displayTF.scroll++;
  63. }
  64. }
  65.  

Report this snippet  

You need to login to post a comment.