reverting 03d2 to vanilla version, moving custom version into its own dir

This commit is contained in:
Dan Buch
2010-02-21 00:19:42 -05:00
parent 14db585c3b
commit 1deb4cb40e
5 changed files with 132 additions and 5 deletions

View File

@@ -1,57 +0,0 @@
package
{
import mx.collections.ArrayCollection;
import mx.controls.TextInput;
import mx.core.Application;
import mx.rpc.events.ResultEvent;
import mx.rpc.http.HTTPService;
public class WeatherApp extends Application
{
function WeatherApp()
{
}
[Bindable]
public var myResult:XML;
[Bindable]
public var weatherObject:Object;
[Bindable]
public var listContents:ArrayCollection;
public var weatherService:HTTPService;
public var zip:TextInput;
public namespace yweather = "http://xml.weather.yahoo.com/ns/rss/1.0";
use namespace yweather;
public function requestWeather():void {
weatherService.cancel();
var params:Object = new Object();
params.p = zip.text;
weatherService.send(params);
}
public function resultHandler(event:ResultEvent):void {
myResult = XML(event.result);
weatherObject = new Object();
weatherObject.zip = zip.text;
weatherObject.city = myResult.channel.yweather::location.@city;
weatherObject.temp = myResult.channel.item.yweather::condition.@temp;
weatherObject.imgsource = parseImageUrl(myResult.channel.item.description);
var a:Array = new Array(weatherObject);
listContents = new ArrayCollection(a);
}
public function parseImageUrl(fromHtml:XMLList):String {
var pattern:RegExp = /img src="(.+?)"/;
var results:Array = pattern.exec(fromHtml);
var imageURL:String = results[1]; // backreference 1 from pattern
return imageURL;
}
}
}

View File

@@ -1,10 +1,53 @@
<?xml version="1.0" encoding="utf-8"?>
<loc:WeatherApp xmlns:mx="http://www.adobe.com/2006/mxml"
xmlns:loc="*"
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
backgroundColor="#FFFFFF"
backgroundAlpha="0"
horizontalAlign="left"
verticalGap="15" horizontalGap="15">
<mx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import mx.rpc.events.ResultEvent;
[Bindable]
private var myResult:XML;
[Bindable]
private var weatherObject:Object;
[Bindable]
private var listContents:ArrayCollection;
private namespace yweather = "http://xml.weather.yahoo.com/ns/rss/1.0";
use namespace yweather;
public function requestWeather():void {
weatherService.cancel();
var params:Object = new Object();
params.p = zip.text;
weatherService.send(params);
}
public function resultHandler(event:ResultEvent):void {
myResult = XML(event.result);
weatherObject = new Object();
weatherObject.zip = zip.text;
weatherObject.city = myResult.channel.yweather::location.@city;
weatherObject.temp = myResult.channel.item.yweather::condition.@temp;
weatherObject.imgsource = parseImageUrl(myResult.channel.item.description);
var a:Array = new Array(weatherObject);
listContents = new ArrayCollection(a);
}
private function parseImageUrl(fromHtml:XMLList):String {
var pattern:RegExp = /img src="(.+?)" /;
var results:Array = pattern.exec(fromHtml);
var imageURL:String = results[1]; // backreference 1 from pattern
return imageURL;
}
]]>
</mx:Script>
<mx:HTTPService
id="weatherService"
@@ -42,4 +85,4 @@
width="400" height="100"
itemRenderer="HBoxWeatherDisplay" />
</loc:WeatherApp>
</mx:Application>