forked from: flash on 2010-6-29
♥0 |
Line 100 |
Modified 2010-06-29 21:09:11 |
MIT License
archived:2017-03-30 01:35:24
ActionScript3 source code
/**
* Copyright ProjectNya ( http://wonderfl.net/user/ProjectNya )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/uCbR
*/
// forked from hacker_q2_kpljv's flash on 2010-6-29
package {
import flash.display.Stage;
import flash.display.Sprite;
import flash.text.TextField;
import flash.events.Event;
public class FlashTest extends Sprite {
private var twitter:Twitter;
private var textField:TextField;
private var fukidashi1:Fukidashi;
private var canvas1:Sprite;
private var testcanvas:Sprite;
public function FlashTest() {
fukidashi1 = new Fukidashi();
addChild(fukidashi1);
textField = new TextField();
textField.text = 'log Here...';
textField.width = stage.stageWidth;
textField.height = stage.stageHeight;
textField.multiline = true;
textField.wordWrap = true;
addChild(textField);
twitter = new Twitter();
twitter.searchUserTimeline('muramatsut');
twitter.addEventListener(Twitter.RESULT_PARSED, parsed);
}
private function parsed(evt:Event):void {
textField.text = evt.target.result.toString();
}
}
}
//import flash.display.DisplayObjectContainer;
//import flash.display.DisplayObject;
import flash.events.EventDispatcher;
import flash.events.Event;
import flash.events.IOErrorEvent;
import flash.events.SecurityErrorEvent;
import flash.net.URLLoader;
import flash.net.URLRequest;
import flash.net.URLRequestHeader;
import flash.net.URLRequestMethod;
import flash.net.URLVariables;
class Twitter extends EventDispatcher {
//private var atomNs:Namespace;
private const URL_TWITTER_SEARCH_ATOM:String = 'http://search.twitter.com/search.atom';
private var urlLoader:URLLoader;
private var urlRequest:URLRequest;
private var urlRequestMethod:URLRequestMethod;
private var urlRequestHeader:URLRequestHeader;
private var urlVariables:URLVariables;
private var _result:Array;
static public const RESULT_PARSED:String = 'result_parsed';
public function Twitter() {
//atomNs = new Namespace('http://www.w3.org/2005/Atom');
_result = new Array();
}
public function searchUserTimeline(userid:String):void {
urlLoader = new URLLoader();
urlRequest = new URLRequest(URL_TWITTER_SEARCH_ATOM);
urlVariables = new URLVariables();
urlVariables.q = 'from:' + userid;
urlRequest.data = urlVariables;
try {
urlLoader.load(urlRequest);
} catch (e:Error) {
trace("hoge");
}
urlLoader.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
urlLoader.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);
urlLoader.addEventListener(Event.COMPLETE, completeHandler);
}
private function completeHandler(e:Event):void {
//default xml namespace = atomNs;
var atomData:XML = new XML(urlLoader.data);
namespace ns = "http://www.w3.org/2005/Atom";
use namespace ns;
for each(var tweet:String in atomData.entry.content) {
_result.push(decodeURIComponent(tweet));
}
dispatchEvent(new Event(RESULT_PARSED));
}
private function securityErrorHandler(e:SecurityErrorEvent):void {
//error
trace("Security Error...");
}
private function ioErrorHandler(e:IOErrorEvent):void {
//error
trace("ioError");
}
public function get result():Array {
return _result;
}
}
import flash.display.Sprite;
class Fukidashi extends Sprite {
private var fukidashi:Sprite;
public function Fukidashi() {
var canvas:Sprite = new Sprite();
fukidashi = createFukidashi(canvas);
addChild(fukidashi);
}
private function createFukidashi(canvas:Sprite):Sprite{
canvas.graphics.beginFill(0xff0000);
canvas.graphics.drawRoundRect(100,100,50,20,5,5);
canvas.graphics.endFill();
return canvas;
}
}