チェンジセット 1088
- コミット日時:
- 2008/08/27 18:15:48 (5 年前)
- ファイル:
凡例:
- 変更無し
- 追加
- 削除
- 更新
- コピー
- 移動
as3/gunyarapaint/trunk/gunyarapaint/src/gunyarapaint.as
r1086 r1088 20 20 private var comm:Com; 21 21 private var oekakiId:uint; 22 private var redirectUrl:String; 22 23 23 24 private const ALERT_TITLE:String = 'ピコカキコ'; … … 84 85 // 通信系 85 86 comm = new Com(); 87 comm.addEventListener('completeGetData', commCompleteHandler); 86 88 if (parameters['postUrl'] && parameters['cookie'] && parameters['magic']) { 87 89 comm.setPostEnv(parameters['postUrl'], parameters['cookie'], parameters['magic']); … … 91 93 oekakiId = uint(parameters['oekakiId']); 92 94 } 93 95 if (parameters['redirectUrl']) { 96 redirectUrl = parameters['redirectUrl']; 97 } 98 94 99 appWidth = this.width; 95 100 appHeight = this.height; … … 191 196 } 192 197 */ 198 this.enabled = false; 193 199 comm.postOekaki(fromTextInput.text, 194 200 messageTextArea.text, … … 198 204 } 199 205 206 private function commCompleteHandler(evt:Event):void { 207 if (comm.getHttpStatus() == 400 || comm.getError()) { 208 // error 209 Alert.show(comm.getData(), ALERT_TITLE); 210 this.enabled = true; 211 } else { 212 // redirect 213 Com.redirect(redirectUrl); 214 } 215 } 216 200 217 private var orecan:gunyarapaint.Canvas; 201 218 private function playLogButtonHandler(evt:Event):void { as3/gunyarapaint/trunk/nicopedia/gunyarapaint/Com.as
r1087 r1088 24 24 25 25 private var loader:URLLoader; 26 private var httpStatus:int; 26 private var httpStatus:int; 27 28 private var error:Boolean; 27 29 28 30 public function Com() … … 50 52 51 53 post(r); 54 } 55 56 public static function redirect(url:String):void { 57 var r:URLRequest = new URLRequest(); 58 r.url = url; 59 r.method = URLRequestMethod.GET; 60 navigateToURL(r, '_top'); 52 61 } 53 62 … … 103 112 104 113 private function post(request:URLRequest):void { 114 error = false; 115 105 116 loader = new URLLoader(); 106 117 loader.addEventListener(SecurityErrorEvent.SECURITY_ERROR, postSecurityErrorHandler); … … 114 125 115 126 private function postSecurityErrorHandler(evt:SecurityErrorEvent):void { 127 error = true; 116 128 Alert.show(evt.text, 'セキュリティエラーが発生しました。'); 129 dispatchEvent(new Event('completeGetData')); 117 130 } 118 131 private function postIOErrorHandler(evt:IOErrorEvent):void { 119 132 // TODO: not event based, see URLLoader help 133 error = true; 120 134 Alert.show(evt.text, 'ネットワークエラーが発生しました。'); 135 dispatchEvent(new Event('completeGetData')); 121 136 } 122 137 private function postOpenHandler(evt:Event):void { 123 138 } 124 139 private function postHttpStatusHandler(evt:HTTPStatusEvent):void { 140 dispatchEvent(new Event('httpStatus')); 125 141 httpStatus = evt.status; 126 142 } … … 130 146 private function postCompleteHandler(evt:Event):void { 131 147 dispatchEvent(new Event('completeGetData')); 132 PopUpManager.removePopUp(this);133 148 } 134 149 public function getData():* { 135 150 return loader.data; 136 151 } 152 public function getHttpStatus():int { 153 return httpStatus; 154 } 155 public function getError():Boolean { 156 return error; 157 } 137 158 } 138 159 } as3/gunyarapaint/trunk/picokakiko/src/picokakiko.as
r1086 r1088 5 5 import mx.controls.Alert; 6 6 import mx.events.FlexEvent; 7 import mx.managers.PopUpManager;8 7 9 8 private var comm:Com; … … 11 10 private var played:Boolean = false; 12 11 private var poster:Boolean = false; 12 private var redirectUrl:String; 13 13 private const ALERT_TITLE:String = 'ピコカキコ'; 14 15 private var onPost:Boolean = false; 14 16 15 17 public function init():void { 16 18 comm = new Com; 19 comm.addEventListener('completeGetData', commCompleteHandler); 17 20 if (parameters['mmlUrl']) { 18 21 var url:String = parameters['mmlUrl']; 19 22 comm.sendGetUrlRequest(url); 20 comm.addEventListener('completeGetData', getMMLHandler);21 23 mml.enabled = false; 22 24 } … … 24 26 comm.setPostEnv(parameters['postUrl'], parameters['cookie'], parameters['magic']); 25 27 postPicoButton.enabled = true; 28 } 29 if (parameters['redirectUrl']) { 30 redirectUrl = parameters['redirectUrl']; 26 31 } 27 32 if (parameters['mmlId']) { … … 41 46 } 42 47 43 private function getMMLHandler(evt:Event):void { 44 mml.text = comm.getData(); 45 mml.enabled = true; 46 playButton.enabled = true; 48 private function commCompleteHandler(evt:Event):void { 49 if (onPost) { 50 onPost = false; 51 if (comm.getHttpStatus() == 400 || comm.getError()) { 52 // error 53 Alert.show(comm.getData(), ALERT_TITLE); 54 postPicoButton.enabled = true; 55 } else { 56 // redirect 57 Com.redirect(redirectUrl); 58 } 59 } else { 60 mml.text = comm.getData(); 61 mml.enabled = true; 62 playButton.enabled = true; 63 } 47 64 } 48 65 … … 64 81 } 65 82 if (mml.text == '') { 66 Alert.show('ピコ マンドが空です。ピコピコしてください。', ALERT_TITLE);83 Alert.show('ピコ文字が空です。ピコピコしてください。', ALERT_TITLE); 67 84 return; 68 85 } … … 72 89 } 73 90 if (mml_player.getWarnings() != '') { 74 Alert.show('投稿するためには、 警告を全て取り除くことが必要です。', ALERT_TITLE);91 Alert.show('投稿するためには、ピコ警告を全て取り除くことが必要です。', ALERT_TITLE); 75 92 return; 76 93 } 94 postPicoButton.enabled = false; 95 onPost = true; 77 96 comm.postPico(fromTextInput.text, messageTextArea.text, mml.text, mmlId); 78 97 } as3/gunyarapaint/trunk/picokakiko/src/picokakiko.mxml
r1086 r1088 11 11 </mx:Script> 12 12 <mx:Label x="28" y="7" text="名前"/> 13 <mx:TextInput id="fromTextInput" x=" 55" y="3" maxChars="32" fontSize="14"/>13 <mx:TextInput id="fromTextInput" x="61" y="3" maxChars="32" fontSize="14" width="154"/> 14 14 <mx:Label x="10" y="51" text="書き込み"/> 15 <mx:TextArea id="messageTextArea" x=" 55" y="33" width="563" height="62" fontSize="14">15 <mx:TextArea id="messageTextArea" x="61" y="30" width="557" height="62" fontSize="14"> 16 16 <mx:text></mx:text> 17 17 </mx:TextArea> 18 18 <mx:VDividedBox x="10" y="100" width="610" height="250"> 19 <mx:TextArea id="mml" width="610" height="170" fontSize="14"> 20 </mx:TextArea> 21 <mx:TextArea id="mml_warnings" width="610" height="57" editable="false"> 22 </mx:TextArea> 19 <mx:HBox> 20 <mx:VBox> 21 <mx:Label text="ピコ文字"/> 22 <mx:Label text="(MML)"/> 23 </mx:VBox> 24 <mx:TextArea id="mml" width="557" height="170" fontSize="14"/> 25 </mx:HBox> 26 <mx:HBox> 27 <mx:Label text="ピコ警告"/> 28 <mx:TextArea id="mml_warnings" width="557" height="57" editable="false"/> 29 </mx:HBox> 23 30 </mx:VDividedBox> 24 31 <mx:Button id="playButton" label="ピコ再生" x="10" y="356"/>

