You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by ca...@apache.org on 2016/11/10 09:23:23 UTC
[16/53] git commit: [flex-asjs] [refs/heads/feature/mdl] - -
Refactored the directory structure of the example projects to be maven-style
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e75059f7/examples/flexjs/CordovaCameraExample/src/main/flex/MyInitialView.mxml
----------------------------------------------------------------------
diff --git a/examples/flexjs/CordovaCameraExample/src/main/flex/MyInitialView.mxml b/examples/flexjs/CordovaCameraExample/src/main/flex/MyInitialView.mxml
new file mode 100644
index 0000000..7472d95
--- /dev/null
+++ b/examples/flexjs/CordovaCameraExample/src/main/flex/MyInitialView.mxml
@@ -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.
+
+-->
+<js:View xmlns:fx="http://ns.adobe.com/mxml/2009"
+ xmlns:js="library://ns.apache.org/flexjs/basic"
+ xmlns:local="*" >
+ <fx:Script>
+ <![CDATA[
+
+ import org.apache.cordova.camera.Camera;
+
+ private var cam:org.apache.cordova.camera.Camera = new org.apache.cordova.camera.Camera();
+
+ public function set ready(value:Boolean):void
+ {
+ status.text = "ready";
+ }
+
+ public function snapPicture() : void
+ {
+ trace("snapping");
+ cam.getPicture(success,failure,{quality:100, destinationType:org.apache.cordova.camera.Camera.DestinationType.FILE_URI});
+ }
+
+ private function success(data:Object):void
+ {
+ output.text = "Success: "+String(data);
+ image.source = String(data);
+ }
+
+ private function failure(message:Object):void
+ {
+ output.text = "Failed: "+String(message);
+ }
+
+ private function onFromPhotoLibrary() : void
+ {
+ cam.getPicture(success,failure,{ quality: 50,
+ destinationType: org.apache.cordova.camera.Camera.DestinationType.FILE_URI,
+ sourceType: org.apache.cordova.camera.Camera.PictureSourceType.PHOTOLIBRARY });
+ }
+
+ ]]>
+ </fx:Script>
+
+ <fx:Style>
+
+ </fx:Style>
+
+ <js:Label id="status" x="20" y="140" width="400" text="loading..."/>
+
+ <js:TextButton text="From Photo Library" x="20" y="20" click="onFromPhotoLibrary()" />
+ <js:TextButton text="Snap Picture" x="20" y="55" click="snapPicture()" />
+
+ <js:Label id="output" x="20" y="110" width="400"/>
+
+ <js:Image id="image" x="20" y="200" width="200" height="200" />
+
+</js:View>
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e75059f7/examples/flexjs/CordovaCameraExample/src/main/resources/config.xml
----------------------------------------------------------------------
diff --git a/examples/flexjs/CordovaCameraExample/src/main/resources/config.xml b/examples/flexjs/CordovaCameraExample/src/main/resources/config.xml
new file mode 100644
index 0000000..00b9f64
--- /dev/null
+++ b/examples/flexjs/CordovaCameraExample/src/main/resources/config.xml
@@ -0,0 +1,44 @@
+<?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.
+
+-->
+<widget id="${groupId}.${artifactId}" version="${version}" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
+ <name>${artifactId}</name>
+ <description>
+ ${description}
+ </description>
+ <author email="dev@flex.apache.org" href="http://flex.apache.org">
+ Apache Flex Team
+ </author>
+ <content src="index.html" />
+ <plugin name="cordova-plugin-whitelist" version="1" />
+ <access origin="*" />
+ <allow-intent href="http://*/*" />
+ <allow-intent href="https://*/*" />
+ <allow-intent href="tel:*" />
+ <allow-intent href="sms:*" />
+ <allow-intent href="mailto:*" />
+ <allow-intent href="geo:*" />
+ <platform name="android">
+ <allow-intent href="market:*" />
+ </platform>
+ <platform name="ios">
+ <allow-intent href="itms:*" />
+ <allow-intent href="itms-apps:*" />
+ </platform>
+</widget>
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e75059f7/examples/flexjs/CreateJSExample/src/CreateJSExample.mxml
----------------------------------------------------------------------
diff --git a/examples/flexjs/CreateJSExample/src/CreateJSExample.mxml b/examples/flexjs/CreateJSExample/src/CreateJSExample.mxml
deleted file mode 100644
index 6709560..0000000
--- a/examples/flexjs/CreateJSExample/src/CreateJSExample.mxml
+++ /dev/null
@@ -1,69 +0,0 @@
-<?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.
-
--->
-<cjs:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
- xmlns:local="*"
- xmlns:js="library://ns.apache.org/flexjs/basic"
- xmlns:cjs="library://ns.apache.org/flexjs/createjs"
- applicationComplete="seq.play()"
- >
-
- <js:valuesImpl>
- <js:SimpleCSSValuesImpl />
- </js:valuesImpl>
-
- <js:beads>
- <js:ApplicationDataBinding />
- </js:beads>
-
- <fx:Declarations>
- <cjs:Sequence id="seq" target="circle" loop="true">
- <cjs:Tween id="tween1" target="circle" xTo="400"
- duration="1000" easing="{Ease.getPowInOut(4)}" />
- <cjs:Tween id="tween2" target="circle" alphaTo="0" yTo="175"
- duration="500" easing="{Ease.getPowInOut(2)}" />
- <cjs:Tween id="tween3" target="circle" alphaTo="0" yTo="225"
- duration="100" />
- <cjs:Tween id="tween4" target="circle" alphaTo="1" yTo="200"
- duration="500" easing="{Ease.getPowInOut(2)}" />
- <cjs:Tween id="tween5" target="circle" xTo="100"
- duration="800" easing="{Ease.getPowInOut(2)}" />
- </cjs:Sequence>
- </fx:Declarations>
-
- <fx:Script>
- <![CDATA[
- // import required for Ease functions in data binding.
- import org.apache.flex.createjs.tween.Ease;
- ]]>
- </fx:Script>
-
- <js:initialView>
- <cjs:View>
-
- <cjs:Circle id="circle" x="100" y="100" radius="50">
- <js:fill>
- <js:SolidColor color="#26C9FF" />
- </js:fill>
- </cjs:Circle>
-
- </cjs:View>
- </js:initialView>
-
-</cjs:Application>
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e75059f7/examples/flexjs/CreateJSExample/src/main/flex/CreateJSExample.mxml
----------------------------------------------------------------------
diff --git a/examples/flexjs/CreateJSExample/src/main/flex/CreateJSExample.mxml b/examples/flexjs/CreateJSExample/src/main/flex/CreateJSExample.mxml
new file mode 100644
index 0000000..6709560
--- /dev/null
+++ b/examples/flexjs/CreateJSExample/src/main/flex/CreateJSExample.mxml
@@ -0,0 +1,69 @@
+<?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.
+
+-->
+<cjs:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
+ xmlns:local="*"
+ xmlns:js="library://ns.apache.org/flexjs/basic"
+ xmlns:cjs="library://ns.apache.org/flexjs/createjs"
+ applicationComplete="seq.play()"
+ >
+
+ <js:valuesImpl>
+ <js:SimpleCSSValuesImpl />
+ </js:valuesImpl>
+
+ <js:beads>
+ <js:ApplicationDataBinding />
+ </js:beads>
+
+ <fx:Declarations>
+ <cjs:Sequence id="seq" target="circle" loop="true">
+ <cjs:Tween id="tween1" target="circle" xTo="400"
+ duration="1000" easing="{Ease.getPowInOut(4)}" />
+ <cjs:Tween id="tween2" target="circle" alphaTo="0" yTo="175"
+ duration="500" easing="{Ease.getPowInOut(2)}" />
+ <cjs:Tween id="tween3" target="circle" alphaTo="0" yTo="225"
+ duration="100" />
+ <cjs:Tween id="tween4" target="circle" alphaTo="1" yTo="200"
+ duration="500" easing="{Ease.getPowInOut(2)}" />
+ <cjs:Tween id="tween5" target="circle" xTo="100"
+ duration="800" easing="{Ease.getPowInOut(2)}" />
+ </cjs:Sequence>
+ </fx:Declarations>
+
+ <fx:Script>
+ <![CDATA[
+ // import required for Ease functions in data binding.
+ import org.apache.flex.createjs.tween.Ease;
+ ]]>
+ </fx:Script>
+
+ <js:initialView>
+ <cjs:View>
+
+ <cjs:Circle id="circle" x="100" y="100" radius="50">
+ <js:fill>
+ <js:SolidColor color="#26C9FF" />
+ </js:fill>
+ </cjs:Circle>
+
+ </cjs:View>
+ </js:initialView>
+
+</cjs:Application>
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e75059f7/examples/flexjs/CreateJSExample/src/main/flex/models/MyModel.as
----------------------------------------------------------------------
diff --git a/examples/flexjs/CreateJSExample/src/main/flex/models/MyModel.as b/examples/flexjs/CreateJSExample/src/main/flex/models/MyModel.as
new file mode 100644
index 0000000..9092424
--- /dev/null
+++ b/examples/flexjs/CreateJSExample/src/main/flex/models/MyModel.as
@@ -0,0 +1,34 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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;
+
+ /**
+ * This model exists to satisfy the requirement that FlexJS apps have
+ * models.
+ */
+ public class MyModel extends EventDispatcher
+ {
+ public function MyModel()
+ {
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e75059f7/examples/flexjs/CreateJSExample/src/models/MyModel.as
----------------------------------------------------------------------
diff --git a/examples/flexjs/CreateJSExample/src/models/MyModel.as b/examples/flexjs/CreateJSExample/src/models/MyModel.as
deleted file mode 100644
index 9092424..0000000
--- a/examples/flexjs/CreateJSExample/src/models/MyModel.as
+++ /dev/null
@@ -1,34 +0,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.
-//
-////////////////////////////////////////////////////////////////////////////////
-package models
-{
- import org.apache.flex.events.Event;
- import org.apache.flex.events.EventDispatcher;
-
- /**
- * This model exists to satisfy the requirement that FlexJS apps have
- * models.
- */
- public class MyModel extends EventDispatcher
- {
- public function MyModel()
- {
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e75059f7/examples/flexjs/DataBindingExample/src/DataBindingExample.mxml
----------------------------------------------------------------------
diff --git a/examples/flexjs/DataBindingExample/src/DataBindingExample.mxml b/examples/flexjs/DataBindingExample/src/DataBindingExample.mxml
deleted file mode 100644
index 751e427..0000000
--- a/examples/flexjs/DataBindingExample/src/DataBindingExample.mxml
+++ /dev/null
@@ -1,53 +0,0 @@
-<?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/e75059f7/examples/flexjs/DataBindingExample/src/MyInitialView.mxml
----------------------------------------------------------------------
diff --git a/examples/flexjs/DataBindingExample/src/MyInitialView.mxml b/examples/flexjs/DataBindingExample/src/MyInitialView.mxml
deleted file mode 100644
index 8345213..0000000
--- a/examples/flexjs/DataBindingExample/src/MyInitialView.mxml
+++ /dev/null
@@ -1,144 +0,0 @@
-<?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;
-
- 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:beads>
- <js:ViewDataBinding />
- </js:beads>
- <js:Container x="0" y="0" className="topContainer" >
- <js:beads>
- <js:VerticalLayout />
- </js:beads>
- <js:Label width="300" text="Enter Stock Symbol or choose from list:" />
- <js:Container>
- <js:beads>
- <js:HorizontalLayout />
- </js:beads>
- <js:Container className="leftSide">
- <js:beads>
- <js:VerticalLayout />
- </js:beads>
- <js:TextInput id="symbolTI" text="{MyModel(applicationModel).stockSymbol}" />
- <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:Container>
- <js:Container className="rightSide">
- <js:beads>
- <js:VerticalLayout />
- </js:beads>
- <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:Container>
- </js:Container>
- <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:Container>
-</js:View>
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e75059f7/examples/flexjs/DataBindingExample/src/StockDataJSONItemConverter.as
----------------------------------------------------------------------
diff --git a/examples/flexjs/DataBindingExample/src/StockDataJSONItemConverter.as b/examples/flexjs/DataBindingExample/src/StockDataJSONItemConverter.as
deleted file mode 100644
index a39606b..0000000
--- a/examples/flexjs/DataBindingExample/src/StockDataJSONItemConverter.as
+++ /dev/null
@@ -1,40 +0,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.
-//
-////////////////////////////////////////////////////////////////////////////////
-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/e75059f7/examples/flexjs/DataBindingExample/src/controllers/MyController.as
----------------------------------------------------------------------
diff --git a/examples/flexjs/DataBindingExample/src/controllers/MyController.as b/examples/flexjs/DataBindingExample/src/controllers/MyController.as
deleted file mode 100644
index b7d52bd..0000000
--- a/examples/flexjs/DataBindingExample/src/controllers/MyController.as
+++ /dev/null
@@ -1,92 +0,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.
-//
-////////////////////////////////////////////////////////////////////////////////
-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/e75059f7/examples/flexjs/DataBindingExample/src/main/flex/DataBindingExample.mxml
----------------------------------------------------------------------
diff --git a/examples/flexjs/DataBindingExample/src/main/flex/DataBindingExample.mxml b/examples/flexjs/DataBindingExample/src/main/flex/DataBindingExample.mxml
new file mode 100644
index 0000000..751e427
--- /dev/null
+++ b/examples/flexjs/DataBindingExample/src/main/flex/DataBindingExample.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/e75059f7/examples/flexjs/DataBindingExample/src/main/flex/MyInitialView.mxml
----------------------------------------------------------------------
diff --git a/examples/flexjs/DataBindingExample/src/main/flex/MyInitialView.mxml b/examples/flexjs/DataBindingExample/src/main/flex/MyInitialView.mxml
new file mode 100644
index 0000000..8345213
--- /dev/null
+++ b/examples/flexjs/DataBindingExample/src/main/flex/MyInitialView.mxml
@@ -0,0 +1,144 @@
+<?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;
+
+ 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:beads>
+ <js:ViewDataBinding />
+ </js:beads>
+ <js:Container x="0" y="0" className="topContainer" >
+ <js:beads>
+ <js:VerticalLayout />
+ </js:beads>
+ <js:Label width="300" text="Enter Stock Symbol or choose from list:" />
+ <js:Container>
+ <js:beads>
+ <js:HorizontalLayout />
+ </js:beads>
+ <js:Container className="leftSide">
+ <js:beads>
+ <js:VerticalLayout />
+ </js:beads>
+ <js:TextInput id="symbolTI" text="{MyModel(applicationModel).stockSymbol}" />
+ <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:Container>
+ <js:Container className="rightSide">
+ <js:beads>
+ <js:VerticalLayout />
+ </js:beads>
+ <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:Container>
+ </js:Container>
+ <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:Container>
+</js:View>
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e75059f7/examples/flexjs/DataBindingExample/src/main/flex/StockDataJSONItemConverter.as
----------------------------------------------------------------------
diff --git a/examples/flexjs/DataBindingExample/src/main/flex/StockDataJSONItemConverter.as b/examples/flexjs/DataBindingExample/src/main/flex/StockDataJSONItemConverter.as
new file mode 100644
index 0000000..a39606b
--- /dev/null
+++ b/examples/flexjs/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/e75059f7/examples/flexjs/DataBindingExample/src/main/flex/controllers/MyController.as
----------------------------------------------------------------------
diff --git a/examples/flexjs/DataBindingExample/src/main/flex/controllers/MyController.as b/examples/flexjs/DataBindingExample/src/main/flex/controllers/MyController.as
new file mode 100644
index 0000000..b7d52bd
--- /dev/null
+++ b/examples/flexjs/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/e75059f7/examples/flexjs/DataBindingExample/src/main/flex/models/MyModel.as
----------------------------------------------------------------------
diff --git a/examples/flexjs/DataBindingExample/src/main/flex/models/MyModel.as b/examples/flexjs/DataBindingExample/src/main/flex/models/MyModel.as
new file mode 100644
index 0000000..5a16d02
--- /dev/null
+++ b/examples/flexjs/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
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e75059f7/examples/flexjs/DataBindingExample/src/models/MyModel.as
----------------------------------------------------------------------
diff --git a/examples/flexjs/DataBindingExample/src/models/MyModel.as b/examples/flexjs/DataBindingExample/src/models/MyModel.as
deleted file mode 100644
index 5a16d02..0000000
--- a/examples/flexjs/DataBindingExample/src/models/MyModel.as
+++ /dev/null
@@ -1,125 +0,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.
-//
-////////////////////////////////////////////////////////////////////////////////
-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
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e75059f7/examples/flexjs/DataBindingExample_Flat/src/DataBindingExample.mxml
----------------------------------------------------------------------
diff --git a/examples/flexjs/DataBindingExample_Flat/src/DataBindingExample.mxml b/examples/flexjs/DataBindingExample_Flat/src/DataBindingExample.mxml
deleted file mode 100644
index 751e427..0000000
--- a/examples/flexjs/DataBindingExample_Flat/src/DataBindingExample.mxml
+++ /dev/null
@@ -1,53 +0,0 @@
-<?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/e75059f7/examples/flexjs/DataBindingExample_Flat/src/MyInitialView.mxml
----------------------------------------------------------------------
diff --git a/examples/flexjs/DataBindingExample_Flat/src/MyInitialView.mxml b/examples/flexjs/DataBindingExample_Flat/src/MyInitialView.mxml
deleted file mode 100644
index 26ca9b0..0000000
--- a/examples/flexjs/DataBindingExample_Flat/src/MyInitialView.mxml
+++ /dev/null
@@ -1,145 +0,0 @@
-<?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"
- xmlns:flat="library://ns.apache.org/flexjs/flat"
- 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:beads>
- <js:ViewDataBinding />
- </js:beads>
- <js:Container x="0" y="0" className="topContainer" >
- <js:beads>
- <js:VerticalLayout />
- </js:beads>
- <js:Label width="300" text="Enter Stock Symbol or choose from list:" />
- <js:Container>
- <js:beads>
- <js:HorizontalLayout />
- </js:beads>
- <js:Container className="leftSide">
- <js:beads>
- <js:VerticalLayout />
- </js:beads>
- <js:TextInput id="symbolTI" text="{MyModel(applicationModel).stockSymbol}" />
- <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:Container>
- <js:Container className="rightSide">
- <js:beads>
- <js:VerticalLayout />
- </js:beads>
- <flat:DropDownList id="list" width="100"
- change="_symbol = list.selectedItem as String; dispatchEvent(new CustomEvent('listChanged'))"
- dataProvider="{MyModel(applicationModel).strings}" />
- <flat:RadioButton id="radio1" text="Price" value="Ask" groupName="group1" change="radioChanged(event)"/>
- <flat:RadioButton id="radio2" text="Change" value="Change" groupName="group1" change="radioChanged(event)"/>
- <flat:RadioButton id="radio3" text="Day's High" value="DaysHigh" groupName="group1" change="radioChanged(event)"/>
- <flat:RadioButton id="radio4" text="Day's Low" value="DaysLow" groupName="group1" change="radioChanged(event)"/>
- <flat:CheckBox id="showAllData" text="Show All Data" change="setState()" />
- </js:Container>
- </js:Container>
- <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:Container>
-</js:View>
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e75059f7/examples/flexjs/DataBindingExample_Flat/src/StockDataJSONItemConverter.as
----------------------------------------------------------------------
diff --git a/examples/flexjs/DataBindingExample_Flat/src/StockDataJSONItemConverter.as b/examples/flexjs/DataBindingExample_Flat/src/StockDataJSONItemConverter.as
deleted file mode 100644
index a39606b..0000000
--- a/examples/flexjs/DataBindingExample_Flat/src/StockDataJSONItemConverter.as
+++ /dev/null
@@ -1,40 +0,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.
-//
-////////////////////////////////////////////////////////////////////////////////
-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/e75059f7/examples/flexjs/DataBindingExample_Flat/src/controllers/MyController.as
----------------------------------------------------------------------
diff --git a/examples/flexjs/DataBindingExample_Flat/src/controllers/MyController.as b/examples/flexjs/DataBindingExample_Flat/src/controllers/MyController.as
deleted file mode 100644
index b7d52bd..0000000
--- a/examples/flexjs/DataBindingExample_Flat/src/controllers/MyController.as
+++ /dev/null
@@ -1,92 +0,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.
-//
-////////////////////////////////////////////////////////////////////////////////
-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/e75059f7/examples/flexjs/DataBindingExample_Flat/src/main/flex/DataBindingExample.mxml
----------------------------------------------------------------------
diff --git a/examples/flexjs/DataBindingExample_Flat/src/main/flex/DataBindingExample.mxml b/examples/flexjs/DataBindingExample_Flat/src/main/flex/DataBindingExample.mxml
new file mode 100644
index 0000000..751e427
--- /dev/null
+++ b/examples/flexjs/DataBindingExample_Flat/src/main/flex/DataBindingExample.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/e75059f7/examples/flexjs/DataBindingExample_Flat/src/main/flex/MyInitialView.mxml
----------------------------------------------------------------------
diff --git a/examples/flexjs/DataBindingExample_Flat/src/main/flex/MyInitialView.mxml b/examples/flexjs/DataBindingExample_Flat/src/main/flex/MyInitialView.mxml
new file mode 100644
index 0000000..26ca9b0
--- /dev/null
+++ b/examples/flexjs/DataBindingExample_Flat/src/main/flex/MyInitialView.mxml
@@ -0,0 +1,145 @@
+<?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"
+ xmlns:flat="library://ns.apache.org/flexjs/flat"
+ 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:beads>
+ <js:ViewDataBinding />
+ </js:beads>
+ <js:Container x="0" y="0" className="topContainer" >
+ <js:beads>
+ <js:VerticalLayout />
+ </js:beads>
+ <js:Label width="300" text="Enter Stock Symbol or choose from list:" />
+ <js:Container>
+ <js:beads>
+ <js:HorizontalLayout />
+ </js:beads>
+ <js:Container className="leftSide">
+ <js:beads>
+ <js:VerticalLayout />
+ </js:beads>
+ <js:TextInput id="symbolTI" text="{MyModel(applicationModel).stockSymbol}" />
+ <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:Container>
+ <js:Container className="rightSide">
+ <js:beads>
+ <js:VerticalLayout />
+ </js:beads>
+ <flat:DropDownList id="list" width="100"
+ change="_symbol = list.selectedItem as String; dispatchEvent(new CustomEvent('listChanged'))"
+ dataProvider="{MyModel(applicationModel).strings}" />
+ <flat:RadioButton id="radio1" text="Price" value="Ask" groupName="group1" change="radioChanged(event)"/>
+ <flat:RadioButton id="radio2" text="Change" value="Change" groupName="group1" change="radioChanged(event)"/>
+ <flat:RadioButton id="radio3" text="Day's High" value="DaysHigh" groupName="group1" change="radioChanged(event)"/>
+ <flat:RadioButton id="radio4" text="Day's Low" value="DaysLow" groupName="group1" change="radioChanged(event)"/>
+ <flat:CheckBox id="showAllData" text="Show All Data" change="setState()" />
+ </js:Container>
+ </js:Container>
+ <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:Container>
+</js:View>
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e75059f7/examples/flexjs/DataBindingExample_Flat/src/main/flex/StockDataJSONItemConverter.as
----------------------------------------------------------------------
diff --git a/examples/flexjs/DataBindingExample_Flat/src/main/flex/StockDataJSONItemConverter.as b/examples/flexjs/DataBindingExample_Flat/src/main/flex/StockDataJSONItemConverter.as
new file mode 100644
index 0000000..a39606b
--- /dev/null
+++ b/examples/flexjs/DataBindingExample_Flat/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/e75059f7/examples/flexjs/DataBindingExample_Flat/src/main/flex/controllers/MyController.as
----------------------------------------------------------------------
diff --git a/examples/flexjs/DataBindingExample_Flat/src/main/flex/controllers/MyController.as b/examples/flexjs/DataBindingExample_Flat/src/main/flex/controllers/MyController.as
new file mode 100644
index 0000000..b7d52bd
--- /dev/null
+++ b/examples/flexjs/DataBindingExample_Flat/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/e75059f7/examples/flexjs/DataBindingExample_Flat/src/main/flex/models/MyModel.as
----------------------------------------------------------------------
diff --git a/examples/flexjs/DataBindingExample_Flat/src/main/flex/models/MyModel.as b/examples/flexjs/DataBindingExample_Flat/src/main/flex/models/MyModel.as
new file mode 100644
index 0000000..5a16d02
--- /dev/null
+++ b/examples/flexjs/DataBindingExample_Flat/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
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e75059f7/examples/flexjs/DataBindingExample_Flat/src/models/MyModel.as
----------------------------------------------------------------------
diff --git a/examples/flexjs/DataBindingExample_Flat/src/models/MyModel.as b/examples/flexjs/DataBindingExample_Flat/src/models/MyModel.as
deleted file mode 100644
index 5a16d02..0000000
--- a/examples/flexjs/DataBindingExample_Flat/src/models/MyModel.as
+++ /dev/null
@@ -1,125 +0,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.
-//
-////////////////////////////////////////////////////////////////////////////////
-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