You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by pe...@apache.org on 2017/05/10 20:51:38 UTC

git commit: [flex-asjs] [refs/heads/develop] - Added DataBindingExampleWithFlexLayout sample app.

Repository: flex-asjs
Updated Branches:
  refs/heads/develop c52908fe7 -> e79d327fc


Added DataBindingExampleWithFlexLayout sample app.


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

Branch: refs/heads/develop
Commit: e79d327fc8aa7cfcf97172ebb1ddd3ccd2cfdbde
Parents: c52908f
Author: Peter Ent <pe...@apache.org>
Authored: Wed May 10 16:51:36 2017 -0400
Committer: Peter Ent <pe...@apache.org>
Committed: Wed May 10 16:51:36 2017 -0400

----------------------------------------------------------------------
 examples/build.xml                              |   2 +
 .../DataBindingExampleWithFlexLayout/README.txt |  57 +++++++
 .../DataBindingExampleWithFlexLayout/build.xml  |  46 ++++++
 .../DataBindingExampleWithFlexLayout/pom.xml    |  74 +++++++++
 .../src/main/config/compile-app-config.xml      |  23 +++
 .../flex/DataBindingExampleWithFlexLayout.mxml  |  53 +++++++
 .../src/main/flex/MyInitialView.mxml            | 152 +++++++++++++++++++
 .../src/main/flex/StockDataJSONItemConverter.as |  40 +++++
 .../src/main/flex/controllers/MyController.as   |  92 +++++++++++
 .../src/main/flex/models/MyModel.as             | 125 +++++++++++++++
 10 files changed, 664 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e79d327f/examples/build.xml
----------------------------------------------------------------------
diff --git a/examples/build.xml b/examples/build.xml
index b4fac50..da2bd7d 100644
--- a/examples/build.xml
+++ b/examples/build.xml
@@ -80,6 +80,7 @@
         <ant dir="${basedir}/flexjs/DataBindingExample"/>
         <ant dir="${basedir}/flexjs/DataBindingExample_as"/>
         <ant dir="${basedir}/flexjs/DataBindingExample_Flat"/>
+        <ant dir="${basedir}/flexjs/DataBindingExampleWithFlexLayout"/>
         <ant dir="${basedir}/flexjs/DataGridExample"/>
         <ant dir="${basedir}/flexjs/DateControlsExample"/>
         <ant dir="${basedir}/flexjs/DesktopMap"/>
@@ -122,6 +123,7 @@
         <ant dir="${basedir}/flexjs/DataBindingExample" target="clean"/>
         <ant dir="${basedir}/flexjs/DataBindingExample_as" target="clean"/>
         <ant dir="${basedir}/flexjs/DataBindingExample_Flat" target="clean"/>
+        <ant dir="${basedir}/flexjs/DataBindingExampleWithFlexLayout" target="clean"/>
         <ant dir="${basedir}/flexjs/DataGridExample" target="clean"/>
         <ant dir="${basedir}/flexjs/DateControlsExample" target="clean"/>
         <ant dir="${basedir}/flexjs/DesktopMap" target="clean"/>

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e79d327f/examples/flexjs/DataBindingExampleWithFlexLayout/README.txt
----------------------------------------------------------------------
diff --git a/examples/flexjs/DataBindingExampleWithFlexLayout/README.txt b/examples/flexjs/DataBindingExampleWithFlexLayout/README.txt
new file mode 100644
index 0000000..948704e
--- /dev/null
+++ b/examples/flexjs/DataBindingExampleWithFlexLayout/README.txt
@@ -0,0 +1,57 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+
+NOTE: This example is the same as DataBindingExample (described below), except
+it uses the VerticalFlexLayout and HorizontalFlexLayout layouts. These layouts
+use the CSS Flexbox for the HTML/JS platform; this is not supported in IE9.
+
+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/e79d327f/examples/flexjs/DataBindingExampleWithFlexLayout/build.xml
----------------------------------------------------------------------
diff --git a/examples/flexjs/DataBindingExampleWithFlexLayout/build.xml b/examples/flexjs/DataBindingExampleWithFlexLayout/build.xml
new file mode 100644
index 0000000..8862bb6
--- /dev/null
+++ b/examples/flexjs/DataBindingExampleWithFlexLayout/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="databindingexampleWithFlexLayout" default="main" basedir=".">
+    <property name="FLEXJS_HOME" location="../../.."/>
+    <property name="example" value="DataBindingExampleWithFlexLayout" />
+    
+    <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" 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/e79d327f/examples/flexjs/DataBindingExampleWithFlexLayout/pom.xml
----------------------------------------------------------------------
diff --git a/examples/flexjs/DataBindingExampleWithFlexLayout/pom.xml b/examples/flexjs/DataBindingExampleWithFlexLayout/pom.xml
new file mode 100644
index 0000000..a0a4bf2
--- /dev/null
+++ b/examples/flexjs/DataBindingExampleWithFlexLayout/pom.xml
@@ -0,0 +1,74 @@
+<?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>DataBindingExampleWithFlexLayout</artifactId>
+  <version>0.8.0-SNAPSHOT</version>
+  <packaging>swf</packaging>
+
+  <name>Apache Flex - FlexJS: Examples: FlexJS: DataBindingExampleWithLayout</name>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.flex.flexjs.compiler</groupId>
+        <artifactId>flexjs-maven-plugin</artifactId>
+        <extensions>true</extensions>
+        <configuration>
+          <mainClass>DataBindingExampleWithFlexLayout.mxml</mainClass>
+        </configuration>
+      </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>
+    <dependency>
+      <groupId>org.apache.flex.flexjs.framework</groupId>
+      <artifactId>Network</artifactId>
+      <version>0.8.0-SNAPSHOT</version>
+      <type>swc</type>
+      <classifier>js</classifier>
+    </dependency>
+  </dependencies>
+
+</project>

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e79d327f/examples/flexjs/DataBindingExampleWithFlexLayout/src/main/config/compile-app-config.xml
----------------------------------------------------------------------
diff --git a/examples/flexjs/DataBindingExampleWithFlexLayout/src/main/config/compile-app-config.xml b/examples/flexjs/DataBindingExampleWithFlexLayout/src/main/config/compile-app-config.xml
new file mode 100644
index 0000000..b4290dc
--- /dev/null
+++ b/examples/flexjs/DataBindingExampleWithFlexLayout/src/main/config/compile-app-config.xml
@@ -0,0 +1,23 @@
+<!--
+
+  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.
+
+-->
+<flex-config>
+    <js-output-optimization>
+        <optimization>skipFunctionCoercions</optimization>
+    </js-output-optimization>
+</flex-config>

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e79d327f/examples/flexjs/DataBindingExampleWithFlexLayout/src/main/flex/DataBindingExampleWithFlexLayout.mxml
----------------------------------------------------------------------
diff --git a/examples/flexjs/DataBindingExampleWithFlexLayout/src/main/flex/DataBindingExampleWithFlexLayout.mxml b/examples/flexjs/DataBindingExampleWithFlexLayout/src/main/flex/DataBindingExampleWithFlexLayout.mxml
new file mode 100644
index 0000000..751e427
--- /dev/null
+++ b/examples/flexjs/DataBindingExampleWithFlexLayout/src/main/flex/DataBindingExampleWithFlexLayout.mxml
@@ -0,0 +1,53 @@
+<?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.
+
+-->
+<js:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
+                   xmlns:local="*"
+                   xmlns:js="library://ns.apache.org/flexjs/basic" 
+                   xmlns:models="models.*" 
+                   xmlns:controllers="controllers.*"
+                   initialize="MyModel(model).stockSymbol='ADBE'"
+                   >
+    <js:valuesImpl>
+        <js:SimpleCSSValuesImpl />
+    </js:valuesImpl>
+    <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>
+</js:Application>

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e79d327f/examples/flexjs/DataBindingExampleWithFlexLayout/src/main/flex/MyInitialView.mxml
----------------------------------------------------------------------
diff --git a/examples/flexjs/DataBindingExampleWithFlexLayout/src/main/flex/MyInitialView.mxml b/examples/flexjs/DataBindingExampleWithFlexLayout/src/main/flex/MyInitialView.mxml
new file mode 100644
index 0000000..034d8c1
--- /dev/null
+++ b/examples/flexjs/DataBindingExampleWithFlexLayout/src/main/flex/MyInitialView.mxml
@@ -0,0 +1,152 @@
+<?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.
+
+-->
+<js:View xmlns:fx="http://ns.adobe.com/mxml/2009"
+				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 = "symbol data";
+            
+			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";
+		
+		.inner {
+			width: 400px;
+		}
+		
+		.output {
+			font-size: 20px;
+		}
+
+        .topContainer {
+            backgroundColor: white;
+        }
+		
+        .leftSide {
+			flex-grow: 1;
+			margin: 6px;
+        }
+		
+		.symbolInput {
+		}
+        
+        .rightSide {
+			flex-grow: 1;
+			margin: 6px;
+        }
+        
+        .quoteButton {
+            margin-top: 10px;
+            margin-bottom: 10px;
+        }
+	</fx:Style>
+    <js:states>
+        <js:State name="hideAll" />        
+        <js:State name="showAll" />        
+    </js:states>
+	
+    <js:beads>
+        <js:ViewDataBinding />
+		<js:VerticalFlexLayout />
+    </js:beads>
+		
+    <js:Label text="Enter Stock Symbol or choose from list:" />
+	
+	<js:Group className="inner" width="400">
+		<js:beads>
+			<js:HorizontalFlexLayout />
+		</js:beads>
+		
+		<js:Group className="leftSide">
+			<js:beads>
+				<js:VerticalFlexLayout />
+			</js:beads>
+			<js:TextInput id="symbolTI" text="{MyModel(applicationModel).stockSymbol}" className="symbolInput" width="50%" />
+			<js:TextButton text="Get Quote" className="quoteButton" width="50%"
+						   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:Group>
+		
+		<js:Group className="rightSide">
+			<js:beads>
+				<js:VerticalFlexLayout />
+			</js:beads>
+			<js:DropDownList id="list" width="50%"
+							 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:Group>
+	</js:Group>
+	
+	<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:View>

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e79d327f/examples/flexjs/DataBindingExampleWithFlexLayout/src/main/flex/StockDataJSONItemConverter.as
----------------------------------------------------------------------
diff --git a/examples/flexjs/DataBindingExampleWithFlexLayout/src/main/flex/StockDataJSONItemConverter.as b/examples/flexjs/DataBindingExampleWithFlexLayout/src/main/flex/StockDataJSONItemConverter.as
new file mode 100644
index 0000000..a39606b
--- /dev/null
+++ b/examples/flexjs/DataBindingExampleWithFlexLayout/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/e79d327f/examples/flexjs/DataBindingExampleWithFlexLayout/src/main/flex/controllers/MyController.as
----------------------------------------------------------------------
diff --git a/examples/flexjs/DataBindingExampleWithFlexLayout/src/main/flex/controllers/MyController.as b/examples/flexjs/DataBindingExampleWithFlexLayout/src/main/flex/controllers/MyController.as
new file mode 100644
index 0000000..6487908
--- /dev/null
+++ b/examples/flexjs/DataBindingExampleWithFlexLayout/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 = "https://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=store%3A%2F%2Fdatatables.org%2Falltableswithkeys&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/e79d327f/examples/flexjs/DataBindingExampleWithFlexLayout/src/main/flex/models/MyModel.as
----------------------------------------------------------------------
diff --git a/examples/flexjs/DataBindingExampleWithFlexLayout/src/main/flex/models/MyModel.as b/examples/flexjs/DataBindingExampleWithFlexLayout/src/main/flex/models/MyModel.as
new file mode 100644
index 0000000..5a16d02
--- /dev/null
+++ b/examples/flexjs/DataBindingExampleWithFlexLayout/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