Skip to content
Browse files

fixed stock quote example with current theme

  • Loading branch information...
1 parent 13d835e commit 571e0b556dfbc604312f56cb5a59a3cb937d2705 @seanhess committed Apr 27, 2009
View
2 examples/StockQuote/src/StockQuote.mxml
@@ -3,7 +3,7 @@
xmlns:glue="stocks.glue.*" xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/halo" minWidth="1024" minHeight="768" xmlns:view="stocks.view.*" xmlns:control="stocks.control.*">
<fx:Declarations>
- <control:MainGlue/>
+ <glue:MainGlue/>
</fx:Declarations>
<s:layout>
View
4 ...uote/src/stocks/service/QuoteService.mxml → ...StockQuote/src/stocks/control/Quotes.mxml
@@ -37,10 +37,6 @@
{
Alert.show("There was an error");
}
-
- private function onLoad(event:Event):void{
- trace("WOOT");
- }
]]>
</fx:Script>
</fx:Object>
View
8 ...ockQuote/src/stocks/control/MainGlue.mxml → .../StockQuote/src/stocks/glue/MainGlue.mxml
@@ -2,13 +2,13 @@
<GlueMap xmlns="http://glue.seanhess.net/2009" xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/halo" xmlns:view="stocks.view.*" xmlns:control="stocks.control.*" xmlns:mate="http://mate.asfusion.com/" xmlns:service="stocks.service.*">
<fx:Declarations>
- <!-- SERVICES -->
-
- <service:QuoteService id="quoteService"/>
+ <!-- CONTROL -->
+ <control:Quotes id="quotes"/>
+ <!-- VIEW -->
<Glue>
<view:QuotePanel id="quotePanel"/>
- <Route event="{QuotePanel.GET_QUOTE}" call="quoteService.getQuote(quotePanel.quote)"/>
+ <Route event="{QuotePanel.GET_QUOTE}" call="quotes.getQuote(quotePanel.quote)"/>
</Glue>
</fx:Declarations>
View
4 examples/StockQuote/src/stocks/model/Quote.as
@@ -1,9 +1,5 @@
package stocks.model
{
- /**
- * The model object gets passed around to everybody. These should be global
- * models? Or at least pass
- */
[Bindable]
public class Quote
{
View
18 examples/StockQuote/src/stocks/service/QuoteServiceParser.as
@@ -1,17 +1,15 @@
package stocks.service
{
- // --------------------------------------------
- // This helper class parses data coming from the
- // stock quotes web service and converts it into
- // an object
-
+
+ /**
+ * Services are helper classes. In this case, a parser
+ *
+ * You could also have a separate class with your actual
+ * web services
+ */
public class QuoteServiceParser
{
- // --------------------------------------------
- // The webservice returns a string representation
- // of an xml object. We first convert to xml
- // and then get the properties from it
public function getPrice(info:Object):Number {
try {
var price:Number = info.quote.stock.price.current;
@@ -20,7 +18,7 @@ package stocks.service
catch (e:Error)
{
}
- return 0;
+ return NaN;
}
}
View
13 examples/StockQuote/src/stocks/view/PriceFormatter.as
@@ -0,0 +1,13 @@
+package stocks.view
+{
+ [Bindable]
+ public class PriceFormatter
+ {
+ public var display:String;
+
+ public function set price(value:Number):void
+ {
+ display = (value) ? value.toString() : "Not Available";
+ }
+ }
+}
View
8 examples/StockQuote/src/stocks/view/QuotePanel.mxml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
-<s:Panel title="Stock Quotes" xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/halo" width="400" height="300">
+<s:Panel title="Stock Quotes" xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/halo" width="400" height="300" xmlns:view="stocks.view.*">
<fx:Script>
<![CDATA[
@@ -16,6 +16,10 @@
]]>
</fx:Script>
+ <fx:Declarations>
+ <view:PriceFormatter id="format" price="{quote.price}"/>
+ </fx:Declarations>
+
<s:layout>
<s:VerticalLayout/>
</s:layout>
@@ -27,5 +31,5 @@
<s:Button label="Get Quote" click="getQuote()"/>
</s:Group>
- <mx:Label text="Price: {quote.price}" />
+ <mx:Label text="Price: {format.display}" />
</s:Panel>

0 comments on commit 571e0b5

Please sign in to comment.
Something went wrong with that request. Please try again.