You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by ah...@apache.org on 2015/08/24 07:33:13 UTC
[23/34] git commit: [flex-asjs] [refs/heads/develop] - move examples
into a flexjs folder now that we have a native folder for low-level examples
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/d33fe63c/examples/flexjs/ChartExample/src/models/ProductsModel.as
----------------------------------------------------------------------
diff --git a/examples/flexjs/ChartExample/src/models/ProductsModel.as b/examples/flexjs/ChartExample/src/models/ProductsModel.as
new file mode 100644
index 0000000..c173c6e
--- /dev/null
+++ b/examples/flexjs/ChartExample/src/models/ProductsModel.as
@@ -0,0 +1,79 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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.EventDispatcher;
+
+ import products.Product;
+
+ public class ProductsModel extends EventDispatcher
+ {
+ public function ProductsModel()
+ {
+ generateWaves(20);
+ }
+
+ private var _productList:Array = [
+ new Product("tx200","Thingys", 5, 285,314,"smallgreenrect.jpg"),
+ new Product("dh440","Doohickies", 10,340,125,"smallredrect.jpg"),
+ new Product("ps220","Weejets", 35,190,240,"smallorangerect.jpg"),
+ new Product("ps100","Widgets", 44,200,82,"smallbluerect.jpg"),
+ new Product("rz300","Sprockets", 80,105,271,"smallyellowrect.jpg")
+ ];
+ public function get productList():Array
+ {
+ return _productList;
+ }
+
+ private var _labelFields:Array = [ "id", "title", "sales2013", "sales2014", "detail" ];
+ public function get labelFields():Array
+ {
+ return _labelFields;
+ }
+
+ private var _wave:Array;
+
+ public function generateWaves(numPoints:int):void
+ {
+ _wave = [];
+
+ var angleIncr:Number = 360/numPoints;
+ var angle:Number = 0;
+
+ for (var i:int=0; i < numPoints; i++)
+ {
+ var p:Object = {x:i,
+ sin:Math.sin(Math.PI/180*angle),
+ cos:Math.cos(Math.PI/180*angle)};
+ angle += angleIncr;
+ _wave.push(p);
+ }
+ }
+
+ public function get wave1():Array
+ {
+ return _wave;
+ }
+
+ public function get wave2():Array
+ {
+ return _wave;
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/d33fe63c/examples/flexjs/ChartExample/src/products/Product.as
----------------------------------------------------------------------
diff --git a/examples/flexjs/ChartExample/src/products/Product.as b/examples/flexjs/ChartExample/src/products/Product.as
new file mode 100644
index 0000000..2205e69
--- /dev/null
+++ b/examples/flexjs/ChartExample/src/products/Product.as
@@ -0,0 +1,45 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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 products
+{
+ public class Product
+ {
+ public function Product(id:String, title:String, detail:Number,sales2013:Number, sales2014:Number ,image:String)
+ {
+ this.id = id;
+ this.title = title;
+ this.detail = detail;
+ this.sales2013 = sales2013;
+ this.sales2014 = sales2014;
+ this.image = image;
+ }
+
+ public var id:String;
+ public var title:String;
+ public var detail:Number;
+ public var image:String;
+ public var sales2013:Number;
+ public var sales2014:Number;
+
+ public function toString():String
+ {
+ return title;
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/d33fe63c/examples/flexjs/CordovaCameraExample/CordovaCameraExample-app.xml
----------------------------------------------------------------------
diff --git a/examples/flexjs/CordovaCameraExample/CordovaCameraExample-app.xml b/examples/flexjs/CordovaCameraExample/CordovaCameraExample-app.xml
new file mode 100644
index 0000000..7a5ed64
--- /dev/null
+++ b/examples/flexjs/CordovaCameraExample/CordovaCameraExample-app.xml
@@ -0,0 +1,252 @@
+<?xml version="1.0" encoding="utf-8" standalone="no"?>
+<!--
+
+ 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.
+
+-->
+<application xmlns="http://ns.adobe.com/air/application/4.0">
+
+<!-- Adobe AIR Application Descriptor File Template.
+
+ Specifies parameters for identifying, installing, and launching AIR applications.
+
+ xmlns - The Adobe AIR namespace: http://ns.adobe.com/air/application/3.8
+ The last segment of the namespace specifies the version
+ of the AIR runtime required for this application to run.
+
+ minimumPatchLevel - The minimum patch level of the AIR runtime required to run
+ the application. Optional.
+-->
+
+ <!-- A universally unique application identifier. Must be unique across all AIR applications.
+ Using a reverse DNS-style name as the id is recommended. (Eg. com.example.ExampleApplication.) Required. -->
+ <id>org.apache.flexjs.cordovacamera</id>
+
+ <!-- Used as the filename for the application. Required. -->
+ <filename>Apache FlexJS Cordova Camera Example</filename>
+
+ <!-- The name that is displayed in the AIR application installer.
+ May have multiple values for each language. See samples or xsd schema file. Optional. -->
+ <name>Apache FlexJS Cordova Camera Example</name>
+
+ <!-- A string value of the format <0-999>.<0-999>.<0-999> that represents application version which can be used to check for application upgrade.
+ Values can also be 1-part or 2-part. It is not necessary to have a 3-part value.
+ An updated version of application must have a versionNumber value higher than the previous version. Required for namespace >= 2.5 . -->
+ <versionNumber>0.0.1</versionNumber>
+
+ <!-- A string value (such as "v1", "2.5", or "Alpha 1") that represents the version of the application, as it should be shown to users. Optional. -->
+ <!-- <versionLabel></versionLabel> -->
+
+ <!-- Description, displayed in the AIR application installer.
+ May have multiple values for each language. See samples or xsd schema file. Optional. -->
+ <!-- <description></description> -->
+
+ <!-- Copyright information. Optional -->
+ <copyright>Copyright 2013 The Apache Software Foundation.</copyright>
+
+ <!-- Publisher ID. Used if you're updating an application created prior to 1.5.3 -->
+ <!-- <publisherID></publisherID> -->
+
+ <!-- Settings for the application's initial window. Required. -->
+ <initialWindow>
+ <!-- The main SWF or HTML file of the application. Required. -->
+ <!-- Note: In Flash Builder, the SWF reference is set automatically. -->
+ <content>CordovaCameraExample.swf</content>
+
+ <!-- The title of the main window. Optional. -->
+ <!-- <title></title> -->
+
+ <!-- The type of system chrome to use (either "standard" or "none"). Optional. Default standard. -->
+ <!-- <systemChrome></systemChrome> -->
+
+ <!-- Whether the window is transparent. Only applicable when systemChrome is none. Optional. Default false. -->
+ <!-- <transparent></transparent> -->
+
+ <!-- Whether the window is initially visible. Optional. Default false. -->
+ <!-- <visible></visible> -->
+
+ <!-- Whether the user can minimize the window. Optional. Default true. -->
+ <!-- <minimizable></minimizable> -->
+
+ <!-- Whether the user can maximize the window. Optional. Default true. -->
+ <!-- <maximizable></maximizable> -->
+
+ <!-- Whether the user can resize the window. Optional. Default true. -->
+ <!-- <resizable></resizable> -->
+
+ <!-- The window's initial width in pixels. Optional. -->
+ <!-- <width></width> -->
+
+ <!-- The window's initial height in pixels. Optional. -->
+ <!-- <height></height> -->
+
+ <!-- The window's initial x position. Optional. -->
+ <!-- <x></x> -->
+
+ <!-- The window's initial y position. Optional. -->
+ <!-- <y></y> -->
+
+ <!-- The window's minimum size, specified as a width/height pair in pixels, such as "400 200". Optional. -->
+ <!-- <minSize></minSize> -->
+
+ <!-- The window's initial maximum size, specified as a width/height pair in pixels, such as "1600 1200". Optional. -->
+ <!-- <maxSize></maxSize> -->
+
+ <!-- The initial aspect ratio of the app when launched (either "portrait" or "landscape"). Optional. Mobile only. Default is the natural orientation of the device -->
+
+ <!-- <aspectRatio></aspectRatio> -->
+
+ <!-- Whether the app will begin auto-orienting on launch. Optional. Mobile only. Default false -->
+
+ <!-- <autoOrients></autoOrients> -->
+
+ <!-- Whether the app launches in full screen. Optional. Mobile only. Default false -->
+
+ <!-- <fullScreen></fullScreen> -->
+
+ <!-- The render mode for the app (either auto, cpu, gpu, or direct). Optional. Default auto -->
+
+ <!-- <renderMode></renderMode> -->
+
+ <!-- Whether or not to pan when a soft keyboard is raised or lowered (either "pan" or "none"). Optional. Defaults "pan." -->
+ <!-- <softKeyboardBehavior></softKeyboardBehavior> -->
+ <autoOrients>false</autoOrients>
+ <fullScreen>false</fullScreen>
+ <visible>true</visible>
+ </initialWindow>
+
+ <!-- We recommend omitting the supportedProfiles element, -->
+ <!-- which in turn permits your application to be deployed to all -->
+ <!-- devices supported by AIR. If you wish to restrict deployment -->
+ <!-- (i.e., to only mobile devices) then add this element and list -->
+ <!-- only the profiles which your application does support. -->
+ <!-- <supportedProfiles>desktop extendedDesktop mobileDevice extendedMobileDevice</supportedProfiles> -->
+ <supportedProfiles>extendedDesktop desktop mobileDevice</supportedProfiles>
+
+ <!-- The subpath of the standard default installation location to use. Optional. -->
+ <installFolder>Apache Flex</installFolder>
+
+ <!-- The subpath of the Programs menu to use. (Ignored on operating systems without a Programs menu.) Optional. -->
+ <programMenuFolder>Apache Flex</programMenuFolder>
+
+ <!-- The icon the system uses for the application. For at least one resolution,
+ specify the path to a PNG file included in the AIR package. Optional. -->
+ <icon>
+ <image16x16>assets/icons/16.png</image16x16>
+ <image29x29>assets/icons/29.png</image29x29>
+ <image32x32>assets/icons/32.png</image32x32>
+ <image36x36>assets/icons/36.png</image36x36>
+ <image48x48>assets/icons/48.png</image48x48>
+ <image57x57>assets/icons/57.png</image57x57>
+ <image72x72>assets/icons/72.png</image72x72>
+ <image114x114>assets/icons/114.png</image114x114>
+ <image128x128>assets/icons/128.png</image128x128>
+ </icon>
+
+ <!-- Whether the application handles the update when a user double-clicks an update version
+ of the AIR file (true), or the default AIR application installer handles the update (false).
+ Optional. Default false. -->
+ <!-- <customUpdateUI></customUpdateUI> -->
+
+ <!-- Whether the application can be launched when the user clicks a link in a web browser.
+ Optional. Default false. -->
+ <!-- <allowBrowserInvocation></allowBrowserInvocation> -->
+
+ <!-- Listing of file types for which the application can register. Optional. -->
+ <!-- <fileTypes> -->
+
+ <!-- Defines one file type. Optional. -->
+ <!-- <fileType> -->
+
+ <!-- The name that the system displays for the registered file type. Required. -->
+ <!-- <name></name> -->
+
+ <!-- The extension to register. Required. -->
+ <!-- <extension></extension> -->
+
+ <!-- The description of the file type. Optional. -->
+ <!-- <description></description> -->
+
+ <!-- The MIME content type. -->
+ <!-- <contentType></contentType> -->
+
+ <!-- The icon to display for the file type. Optional. -->
+ <!-- <icon>
+ <image16x16></image16x16>
+ <image32x32></image32x32>
+ <image48x48></image48x48>
+ <image128x128></image128x128>
+ </icon> -->
+
+ <!-- </fileType> -->
+ <!-- </fileTypes> -->
+
+ <!-- iOS specific capabilities -->
+ <!-- <iPhone> -->
+ <!-- A list of plist key/value pairs to be added to the application Info.plist -->
+ <!-- <InfoAdditions>
+ <![CDATA[
+ <key>UIDeviceFamily</key>
+ <array>
+ <string>1</string>
+ <string>2</string>
+ </array>
+ <key>UIStatusBarStyle</key>
+ <string>UIStatusBarStyleBlackOpaque</string>
+ <key>UIRequiresPersistentWiFi</key>
+ <string>YES</string>
+ ]]>
+ </InfoAdditions> -->
+ <!-- A list of plist key/value pairs to be added to the application Entitlements.plist -->
+ <!-- <Entitlements>
+ <![CDATA[
+ <key>keychain-access-groups</key>
+ <array>
+ <string></string>
+ <string></string>
+ </array>
+ ]]>
+ </Entitlements> -->
+ <!-- Display Resolution for the app (either "standard" or "high"). Optional. Default "standard" -->
+ <!-- <requestedDisplayResolution></requestedDisplayResolution> -->
+ <!-- </iPhone> -->
+
+ <!-- Specify Android specific tags that get passed to AndroidManifest.xml file. -->
+ <!--<android> -->
+ <!-- <manifestAdditions>
+ <![CDATA[
+ <manifest android:installLocation="auto">
+ <uses-permission android:name="android.permission.INTERNET"/>
+ <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
+ <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
+ <uses-feature android:required="true" android:name="android.hardware.touchscreen.multitouch"/>
+ <application android:enabled="true">
+ <activity android:excludeFromRecents="false">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN"/>
+ <category android:name="android.intent.category.LAUNCHER"/>
+ </intent-filter>
+ </activity>
+ </application>
+ </manifest>
+ ]]>
+ </manifestAdditions> -->
+ <!-- Color depth for the app (either "32bit" or "16bit"). Optional. Default 16bit before namespace 3.0, 32bit after -->
+ <!-- <colorDepth></colorDepth> -->
+ <!-- </android> -->
+ <!-- End of the schema for adding the android specific tags in AndroidManifest.xml file -->
+
+</application>
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/d33fe63c/examples/flexjs/CordovaCameraExample/build.xml
----------------------------------------------------------------------
diff --git a/examples/flexjs/CordovaCameraExample/build.xml b/examples/flexjs/CordovaCameraExample/build.xml
new file mode 100644
index 0000000..92f4c07
--- /dev/null
+++ b/examples/flexjs/CordovaCameraExample/build.xml
@@ -0,0 +1,110 @@
+<?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="cordovacameraexample" default="main" basedir=".">
+ <property name="FLEXJS_HOME" location="../.."/>
+ <property name="example" value="CordovaCameraExample" />
+
+ <!-- this project needs AIR 3.4 FP 11.4 -->
+ <property name="swf.version" value="17" />
+ <property name="playerglobal.version" value="11.4" />
+
+ <property file="${FLEXJS_HOME}/env.properties"/>
+ <property environment="env"/>
+ <property file="${FLEXJS_HOME}/build.properties"/>
+ <property name="FLEX_HOME" value="${FLEXJS_HOME}"/>
+ <available file="${env.FALCON_HOME}/lib/falcon-mxmlc.jar"
+ type="file"
+ property="FALCON_HOME"
+ value="${env.FALCON_HOME}"/>
+
+ <available file="${FLEXJS_HOME}/../flex-falcon/compiler/generated/dist/sdk/lib/falcon-mxmlc.jar"
+ type="file"
+ property="FALCON_HOME"
+ value="${FLEXJS_HOME}/../flex-falcon/compiler/generated/dist/sdk"/>
+
+ <available file="${env.FALCONJX_HOME}/lib/jsc.jar"
+ type="file"
+ property="FALCONJX_HOME"
+ value="${env.FALCONJX_HOME}"/>
+
+ <available file="${FLEXJS_HOME}/../flex-falcon/compiler.jx/lib/jsc.jar"
+ type="file"
+ property="FALCONJX_HOME"
+ value="${FLEXJS_HOME}/../flex-falcon/compiler.jx"/>
+
+ <available file="${env.GOOG_HOME}/closure/goog/base.js"
+ type="file"
+ property="GOOG_HOME"
+ value="${env.GOOG_HOME}"/>
+
+ <available file="${FLEXJS_HOME}/js/lib/google/closure-library/closure/goog/base.js"
+ type="file"
+ property="GOOG_HOME"
+ value="${FLEXJS_HOME}/js/lib/google/closure-library"/>
+
+ <property name="AIR_HOME" value="${env.AIR_HOME}"/>
+
+
+ <condition property="adl" value="adl.exe">
+ <os family="windows"/>
+ </condition>
+
+ <condition property="adl" value="adl">
+ <os family="mac"/>
+ </condition>
+
+ <condition property="runtime" value="win">
+ <os family="windows"/>
+ </condition>
+
+ <condition property="runtime" value="mac">
+ <os family="mac"/>
+ </condition>
+
+ <include file="${basedir}/../build_example.xml" />
+
+ <target name="main" depends="clean,build_example.compileair,build_example.compilejsair" description="Clean build of ${example}">
+ </target>
+
+ <target name="clean">
+ <echo>playerglobal.version = ${playerglobal.version}</echo>
+ <delete dir="${basedir}/bin" failonerror="false" />
+ <delete dir="${basedir}/bin-debug" failonerror="false" />
+ <delete dir="${basedir}/bin-release" failonerror="false" />
+ </target>
+
+ <target name="run">
+ <exec executable="${AIR_HOME}/bin/${adl}" dir="${basedir}/bin-debug" failonerror="true">
+ <arg value="-runtime" />
+ <arg value="${AIR_HOME}/runtimes/air/${runtime}" />
+ <arg value="-screensize" />
+ <arg value="640x960:640x960" />
+ <arg value="-profile" />
+ <arg value="mobileDevice" />
+ <arg value="-XscreenDPI" />
+ <arg value="240" />
+ <arg value="-XversionPlatform" />
+ <arg value="AND" />
+ <arg value="${basedir}/bin-debug/${example}-app.xml" />
+ </exec>
+ </target>
+</project>
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/d33fe63c/examples/flexjs/CordovaCameraExample/src/CordovaCameraExample.mxml
----------------------------------------------------------------------
diff --git a/examples/flexjs/CordovaCameraExample/src/CordovaCameraExample.mxml b/examples/flexjs/CordovaCameraExample/src/CordovaCameraExample.mxml
new file mode 100644
index 0000000..5e70a10
--- /dev/null
+++ b/examples/flexjs/CordovaCameraExample/src/CordovaCameraExample.mxml
@@ -0,0 +1,39 @@
+<?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.
+//
+////////////////////////////////////////////////////////////////////////////////
+-->
+<cordova:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
+ xmlns:local="*"
+ xmlns:models="models.*"
+ xmlns:js="library://ns.apache.org/flexjs/basic"
+ xmlns:cordova="library://ns.apache.org/flexjs/cordova"
+ deviceready="MyInitialView(initialView).ready = true"
+ >
+
+ <cordova:valuesImpl>
+ <js:SimpleCSSValuesImpl />
+ </cordova:valuesImpl>
+ <cordova:initialView>
+ <local:MyInitialView />
+ </cordova:initialView>
+ <cordova:beads>
+ <js:MixinManager />
+ <cordova:Weinre guid="aharui" />
+ </cordova:beads>
+</cordova:Application>
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/d33fe63c/examples/flexjs/CordovaCameraExample/src/MyInitialView.mxml
----------------------------------------------------------------------
diff --git a/examples/flexjs/CordovaCameraExample/src/MyInitialView.mxml b/examples/flexjs/CordovaCameraExample/src/MyInitialView.mxml
new file mode 100644
index 0000000..29e31e3
--- /dev/null
+++ b/examples/flexjs/CordovaCameraExample/src/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:ViewBase 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:ViewBase>
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/d33fe63c/examples/flexjs/CordovaCameraExample/src/README.txt
----------------------------------------------------------------------
diff --git a/examples/flexjs/CordovaCameraExample/src/README.txt b/examples/flexjs/CordovaCameraExample/src/README.txt
new file mode 100644
index 0000000..52d21ff
--- /dev/null
+++ b/examples/flexjs/CordovaCameraExample/src/README.txt
@@ -0,0 +1,24 @@
+Running the CordovaCameraExample on an Android Device
+
+From Flash Builder or the command line, run the FlexJS cross compiler, FalconJX, to build the HTML/JavaScript version of your app.
+% cd ~/dev/flex-asjs/examples/CordovaCameraExample
+% ant
+
+Go to your mobile development directory:
+%cd ~/mobile
+
+Copy into this directory, the cordova-build.xml ANT script:
+% cp ~/dev/flex-asjs/cordova-build.xml
+
+Create the Cordova project for your FlexJS application:
+% ant -f cordova-build.xml -DPROJECT_NAME=CordovaCameraExample -DTARGET_DIR=. -DPROJECT_DIR=/Users/home/dev/flex-asjs/examples/CordovaCameraExample/
+
+Load the Cordova camera plugin:
+cd CordovaCameraExample
+% cordova plugin add org.apache.cordova.camera
+
+Modify the www/index.html file to include the cordova.js source (place this line with the other <script> elements):
+<script type="text/javascript" charset="utf-8" src="cordova.js"></script>
+
+Run your app on your connected device:
+% cordova run
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/d33fe63c/examples/flexjs/DataBindingExample/build.xml
----------------------------------------------------------------------
diff --git a/examples/flexjs/DataBindingExample/build.xml b/examples/flexjs/DataBindingExample/build.xml
new file mode 100644
index 0000000..c14ec77
--- /dev/null
+++ b/examples/flexjs/DataBindingExample/build.xml
@@ -0,0 +1,73 @@
+<?xml version="1.0"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+-->
+
+
+<project name="databindingexample" default="main" basedir=".">
+ <property name="FLEXJS_HOME" location="../.."/>
+ <property name="example" value="DataBindingExample" />
+
+ <property file="${FLEXJS_HOME}/env.properties"/>
+ <property environment="env"/>
+ <property file="${FLEXJS_HOME}/build.properties"/>
+ <property name="FLEX_HOME" value="${FLEXJS_HOME}"/>
+ <available file="${env.FALCON_HOME}/lib/falcon-mxmlc.jar"
+ type="file"
+ property="FALCON_HOME"
+ value="${env.FALCON_HOME}"/>
+
+ <available file="${FLEXJS_HOME}/../flex-falcon/compiler/generated/dist/sdk/lib/falcon-mxmlc.jar"
+ type="file"
+ property="FALCON_HOME"
+ value="${FLEXJS_HOME}/../flex-falcon/compiler/generated/dist/sdk"/>
+
+ <available file="${env.FALCONJX_HOME}/lib/jsc.jar"
+ type="file"
+ property="FALCONJX_HOME"
+ value="${env.FALCONJX_HOME}"/>
+
+ <available file="${FLEXJS_HOME}/../flex-falcon/compiler.jx/lib/jsc.jar"
+ type="file"
+ property="FALCONJX_HOME"
+ value="${FLEXJS_HOME}/../flex-falcon/compiler.jx"/>
+
+ <available file="${env.GOOG_HOME}/closure/goog/base.js"
+ type="file"
+ property="GOOG_HOME"
+ value="${env.GOOG_HOME}"/>
+
+ <available file="${FLEXJS_HOME}/js/lib/google/closure-library/closure/goog/base.js"
+ type="file"
+ property="GOOG_HOME"
+ value="${FLEXJS_HOME}/js/lib/google/closure-library"/>
+
+ <include file="${basedir}/../build_example.xml" />
+
+ <target name="main" depends="clean,build_example.compile,build_example.compilejs" description="Clean build of ${example}">
+ </target>
+
+ <target name="clean">
+ <delete dir="${basedir}/bin" failonerror="false" />
+ <delete dir="${basedir}/bin-debug" failonerror="false" />
+ <delete dir="${basedir}/bin-release" failonerror="false" />
+ </target>
+
+
+
+</project>
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/d33fe63c/examples/flexjs/DataBindingExample/src/DataBindingExample.mxml
----------------------------------------------------------------------
diff --git a/examples/flexjs/DataBindingExample/src/DataBindingExample.mxml b/examples/flexjs/DataBindingExample/src/DataBindingExample.mxml
new file mode 100644
index 0000000..751e427
--- /dev/null
+++ b/examples/flexjs/DataBindingExample/src/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/d33fe63c/examples/flexjs/DataBindingExample/src/MyInitialView.mxml
----------------------------------------------------------------------
diff --git a/examples/flexjs/DataBindingExample/src/MyInitialView.mxml b/examples/flexjs/DataBindingExample/src/MyInitialView.mxml
new file mode 100644
index 0000000..667254d
--- /dev/null
+++ b/examples/flexjs/DataBindingExample/src/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:ViewBase 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:ViewBaseDataBinding />
+ </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:ViewBase>
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/d33fe63c/examples/flexjs/DataBindingExample/src/README.txt
----------------------------------------------------------------------
diff --git a/examples/flexjs/DataBindingExample/src/README.txt b/examples/flexjs/DataBindingExample/src/README.txt
new file mode 100644
index 0000000..91a0359
--- /dev/null
+++ b/examples/flexjs/DataBindingExample/src/README.txt
@@ -0,0 +1,53 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements. See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You under the Apache License, Version 2.0
+// (the "License"); you may not use this file except in compliance with
+// the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+
+DESCRIPTION
+
+The DataBindingExample shows a Flex application that can communicate with
+a third-party data source (in this case, yahoo.finance) and display the values
+returned using data binding. It also demonstrates that you can use “states” to
+control the UI.
+
+This Flex application may be run as a Flash SWF or cross-compiled (using Falcon JX)
+into JavaScript and HTML and run without Flash.
+
+The DataBindingExample also shows how the model-view-controller (MVC) pattern
+can be used to separate the parts of the application. This is facilitated by
+the use of FlexJS beads added to the main application that provide the
+data connection (via HTTPService) and interacting with the rest of the application
+via events.
+
+COMPONENTS and BEADS
+
+- Button
+- CheckBox
+- ComboBox
+- Container
+- Label
+- RadioButton
+- TextArea
+- TextInput
+
+- Data binding: the text properties of TextArea and Label are linked with results
+from the remote server calls.
+
+NOTES
+
+The cross-compilation to JavaScript often results in non-fatal warnings. Some of these warnings
+should be addressed in future releases of the Falcon JX compiler.
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/d33fe63c/examples/flexjs/DataBindingExample/src/StockDataJSONItemConverter.as
----------------------------------------------------------------------
diff --git a/examples/flexjs/DataBindingExample/src/StockDataJSONItemConverter.as b/examples/flexjs/DataBindingExample/src/StockDataJSONItemConverter.as
new file mode 100644
index 0000000..a39606b
--- /dev/null
+++ b/examples/flexjs/DataBindingExample/src/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/d33fe63c/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
new file mode 100644
index 0000000..2ee16ae
--- /dev/null
+++ b/examples/flexjs/DataBindingExample/src/controllers/MyController.as
@@ -0,0 +1,81 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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 models.MyModel;
+
+ public class MyController implements IDocument
+ {
+ public function MyController(app:Application = null)
+ {
+ if (app)
+ {
+ this.app = app as DataBindingExample;
+ app.addEventListener("viewChanged", viewChangeHandler);
+ }
+ }
+
+ 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 var app:DataBindingExample;
+
+ private function viewChangeHandler(event:Event):void
+ {
+ app.initialView.addEventListener("buttonClicked", buttonClickHandler);
+ app.initialView.addEventListener("radioClicked", radioClickHandler);
+ app.initialView.addEventListener("listChanged", listChangedHandler);
+ }
+
+ private function buttonClickHandler(event:Event):void
+ {
+ var sym:String = MyInitialView(app.initialView).symbol;
+ app.service.url = queryBegin + sym + queryEnd;
+ app.service.send();
+ app.service.addEventListener("complete", completeHandler);
+ }
+
+ private function radioClickHandler(event:Event):void
+ {
+ var field:String = MyInitialView(app.initialView).requestedField;
+ MyModel(app.model).requestedField = field;
+ }
+
+ private function completeHandler(event:Event):void
+ {
+ MyModel(app.model).responseData = app.collection.getItemAt(0);
+ }
+
+ private function listChangedHandler(event:Event):void
+ {
+ MyModel(app.model).stockSymbol = MyInitialView(app.initialView).symbol;
+ }
+
+ public function setDocument(document:Object, id:String = null):void
+ {
+ this.app = document as DataBindingExample;
+ app.addEventListener("viewChanged", viewChangeHandler);
+ }
+
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/d33fe63c/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
new file mode 100644
index 0000000..5a16d02
--- /dev/null
+++ b/examples/flexjs/DataBindingExample/src/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/d33fe63c/examples/flexjs/DataBindingExample_Flat/build.xml
----------------------------------------------------------------------
diff --git a/examples/flexjs/DataBindingExample_Flat/build.xml b/examples/flexjs/DataBindingExample_Flat/build.xml
new file mode 100644
index 0000000..ad0a98c
--- /dev/null
+++ b/examples/flexjs/DataBindingExample_Flat/build.xml
@@ -0,0 +1,74 @@
+<?xml version="1.0"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+-->
+
+
+<project name="databindingexample_flat" default="main" basedir=".">
+ <property name="FLEXJS_HOME" location="../.."/>
+ <property name="example" value="DataBindingExample" />
+ <property name="theme_arg" value="-theme=${FLEXJS_HOME}/frameworks/libs/Flat.swc" />
+
+ <property file="${FLEXJS_HOME}/env.properties"/>
+ <property environment="env"/>
+ <property file="${FLEXJS_HOME}/build.properties"/>
+ <property name="FLEX_HOME" value="${FLEXJS_HOME}"/>
+ <available file="${env.FALCON_HOME}/lib/falcon-mxmlc.jar"
+ type="file"
+ property="FALCON_HOME"
+ value="${env.FALCON_HOME}"/>
+
+ <available file="${FLEXJS_HOME}/../flex-falcon/compiler/generated/dist/sdk/lib/falcon-mxmlc.jar"
+ type="file"
+ property="FALCON_HOME"
+ value="${FLEXJS_HOME}/../flex-falcon/compiler/generated/dist/sdk"/>
+
+ <available file="${env.FALCONJX_HOME}/lib/jsc.jar"
+ type="file"
+ property="FALCONJX_HOME"
+ value="${env.FALCONJX_HOME}"/>
+
+ <available file="${FLEXJS_HOME}/../flex-falcon/compiler.jx/lib/jsc.jar"
+ type="file"
+ property="FALCONJX_HOME"
+ value="${FLEXJS_HOME}/../flex-falcon/compiler.jx"/>
+
+ <available file="${env.GOOG_HOME}/closure/goog/base.js"
+ type="file"
+ property="GOOG_HOME"
+ value="${env.GOOG_HOME}"/>
+
+ <available file="${FLEXJS_HOME}/js/lib/google/closure-library/closure/goog/base.js"
+ type="file"
+ property="GOOG_HOME"
+ value="${FLEXJS_HOME}/js/lib/google/closure-library"/>
+
+ <include file="${basedir}/../build_example.xml" />
+
+ <target name="main" depends="clean,build_example.compile,build_example.compilejs" description="Clean build of ${example}">
+ </target>
+
+ <target name="clean">
+ <delete dir="${basedir}/bin" failonerror="false" />
+ <delete dir="${basedir}/bin-debug" failonerror="false" />
+ <delete dir="${basedir}/bin-release" failonerror="false" />
+ </target>
+
+
+
+</project>
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/d33fe63c/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
new file mode 100644
index 0000000..751e427
--- /dev/null
+++ b/examples/flexjs/DataBindingExample_Flat/src/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/d33fe63c/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
new file mode 100644
index 0000000..b153ba5
--- /dev/null
+++ b/examples/flexjs/DataBindingExample_Flat/src/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:ViewBase xmlns:fx="http://ns.adobe.com/mxml/2009"
+ xmlns:js="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:ViewBaseDataBinding />
+ </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:ViewBase>
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/d33fe63c/examples/flexjs/DataBindingExample_Flat/src/README.txt
----------------------------------------------------------------------
diff --git a/examples/flexjs/DataBindingExample_Flat/src/README.txt b/examples/flexjs/DataBindingExample_Flat/src/README.txt
new file mode 100644
index 0000000..afe521b
--- /dev/null
+++ b/examples/flexjs/DataBindingExample_Flat/src/README.txt
@@ -0,0 +1,52 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements. See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You under the Apache License, Version 2.0
+// (the "License"); you may not use this file except in compliance with
+// the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+
+DESCRIPTION
+
+The DataBindingTest example 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.
+
+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 DataBindingTest example 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/d33fe63c/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
new file mode 100644
index 0000000..a39606b
--- /dev/null
+++ b/examples/flexjs/DataBindingExample_Flat/src/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/d33fe63c/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
new file mode 100644
index 0000000..2ee16ae
--- /dev/null
+++ b/examples/flexjs/DataBindingExample_Flat/src/controllers/MyController.as
@@ -0,0 +1,81 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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 models.MyModel;
+
+ public class MyController implements IDocument
+ {
+ public function MyController(app:Application = null)
+ {
+ if (app)
+ {
+ this.app = app as DataBindingExample;
+ app.addEventListener("viewChanged", viewChangeHandler);
+ }
+ }
+
+ 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 var app:DataBindingExample;
+
+ private function viewChangeHandler(event:Event):void
+ {
+ app.initialView.addEventListener("buttonClicked", buttonClickHandler);
+ app.initialView.addEventListener("radioClicked", radioClickHandler);
+ app.initialView.addEventListener("listChanged", listChangedHandler);
+ }
+
+ private function buttonClickHandler(event:Event):void
+ {
+ var sym:String = MyInitialView(app.initialView).symbol;
+ app.service.url = queryBegin + sym + queryEnd;
+ app.service.send();
+ app.service.addEventListener("complete", completeHandler);
+ }
+
+ private function radioClickHandler(event:Event):void
+ {
+ var field:String = MyInitialView(app.initialView).requestedField;
+ MyModel(app.model).requestedField = field;
+ }
+
+ private function completeHandler(event:Event):void
+ {
+ MyModel(app.model).responseData = app.collection.getItemAt(0);
+ }
+
+ private function listChangedHandler(event:Event):void
+ {
+ MyModel(app.model).stockSymbol = MyInitialView(app.initialView).symbol;
+ }
+
+ public function setDocument(document:Object, id:String = null):void
+ {
+ this.app = document as DataBindingExample;
+ app.addEventListener("viewChanged", viewChangeHandler);
+ }
+
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/d33fe63c/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
new file mode 100644
index 0000000..5a16d02
--- /dev/null
+++ b/examples/flexjs/DataBindingExample_Flat/src/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/d33fe63c/examples/flexjs/DataBindingExample_as/build.xml
----------------------------------------------------------------------
diff --git a/examples/flexjs/DataBindingExample_as/build.xml b/examples/flexjs/DataBindingExample_as/build.xml
new file mode 100644
index 0000000..accb229
--- /dev/null
+++ b/examples/flexjs/DataBindingExample_as/build.xml
@@ -0,0 +1,73 @@
+<?xml version="1.0"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+-->
+
+
+<project name="databindingexample_as" default="main" basedir=".">
+ <property name="FLEXJS_HOME" location="../.."/>
+ <property name="example" value="DataBindingExample" />
+
+ <property file="${FLEXJS_HOME}/env.properties"/>
+ <property environment="env"/>
+ <property file="${FLEXJS_HOME}/build.properties"/>
+ <property name="FLEX_HOME" value="${FLEXJS_HOME}"/>
+ <available file="${env.FALCON_HOME}/lib/falcon-mxmlc.jar"
+ type="file"
+ property="FALCON_HOME"
+ value="${env.FALCON_HOME}"/>
+
+ <available file="${FLEXJS_HOME}/../flex-falcon/compiler/generated/dist/sdk/lib/falcon-mxmlc.jar"
+ type="file"
+ property="FALCON_HOME"
+ value="${FLEXJS_HOME}/../flex-falcon/compiler/generated/dist/sdk"/>
+
+ <available file="${env.FALCONJX_HOME}/lib/jsc.jar"
+ type="file"
+ property="FALCONJX_HOME"
+ value="${env.FALCONJX_HOME}"/>
+
+ <available file="${FLEXJS_HOME}/../flex-falcon/compiler.jx/lib/jsc.jar"
+ type="file"
+ property="FALCONJX_HOME"
+ value="${FLEXJS_HOME}/../flex-falcon/compiler.jx"/>
+
+ <available file="${env.GOOG_HOME}/closure/goog/base.js"
+ type="file"
+ property="GOOG_HOME"
+ value="${env.GOOG_HOME}"/>
+
+ <available file="${FLEXJS_HOME}/js/lib/google/closure-library/closure/goog/base.js"
+ type="file"
+ property="GOOG_HOME"
+ value="${FLEXJS_HOME}/js/lib/google/closure-library"/>
+
+ <include file="${basedir}/../build_example.xml" />
+
+ <target name="main" depends="clean,build_example.compileas,build_example.compileasjs" 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" />
+ </target>
+
+
+
+</project>
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/d33fe63c/examples/flexjs/DataBindingExample_as/src/DataBindingExample.as
----------------------------------------------------------------------
diff --git a/examples/flexjs/DataBindingExample_as/src/DataBindingExample.as b/examples/flexjs/DataBindingExample_as/src/DataBindingExample.as
new file mode 100644
index 0000000..d89b6f1
--- /dev/null
+++ b/examples/flexjs/DataBindingExample_as/src/DataBindingExample.as
@@ -0,0 +1,270 @@
+/**
+
+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.core.Application;
+import org.apache.flex.core.ItemRendererClassFactory;
+import org.apache.flex.core.SimpleCSSValuesImpl;
+import org.apache.flex.events.Event;
+import org.apache.flex.html.beads.CSSButtonView;
+import org.apache.flex.html.beads.CSSTextButtonView;
+import org.apache.flex.html.beads.CSSTextToggleButtonView;
+import org.apache.flex.html.beads.CheckBoxView;
+import org.apache.flex.html.beads.ContainerView;
+import org.apache.flex.html.beads.DataItemRendererFactoryForArrayData;
+import org.apache.flex.html.beads.DropDownListView;
+import org.apache.flex.html.beads.ListView;
+import org.apache.flex.html.beads.RadioButtonView;
+import org.apache.flex.html.beads.SingleLineBorderBead;
+import org.apache.flex.html.beads.SolidBackgroundBead;
+import org.apache.flex.html.beads.TextAreaView;
+import org.apache.flex.html.beads.TextButtonMeasurementBead;
+import org.apache.flex.html.beads.TextFieldLabelMeasurementBead;
+import org.apache.flex.html.beads.TextFieldView;
+import org.apache.flex.html.beads.TextInputWithBorderView;
+import org.apache.flex.html.beads.TextItemRendererFactoryForArrayData;
+import org.apache.flex.html.beads.controllers.DropDownListController;
+import org.apache.flex.html.beads.controllers.ItemRendererMouseController;
+import org.apache.flex.html.beads.controllers.EditableTextKeyboardController;
+import org.apache.flex.html.beads.controllers.ListSingleSelectionMouseController;
+import org.apache.flex.html.beads.layouts.VerticalLayout;
+import org.apache.flex.html.beads.models.ArraySelectionModel;
+import org.apache.flex.html.beads.models.SingleLineBorderModel;
+import org.apache.flex.html.beads.models.TextModel;
+import org.apache.flex.html.beads.models.ToggleButtonModel;
+import org.apache.flex.html.beads.models.ValueToggleButtonModel;
+import org.apache.flex.html.supportClasses.DropDownListList;
+import org.apache.flex.html.supportClasses.DataGroup;
+import org.apache.flex.html.supportClasses.ScrollingViewport;
+import org.apache.flex.html.supportClasses.StringItemRenderer;
+import org.apache.flex.net.HTTPService;
+import org.apache.flex.collections.parsers.JSONInputParser;
+import org.apache.flex.collections.LazyCollection;
+import org.apache.flex.utils.ViewSourceContextMenuOption;
+
+import models.MyModel;
+import controllers.MyController;
+
+public class DataBindingExample extends Application
+{
+
+ public function DataBindingExample()
+ {
+ addEventListener("initialize", initializeHandler);
+ var vi:SimpleCSSValuesImpl = new SimpleCSSValuesImpl();
+ setupStyles(vi);
+ valuesImpl = vi;
+ initialView = new MyInitialView();
+ model = new MyModel();
+ controller = new MyController(this);
+ service = new HTTPService();
+ collection = new LazyCollection();
+ collection.inputParser = new JSONInputParser();
+ collection.itemConverter = new StockDataJSONItemConverter();
+ service.addBead(collection);
+ addBead(service);
+ addBead(new ViewSourceContextMenuOption());
+ }
+
+ public var service:HTTPService;
+ public var collection:LazyCollection;
+
+ private function initializeHandler(event:Event):void
+ {
+ MyModel(model).stockSymbol="ADBE";
+ }
+
+ private function setupStyles(vi:SimpleCSSValuesImpl):void
+ {
+ var viv:Object = vi.values = {};
+ viv["global"] =
+ {
+ fontFamily: "Arial",
+ fontSize: 12
+ };
+
+ var o:Object;
+
+ o = viv[makeDefinitionName("org.apache.flex.html::Container")] =
+ {
+
+ iBeadView: ContainerView
+ };
+
+ CONFIG::as_only {
+ o.iBackgroundBead = SolidBackgroundBead;
+ o.iBorderBead = SingleLineBorderBead;
+ }
+
+ viv[makeDefinitionName("org.apache.flex.html::List")] =
+ {
+ iBeadModel: ArraySelectionModel,
+ iBeadView: ListView,
+ iBeadController: ListSingleSelectionMouseController,
+ iBeadLayout: VerticalLayout,
+ iDataGroup: DataGroup,
+ iDataProviderItemRendererMapper: DataItemRendererFactoryForArrayData,
+ IViewport: ScrollingViewport,
+ iItemRendererClassFactory: ItemRendererClassFactory,
+ iItemRenderer: StringItemRenderer
+ };
+
+ o = viv[makeDefinitionName("org.apache.flex.html::Button")] =
+ {
+ backgroundColor: 0xd8d8d8,
+ border: [1, "solid", 0x000000],
+ padding: 4
+ };
+ CONFIG::as_only {
+ o.iBeadView = CSSButtonView;
+ }
+
+ viv[makeDefinitionName("org.apache.flex.html::Button:hover")] =
+ {
+ backgroundColor: 0x9fa0a1,
+ border: [1, "solid", 0x000000],
+ padding: 4
+ };
+
+ viv[makeDefinitionName("org.apache.flex.html::Button:active")] =
+ {
+ backgroundColor: 0x929496,
+ border: [1, "solid", 0x000000],
+ padding: 4
+ };
+
+ CONFIG::as_only {
+ viv["org.apache.flex.html::CheckBox"] =
+ {
+ iBeadModel: ToggleButtonModel,
+ iBeadView: CheckBoxView
+ };
+
+ viv["org.apache.flex.html::DropDownList"] =
+ {
+ iBeadModel: ArraySelectionModel,
+ iBeadView: DropDownListView,
+ iBeadController: DropDownListController,
+ iPopUp: DropDownListList
+ };
+
+ viv["org.apache.flex.html.supportClasses::DropDownListList"] =
+ {
+ iBeadModel: ArraySelectionModel,
+ iDataProviderItemRendererMapper: TextItemRendererFactoryForArrayData,
+ iItemRendererClassFactory: ItemRendererClassFactory,
+ iItemRenderer: StringItemRenderer,
+ iBackgroundBead: SolidBackgroundBead,
+ borderStyle: "solid",
+ borderRadius: 4,
+ borderColor: 0,
+ borderWidth: 1,
+ backgroundColor: 0xFFFFFF
+ };
+
+ viv["org.apache.flex.html::Label"] =
+ {
+ iBeadModel: TextModel,
+ iBeadView: TextFieldView,
+ iMeasurementBead: TextFieldLabelMeasurementBead
+ };
+
+ viv["org.apache.flex.html::List"] =
+ {
+ iBorderBead: SingleLineBorderBead,
+ iBorderModel: SingleLineBorderModel
+ };
+
+ viv["org.apache.flex.html::RadioButton"] =
+ {
+ iBeadModel: ValueToggleButtonModel,
+ iBeadView: RadioButtonView
+ };
+
+ viv["org.apache.flex.html::TextArea"] =
+ {
+ iBeadModel: TextModel,
+ iBeadView: TextAreaView,
+ iBeadController: EditableTextKeyboardController,
+ iBorderBead: SingleLineBorderBead,
+ iBorderModel: SingleLineBorderModel,
+ borderStyle: "solid",
+ borderColor: 0,
+ borderWidth: 1,
+ backgroundColor: 0xFFFFFF
+ };
+
+ viv["org.apache.flex.html::TextButton"] =
+ {
+ iBeadModel: TextModel,
+ iBeadView: CSSTextButtonView,
+ iMeasurementBead: TextButtonMeasurementBead
+ };
+
+ viv["org.apache.flex.html::TextInput"] =
+ {
+ iBeadModel: TextModel,
+ iBeadView: TextInputWithBorderView,
+ iBeadController: EditableTextKeyboardController,
+ iBorderBead: SingleLineBorderBead,
+ iBackgroundBead: SolidBackgroundBead,
+ borderStyle: "solid",
+ borderColor: 0,
+ borderWidth: 1,
+ backgroundColor: 0xFFFFFF
+ };
+
+ viv["org.apache.flex.html::ToggleTextButton"] =
+ {
+ iBeadModel: ToggleButtonModel,
+ iBeadView: CSSTextToggleButtonView
+ };
+
+ viv["org.apache.flex.html::SimpleList"] =
+ {
+ iBeadModel: ArraySelectionModel,
+ iBeadView: ListView,
+ iBeadController: ListSingleSelectionMouseController,
+ iBeadLayout: VerticalLayout,
+ iDataGroup: DataGroup,
+ iDataProviderItemRendererMapper: TextItemRendererFactoryForArrayData,
+ IViewport: ScrollingViewport,
+ iItemRendererClassFactory: ItemRendererClassFactory,
+ iItemRenderer: StringItemRenderer
+ }
+
+ viv["org.apache.flex.html.supportClasses::StringItemRenderer"] =
+ {
+ iBeadController: ItemRendererMouseController,
+ height: 16
+ }
+ }
+ }
+
+ private function makeDefinitionName(s:String):String
+ {
+ CONFIG::js_only {
+ s = s.replace("::", ".");
+ }
+ return s;
+ }
+}
+
+}