flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From p...@apache.org
Subject git commit: [flex-asjs] [refs/heads/develop] - Add example for Express framework.
Date Wed, 04 Jan 2017 21:31:10 GMT
Repository: flex-asjs
Updated Branches:
  refs/heads/develop 83eb2496d -> f72f3d318


Add example for Express framework.


Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/f72f3d31
Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/f72f3d31
Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/f72f3d31

Branch: refs/heads/develop
Commit: f72f3d318419a9d518dc181dbabaf79d42b09b58
Parents: 83eb249
Author: Peter Ent <pent@apache.org>
Authored: Wed Jan 4 16:31:07 2017 -0500
Committer: Peter Ent <pent@apache.org>
Committed: Wed Jan 4 16:31:07 2017 -0500

----------------------------------------------------------------------
 examples/express/DataBindingExample/README.txt  |  53 ++++++++
 examples/express/DataBindingExample/build.xml   |  46 +++++++
 examples/express/DataBindingExample/pom.xml     |  75 +++++++++++
 .../src/main/flex/DataBindingExample.mxml       |  51 +++++++
 .../src/main/flex/MyInitialView.mxml            | 132 +++++++++++++++++++
 .../src/main/flex/StockDataJSONItemConverter.as |  40 ++++++
 .../src/main/flex/controllers/MyController.as   |  92 +++++++++++++
 .../src/main/flex/models/MyModel.as             | 125 ++++++++++++++++++
 8 files changed, 614 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/f72f3d31/examples/express/DataBindingExample/README.txt
----------------------------------------------------------------------
diff --git a/examples/express/DataBindingExample/README.txt b/examples/express/DataBindingExample/README.txt
new file mode 100644
index 0000000..91a0359
--- /dev/null
+++ b/examples/express/DataBindingExample/README.txt
@@ -0,0 +1,53 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  Licensed to the Apache Software Foundation (ASF) under one or more
+//  contributor license agreements.  See the NOTICE file distributed with
+//  this work for additional information regarding copyright ownership.
+//  The ASF licenses this file to You under the Apache License, Version 2.0
+//  (the "License"); you may not use this file except in compliance with
+//  the License.  You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+
+DESCRIPTION
+
+The DataBindingExample shows a Flex application that can communicate with
+a third-party data source (in this case, yahoo.finance) and display the values
+returned using data binding. It also demonstrates that you can use “states” to
+control the UI.
+
+This Flex application may be run as a Flash SWF or cross-compiled (using Falcon JX)
+into JavaScript and HTML and run without Flash.
+
+The DataBindingExample  also shows how the model-view-controller (MVC) pattern
+can be used to separate the parts of the application. This is facilitated by
+the use of FlexJS beads added to the main application that provide the
+data connection (via HTTPService) and interacting with the rest of the application
+via events.
+
+COMPONENTS and BEADS
+
+- Button
+- CheckBox
+- ComboBox
+- Container
+- Label
+- RadioButton
+- TextArea
+- TextInput
+
+- Data binding: the text properties of TextArea and Label are linked with results
+from the remote server calls.
+
+NOTES
+
+The cross-compilation to JavaScript often results in non-fatal warnings. Some of these warnings
+should be addressed in future releases of the Falcon JX compiler.

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/f72f3d31/examples/express/DataBindingExample/build.xml
----------------------------------------------------------------------
diff --git a/examples/express/DataBindingExample/build.xml b/examples/express/DataBindingExample/build.xml
new file mode 100644
index 0000000..6739bb6
--- /dev/null
+++ b/examples/express/DataBindingExample/build.xml
@@ -0,0 +1,46 @@
+<?xml version="1.0"?>
+<!--
+
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+
+-->
+
+
+<project name="databindingexample" default="main" basedir=".">
+    <property name="FLEXJS_HOME" location="../../.."/>
+    <property name="example" value="DataBindingExample" />
+    
+    <property file="${FLEXJS_HOME}/env.properties"/>
+    <property environment="env"/>
+    <property file="${FLEXJS_HOME}/build.properties"/>
+    <property name="FLEX_HOME" value="${FLEXJS_HOME}"/>
+    <property name="opt1_arg" value="-js-output-optimization=skipAsCoercions" />
+
+    <include file="${basedir}/../../build_example.xml" />
+    
+    <target name="main" depends="clean,build_example.compile,build_example.compilejs"
description="Clean build of ${example}">
+    </target>
+    
+    <target name="clean">
+        <delete dir="${basedir}/bin" failonerror="false" />
+        <delete dir="${basedir}/bin-debug" failonerror="false" />
+        <delete dir="${basedir}/bin-release" failonerror="false" />
+        <delete dir="${basedir}/target" failonerror="false" />
+    </target>
+
+    
+    
+</project>

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/f72f3d31/examples/express/DataBindingExample/pom.xml
----------------------------------------------------------------------
diff --git a/examples/express/DataBindingExample/pom.xml b/examples/express/DataBindingExample/pom.xml
new file mode 100644
index 0000000..777898a
--- /dev/null
+++ b/examples/express/DataBindingExample/pom.xml
@@ -0,0 +1,75 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <groupId>org.apache.flex.flexjs.examples</groupId>
+    <artifactId>examples-flexjs</artifactId>
+    <version>0.8.0-SNAPSHOT</version>
+  </parent>
+
+  <artifactId>DataBindingExample</artifactId>
+  <version>0.8.0-SNAPSHOT</version>
+  <packaging>swf</packaging>
+
+  <name>Apache Flex - FlexJS: Examples: FlexJS: DataBindingExample</name>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.flex.flexjs.compiler</groupId>
+        <artifactId>flexjs-maven-plugin</artifactId>
+        <extensions>true</extensions>
+        <configuration>
+          <mainClass>DataBindingExample.mxml</mainClass>
+        </configuration>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-war-plugin</artifactId>
+      </plugin>
+      <plugin>
+        <groupId>org.codehaus.mojo</groupId>
+        <artifactId>build-helper-maven-plugin</artifactId>
+      </plugin>
+    </plugins>
+  </build>
+
+  <dependencies>
+    <dependency>
+      <groupId>com.adobe.flash.framework</groupId>
+      <artifactId>playerglobal</artifactId>
+      <version>${flash.version}</version>
+      <type>swc</type>
+      <scope>provided</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.flex.flexjs.framework</groupId>
+      <artifactId>Network</artifactId>
+      <version>0.8.0-SNAPSHOT</version>
+      <type>swc</type>
+    </dependency>
+  </dependencies>
+
+</project>

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/f72f3d31/examples/express/DataBindingExample/src/main/flex/DataBindingExample.mxml
----------------------------------------------------------------------
diff --git a/examples/express/DataBindingExample/src/main/flex/DataBindingExample.mxml b/examples/express/DataBindingExample/src/main/flex/DataBindingExample.mxml
new file mode 100644
index 0000000..930bf47
--- /dev/null
+++ b/examples/express/DataBindingExample/src/main/flex/DataBindingExample.mxml
@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements.  See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License.  You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+-->
+<express:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
+                   xmlns:local="*"
+                   xmlns:express="library://ns.apache.org/flexjs/express"
+                   xmlns:js="library://ns.apache.org/flexjs/basic" 
+                   xmlns:models="models.*" 
+                   xmlns:controllers="controllers.*"
+                   initialize="MyModel(model).stockSymbol='ADBE'"
+                   >
+    <js:initialView>
+        <local:MyInitialView />
+    </js:initialView>
+    <js:model>
+        <models:MyModel />
+    </js:model>
+    <js:controller>
+        <controllers:MyController />
+    </js:controller>
+    <js:beads>
+        <js:HTTPService id="service">
+            <js:LazyCollection id="collection">
+                <js:inputParser>
+                    <js:JSONInputParser />
+                </js:inputParser>
+                <js:itemConverter>
+                    <local:StockDataJSONItemConverter />
+                </js:itemConverter> 
+            </js:LazyCollection>
+        </js:HTTPService>
+        <js:CSSFontFaceBead />
+        <js:ViewSourceContextMenuOption />
+    </js:beads>
+</express:Application>

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/f72f3d31/examples/express/DataBindingExample/src/main/flex/MyInitialView.mxml
----------------------------------------------------------------------
diff --git a/examples/express/DataBindingExample/src/main/flex/MyInitialView.mxml b/examples/express/DataBindingExample/src/main/flex/MyInitialView.mxml
new file mode 100644
index 0000000..2b111f3
--- /dev/null
+++ b/examples/express/DataBindingExample/src/main/flex/MyInitialView.mxml
@@ -0,0 +1,132 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements.  See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License.  You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+-->
+<express:VView xmlns:fx="http://ns.adobe.com/mxml/2009"
+			    xmlns:express="library://ns.apache.org/flexjs/express"
+				xmlns:js="library://ns.apache.org/flexjs/basic"
+			    initComplete="initControls()">
+    <fx:Script>
+        <![CDATA[
+			import models.MyModel;
+			
+			import org.apache.flex.events.CustomEvent;
+			
+			private var _symbol:String;
+			
+            public function get symbol():String
+            {
+                return _symbol;
+            }
+			
+			public function get requestedField():String
+			{
+				return radio1.selectedValue as String;
+			}
+			
+            [Bindable]
+            public var fieldText:String;
+            
+			private function radioChanged(e:org.apache.flex.events.Event):void
+			{
+				dispatchEvent(new CustomEvent("radioClicked"));
+				fieldText = RadioButton(e.target).text;
+			}
+			
+			private function initControls():void
+			{
+				list.selectedItem = MyModel(applicationModel).stockSymbol;
+				radio1.selectedValue = MyModel(applicationModel).requestedField;
+				if (radio1.selected)
+					fieldText = radio1.text;
+				else if (radio2.selected)
+					fieldText = radio2.text;
+				else if (radio3.selected)
+					fieldText = radio3.text;
+				else if (radio4.selected)
+					fieldText = radio4.text;
+				
+			}
+            
+            private function setState():void
+            {
+                currentState = showAllData.selected ? "showAll" : "hideAll";    
+            }
+		]]>
+    </fx:Script>
+	<fx:Style>
+		@namespace basic "library://ns.apache.org/flexjs/basic";
+		
+		.output {
+			font-size: 20px;
+		}
+
+        .topContainer {
+            padding: 10px;
+            
+        }
+        .leftSide {
+            vertical-align: top;
+            margin-right: 10px;
+        }
+        
+        .rightSide {
+            vertical-align: top;
+            margin-left: 10px;
+            padding-left: 10px;
+        }
+        
+        .quoteButton {
+            margin-top: 10px;
+            margin-bottom: 10px;
+        }
+	</fx:Style>
+	
+    <js:states>
+        <js:State name="hideAll" />        
+        <js:State name="showAll" />        
+    </js:states>
+
+    <js:VContainer x="0" y="0" className="topContainer" >
+        <js:Label width="300" text="Enter Stock Symbol or choose from list:" />
+        <js:HContainer>
+            <js:VContainer className="leftSide">
+                <express:TextInput id="symbolTI" text="{MyModel(applicationModel).stockSymbol}"
prompt="symbol" />
+                <js:TextButton text="Get Quote" className="quoteButton" 
+                                  click="_symbol = symbolTI.text; dispatchEvent(new CustomEvent('buttonClicked'))"
/>
+                <js:Label id="field" text="{fieldText}"/>
+                <js:Label className="output" height="24" text="{MyModel(applicationModel).responseText}"
/>
+            </js:VContainer>
+            <js:VContainer className="rightSide">
+                <js:DropDownList id="list" width="100"
+                                    change="_symbol = list.selectedItem as String; dispatchEvent(new
CustomEvent('listChanged'))"
+                                    dataProvider="{MyModel(applicationModel).strings}" />
+                <js:RadioButton id="radio1" text="Price" value="Ask" groupName="group1"
change="radioChanged(event)"/>
+                <js:RadioButton id="radio2" text="Change" value="Change" groupName="group1"
change="radioChanged(event)"/>
+                <js:RadioButton id="radio3" text="Day's High" value="DaysHigh" groupName="group1"
change="radioChanged(event)"/>
+                <js:RadioButton id="radio4" text="Day's Low" value="DaysLow" groupName="group1"
change="radioChanged(event)"/>
+                <js:CheckBox id="showAllData" text="Show All Data" change="setState()"
/>
+            </js:VContainer>
+        </js:HContainer>
+        <js:Label id="bindtest" text="{fieldText + ' expression binding'}" />
+        <js:Label width="300" text.showAll="110" includeIn="showAll" />
+        <js:TextArea id="ta" width="300" height="100" height.showAll="110" 
+                        includeIn="showAll"
+                        text="{MyModel(applicationModel).allData}" />
+    </js:VContainer>	
+</express:VView>

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/f72f3d31/examples/express/DataBindingExample/src/main/flex/StockDataJSONItemConverter.as
----------------------------------------------------------------------
diff --git a/examples/express/DataBindingExample/src/main/flex/StockDataJSONItemConverter.as
b/examples/express/DataBindingExample/src/main/flex/StockDataJSONItemConverter.as
new file mode 100644
index 0000000..a39606b
--- /dev/null
+++ b/examples/express/DataBindingExample/src/main/flex/StockDataJSONItemConverter.as
@@ -0,0 +1,40 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  Licensed to the Apache Software Foundation (ASF) under one or more
+//  contributor license agreements.  See the NOTICE file distributed with
+//  this work for additional information regarding copyright ownership.
+//  The ASF licenses this file to You under the Apache License, Version 2.0
+//  (the "License"); you may not use this file except in compliance with
+//  the License.  You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package
+{
+    import org.apache.flex.collections.converters.JSONItemConverter;
+    
+    public class StockDataJSONItemConverter extends JSONItemConverter
+    {
+        public function StockDataJSONItemConverter()
+        {
+            super();
+        }
+        
+        override public function convertItem(data:String):Object
+        {
+            var obj:Object = super.convertItem(data);
+			if (obj["query"]["count"] == 0)
+				return "No Data";
+			
+			obj = obj["query"]["results"]["quote"];
+			return obj;
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/f72f3d31/examples/express/DataBindingExample/src/main/flex/controllers/MyController.as
----------------------------------------------------------------------
diff --git a/examples/express/DataBindingExample/src/main/flex/controllers/MyController.as
b/examples/express/DataBindingExample/src/main/flex/controllers/MyController.as
new file mode 100644
index 0000000..b7d52bd
--- /dev/null
+++ b/examples/express/DataBindingExample/src/main/flex/controllers/MyController.as
@@ -0,0 +1,92 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  Licensed to the Apache Software Foundation (ASF) under one or more
+//  contributor license agreements.  See the NOTICE file distributed with
+//  this work for additional information regarding copyright ownership.
+//  The ASF licenses this file to You under the Apache License, Version 2.0
+//  (the "License"); you may not use this file except in compliance with
+//  the License.  You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package controllers
+{
+	import org.apache.flex.events.Event;
+
+	import org.apache.flex.core.Application;
+	import org.apache.flex.core.IDocument;
+	import org.apache.flex.net.HTTPService;
+	import org.apache.flex.collections.LazyCollection;
+
+    import models.MyModel;
+
+	public class MyController implements IDocument
+	{
+		public function MyController(app:Application = null)
+		{
+			if (app)
+			{
+				app.addEventListener("viewChanged", viewChangeHandler);
+			}
+		}
+
+		private var model:MyModel;
+		private var initialView:Object;
+		private var service:HTTPService;
+		private var collection:LazyCollection;
+
+        private var queryBegin:String = "http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20yahoo.finance.quotes%20where%20symbol%20in%20(%22";
+        private var queryEnd:String = "%22)%0A%09%09&env=http%3A%2F%2Fdatatables.org%2Falltables.env&format=json";
+
+		private function viewChangeHandler(event:Event):void
+		{
+			var app:Application = event.target as Application;
+			app.initialView.addEventListener("buttonClicked", buttonClickHandler);
+			app.initialView.addEventListener("radioClicked", radioClickHandler);
+            app.initialView.addEventListener("listChanged", listChangedHandler);
+
+            initialView = app.initialView;
+			model = app.model as MyModel;
+			service = app["service"] as HTTPService;
+			collection = app["collection"] as LazyCollection;
+		}
+
+        private function buttonClickHandler(event:Event):void
+        {
+            var sym:String = MyInitialView(initialView).symbol;
+            service.url = queryBegin + sym + queryEnd;
+            service.send();
+            service.addEventListener("complete", completeHandler);
+        }
+
+		private function radioClickHandler(event:Event):void
+		{
+			var field:String = MyInitialView(initialView).requestedField;
+			model.requestedField = field;
+		}
+
+        private function completeHandler(event:Event):void
+        {
+			model.responseData = collection.getItemAt(0);
+        }
+
+        private function listChangedHandler(event:Event):void
+        {
+            model.stockSymbol = MyInitialView(initialView).symbol;
+        }
+
+		public function setDocument(document:Object, id:String = null):void
+		{
+			var app:Application = document as Application;
+			app.addEventListener("viewChanged", viewChangeHandler);
+		}
+
+	}
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/f72f3d31/examples/express/DataBindingExample/src/main/flex/models/MyModel.as
----------------------------------------------------------------------
diff --git a/examples/express/DataBindingExample/src/main/flex/models/MyModel.as b/examples/express/DataBindingExample/src/main/flex/models/MyModel.as
new file mode 100644
index 0000000..5a16d02
--- /dev/null
+++ b/examples/express/DataBindingExample/src/main/flex/models/MyModel.as
@@ -0,0 +1,125 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  Licensed to the Apache Software Foundation (ASF) under one or more
+//  contributor license agreements.  See the NOTICE file distributed with
+//  this work for additional information regarding copyright ownership.
+//  The ASF licenses this file to You under the Apache License, Version 2.0
+//  (the "License"); you may not use this file except in compliance with
+//  the License.  You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package models
+{
+	import org.apache.flex.events.Event;
+	import org.apache.flex.events.EventDispatcher;
+	
+	public class MyModel extends EventDispatcher
+	{
+		public function MyModel()
+		{
+		}
+		
+		private var _requestedField:String = "Ask";
+		
+		[Bindable("requestedFieldChanged")]
+		public function get requestedField():String
+		{
+			return _requestedField;
+		}
+		
+		public function set requestedField(value:String):void
+		{
+			if (value != _requestedField)
+			{
+				_requestedField = value;
+				dispatchEvent(new Event("requestedFieldChanged"));
+				if (_responseData)
+					dispatchEvent(new Event("responseTextChanged"));
+			}
+		}
+		
+		[Bindable("responseTextChanged")]
+		public function get responseText():String
+		{
+			if (_responseData == null)
+				return "";
+			if (_responseData == "No Data")
+				return _responseData as String;
+			var s:String = _responseData[_requestedField];
+			if (s == null)
+			{
+				if (_requestedField == "Ask")
+					s = _responseData["Bid"];
+			}
+			return s;
+		}
+		
+		private var _responseData:Object;
+		
+		[Bindable("responseDataChanged")]
+		public function get responseData():Object
+		{
+			return _responseData;
+		}
+		
+		public function set responseData(value:Object):void
+		{
+			if (value != _responseData)
+			{
+				_responseData = value;
+				_allData = "";
+				dispatchEvent(new Event("responseDataChanged"));
+				dispatchEvent(new Event("responseTextChanged"));
+			}
+		}
+		
+		private var _allData:String = "";
+		
+		[Bindable("responseDataChanged")]
+		public function get allData():String
+		{
+			if (_allData == "" && _responseData != null)
+			{
+				for (var p:String in _responseData)
+				{
+					_allData += p + ": " + _responseData[p] + "\n";
+				}
+			}
+			return _allData;
+		}
+		
+		
+		private var _stockSymbol:String;
+		
+		[Bindable("stockSymbolChanged")]
+		public function get stockSymbol():String
+		{
+			return _stockSymbol;
+		}
+		
+		public function set stockSymbol(value:String):void
+		{
+			if (value != _stockSymbol)
+			{
+				_stockSymbol = value;
+				dispatchEvent(new Event("stockSymbolChanged"));
+			}
+		}
+
+        private var _strings:Array = ["AAPL", "ADBE", "GOOG", "MSFT", "YHOO"];
+        [Bindable("__NoChangeEvent__")]
+        public function get strings():Array
+        {
+            return _strings;
+        }
+
+	}
+}
\ No newline at end of file


Mime
View raw message