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

cat-town
Dan Buch 15 years ago
parent 14db585c3b
commit 1deb4cb40e

@ -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>

@ -0,0 +1,31 @@
<?xml version="1.0" encoding="utf-8"?>
<mx:HBox xmlns:mx="http://www.adobe.com/2006/mxml" width="400" height="100"
xmlns:me="components.*" >
<mx:Script>
<![CDATA[
private var _data:Object;
override public function set data(value:Object):void {
_data = value;
if (data != null) {
zip.text = _data.zip;
city.text = _data.city;
temp.text = _data.temp + 'F';
img.source = _data.imgsource;
}
}
override public function get data():Object {
return _data;
}
]]>
</mx:Script>
<mx:Image id="img" />
<mx:VBox height="100%">
<mx:Text id="zip" />
<mx:Text id="city" />
<mx:Text id="temp" />
</mx:VBox>
</mx:HBox>

@ -0,0 +1,45 @@
<?xml version="1.0" encoding="utf-8"?>
<loc:WeatherApp xmlns:mx="http://www.adobe.com/2006/mxml"
xmlns:loc="*"
backgroundColor="#FFFFFF"
backgroundAlpha="0"
horizontalAlign="left"
verticalGap="15" horizontalGap="15">
<mx:HTTPService
id="weatherService"
url="http://weather.yahooapis.com/forecastrss"
resultFormat="e4x"
result="resultHandler(event)" />
<mx:Text text="1. Basic Form + HTTPService Retrieval" />
<mx:Form width="400">
<mx:FormItem label="Zip Code">
<mx:TextInput id="zip" />
<mx:Button label="Get Weather"
click="requestWeather()" />
</mx:FormItem>
</mx:Form>
<mx:Text text="Raw RSS Feed" />
<mx:TextArea id="resultFld"
text="{myResult}"
width="400" height="152" />
<mx:Text text="1. List w/ Image Item Renderer (Drop-In)" />
<mx:List dataProvider="{listContents}"
labelField="imgsource"
width="400" height="100"
itemRenderer="mx.controls.Image" />
<mx:Text text="2. List w/ HBoxWeatherDisplay itemRenderer" />
<mx:List dataProvider="{listContents}"
labelField="zip"
width="400" height="100"
itemRenderer="HBoxWeatherDisplay" />
</loc:WeatherApp>

@ -111,11 +111,11 @@
$(MXMLC) 03d1-datagrid/DataGridExample.mxml -warnings -l+=03d1-datagrid -output 03d1-datagrid/DataGridExample.swf
03d2-item-renderers/HBoxWeatherDisplay.swf: 03d2-item-renderers/HBoxWeatherDisplay.mxml 03d2-item-renderers/WeatherApp.as
03d2-item-renderers/HBoxWeatherDisplay.swf: 03d2-item-renderers/HBoxWeatherDisplay.mxml
$(MXMLC) 03d2-item-renderers/HBoxWeatherDisplay.mxml -warnings -l+=03d2-item-renderers -output 03d2-item-renderers/HBoxWeatherDisplay.swf
03d2-item-renderers/WeatherDisplay.swf: 03d2-item-renderers/WeatherDisplay.mxml 03d2-item-renderers/WeatherApp.as
03d2-item-renderers/WeatherDisplay.swf: 03d2-item-renderers/WeatherDisplay.mxml
$(MXMLC) 03d2-item-renderers/WeatherDisplay.mxml -warnings -l+=03d2-item-renderers -output 03d2-item-renderers/WeatherDisplay.swf
@ -135,6 +135,14 @@ custom-03d1-datagrid/Snarf.swf: custom-03d1-datagrid/Snarf.mxml custom-03d1-data
$(MXMLC) custom-03d1-datagrid/Snarf.mxml -warnings -l+=custom-03d1-datagrid -output custom-03d1-datagrid/Snarf.swf
custom-03d2-item-renderers/HBoxWeatherDisplay.swf: custom-03d2-item-renderers/HBoxWeatherDisplay.mxml custom-03d2-item-renderers/WeatherApp.as
$(MXMLC) custom-03d2-item-renderers/HBoxWeatherDisplay.mxml -warnings -l+=custom-03d2-item-renderers -output custom-03d2-item-renderers/HBoxWeatherDisplay.swf
custom-03d2-item-renderers/WeatherDisplay.swf: custom-03d2-item-renderers/WeatherDisplay.mxml custom-03d2-item-renderers/WeatherApp.as
$(MXMLC) custom-03d2-item-renderers/WeatherDisplay.mxml -warnings -l+=custom-03d2-item-renderers -output custom-03d2-item-renderers/WeatherDisplay.swf
custom-03d3-lists/ListControl.swf: custom-03d3-lists/ListControl.mxml custom-03d3-lists/ListApp.as
$(MXMLC) custom-03d3-lists/ListControl.mxml -warnings -l+=custom-03d3-lists -output custom-03d3-lists/ListControl.swf

Loading…
Cancel
Save