あなたが探しているのはこのようなものです:
import fl.controls.TextArea;
/**** vars ****/
var user:String;
var url:String;
var tweetCount:int;
var tweets:Array;
var times:Array;
var textArea:TextArea;
/**** setup ****/
user = "leifpagrotsky";
tweetCount = 10;
setupText();//setup a text area component
loadTweets();
/**** start getting tweets ****/
function loadTweets()
{
url = "http://search.twitter.com/search.atom?q=+from:" + user + "&rpp=" + tweetCount;
var urlReq:URLRequest = new URLRequest(url);
var loader:URLLoader = new URLLoader();
loader.addEventListener(Event.COMPLETE, getTweets);
loader.addEventListener(IOErrorEvent.IO_ERROR, IOError);
loader.addEventListener(SecurityErrorEvent.SECURITY_ERROR, SError);
loader.load(urlReq);
}
function setupText():void{
textArea = addChild(new TextArea()) as TextArea;//create and add it to the stage - make sure the component is in the library
textArea.setSize(stage.stageWidth,stage.stageHeight);
textArea.editable = false;
}
function getTweets(e:Event):void
{
if (e.target.data)
{
var displayText:String = "";//make a string to collect all the text you want to display
tweets = new Array();
times = new Array();
var twitterXML:XML = new XML(e.target.data);
var tweetList:XMLList = twitterXML.children();
var tweetItem:String;
var timeItem:String;
for (var i:int = 0; i < tweetList.length(); i++)
{
tweetItem = tweetList[i].*::title;
timeItem = tweetList[i].*::published;
if ( tweetItem != "" )
{
tweets.push(tweetItem);
trace(tweetItem);
displayText += tweetItem+"\n";//add the details you need like the message
}
if ( timeItem != "" )
{
timeItem = timeItem.split("T").join(" - ");
timeItem = timeItem.split("Z").join("");
times.push(timeItem);
trace(timeItem);
displayText += timeItem+"\n\n";//...and time
}
}
trace(tweets.length);
textArea.text = displayText;//finally after all the text is accumulated into a string, send it to the text area
}
}
function IOError(e:Event):void
{
trace("io error!");
}
function SError(e:Event):void
{
trace("security error!");
}
チュートリアルを使用するときに私がお勧めするのは、チュートリアルを分解して各部分を理解することです。次に、何をする必要があるかが明らかになるはずです。理解せずにコードをコピーして貼り付けるだけでは不十分です。
基本的なTextFieldを使用することもできます。簡略化したバージョンは次のとおりです。
var output:TextField = addChild(setupText()) as TextField;//add text
loadTweets("leifpagrotsky",10);//call tweeter
function loadTweets(user:String,count:int):void{
new URLLoader(new URLRequest("http://search.twitter.com/search.atom?q=+from:" + user + "&rpp=" + count))
.addEventListener(Event.COMPLETE,tweetsLoaded);//load and wait for the response
}
function tweetsLoaded(e:Event):void{
if(e.target.data){//if we have some data
var out:String = "";//make a new blank string we can later plug into the text on screen
var stream:XML = new XML(e.target.data);//plug the data into an XML object
var tweets:XMLList = stream.*;//get the tweet nodes
var numTweets:int = tweets.length();//count them once
for(var i:int = 0 ; i < numTweets; i++) //for each tweet message
if(String(tweets[i].*::title).length) //if there the message's length is > 0
out += tweets[i].*::title+"\n<b>"+tweets[i].*::published+"</b>\n\n";//add it to our string
output.htmlText = out;//finally plug the string to the text field
}
}
function setupText():TextField {//set up the text field
var t:TextField = new TextField();
t.defaultTextFormat = new TextFormat("Verdana",11,0);
t.multiline = true;
t.autoSize = TextFieldAutoSize.LEFT;
t.width = stage.stageWidth;
t.height = stage.stageHeight;
t.border = true;
return t;
}