flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aha...@apache.org
Subject [26/37] git commit: [flex-asjs] [refs/heads/spark] - Added StorageExample to FlexJS examples.
Date Thu, 24 Mar 2016 19:59:47 GMT
Added StorageExample to FlexJS examples.


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

Branch: refs/heads/spark
Commit: 1c69a390af29678d4797d3e9648b06b69ed87510
Parents: 1bc555d
Author: Peter Ent <pent@apache.org>
Authored: Wed Mar 9 11:13:26 2016 -0500
Committer: Peter Ent <pent@apache.org>
Committed: Wed Mar 9 11:13:26 2016 -0500

----------------------------------------------------------------------
 examples/build.xml                              |   2 +
 examples/flexjs/StorageExample/README.txt       |  81 ++++++
 .../StorageExample/StorageExample-app.xml       | 252 +++++++++++++++++++
 examples/flexjs/StorageExample/build.xml        |  77 ++++++
 examples/flexjs/StorageExample/pom.xml          |  50 ++++
 .../StorageExample/src/MyInitialView.mxml       | 131 ++++++++++
 .../StorageExample/src/StorageExample.mxml      |  42 ++++
 .../flexjs/StorageExample/src/models/MyModel.as |  58 +++++
 8 files changed, 693 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/1c69a390/examples/build.xml
----------------------------------------------------------------------
diff --git a/examples/build.xml b/examples/build.xml
index 7efccfc..27d1816 100644
--- a/examples/build.xml
+++ b/examples/build.xml
@@ -85,6 +85,7 @@
         <ant dir="${basedir}/flexjs/MapSearch"/>
         <ant dir="${basedir}/flexjs/MobileTrader"/>
         <ant dir="${basedir}/flexjs/ChartExample"/>
+        <ant dir="${basedir}/flexjs/StorageExample"/>
         <ant dir="${basedir}/flexjs/TodoListSampleApp"/>
         <ant dir="${basedir}/flexjs/TreeExample"/>
         <ant dir="${basedir}/native/ButtonExample"/>
@@ -113,6 +114,7 @@
         <ant dir="${basedir}/flexjs/MapSearch" target="clean"/>
         <ant dir="${basedir}/flexjs/MobileTrader" target="clean"/>
         <ant dir="${basedir}/flexjs/ChartExample" target="clean"/>
+        <ant dir="${basedir}/flexjs/StorageExample" target="clean"/>
         <ant dir="${basedir}/flexjs/TodoListSampleApp" target="clean"/>
         <ant dir="${basedir}/flexjs/TreeExample" target="clean"/>
         <ant dir="${basedir}/native/ButtonExample" target="clean"/>

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/1c69a390/examples/flexjs/StorageExample/README.txt
----------------------------------------------------------------------
diff --git a/examples/flexjs/StorageExample/README.txt b/examples/flexjs/StorageExample/README.txt
new file mode 100644
index 0000000..12cb609
--- /dev/null
+++ b/examples/flexjs/StorageExample/README.txt
@@ -0,0 +1,81 @@
+Storage Example
+
+The StorageExample is designed to show you have to read and write simple, but permanent files
using
+the FlexJS Storage framework.
+
+Permanent storage is available when the target platform is either Adobe AIR (desktop or mobile
device)
+or Apache Cordova (mobile devices).
+
+Build the Example
+
+1. Run the build (ant)
+
+This will build both the AIR and Cordova-compatible versions. The AIR version will be in
the
+bin-debug directory. The Cordova-compatible versions will be in the js-debug and js-release
+directories.
+
+Running on Adobe AIR
+
+1. Run the example (ant run).
+
+This will launch the SWF as an AIR application. 
+
+Running on an Android Device using Cordova
+
+This is a somewhat complex process. The JavaScript and HTML files that were built (bin/js-debug)
+need to be moved into a Cordova project. Once there, the application can be deployed to a
device
+or run in an emulator.
+
+1. In a clean directory, outside of the flex-asjs directories, use the cordova command line
+interface to build an empty application:
+
+cordova create filetest org.apache.flex "FileTest"
+cd filetest
+
+2. Add in the Android platform and the Cordova File plugin:
+
+cordova platform add android
+cordova plugin add cordova-plugin-file
+
+3. Go to the StorageExample/bin/js-debug directory and copy all of the files and directories
+into the filetest/www directory:
+
+index.html (replaces the index.html from the generated cordova app)
+MyInitialView.js
+StorageExample.css
+StorageExample.js
+externs/
+library/
+models/
+org/
+
+
+4. Open filetest/www/index.html and replace the <body> element with this:
+
+<body onload="startup()">
+  <script type="text/javascript" src="cordova.js"></script>
+  <script type="text/javascript">
+      function startup() {
+        document.addEventListener('deviceready', this.onDeviceReady, false);
+      }
+      function onDeviceReady() {
+         new StorageExample().start();
+      }
+  </script>
+</body>
+
+
+5. Build the Cordova app from the top filetest directory:
+
+cordova build
+
+6. You can run it either in an emulator on a connected device:
+
+(emulator): cordova emulate android
+(device): cordova run android
+
+The filetest/platforms/android directory can be opened from Android Studio if you want to
+use an Android IDE. If you need to make changes, do that in the filetest/www directory,
+then run "cordova build" again. Android Studio will detect the change, ask you to re-sync,
+and after that, you can re-redeploy the changed app to the device.
+ 
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/1c69a390/examples/flexjs/StorageExample/StorageExample-app.xml
----------------------------------------------------------------------
diff --git a/examples/flexjs/StorageExample/StorageExample-app.xml b/examples/flexjs/StorageExample/StorageExample-app.xml
new file mode 100644
index 0000000..62657d2
--- /dev/null
+++ b/examples/flexjs/StorageExample/StorageExample-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/16.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.storageexample</id>
+
+	<!-- Used as the filename for the application. Required. -->
+	<filename>Apache FlexJS Storage 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 Storage 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.6.0</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 2015 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>StorageExample.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>640</width>
+
+		<!-- The window's initial height in pixels. Optional. -->
+		<height>720</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</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/1c69a390/examples/flexjs/StorageExample/build.xml
----------------------------------------------------------------------
diff --git a/examples/flexjs/StorageExample/build.xml b/examples/flexjs/StorageExample/build.xml
new file mode 100644
index 0000000..a976cad
--- /dev/null
+++ b/examples/flexjs/StorageExample/build.xml
@@ -0,0 +1,77 @@
+<?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="storageexample" default="main" basedir=".">
+    <property name="FLEXJS_HOME" location="../../.."/>
+    <property name="example" value="StorageExample" />
+    
+    <!-- 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}"/>
+    <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" />
+
+    <property name="extlib_arg" value="-external-library-path=${FALCONJX_HOME}/../externs/cordova/out/bin/cordova.swc"/>
+    <property name="opt1_arg" value="-remove-circulars" />
+
+<!-- build_example.compileair, -->
+    <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="-profile" />
+            <arg value="extendedDesktop" />
+            <arg value="${basedir}/bin-debug/${example}-app.xml" />
+        </exec>
+    </target>
+</project>

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/1c69a390/examples/flexjs/StorageExample/pom.xml
----------------------------------------------------------------------
diff --git a/examples/flexjs/StorageExample/pom.xml b/examples/flexjs/StorageExample/pom.xml
new file mode 100644
index 0000000..06ac9b2
--- /dev/null
+++ b/examples/flexjs/StorageExample/pom.xml
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.apache.flex.examples.flexjs</groupId>
+        <artifactId>examples</artifactId>
+        <version>1.0.0-SNAPSHOT</version>
+    </parent>
+
+    <artifactId>StorageExample</artifactId>
+    <version>1.0.0-SNAPSHOT</version>
+    <packaging>swf</packaging>
+
+    <build>
+        <sourceDirectory>src</sourceDirectory>
+        <plugins>
+            <plugin>
+                <groupId>net.flexmojos.oss</groupId>
+                <artifactId>flexmojos-maven-plugin</artifactId>
+                <version>7.1.0-SNAPSHOT</version>
+                <extensions>true</extensions>
+                <configuration>
+                    <sourceFile>StorageExample.mxml</sourceFile>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+
+</project>

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/1c69a390/examples/flexjs/StorageExample/src/MyInitialView.mxml
----------------------------------------------------------------------
diff --git a/examples/flexjs/StorageExample/src/MyInitialView.mxml b/examples/flexjs/StorageExample/src/MyInitialView.mxml
new file mode 100644
index 0000000..2bb6b7a
--- /dev/null
+++ b/examples/flexjs/StorageExample/src/MyInitialView.mxml
@@ -0,0 +1,131 @@
+<?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="*"
+				initComplete="startup()">
+    <fx:Script>
+        <![CDATA[			
+			import org.apache.flex.storage.PermanentStorage;
+			import org.apache.flex.storage.events.FileReadEvent;
+			import org.apache.flex.storage.events.FileWriteEvent;
+			
+			private function startup():void
+			{
+				trace("Starting up");
+			}
+			
+			private function onRead():void
+			{
+				var storage:PermanentStorage = new PermanentStorage();
+				
+				var useFile:String = readFileNameField.text;
+				
+				storage.addEventListener("COMPLETE", handleRead);
+				storage.addEventListener("ERROR", handleRead);
+				storage.readTextFromDataFile( useFile );
+			}
+			
+			private function handleRead(event:FileReadEvent):void
+			{
+				trace("Read event type: "+event.type);
+				if (event.type == "ERROR") {
+					status.text = "Error: "+event.errorMessage;
+					readContent.text = "";
+				}
+				else {
+					trace(event.data);
+					status.text = "Read Success!";
+					readContent.text = String(event.data);
+				}
+			}
+			
+			private function onSave():void
+			{
+				var storage:PermanentStorage = new PermanentStorage();
+				var today:Date = new Date();
+				
+				var useFile:String = writeFileNameField.text;
+				var useContent:String = today.toString() + " " + contentField.text;
+				
+				storage.addEventListener("COMPLETE", handleSave);
+				storage.writeTextToDataFile(useFile, useContent);
+			}
+			
+			private function handleSave(event:FileWriteEvent):void
+			{
+				if (event.type == "ERROR") {
+					status.text = "Error: "+event.errorMessage;
+				} else {
+					status.text = "Write Success!";
+				}
+			}
+		]]>
+    </fx:Script>
+	
+	<fx:Style>
+	
+	.labelStyle {
+		color: #9999FF;
+	}
+	
+	.contentStyle {
+		font-size: 18pt;
+	}
+	
+	</fx:Style>
+	
+	<js:beads>
+		<js:ViewBaseDataBinding />
+	</js:beads>
+	
+	<js:VContainer width="100%" height="100%">
+		<js:Label text="Storage Example" width="100%" />
+		<js:Spacer height="20" />
+		
+		<js:HContainer>
+			<js:Label text="Write File Name:" className="labelStyle" />
+			<js:TextInput id="writeFileNameField" text="testfile.txt" />
+		</js:HContainer>
+		<js:HContainer>
+			<js:Label text="Content:" className="labelStyle" />
+			<js:TextInput id="contentField" />
+		</js:HContainer>
+		<js:TextButton text="SAVE" click="onSave()" />
+		<js:Spacer height="20" />
+		
+		<js:Label id="status" />
+		<js:Spacer height="20" />
+		
+		<js:HContainer>
+			<js:Label text="Read File Name:" className="labelStyle" />
+			<js:TextInput id="readFileNameField" text="testfile.txt" />
+		</js:HContainer>
+		<js:TextButton text="READ" click="onRead()" />
+		<js:HContainer>
+			<js:Label text="Content:" className="labelStyle" />
+		</js:HContainer>
+		<js:HContainer>
+			<js:Label id="readContent" className="contentStyle" />
+		</js:HContainer>
+	</js:VContainer>
+		
+
+</js:ViewBase>

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/1c69a390/examples/flexjs/StorageExample/src/StorageExample.mxml
----------------------------------------------------------------------
diff --git a/examples/flexjs/StorageExample/src/StorageExample.mxml b/examples/flexjs/StorageExample/src/StorageExample.mxml
new file mode 100644
index 0000000..1b9842a
--- /dev/null
+++ b/examples/flexjs/StorageExample/src/StorageExample.mxml
@@ -0,0 +1,42 @@
+<?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" 
+				   >
+	
+	<!-- This application demonstrates how to use the Google MAP API
+	     on both the AIR and JavaScript/browser platform. After cross-
+	     compiling this application for JavaScript, edit the index.html
+	     file and include your Google developer API token.
+	-->
+	
+	<js:valuesImpl>
+		<js:SimpleCSSValuesImpl />
+	</js:valuesImpl>
+	<js:initialView>
+		<local:MyInitialView />
+	</js:initialView>
+	<js:beads>
+		<js:MixinManager />
+	</js:beads>
+	
+</js:Application>

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/1c69a390/examples/flexjs/StorageExample/src/models/MyModel.as
----------------------------------------------------------------------
diff --git a/examples/flexjs/StorageExample/src/models/MyModel.as b/examples/flexjs/StorageExample/src/models/MyModel.as
new file mode 100644
index 0000000..e0dab68
--- /dev/null
+++ b/examples/flexjs/StorageExample/src/models/MyModel.as
@@ -0,0 +1,58 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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.core.IBeadModel;
+	import org.apache.flex.core.IStrand;
+	import org.apache.flex.events.Event;
+	import org.apache.flex.events.EventDispatcher;
+	
+	public class MyModel extends EventDispatcher implements IBeadModel
+	{
+		public function MyModel()
+		{
+			super();
+		}
+		
+		private var _strand:IStrand;
+		
+		public function set strand(value:IStrand):void
+		{
+			_strand = value;
+		}
+		
+		private var _cities:Array = ["Sydney", "NYC", "Mexico City", "London", "Rio de Janeiro"];
+		
+		[Bindable]
+		public function get cities():Array
+		{
+			return _cities;
+		}
+		
+		private var _coordinates:Array = [{lat:-33.86, lng:151.211},
+			{lat:40.712, lng:-74.0059},
+			{lat:19.26, lng:-99.03},
+			{lat:51.4, lng:-0.1},
+			{lat:-22.95, lng:-43.12}];
+		public function get coordinates():Array
+		{
+			return _coordinates;
+		}
+	}
+}
\ No newline at end of file


Mime
View raw message