flash on 2010-10-6
♥0 |
Line 61 |
Modified 2010-10-06 19:08:12 |
MIT License
archived:2017-03-20 06:42:55
ActionScript3 source code
/**
* Copyright uwi ( http://wonderfl.net/user/uwi )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/5PvV
*/
package {
import flash.display.Sprite;
import flash.text.TextField;
import flash.events.*;
import flash.net.*;
import com.adobe.serialization.json.*;
import mx.rpc.events.ResultEvent;
import mx.rpc.http.*;
import com.bit101.components.*;
import flash.text.*;
public class Test extends Sprite {
private var _tf : TextField;
private var _ta : TextArea;
private var _res : TextArea;
public function Test() {
_tf = new TextField();
_tf.width = 465;
_tf.height = 465;
addChild(_tf);
_ta = new TextArea(this, 0, 0);
_ta.textField.embedFonts = false;
_ta.textField.defaultTextFormat = new TextFormat("Arial", 10);
_ta.width = 300;
_ta.height = 230;
_res = new TextArea(this, 0, 250);
_res.textField.embedFonts = false;
_res.textField.defaultTextFormat = new TextFormat("Arial", 10);
_res.width = 300;
_res.height = 200;
var sm : PushButton = new PushButton(this, 350, 0, "submit", function(e : MouseEvent) : void {
_res.text = "";
for each(var line : String in _ta.text.split('\r')){
check(line);
}
});
}
public function check(q : String) : void
{
var service:HTTPService = new HTTPService();
service.url = 'http://ajax.googleapis.com/ajax/services/search/local';
service.request.v = '1.0';
service.request.q = q;
service.resultFormat = 'text';
service.addEventListener(ResultEvent.RESULT, function(event:ResultEvent) : void {
try {
var json:Object = JSON.decode(event.result as String);
// tr(event.result);
_res.text += q + "\n";
for each(var o : Object in json.responseData.results){
_res.text += o.ddUrl.toString() + "\n";
}
} catch(ignored:Error) {
}
});
service.send();
}
private function tr(...o : Array) : void
{
_tf.appendText(o + "\n");
}
}
}