Embed Flash Yahoo Weather in your page with Yahoo APIs
2009-10-20 00:00:00 来源:WEB开发网 package {
import flash.display.Sprite;
import flash.text.TextField;
import com.yahoo.webapis.weather.*;
import com.yahoo.webapis.weather.events.*;
public class weather extends Sprite {
var the_weather:WeatherService = new WeatherService();
var text_field:TextField = new TextField();
public function weather() {
the_weather.getWeather("ITXX0085", "metric");
the_weather.addEventListener(WeatherResultEvent.WEATHER_LOADED, show_weather);
addChild(text_field);
text_field.width=500;
text_field.height=300;
text_field.x=30;
text_field.y=30;
}
function show_weather(event:WeatherResultEvent):void {
var weather_string:String;
weather_string="Temperature: "+event.data.current.temperature+" "+event.data.units.temperature+"\n";
weather_string+="Description: "+event.data.current.description+"\n";
weather_string+="Wind temperature: "+event.data.current.wind.chill+"\n";
weather_string+="Wind direction: "+event.data.current.wind.direction+"°\n";
weather_string+="Wind speed: "+event.data.current.wind.speed+"\n";
weather_string+="Humidity: "+event.data.current.atmosphere.humidity+"%\n";
weather_string+="Pressure: "+event.data.current.atmosphere.pressure+" "+event.data.units.pressure+"\n";
weather_string+="Visibility: "+event.data.current.atmosphere.visibility+" "+event.data.units.distance+"\n";
weather_string+="Sunrise: "+event.data.current.astronomy.sunrise+"\n";
weather_string+="Sunset: "+event.data.current.astronomy.sunset+"\n";
weather_string+="Image path: "+event.data.current.imageURL+"\n";
weather_string+="Weather code: "+event.data.current.code+"\n";
weather_string+="Last updated: "+event.data.timeToLive+"\n";
weather_string+="City: "+event.data.location.city+" ("+event.data.location.country+")\n";
}
}
}
- ››FLASH不等于运算符!=的使用实例
- ››FLASH不全等运算符!==
- ››FLASH字符串分隔符运算符
- ››FLASH% 模运算符
- ››Flash+、++、+= 加法运算符
- ››Flash, 逗号运算符
- ››flash中的-、--、-=减法运算符
- ››Flash的-Infinity 常数、.点运算符、/ 除法运算符...
- ››Flash两种注释方法/*..*/ 和// 注释行分隔符运算符...
- ››Flash的/=除法赋值运算符、=赋值运算符、== 等于运...
- ››Flash之?: 条件运算符、^ 按位 XOR 运算符、^= 按...
- ››Flash的_framesloaded代码示例
更多精彩
赞助商链接