こちらの記事を参考にしながらAS3でTwitterアプリを作ってみました。
// http://blog.alt-scape.com/archives/234 参考サイト
//ステージを画面に100%表示
logo1.x = stage.stageWidth/2;
logo1.y = stage.stageHeight/2;
stage.scaleMode=StageScaleMode.NO_SCALE;
//左上にステージを配置
stage.align=StageAlign.TOP_LEFT;
//「xmlData.xml」を読み込んで,変数xmlに格納
var xml:XML;
/*読み込み処理自体はテキスト・ファイルと同じく
URLLoader+URLRequestで作成*/
var loader:URLLoader = new URLLoader();
var request:URLRequest=new URLRequest("http://clist.jp/wordpress/wp-content/uploads/crossdomain-proxy.php?url=http://twitter.com/statuses/public_timeline.xml?cache=");
// http://pcod.no-ip.org/yats/public_timeline
// http://twitter.com/statuses/public_timeline.xml
// http://localhost/xampp/box/public_timeline.xml
var tmr:Timer=new Timer(3000,100);//3000,2000,1000
tmr.start();
var tf:TextField = new TextField();
var fmt:TextFormat = new TextFormat();
function traceData(event:Event) {
//読み込んだ内容を元に,XMLデータを作成
xml=new XML(event.target.data);
}
var i:int=0;
loader.addEventListener(Event.COMPLETE,traceData);
loader.load(request);
tmr.addEventListener(TimerEvent.TIMER, onTimer);
function onTimer(event:TimerEvent) {
var len:int=0;
if (String(xml..status.text[i])=="undefined") {
i=0;
//trace("YES!!!!!");
loader.load(request);
}
if (i<23) {
trace("---------------"+ar_ft+"," + i +"---------------");
var txt:String=String(xml..status.text[i]);
trace(txt);
tf = new TextField();
fmt = new TextFormat();
if (txt.length<30) {
len = 30-txt.length;
} else {
len=0;
}
fmt.size=int(10+len);// 5-30 , 1- 160
var ar_ft:Array=["_sans","Times New Roman","_明朝"];
fmt.font=ar_ft[int(Math.random()*3)];
var color:ColorTransform=new ColorTransform(Math.random(),Math.random(),Math.random(),1,0,0,0,0);
//mc.transform.colorTransform = color;
var r:uint=255*Math.random()*0.5;
var g:uint=255*Math.random()*0.5;
var b:uint=255*Math.random()*0.5;
var r2:uint=255*Math.random()*0.2+200;
var g2:uint=255*Math.random()*0.2+200;
var b2:uint=255*Math.random()*0.2+200;
var newColor:uint=r<<16|g<<8|b;
var newColor2:uint=r2<<16|g2<<8|b2;
trace(newColor.toString(16));
fmt.color=newColor2;
tf.text=txt;
tf.setTextFormat(fmt);
tf.autoSize=TextFieldAutoSize.LEFT;
tf.background=true;
tf.backgroundColor=newColor;//0x0000ff*Math.random();
tf.border=true;
if (txt.length>60) {
tf.wordWrap=true;
tf.width=250;
}
tf.x = 5 + (stage.stageWidth-tf.textWidth-10) * Math.random();
tf.y = 5 + (stage.stageHeight-tf.textHeight-10) * Math.random();
addChild(tf);
i++;
}
}






コメントのRSSを取得する · トラックバック