Hi,
ich habs nach deiner kleinen beschreibung versucht. War ja eigentlich nich viel zu machen oder?
AS3 in den ersten frame eines lehren Films.
Code:
import com.swfjunkie.tweetr.Tweetr;
import com.swfjunkie.tweetr.data.objects.*;
import com.swfjunkie.tweetr.events.TweetEvent;
import com.swfjunkie.tweetr.utils.TweetUtil;
import flash.text.StyleSheet;
import flash.text.TextField;
var textField:TextField = new TextField();
var tweetr:Tweetr;
var styles:StyleSheet = new StyleSheet();
// styles
initStyles();
// tweetr
tweetr = new Tweetr();
tweetr.serviceHost = "labs.swfjunkie.com/tweetr/proxy";
tweetr.addEventListener(TweetEvent.COMPLETE, handleTweetsLoaded);
tweetr.addEventListener(TweetEvent.FAILED, handleTweetsFail);
// %23 steht # url-encodet
tweetr.search("%23flash");
function handleTweetsLoaded(event:TweetEvent):void {
if (event.responseArray.length != 0) {
var tweet:SearchResultData = event.responseArray[0] as SearchResultData;
showTweet(tweet);
} else {
textField.htmlText = "<p class=\"tweet\">No tweets available</p>";
addChild (textField);
}
}
function handleTweetsFail(event:TweetEvent):void {
// handle error here
}
function showTweet(tweet:SearchResultData):void {
textField.htmlText = "<img src=\""+tweet.userProfileImage+"\" height=\"50\" width=\"50\">" +
"<p class=\"tweet\"><b>" +
"<a target=\"_blank\" href=\"http://twitter.com/"+tweet.user+"\">@"+tweet.user+"</a></b> " +
""+tweet.text + "" +
"<br><span class=\"age\">"+TweetUtil.returnTweetAge(tweet.createdAt)+"</span></p>";
addChild(textField);
}
function initStyles():void {
import com.swfjunkie.tweetr.Tweetr;
import com.swfjunkie.tweetr.data.objects.*;
import com.swfjunkie.tweetr.events.TweetEvent;
import com.swfjunkie.tweetr.utils.TweetUtil;
import flash.text.StyleSheet;
import flash.text.TextField;
var textField:TextField = new TextField();
var tweetr:Tweetr;
var styles:StyleSheet = new StyleSheet();
// styles
initStyles();
// tweetr
tweetr = new Tweetr();
tweetr.serviceHost = "labs.swfjunkie.com/tweetr/proxy";
tweetr.addEventListener(TweetEvent.COMPLETE, handleTweetsLoaded);
tweetr.addEventListener(TweetEvent.FAILED, handleTweetsFail);
// %23 steht # url-encodet
tweetr.search("%23flash");
function handleTweetsLoaded(event:TweetEvent):void {
if (event.responseArray.length != 0) {
var tweet:SearchResultData = event.responseArray[0] as SearchResultData;
showTweet(tweet);
} else {
textField.htmlText = "<p class=\"tweet\">No tweets available</p>";
addChild (textField);
}
}
function handleTweetsFail(event:TweetEvent):void {
// handle error here
}
function showTweet(tweet:SearchResultData):void {
textField.htmlText = "<img src=\""+tweet.userProfileImage+"\" height=\"50\" width=\"50\">" +
"<p class=\"tweet\"><b>" +
"<a target=\"_blank\" href=\"http://twitter.com/"+tweet.user+"\">@"+tweet.user+"</a></b> " +
""+tweet.text + "" +
"<br><span class=\"age\">"+TweetUtil.returnTweetAge(tweet.createdAt)+"</span></p>";
addChild(textField);
}
function initStyles():void {
styles.setStyle(".tweet", {color: "#FFFFFF", fontFamily: "Georgia", fontSize: "12"});
styles.setStyle(".age", {fontStyle: "italic", fontSize: "10"});
textField.styleSheet = styles;
textField.width = 310;
textField.wordWrap = true;
textField.multiline = true;
}
styles.setStyle(".tweet", {color: "#FFFFFF", fontFamily: "Georgia", fontSize: "12"});
styles.setStyle(".age", {fontStyle: "italic", fontSize: "10"});
textField.styleSheet = styles;
textField.width = 310;
textField.wordWrap = true;
textField.multiline = true;
} dann hoch laden und gut ist. Oder?
Muss ich die proxy bei mir selber hoch laden und installieren?
cya
Hugo