WEB开发网
开发学院图形图像Flash Embed Flash Yahoo Weather in your page with Ya... 阅读

Embed Flash Yahoo Weather in your page with Yahoo APIs

 2009-10-20 00:00:00 来源:WEB开发网   
核心提示: package{importflash.display.Sprite;importflash.text.TextField;importcom.yahoo.webapis.weather.*;importcom.yahoo.webapis.weather.events.*;publicclass

 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";
  }
 }
}

上一页  1 2 3 4  下一页

Tags:Embed Flash Yahoo

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接