http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e75059f7/examples/flexjs/FlexWebsiteStatsViewer/src/main/flex/models/StatsModel.as ---------------------------------------------------------------------- diff --git a/examples/flexjs/FlexWebsiteStatsViewer/src/main/flex/models/StatsModel.as b/examples/flexjs/FlexWebsiteStatsViewer/src/main/flex/models/StatsModel.as new file mode 100644 index 0000000..d6d1254 --- /dev/null +++ b/examples/flexjs/FlexWebsiteStatsViewer/src/main/flex/models/StatsModel.as @@ -0,0 +1,55 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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 StatsModel extends EventDispatcher + { + private var _lastThirtyDaysUsers:Array; + public function StatsModel() + { + + } + + [Bindable("lastThirtyDaysDataChanged")] + public function get lastThirtyDaysUsers():Array + { + return _lastThirtyDaysUsers; + } + + public function set lastThirtyDaysUsers(v:Array):void + { + if(v != _lastThirtyDaysUsers) + { + _lastThirtyDaysUsers = v; + dispatchEvent(new Event("lastThirtyDaysDataChanged")); + } + } + + private var _labelFields:Array = [ "date", "users"]; + public function get labelFields():Array + { + return _labelFields; + } + + } + +}
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e75059f7/examples/flexjs/FlexWebsiteStatsViewer/src/models/StatsModel.as ---------------------------------------------------------------------- diff --git a/examples/flexjs/FlexWebsiteStatsViewer/src/models/StatsModel.as b/examples/flexjs/FlexWebsiteStatsViewer/src/models/StatsModel.as deleted file mode 100644 index d6d1254..0000000 --- a/examples/flexjs/FlexWebsiteStatsViewer/src/models/StatsModel.as +++ /dev/null @@ -1,55 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// -// Licensed to the Apache Software Foundation (ASF) under one or more -// contributor license agreements. See the NOTICE file distributed with -// this work for additional information regarding copyright ownership. -// The ASF licenses this file to You under the Apache License, Version 2.0 -// (the "License"); you may not use this file except in compliance with -// the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -//////////////////////////////////////////////////////////////////////////////// -package models -{ - import org.apache.flex.events.Event; - import org.apache.flex.events.EventDispatcher; - - public class StatsModel extends EventDispatcher - { - private var _lastThirtyDaysUsers:Array; - public function StatsModel() - { - - } - - [Bindable("lastThirtyDaysDataChanged")] - public function get lastThirtyDaysUsers():Array - { - return _lastThirtyDaysUsers; - } - - public function set lastThirtyDaysUsers(v:Array):void - { - if(v != _lastThirtyDaysUsers) - { - _lastThirtyDaysUsers = v; - dispatchEvent(new Event("lastThirtyDaysDataChanged")); - } - } - - private var _labelFields:Array = [ "date", "users"]; - public function get labelFields():Array - { - return _labelFields; - } - - } - -} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e75059f7/examples/flexjs/HelloWorld/src/HelloWorld.mxml ---------------------------------------------------------------------- diff --git a/examples/flexjs/HelloWorld/src/HelloWorld.mxml b/examples/flexjs/HelloWorld/src/HelloWorld.mxml deleted file mode 100644 index 70d8d20..0000000 --- a/examples/flexjs/HelloWorld/src/HelloWorld.mxml +++ /dev/null @@ -1,30 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- - -Licensed to the Apache Software Foundation (ASF) under one or more -contributor license agreements. See the NOTICE file distributed with -this work for additional information regarding copyright ownership. -The ASF licenses this file to You under the Apache License, Version 2.0 -(the "License"); you may not use this file except in compliance with -the License. You may obtain a copy of the License at - -http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. - ---> -<js:Application xmlns:fx="http://ns.adobe.com/mxml/2009" - xmlns:js="library://ns.apache.org/flexjs/basic" > - <js:valuesImpl> - <js:SimpleCSSValuesImpl /> - </js:valuesImpl> - <js:initialView> - <js:View> - <js:Label text="Hello World!" /> - </js:View> - </js:initialView> -</js:Application> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e75059f7/examples/flexjs/HelloWorld/src/main/flex/HelloWorld.mxml ---------------------------------------------------------------------- diff --git a/examples/flexjs/HelloWorld/src/main/flex/HelloWorld.mxml b/examples/flexjs/HelloWorld/src/main/flex/HelloWorld.mxml new file mode 100644 index 0000000..70d8d20 --- /dev/null +++ b/examples/flexjs/HelloWorld/src/main/flex/HelloWorld.mxml @@ -0,0 +1,30 @@ +<?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:js="library://ns.apache.org/flexjs/basic" > + <js:valuesImpl> + <js:SimpleCSSValuesImpl /> + </js:valuesImpl> + <js:initialView> + <js:View> + <js:Label text="Hello World!" /> + </js:View> + </js:initialView> +</js:Application> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e75059f7/examples/flexjs/MapSearch/src/MapSearch.mxml ---------------------------------------------------------------------- diff --git a/examples/flexjs/MapSearch/src/MapSearch.mxml b/examples/flexjs/MapSearch/src/MapSearch.mxml deleted file mode 100644 index af06140..0000000 --- a/examples/flexjs/MapSearch/src/MapSearch.mxml +++ /dev/null @@ -1,46 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!--- -// -// Licensed to the Apache Software Foundation (ASF) under one or more -// contributor license agreements. See the NOTICE file distributed with -// this work for additional information regarding copyright ownership. -// The ASF licenses this file to You under the Apache License, Version 2.0 -// (the "License"); you may not use this file except in compliance with -// the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -//////////////////////////////////////////////////////////////////////////////// ---> -<js:Application xmlns:fx="http://ns.adobe.com/mxml/2009" - xmlns:local="*" - xmlns:models="models.*" - 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:model> - <models:MyModel /> - </js:model> - <js:beads> - <js:MixinManager /> - </js:beads> - -</js:Application> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e75059f7/examples/flexjs/MapSearch/src/MyInitialView.mxml ---------------------------------------------------------------------- diff --git a/examples/flexjs/MapSearch/src/MyInitialView.mxml b/examples/flexjs/MapSearch/src/MyInitialView.mxml deleted file mode 100644 index 54ec4a2..0000000 --- a/examples/flexjs/MapSearch/src/MyInitialView.mxml +++ /dev/null @@ -1,211 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- - -Licensed to the Apache Software Foundation (ASF) under one or more -contributor license agreements. See the NOTICE file distributed with -this work for additional information regarding copyright ownership. -The ASF licenses this file to You under the Apache License, Version 2.0 -(the "License"); you may not use this file except in compliance with -the License. You may obtain a copy of the License at - -http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. - ---> -<js:View xmlns:fx="http://ns.adobe.com/mxml/2009" - xmlns:js="library://ns.apache.org/flexjs/basic" - xmlns:google="library://ns.apache.org/flexjs/google" - xmlns:local="*" - initComplete="initControls()"> - <fx:Script> - <![CDATA[ - import models.MyModel; - import org.apache.flex.events.Event; - - import google.maps.places.PlaceResult; - import google.maps.Marker; - - private function initControls() : void - { - - } - - /** - * Called when the map is ready for use. This function adds a variety of event - * listners, some of which will trigger a new search. - */ - private function onMapReady() : void - { - map.addEventListener("centered", onMapCenteredOrChanged); - map.addEventListener("boundsChanged", onMapCenteredOrChanged); - map.addEventListener("zoomChanged", onMapCenteredOrChanged); - map.addEventListener("dragEnd", onMapCenteredOrChanged); - map.addEventListener("markerClicked", onMarkerClicked); - - // Listen for changes to the search results on the map's model. - map.model.addEventListener("searchResultsChanged", onSearchResults); - } - - private var selectedCity:String; - - /** - * Triggered by a change in the drop list with a new city selected. This - * will also update the input fields. - */ - private function changeCity(event:org.apache.flex.events.Event) : void - { - var index:int = list.selectedIndex; - mapLocation.text = MyModel(applicationModel).cities[index]; - codeAddress(); - } - - private function codeAddress() : void - { - map.markAddress(mapLocation.text); - } - - private function searchOnMap() : void - { - map.nearbySearch(search.text); - } - - private function clearSearchResults() : void - { - map.clearSearchResults(); - } - - private function orientMap() : void - { - map.centerOnAddress(mapLocation.text); - } - - /** - * Called when the map has been re-centered or moved. The search results are - * cleared and a new search is triggered. - */ - private function onMapCenteredOrChanged(event:org.apache.flex.events.Event):void - { - clearSearchResults(); - if (search.text) searchOnMap(); - } - - /** - * Called when search results are available in the map's model. This function - * transfers those results to the application's model which is bound to the - * List component. - */ - private function onSearchResults(event:org.apache.flex.events.Event):void - { - var searchResults:Array = map.searchResults; - MyModel(applicationModel).searchResults = searchResults; - } - - /** - * Called when a marker on the map has been selected. This function centers - * the map on the marker and, if necessary, zooms the map in for closer - * inspection. - */ - private function onMarkerClicked(event:org.apache.flex.events.Event):void - { - var marker:Marker = map.selectedMarker as Marker; - map.setZoom(12); - map.setCenter(marker.getPosition()); - } - - ]]> - </fx:Script> - - <fx:Style> - @namespace basic "library://ns.apache.org/flexjs/basic"; - - .FormLabel { - font-weight: bold; - font-size: 12; - padding-left: 20px; - padding-right: 20px; - padding-top: 20px; - padding-bottom: 20px; - height: 22px; - } - - .FormButton { - font-weight: bold; - font-size: 12; - color: #000000; - background-color: #FFFFFF; - border-style: solid; - padding-top: 5px; - padding-bottom: 5px; - padding-left: 5px; - padding-right: 5px; - } - - .FormInput { - font-weight: normal; - font-size: 12; - color: #0000DE; - padding: 0px; - height: 20px; - } - - .InnerBox { - margin-top: 11px; - margin-bottom: 10px; - } - </fx:Style> - - <js:beads> - <js:ViewDataBinding /> - </js:beads> - - - <js:Container x="5" y="5" className="topContainer" > - <js:beads> - <js:VerticalLayout /> - </js:beads> - - <js:Container className="InnerBox"> - <js:beads> - <js:HorizontalLayout /> - </js:beads> - <js:Label id="label1" text="Location:" className="FormLabel" /> - <js:TextInput id="mapLocation" /> - <js:TextButton text="Go" id="goButton" click="orientMap()" className="FormButton" /> - - <js:DropDownList id="list" width="100" height="20" - change="changeCity(event)" - dataProvider="{MyModel(applicationModel).cities}" /> - </js:Container> - - <google:Map id="map" width="450" height="300" className="MainMap" - token="AIzaSyDkQgg2iojLCYeuW6hK7DkuAHD-SwJJhdE" - ready="onMapReady()"/> - - <js:Container className="InnerBox"> - <js:beads> - <js:HorizontalLayout /> - </js:beads> - <js:Label id="label2" text="Search on Map:" className="FormLabel" /> - <js:TextInput id="search" /> - <js:TextButton text="Find" click="searchOnMap()" className="FormButton" /> - <js:TextButton text="Clear"click="clearSearchResults()" className="FormButton" /> - </js:Container> - - <js:List id="resultsList" width="450" height="200"> - <js:beads> - <js:SimpleBinding - sourceID="applicationModel" - sourcePropertyName="searchResults" - eventName="searchResultsChanged" - destinationPropertyName="dataProvider" /> - </js:beads> - </js:List> - - </js:Container> - -</js:View> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e75059f7/examples/flexjs/MapSearch/src/main/flex/MapSearch.mxml ---------------------------------------------------------------------- diff --git a/examples/flexjs/MapSearch/src/main/flex/MapSearch.mxml b/examples/flexjs/MapSearch/src/main/flex/MapSearch.mxml new file mode 100644 index 0000000..af06140 --- /dev/null +++ b/examples/flexjs/MapSearch/src/main/flex/MapSearch.mxml @@ -0,0 +1,46 @@ +<?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:models="models.*" + 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:model> + <models:MyModel /> + </js:model> + <js:beads> + <js:MixinManager /> + </js:beads> + +</js:Application> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e75059f7/examples/flexjs/MapSearch/src/main/flex/MyInitialView.mxml ---------------------------------------------------------------------- diff --git a/examples/flexjs/MapSearch/src/main/flex/MyInitialView.mxml b/examples/flexjs/MapSearch/src/main/flex/MyInitialView.mxml new file mode 100644 index 0000000..54ec4a2 --- /dev/null +++ b/examples/flexjs/MapSearch/src/main/flex/MyInitialView.mxml @@ -0,0 +1,211 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + +Licensed to the Apache Software Foundation (ASF) under one or more +contributor license agreements. See the NOTICE file distributed with +this work for additional information regarding copyright ownership. +The ASF licenses this file to You under the Apache License, Version 2.0 +(the "License"); you may not use this file except in compliance with +the License. You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +--> +<js:View xmlns:fx="http://ns.adobe.com/mxml/2009" + xmlns:js="library://ns.apache.org/flexjs/basic" + xmlns:google="library://ns.apache.org/flexjs/google" + xmlns:local="*" + initComplete="initControls()"> + <fx:Script> + <![CDATA[ + import models.MyModel; + import org.apache.flex.events.Event; + + import google.maps.places.PlaceResult; + import google.maps.Marker; + + private function initControls() : void + { + + } + + /** + * Called when the map is ready for use. This function adds a variety of event + * listners, some of which will trigger a new search. + */ + private function onMapReady() : void + { + map.addEventListener("centered", onMapCenteredOrChanged); + map.addEventListener("boundsChanged", onMapCenteredOrChanged); + map.addEventListener("zoomChanged", onMapCenteredOrChanged); + map.addEventListener("dragEnd", onMapCenteredOrChanged); + map.addEventListener("markerClicked", onMarkerClicked); + + // Listen for changes to the search results on the map's model. + map.model.addEventListener("searchResultsChanged", onSearchResults); + } + + private var selectedCity:String; + + /** + * Triggered by a change in the drop list with a new city selected. This + * will also update the input fields. + */ + private function changeCity(event:org.apache.flex.events.Event) : void + { + var index:int = list.selectedIndex; + mapLocation.text = MyModel(applicationModel).cities[index]; + codeAddress(); + } + + private function codeAddress() : void + { + map.markAddress(mapLocation.text); + } + + private function searchOnMap() : void + { + map.nearbySearch(search.text); + } + + private function clearSearchResults() : void + { + map.clearSearchResults(); + } + + private function orientMap() : void + { + map.centerOnAddress(mapLocation.text); + } + + /** + * Called when the map has been re-centered or moved. The search results are + * cleared and a new search is triggered. + */ + private function onMapCenteredOrChanged(event:org.apache.flex.events.Event):void + { + clearSearchResults(); + if (search.text) searchOnMap(); + } + + /** + * Called when search results are available in the map's model. This function + * transfers those results to the application's model which is bound to the + * List component. + */ + private function onSearchResults(event:org.apache.flex.events.Event):void + { + var searchResults:Array = map.searchResults; + MyModel(applicationModel).searchResults = searchResults; + } + + /** + * Called when a marker on the map has been selected. This function centers + * the map on the marker and, if necessary, zooms the map in for closer + * inspection. + */ + private function onMarkerClicked(event:org.apache.flex.events.Event):void + { + var marker:Marker = map.selectedMarker as Marker; + map.setZoom(12); + map.setCenter(marker.getPosition()); + } + + ]]> + </fx:Script> + + <fx:Style> + @namespace basic "library://ns.apache.org/flexjs/basic"; + + .FormLabel { + font-weight: bold; + font-size: 12; + padding-left: 20px; + padding-right: 20px; + padding-top: 20px; + padding-bottom: 20px; + height: 22px; + } + + .FormButton { + font-weight: bold; + font-size: 12; + color: #000000; + background-color: #FFFFFF; + border-style: solid; + padding-top: 5px; + padding-bottom: 5px; + padding-left: 5px; + padding-right: 5px; + } + + .FormInput { + font-weight: normal; + font-size: 12; + color: #0000DE; + padding: 0px; + height: 20px; + } + + .InnerBox { + margin-top: 11px; + margin-bottom: 10px; + } + </fx:Style> + + <js:beads> + <js:ViewDataBinding /> + </js:beads> + + + <js:Container x="5" y="5" className="topContainer" > + <js:beads> + <js:VerticalLayout /> + </js:beads> + + <js:Container className="InnerBox"> + <js:beads> + <js:HorizontalLayout /> + </js:beads> + <js:Label id="label1" text="Location:" className="FormLabel" /> + <js:TextInput id="mapLocation" /> + <js:TextButton text="Go" id="goButton" click="orientMap()" className="FormButton" /> + + <js:DropDownList id="list" width="100" height="20" + change="changeCity(event)" + dataProvider="{MyModel(applicationModel).cities}" /> + </js:Container> + + <google:Map id="map" width="450" height="300" className="MainMap" + token="AIzaSyDkQgg2iojLCYeuW6hK7DkuAHD-SwJJhdE" + ready="onMapReady()"/> + + <js:Container className="InnerBox"> + <js:beads> + <js:HorizontalLayout /> + </js:beads> + <js:Label id="label2" text="Search on Map:" className="FormLabel" /> + <js:TextInput id="search" /> + <js:TextButton text="Find" click="searchOnMap()" className="FormButton" /> + <js:TextButton text="Clear"click="clearSearchResults()" className="FormButton" /> + </js:Container> + + <js:List id="resultsList" width="450" height="200"> + <js:beads> + <js:SimpleBinding + sourceID="applicationModel" + sourcePropertyName="searchResults" + eventName="searchResultsChanged" + destinationPropertyName="dataProvider" /> + </js:beads> + </js:List> + + </js:Container> + +</js:View> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e75059f7/examples/flexjs/MapSearch/src/main/flex/models/MyModel.as ---------------------------------------------------------------------- diff --git a/examples/flexjs/MapSearch/src/main/flex/models/MyModel.as b/examples/flexjs/MapSearch/src/main/flex/models/MyModel.as new file mode 100644 index 0000000..8a1e8fd --- /dev/null +++ b/examples/flexjs/MapSearch/src/main/flex/models/MyModel.as @@ -0,0 +1,71 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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; + } + + private var _searchResults:Array = []; + + [Bindable("searchResultsChanged")] + public function get searchResults():Array + { + return _searchResults; + } + public function set searchResults(value:Array):void + { + _searchResults = value; + dispatchEvent(new Event("searchResultsChanged")); + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e75059f7/examples/flexjs/MapSearch/src/models/MyModel.as ---------------------------------------------------------------------- diff --git a/examples/flexjs/MapSearch/src/models/MyModel.as b/examples/flexjs/MapSearch/src/models/MyModel.as deleted file mode 100644 index 8a1e8fd..0000000 --- a/examples/flexjs/MapSearch/src/models/MyModel.as +++ /dev/null @@ -1,71 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// -// Licensed to the Apache Software Foundation (ASF) under one or more -// contributor license agreements. See the NOTICE file distributed with -// this work for additional information regarding copyright ownership. -// The ASF licenses this file to You under the Apache License, Version 2.0 -// (the "License"); you may not use this file except in compliance with -// the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -//////////////////////////////////////////////////////////////////////////////// -package models -{ - import org.apache.flex.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; - } - - private var _searchResults:Array = []; - - [Bindable("searchResultsChanged")] - public function get searchResults():Array - { - return _searchResults; - } - public function set searchResults(value:Array):void - { - _searchResults = value; - dispatchEvent(new Event("searchResultsChanged")); - } - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e75059f7/examples/flexjs/MobileMap/resources/config.xml ---------------------------------------------------------------------- diff --git a/examples/flexjs/MobileMap/resources/config.xml b/examples/flexjs/MobileMap/resources/config.xml deleted file mode 100644 index 00b9f64..0000000 --- a/examples/flexjs/MobileMap/resources/config.xml +++ /dev/null @@ -1,44 +0,0 @@ -<?xml version='1.0' encoding='utf-8'?> -<!-- - - Licensed to the Apache Software Foundation (ASF) under one or more - contributor license agreements. See the NOTICE file distributed with - this work for additional information regarding copyright ownership. - The ASF licenses this file to You under the Apache License, Version 2.0 - (the "License"); you may not use this file except in compliance with - the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - ---> -<widget id="${groupId}.${artifactId}" version="${version}" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0"> - <name>${artifactId}</name> - <description> - ${description} - </description> - <author email="[email protected]" href="http://flex.apache.org"> - Apache Flex Team - </author> - <content src="index.html" /> - <plugin name="cordova-plugin-whitelist" version="1" /> - <access origin="*" /> - <allow-intent href="http://*/*" /> - <allow-intent href="https://*/*" /> - <allow-intent href="tel:*" /> - <allow-intent href="sms:*" /> - <allow-intent href="mailto:*" /> - <allow-intent href="geo:*" /> - <platform name="android"> - <allow-intent href="market:*" /> - </platform> - <platform name="ios"> - <allow-intent href="itms:*" /> - <allow-intent href="itms-apps:*" /> - </platform> -</widget> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e75059f7/examples/flexjs/MobileMap/src/MobileMap.mxml ---------------------------------------------------------------------- diff --git a/examples/flexjs/MobileMap/src/MobileMap.mxml b/examples/flexjs/MobileMap/src/MobileMap.mxml deleted file mode 100644 index 1a68662..0000000 --- a/examples/flexjs/MobileMap/src/MobileMap.mxml +++ /dev/null @@ -1,71 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- - -Licensed to the Apache Software Foundation (ASF) under one or more -contributor license agreements. See the NOTICE file distributed with -this work for additional information regarding copyright ownership. -The ASF licenses this file to You under the Apache License, Version 2.0 -(the "License"); you may not use this file except in compliance with -the License. You may obtain a copy of the License at - -http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. - ---> -<mjs:Application xmlns:fx="http://ns.adobe.com/mxml/2009" - xmlns:js="library://ns.apache.org/flexjs/basic" - xmlns:mjs="library://ns.apache.org/flexjs/cordova" - xmlns:google="library://ns.apache.org/flexjs/google" - applicationComplete="onDeviceReady()"> - <js:valuesImpl> - <js:SimpleCSSValuesImpl /> - </js:valuesImpl> - <fx:Script> - <![CDATA[ - import org.apache.cordova.geolocation.Geolocation; - import google.maps.LatLng; - - private function onDeviceReady():void { - label.text = "The device ready, loading map..."; - - var location:Geolocation = new Geolocation(); - location.getCurrentPosition(onSuccess, onError); - } - - private function onSuccess(position:Object):void - { - // Extract the latitude and longitude from the position - // given and covert it to GoogleMaps LatLng object so - // the map can be centered on it. - - var lat:Number = Number(position["coords"]["latitude"]); - var lng:Number = Number(position["coords"]["longitude"]); - - label.text = String(lat) + ", " + String(lng); - map.setCenter(new LatLng(lat, lng)); - } - - private function onError(error:*):void - { - label.text = "Location failure"; - } - ]]> - </fx:Script> - <js:initialView> - <js:View> - <js:VContainer width="450" height="640"> - <js:HContainer width="100%" height="40"> - <js:Label text="Current Location: " width="25%" /> - <js:Label id="label" text="" width="75%" /> - </js:HContainer> - <google:Map id="map" width="100%" height="600" - token="AIzaSyDkQgg2iojLCYeuW6hK7DkuAHD-SwJJhdE" /> - </js:VContainer> - </js:View> - </js:initialView> -</mjs:Application> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e75059f7/examples/flexjs/MobileMap/src/main/flex/MobileMap.mxml ---------------------------------------------------------------------- diff --git a/examples/flexjs/MobileMap/src/main/flex/MobileMap.mxml b/examples/flexjs/MobileMap/src/main/flex/MobileMap.mxml new file mode 100644 index 0000000..1a68662 --- /dev/null +++ b/examples/flexjs/MobileMap/src/main/flex/MobileMap.mxml @@ -0,0 +1,71 @@ +<?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. + +--> +<mjs:Application xmlns:fx="http://ns.adobe.com/mxml/2009" + xmlns:js="library://ns.apache.org/flexjs/basic" + xmlns:mjs="library://ns.apache.org/flexjs/cordova" + xmlns:google="library://ns.apache.org/flexjs/google" + applicationComplete="onDeviceReady()"> + <js:valuesImpl> + <js:SimpleCSSValuesImpl /> + </js:valuesImpl> + <fx:Script> + <![CDATA[ + import org.apache.cordova.geolocation.Geolocation; + import google.maps.LatLng; + + private function onDeviceReady():void { + label.text = "The device ready, loading map..."; + + var location:Geolocation = new Geolocation(); + location.getCurrentPosition(onSuccess, onError); + } + + private function onSuccess(position:Object):void + { + // Extract the latitude and longitude from the position + // given and covert it to GoogleMaps LatLng object so + // the map can be centered on it. + + var lat:Number = Number(position["coords"]["latitude"]); + var lng:Number = Number(position["coords"]["longitude"]); + + label.text = String(lat) + ", " + String(lng); + map.setCenter(new LatLng(lat, lng)); + } + + private function onError(error:*):void + { + label.text = "Location failure"; + } + ]]> + </fx:Script> + <js:initialView> + <js:View> + <js:VContainer width="450" height="640"> + <js:HContainer width="100%" height="40"> + <js:Label text="Current Location: " width="25%" /> + <js:Label id="label" text="" width="75%" /> + </js:HContainer> + <google:Map id="map" width="100%" height="600" + token="AIzaSyDkQgg2iojLCYeuW6hK7DkuAHD-SwJJhdE" /> + </js:VContainer> + </js:View> + </js:initialView> +</mjs:Application> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e75059f7/examples/flexjs/MobileMap/src/main/resources/config.xml ---------------------------------------------------------------------- diff --git a/examples/flexjs/MobileMap/src/main/resources/config.xml b/examples/flexjs/MobileMap/src/main/resources/config.xml new file mode 100644 index 0000000..00b9f64 --- /dev/null +++ b/examples/flexjs/MobileMap/src/main/resources/config.xml @@ -0,0 +1,44 @@ +<?xml version='1.0' encoding='utf-8'?> +<!-- + + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +--> +<widget id="${groupId}.${artifactId}" version="${version}" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0"> + <name>${artifactId}</name> + <description> + ${description} + </description> + <author email="[email protected]" href="http://flex.apache.org"> + Apache Flex Team + </author> + <content src="index.html" /> + <plugin name="cordova-plugin-whitelist" version="1" /> + <access origin="*" /> + <allow-intent href="http://*/*" /> + <allow-intent href="https://*/*" /> + <allow-intent href="tel:*" /> + <allow-intent href="sms:*" /> + <allow-intent href="mailto:*" /> + <allow-intent href="geo:*" /> + <platform name="android"> + <allow-intent href="market:*" /> + </platform> + <platform name="ios"> + <allow-intent href="itms:*" /> + <allow-intent href="itms-apps:*" /> + </platform> +</widget> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e75059f7/examples/flexjs/MobileStocks/resources/config.xml ---------------------------------------------------------------------- diff --git a/examples/flexjs/MobileStocks/resources/config.xml b/examples/flexjs/MobileStocks/resources/config.xml deleted file mode 100644 index 00b9f64..0000000 --- a/examples/flexjs/MobileStocks/resources/config.xml +++ /dev/null @@ -1,44 +0,0 @@ -<?xml version='1.0' encoding='utf-8'?> -<!-- - - Licensed to the Apache Software Foundation (ASF) under one or more - contributor license agreements. See the NOTICE file distributed with - this work for additional information regarding copyright ownership. - The ASF licenses this file to You under the Apache License, Version 2.0 - (the "License"); you may not use this file except in compliance with - the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - ---> -<widget id="${groupId}.${artifactId}" version="${version}" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0"> - <name>${artifactId}</name> - <description> - ${description} - </description> - <author email="[email protected]" href="http://flex.apache.org"> - Apache Flex Team - </author> - <content src="index.html" /> - <plugin name="cordova-plugin-whitelist" version="1" /> - <access origin="*" /> - <allow-intent href="http://*/*" /> - <allow-intent href="https://*/*" /> - <allow-intent href="tel:*" /> - <allow-intent href="sms:*" /> - <allow-intent href="mailto:*" /> - <allow-intent href="geo:*" /> - <platform name="android"> - <allow-intent href="market:*" /> - </platform> - <platform name="ios"> - <allow-intent href="itms:*" /> - <allow-intent href="itms-apps:*" /> - </platform> -</widget> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e75059f7/examples/flexjs/MobileStocks/src/MobileStocks.mxml ---------------------------------------------------------------------- diff --git a/examples/flexjs/MobileStocks/src/MobileStocks.mxml b/examples/flexjs/MobileStocks/src/MobileStocks.mxml deleted file mode 100644 index 1d30b37..0000000 --- a/examples/flexjs/MobileStocks/src/MobileStocks.mxml +++ /dev/null @@ -1,50 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- - -Licensed to the Apache Software Foundation (ASF) under one or more -contributor license agreements. See the NOTICE file distributed with -this work for additional information regarding copyright ownership. -The ASF licenses this file to You under the Apache License, Version 2.0 -(the "License"); you may not use this file except in compliance with -the License. You may obtain a copy of the License at - -http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. - ---> -<cordova:Application xmlns:fx="http://ns.adobe.com/mxml/2009" - xmlns:local="*" - xmlns:models="models.*" - xmlns:views="views.*" - xmlns:js="library://ns.apache.org/flexjs/basic" - xmlns:cordova="library://ns.apache.org/flexjs/cordova" - > - <fx:Declarations> - <!-- Place non-visual elements (e.g., services, value objects) here --> - </fx:Declarations> - - <js:valuesImpl> - <js:SimpleCSSValuesImpl /> - </js:valuesImpl> - - <js:model> - <models:ProductsModel /> - </js:model> - - <js:initialView> - <local:MyInitialView width="100%" height="100%" className="InitalView" /> - </js:initialView> - - <js:beads> - <cordova:Weinre guid="aharui" /> - <js:MixinManager /> - <js:DeviceSizeBead /> - </js:beads> - - -</cordova:Application> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e75059f7/examples/flexjs/MobileStocks/src/MyInitialView.mxml ---------------------------------------------------------------------- diff --git a/examples/flexjs/MobileStocks/src/MyInitialView.mxml b/examples/flexjs/MobileStocks/src/MyInitialView.mxml deleted file mode 100755 index b6853e2..0000000 --- a/examples/flexjs/MobileStocks/src/MyInitialView.mxml +++ /dev/null @@ -1,253 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- - -Licensed to the Apache Software Foundation (ASF) under one or more -contributor license agreements. See the NOTICE file distributed with -this work for additional information regarding copyright ownership. -The ASF licenses this file to You under the Apache License, Version 2.0 -(the "License"); you may not use this file except in compliance with -the License. You may obtain a copy of the License at - -http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. - ---> -<js:View xmlns:fx="http://ns.adobe.com/mxml/2009" - xmlns:local="*" - xmlns:js="library://ns.apache.org/flexjs/basic" - xmlns:views="views.*" - xmlns:apache="org.apache.flex.html.beads.*" - xmlns:html="org.apache.flex.html.*" - xmlns:controller="controller.*" - initComplete="onInitComplete()" xmlns:models="models.*" > - - <fx:Style> - @namespace js "library://ns.apache.org/flexjs/basic"; - @namespace views "views.*"; - - js|Container { - background-color: #FFFFFF; - } - - js|TextInput { - font-size: 10pt; - } - - js|Label { - font-size: 8pt; - } - - js|StackedViewManager { - padding-top: 0px; - padding-bottom: 0px; - padding-left: 0px; - padding-right: 0px; - } - - js|TabbedViewManager { - position : absolute ; - height : 100% ; - width : 100% ; - left : 0px ; - top : 0px ; - border: solid 1px #444444; - background-color: #FFFFFF; - } - - .NavigationBar { - background-image: url("assets/background.png"); - height: 56px; - width: 100%; - IBeadLayout: ClassReference("org.apache.flex.html.beads.layouts.HorizontalLayout"); - } - - .TabBar { - background-color: #DEDEDE; - height: 55px; - vertical-align: middle; - line-height: 55px; - } - - .BackButton:hover { - background-image: url('assets/arrow_left_24.png'); - } - - .BackButton:active { - background-image: url('assets/arrow_left_24.png'); - } - - .BackButton { - background-image: url('assets/arrow_left_24.png'); - } - - views|LaunchView { - width: 100%; - height: 100%; - IBeadController:ClassReference('controller.LaunchViewController'); - background-color: #FFFFFF; - } - - views|WatchListView { - width: 100%; - height: 100%; - IBeadController:ClassReference('controller.WatchListController'); - background-color: #FFFFFF; - } - - .WatchListInner { - height: 480px; - width: 100%; - background-color: #FFFFFF; - } - - .WatchListDataGrid { - height: 480px; - width: 100%; - } - - .WatchListInputArea { - background-color: #FFFFFF; - width: 480px; - height: 25px; - padding-top: 5px; - padding-bottom: 2px; - } - - views|StockView { - width: 100%; - height: 100%; - } - - .redCell { - color: #FF0000; - } - - .greenCell { - color: #00FF00; - } - - .ViewTitle { - font-size: 18pt; - font-weight: bold; - padding: 10pt; - } - - .StockName { - font-size: 14pt; - font-weight: normal; - padding: 10pt; - } - - .StockDetailArea { - padding: 10pt; - } - - .StockLabel { - font-size: 18pt; - font-weight: normal; - color: #2255DD; - } - - .StockRemoveButton { - background-color: #FF5522; - font-size: 16pt; - font-weight: bold; - color: #FFFFFF; - width: 200px; - height: 50px; - } - - .StockRemoveButton:hover { - background-color: #DD3300; - } - - .StockValue { - font-size: 18pt; - font-weight: normal; - color: #999999; - } - - @media -flex-flash - { - .NavigationBar { - IBackgroundBead: ClassReference("org.apache.flex.html.beads.BackgroundImageBead"); - } - } - - </fx:Style> - - <fx:Script> - <![CDATA[ - import org.apache.flex.core.IBeadController; - import org.apache.flex.core.IBeadModel; - import org.apache.flex.events.Event; - import org.apache.flex.mobile.IViewManagerView; - import org.apache.flex.mobile.IViewManager; - import org.apache.flex.mobile.chrome.NavigationBar; - - import models.ProductsModel; - - private function onInitComplete():void - { - (applicationModel as ProductsModel).loadDataFromStorage(); - } - - /* debugging */ - private function tabbedViewChanged(event:org.apache.flex.events.Event):void - { - //var manager:IViewManager = event.currentTarget as IViewManager; - //trace("TabbedViewChanged for "+manager); - } - - private function watchListStackChanged(event:org.apache.flex.events.Event):void - { - //trace("watchlist stack changed"); - var manager:StackedViewManager = event.currentTarget as StackedViewManager; - - var currentView:IViewManagerView = manager.selectedView; - backButton.visible = manager.views.length > 1; - } - - private function goBack(event:org.apache.flex.events.MouseEvent):void - { - if (navController.selectedIndex == 1) { - watchListStack.pop(); - } - } - ]]> - </fx:Script> - - <js:beads> - <js:ViewDataBinding /> - </js:beads> - - <js:TabbedViewManager id="navController" width="100%" height="100%" x="0" y="0" viewChanged="tabbedViewChanged(event)"> - <js:navigationBarItems> - <js:TextButton id="backButton" width="45" height="45" className="BackButton" visible="false" click="goBack(event)"> - <js:beads> - <apache:ImageButtonView /> - </js:beads> - </js:TextButton> - <js:Image source="assets/logo.png" width="218" height="55" /> - </js:navigationBarItems> - <js:views> - <js:StackedViewManager title="Assets"> - <js:views> - <views:LaunchView id="assetsView" title="Assets" dataModel="{applicationModel}" /> - </js:views> - </js:StackedViewManager> - - <js:StackedViewManager id="watchListStack" title="Watch List" viewChanged="watchListStackChanged(event)"> - <js:views> - <views:WatchListView id="watchListView" dataModel="{applicationModel}"/> - </js:views> - </js:StackedViewManager> - </js:views> - </js:TabbedViewManager> - -</js:View> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e75059f7/examples/flexjs/MobileStocks/src/StockDataJSONItemConverter.as ---------------------------------------------------------------------- diff --git a/examples/flexjs/MobileStocks/src/StockDataJSONItemConverter.as b/examples/flexjs/MobileStocks/src/StockDataJSONItemConverter.as deleted file mode 100755 index 92a75dc..0000000 --- a/examples/flexjs/MobileStocks/src/StockDataJSONItemConverter.as +++ /dev/null @@ -1,41 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// -// Licensed to the Apache Software Foundation (ASF) under one or more -// contributor license agreements. See the NOTICE file distributed with -// this work for additional information regarding copyright ownership. -// The ASF licenses this file to You under the Apache License, Version 2.0 -// (the "License"); you may not use this file except in compliance with -// the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -//////////////////////////////////////////////////////////////////////////////// -package -{ - import org.apache.flex.collections.converters.JSONItemConverter; - - public class StockDataJSONItemConverter extends JSONItemConverter - { - public function StockDataJSONItemConverter() - { - super(); - } - - override public function convertItem(data:String):Object - { - var obj:Object = super.convertItem(data); - if (obj["query"] == null) return "No Data"; - if (obj["query"]["count"] == 0) - return "No Data"; - - obj = obj["query"]["results"]["quote"]; - return obj; - } - } -} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e75059f7/examples/flexjs/MobileStocks/src/VerticalLayoutTextView.mxml ---------------------------------------------------------------------- diff --git a/examples/flexjs/MobileStocks/src/VerticalLayoutTextView.mxml b/examples/flexjs/MobileStocks/src/VerticalLayoutTextView.mxml deleted file mode 100755 index 0353195..0000000 --- a/examples/flexjs/MobileStocks/src/VerticalLayoutTextView.mxml +++ /dev/null @@ -1,68 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- - -Licensed to the Apache Software Foundation (ASF) under one or more -contributor license agreements. See the NOTICE file distributed with -this work for additional information regarding copyright ownership. -The ASF licenses this file to You under the Apache License, Version 2.0 -(the "License"); you may not use this file except in compliance with -the License. You may obtain a copy of the License at - -http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. - ---> -<js:View xmlns:fx="http://ns.adobe.com/mxml/2009" - xmlns:js="library://ns.apache.org/flexjs/basic" - > - - <fx:Style> - @namespace js "library://ns.apache.org/flexjs/basic"; - @namespace views "views.*"; - - .TopContainer { - background-color: #FFFFCC; - } - - .MidContainer { - background-color: #FFCCFF; - } - - .BotContainer { - background-color: #CCFFFF; - } - - </fx:Style> - - <fx:Script> - <![CDATA[ - - ]]> - </fx:Script> - - <js:beads> - <js:ViewDataBinding /> - </js:beads> - - <js:VContainer width="100%" height="100%"> - - <js:Container width="100%" height="25%" className="TopContainer"> - <js:Label text="Top Container: 25%" /> - </js:Container> - - <js:Container width="100%" height="50%" className="MidContainer"> - <js:Label text="Middle Container: 50%" /> - </js:Container> - - <js:Container width="100%" height="25%" className="BotContainer"> - <js:Label text="Bottom Container: 25%" /> - </js:Container> - - </js:VContainer> - -</js:View> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e75059f7/examples/flexjs/MobileStocks/src/assets/arrow_left_24.png ---------------------------------------------------------------------- diff --git a/examples/flexjs/MobileStocks/src/assets/arrow_left_24.png b/examples/flexjs/MobileStocks/src/assets/arrow_left_24.png deleted file mode 100755 index a3019ba..0000000 Binary files a/examples/flexjs/MobileStocks/src/assets/arrow_left_24.png and /dev/null differ http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e75059f7/examples/flexjs/MobileStocks/src/assets/background.png ---------------------------------------------------------------------- diff --git a/examples/flexjs/MobileStocks/src/assets/background.png b/examples/flexjs/MobileStocks/src/assets/background.png deleted file mode 100755 index 87bbd59..0000000 Binary files a/examples/flexjs/MobileStocks/src/assets/background.png and /dev/null differ http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e75059f7/examples/flexjs/MobileStocks/src/assets/logo.png ---------------------------------------------------------------------- diff --git a/examples/flexjs/MobileStocks/src/assets/logo.png b/examples/flexjs/MobileStocks/src/assets/logo.png deleted file mode 100755 index 0fb0f21..0000000 Binary files a/examples/flexjs/MobileStocks/src/assets/logo.png and /dev/null differ http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e75059f7/examples/flexjs/MobileStocks/src/controller/LaunchViewController.as ---------------------------------------------------------------------- diff --git a/examples/flexjs/MobileStocks/src/controller/LaunchViewController.as b/examples/flexjs/MobileStocks/src/controller/LaunchViewController.as deleted file mode 100644 index 2b88d26..0000000 --- a/examples/flexjs/MobileStocks/src/controller/LaunchViewController.as +++ /dev/null @@ -1,150 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// -// Licensed to the Apache Software Foundation (ASF) under one or more -// contributor license agreements. See the NOTICE file distributed with -// this work for additional information regarding copyright ownership. -// The ASF licenses this file to You under the Apache License, Version 2.0 -// (the "License"); you may not use this file except in compliance with -// the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -//////////////////////////////////////////////////////////////////////////////// -package controller -{ - import models.ProductsModel; - import models.Stock; - - import org.apache.flex.core.IBeadController; - import org.apache.flex.core.IBeadModel; - import org.apache.flex.core.IStrand; - import org.apache.flex.events.Event; - import org.apache.flex.events.EventDispatcher; - import org.apache.flex.utils.Timer; - import org.apache.flex.collections.ArrayList; - - import views.LaunchView; - - public class LaunchViewController extends EventDispatcher implements IBeadController - { - public function LaunchViewController() - { - super(); - - timer = new Timer(updateInterval, 0); - timer.addEventListener("timer", timerHandler); - } - - public var updateInterval:Number = 5000; - - protected var timer:Timer; - - private var index:Number = 0; - private var selectedStock:Stock; - private var _strand:IStrand; - - public function set strand(value:IStrand):void - { - _strand = value; - - var view:LaunchView = value as LaunchView; - view.addEventListener("addSymbol", handleAddSymbol); - view.addEventListener("removeSymbol", handleRemoveSymbol); - view.addEventListener("symbolSelected", handleGridSelection); - } - - private var _model:IBeadModel; - public function set model(value:IBeadModel):void - { - _model = value; - } - public function get model():IBeadModel - { - return _model; - } - - private function handleAddSymbol(event:Event):void - { - var view:LaunchView = _strand as LaunchView; - var symbol:String = view.symbolInput.text.toUpperCase(); - var shares:Number = Number(view.sharesInput.text); - if (isNaN(shares) || shares < 0) shares = 0; - - (model as ProductsModel).addStockToAssetList(symbol, shares); - (model as ProductsModel).saveDataToStorage(); - - subscribe(); - - view.symbolInput.text = ""; - view.sharesInput.text = ""; - view.addButton.text = "Add"; - } - - private function handleGridSelection(event:Event):void - { - var view:LaunchView = _strand as LaunchView; - var index:int = view.assetGrid.selectedIndex; - var data:Object = (model as ProductsModel).assetList.getItemAt(index); - view.symbolInput.text = data.symbol; - view.sharesInput.text = String(data.shares); - - view.addButton.text = "Change"; - } - - public function handleRemoveSymbol(event:Event):void - { - var view:LaunchView = _strand as LaunchView; - var index:int = view.assetGrid.selectedIndex; - if (index < 0) return; - - (model as ProductsModel).removeStockFromAssetListAtIndex(index); - - view.symbolInput.text = ""; - view.sharesInput.text = ""; - - view.addButton.text = "Add"; - } - - public function subscribe():void - { - if (!timer.running) - { - timer.start(); - } - } - - public function unsubscribe():void - { - if (timer.running) - { - timer.stop(); - } - } - - /** - * Each time the handler goes off a different stock in the list - * is updated. This keeps the app from sending too many requests - * all at once. - */ - protected function timerHandler(event:*):void - { - var stockList:ArrayList = (model as ProductsModel).assetList; - - if (stockList.length == 0) return; - - if (index >= stockList.length) index = 0; - - (model as ProductsModel).updateStockData(stockList.getItemAt(index) as Stock); - index++; - - var newEvent:Event = new Event("update"); - model.dispatchEvent(newEvent); - } - } -} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e75059f7/examples/flexjs/MobileStocks/src/controller/WatchListController.as ---------------------------------------------------------------------- diff --git a/examples/flexjs/MobileStocks/src/controller/WatchListController.as b/examples/flexjs/MobileStocks/src/controller/WatchListController.as deleted file mode 100644 index 0d94e5f..0000000 --- a/examples/flexjs/MobileStocks/src/controller/WatchListController.as +++ /dev/null @@ -1,139 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// -// Licensed to the Apache Software Foundation (ASF) under one or more -// contributor license agreements. See the NOTICE file distributed with -// this work for additional information regarding copyright ownership. -// The ASF licenses this file to You under the Apache License, Version 2.0 -// (the "License"); you may not use this file except in compliance with -// the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -//////////////////////////////////////////////////////////////////////////////// -package controller -{ - import models.ProductsModel; - import models.Stock; - - import org.apache.flex.core.IBeadController; - import org.apache.flex.core.IBeadModel; - import org.apache.flex.core.IStrand; - import org.apache.flex.events.Event; - import org.apache.flex.events.EventDispatcher; - import org.apache.flex.utils.Timer; - import org.apache.flex.collections.ArrayList; - - import views.StockView; - import views.WatchListView; - - public class WatchListController extends EventDispatcher implements IBeadController - { - public function WatchListController() - { - super(); - - timer = new Timer(updateInterval, 0); - timer.addEventListener("timer", timerHandler); - } - - public var updateInterval:Number = 5000; - - protected var timer:Timer; - - private var index:Number = 0; - private var selectedStock:Stock; - private var _strand:IStrand; - - public function set strand(value:IStrand):void - { - _strand = value; - - var view:WatchListView = value as WatchListView; - view.addEventListener("addSymbol", handleAddSymbol); - view.addEventListener("stockSelected", handleGridSelection); - } - - private var _model:IBeadModel; - public function set model(value:IBeadModel):void - { - _model = value; - } - public function get model():IBeadModel - { - return _model; - } - - private function handleAddSymbol(event:Event):void - { - var view:WatchListView = _strand as WatchListView; - var symbol:String = view.symbolName.text.toUpperCase(); - - view.symbolName.text = ""; - - (model as ProductsModel).addStockToWatchList(symbol); - (model as ProductsModel).saveDataToStorage(); - - subscribe(); - } - - private function handleGridSelection(event:Event):void - { - var view:WatchListView = _strand as WatchListView; - selectedStock = (model as ProductsModel).watchList.getItemAt(view.selectedStockIndex) as Stock; - trace("Selected stock "+selectedStock.symbol); - - var stockView:StockView = view.showStockDetails(selectedStock); - stockView.addEventListener("removeFromList", handleRemoveFromList); - } - - public function handleRemoveFromList(event:Event):void - { - (model as ProductsModel).removeStockFromWatchList(selectedStock); - - var view:WatchListView = _strand as WatchListView; - view.popView(); - } - - public function subscribe():void - { - if (!timer.running) - { - timer.start(); - } - } - - public function unsubscribe():void - { - if (timer.running) - { - timer.stop(); - } - } - - /** - * Each time the handler goes off a different stock in the list - * is updated. This keeps the app from sending too many requests - * all at once. - */ - protected function timerHandler(event:*):void - { - var stockList:ArrayList = (model as ProductsModel).watchList; - - if (stockList.length == 0) return; - - if (index >= stockList.length) index = 0; - - (model as ProductsModel).updateStockData(stockList.getItemAt(index) as Stock); - index++; - - var newEvent:Event = new Event("update"); - model.dispatchEvent(newEvent); - } - } -} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e75059f7/examples/flexjs/MobileStocks/src/main/flex/MobileStocks.mxml ---------------------------------------------------------------------- diff --git a/examples/flexjs/MobileStocks/src/main/flex/MobileStocks.mxml b/examples/flexjs/MobileStocks/src/main/flex/MobileStocks.mxml new file mode 100644 index 0000000..1d30b37 --- /dev/null +++ b/examples/flexjs/MobileStocks/src/main/flex/MobileStocks.mxml @@ -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. + +--> +<cordova:Application xmlns:fx="http://ns.adobe.com/mxml/2009" + xmlns:local="*" + xmlns:models="models.*" + xmlns:views="views.*" + xmlns:js="library://ns.apache.org/flexjs/basic" + xmlns:cordova="library://ns.apache.org/flexjs/cordova" + > + <fx:Declarations> + <!-- Place non-visual elements (e.g., services, value objects) here --> + </fx:Declarations> + + <js:valuesImpl> + <js:SimpleCSSValuesImpl /> + </js:valuesImpl> + + <js:model> + <models:ProductsModel /> + </js:model> + + <js:initialView> + <local:MyInitialView width="100%" height="100%" className="InitalView" /> + </js:initialView> + + <js:beads> + <cordova:Weinre guid="aharui" /> + <js:MixinManager /> + <js:DeviceSizeBead /> + </js:beads> + + +</cordova:Application> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e75059f7/examples/flexjs/MobileStocks/src/main/flex/MyInitialView.mxml ---------------------------------------------------------------------- diff --git a/examples/flexjs/MobileStocks/src/main/flex/MyInitialView.mxml b/examples/flexjs/MobileStocks/src/main/flex/MyInitialView.mxml new file mode 100755 index 0000000..b6853e2 --- /dev/null +++ b/examples/flexjs/MobileStocks/src/main/flex/MyInitialView.mxml @@ -0,0 +1,253 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + +Licensed to the Apache Software Foundation (ASF) under one or more +contributor license agreements. See the NOTICE file distributed with +this work for additional information regarding copyright ownership. +The ASF licenses this file to You under the Apache License, Version 2.0 +(the "License"); you may not use this file except in compliance with +the License. You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +--> +<js:View xmlns:fx="http://ns.adobe.com/mxml/2009" + xmlns:local="*" + xmlns:js="library://ns.apache.org/flexjs/basic" + xmlns:views="views.*" + xmlns:apache="org.apache.flex.html.beads.*" + xmlns:html="org.apache.flex.html.*" + xmlns:controller="controller.*" + initComplete="onInitComplete()" xmlns:models="models.*" > + + <fx:Style> + @namespace js "library://ns.apache.org/flexjs/basic"; + @namespace views "views.*"; + + js|Container { + background-color: #FFFFFF; + } + + js|TextInput { + font-size: 10pt; + } + + js|Label { + font-size: 8pt; + } + + js|StackedViewManager { + padding-top: 0px; + padding-bottom: 0px; + padding-left: 0px; + padding-right: 0px; + } + + js|TabbedViewManager { + position : absolute ; + height : 100% ; + width : 100% ; + left : 0px ; + top : 0px ; + border: solid 1px #444444; + background-color: #FFFFFF; + } + + .NavigationBar { + background-image: url("assets/background.png"); + height: 56px; + width: 100%; + IBeadLayout: ClassReference("org.apache.flex.html.beads.layouts.HorizontalLayout"); + } + + .TabBar { + background-color: #DEDEDE; + height: 55px; + vertical-align: middle; + line-height: 55px; + } + + .BackButton:hover { + background-image: url('assets/arrow_left_24.png'); + } + + .BackButton:active { + background-image: url('assets/arrow_left_24.png'); + } + + .BackButton { + background-image: url('assets/arrow_left_24.png'); + } + + views|LaunchView { + width: 100%; + height: 100%; + IBeadController:ClassReference('controller.LaunchViewController'); + background-color: #FFFFFF; + } + + views|WatchListView { + width: 100%; + height: 100%; + IBeadController:ClassReference('controller.WatchListController'); + background-color: #FFFFFF; + } + + .WatchListInner { + height: 480px; + width: 100%; + background-color: #FFFFFF; + } + + .WatchListDataGrid { + height: 480px; + width: 100%; + } + + .WatchListInputArea { + background-color: #FFFFFF; + width: 480px; + height: 25px; + padding-top: 5px; + padding-bottom: 2px; + } + + views|StockView { + width: 100%; + height: 100%; + } + + .redCell { + color: #FF0000; + } + + .greenCell { + color: #00FF00; + } + + .ViewTitle { + font-size: 18pt; + font-weight: bold; + padding: 10pt; + } + + .StockName { + font-size: 14pt; + font-weight: normal; + padding: 10pt; + } + + .StockDetailArea { + padding: 10pt; + } + + .StockLabel { + font-size: 18pt; + font-weight: normal; + color: #2255DD; + } + + .StockRemoveButton { + background-color: #FF5522; + font-size: 16pt; + font-weight: bold; + color: #FFFFFF; + width: 200px; + height: 50px; + } + + .StockRemoveButton:hover { + background-color: #DD3300; + } + + .StockValue { + font-size: 18pt; + font-weight: normal; + color: #999999; + } + + @media -flex-flash + { + .NavigationBar { + IBackgroundBead: ClassReference("org.apache.flex.html.beads.BackgroundImageBead"); + } + } + + </fx:Style> + + <fx:Script> + <![CDATA[ + import org.apache.flex.core.IBeadController; + import org.apache.flex.core.IBeadModel; + import org.apache.flex.events.Event; + import org.apache.flex.mobile.IViewManagerView; + import org.apache.flex.mobile.IViewManager; + import org.apache.flex.mobile.chrome.NavigationBar; + + import models.ProductsModel; + + private function onInitComplete():void + { + (applicationModel as ProductsModel).loadDataFromStorage(); + } + + /* debugging */ + private function tabbedViewChanged(event:org.apache.flex.events.Event):void + { + //var manager:IViewManager = event.currentTarget as IViewManager; + //trace("TabbedViewChanged for "+manager); + } + + private function watchListStackChanged(event:org.apache.flex.events.Event):void + { + //trace("watchlist stack changed"); + var manager:StackedViewManager = event.currentTarget as StackedViewManager; + + var currentView:IViewManagerView = manager.selectedView; + backButton.visible = manager.views.length > 1; + } + + private function goBack(event:org.apache.flex.events.MouseEvent):void + { + if (navController.selectedIndex == 1) { + watchListStack.pop(); + } + } + ]]> + </fx:Script> + + <js:beads> + <js:ViewDataBinding /> + </js:beads> + + <js:TabbedViewManager id="navController" width="100%" height="100%" x="0" y="0" viewChanged="tabbedViewChanged(event)"> + <js:navigationBarItems> + <js:TextButton id="backButton" width="45" height="45" className="BackButton" visible="false" click="goBack(event)"> + <js:beads> + <apache:ImageButtonView /> + </js:beads> + </js:TextButton> + <js:Image source="assets/logo.png" width="218" height="55" /> + </js:navigationBarItems> + <js:views> + <js:StackedViewManager title="Assets"> + <js:views> + <views:LaunchView id="assetsView" title="Assets" dataModel="{applicationModel}" /> + </js:views> + </js:StackedViewManager> + + <js:StackedViewManager id="watchListStack" title="Watch List" viewChanged="watchListStackChanged(event)"> + <js:views> + <views:WatchListView id="watchListView" dataModel="{applicationModel}"/> + </js:views> + </js:StackedViewManager> + </js:views> + </js:TabbedViewManager> + +</js:View> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e75059f7/examples/flexjs/MobileStocks/src/main/flex/StockDataJSONItemConverter.as ---------------------------------------------------------------------- diff --git a/examples/flexjs/MobileStocks/src/main/flex/StockDataJSONItemConverter.as b/examples/flexjs/MobileStocks/src/main/flex/StockDataJSONItemConverter.as new file mode 100755 index 0000000..92a75dc --- /dev/null +++ b/examples/flexjs/MobileStocks/src/main/flex/StockDataJSONItemConverter.as @@ -0,0 +1,41 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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"] == null) return "No Data"; + if (obj["query"]["count"] == 0) + return "No Data"; + + obj = obj["query"]["results"]["quote"]; + return obj; + } + } +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e75059f7/examples/flexjs/MobileStocks/src/main/flex/VerticalLayoutTextView.mxml ---------------------------------------------------------------------- diff --git a/examples/flexjs/MobileStocks/src/main/flex/VerticalLayoutTextView.mxml b/examples/flexjs/MobileStocks/src/main/flex/VerticalLayoutTextView.mxml new file mode 100755 index 0000000..0353195 --- /dev/null +++ b/examples/flexjs/MobileStocks/src/main/flex/VerticalLayoutTextView.mxml @@ -0,0 +1,68 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + +Licensed to the Apache Software Foundation (ASF) under one or more +contributor license agreements. See the NOTICE file distributed with +this work for additional information regarding copyright ownership. +The ASF licenses this file to You under the Apache License, Version 2.0 +(the "License"); you may not use this file except in compliance with +the License. You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +--> +<js:View xmlns:fx="http://ns.adobe.com/mxml/2009" + xmlns:js="library://ns.apache.org/flexjs/basic" + > + + <fx:Style> + @namespace js "library://ns.apache.org/flexjs/basic"; + @namespace views "views.*"; + + .TopContainer { + background-color: #FFFFCC; + } + + .MidContainer { + background-color: #FFCCFF; + } + + .BotContainer { + background-color: #CCFFFF; + } + + </fx:Style> + + <fx:Script> + <![CDATA[ + + ]]> + </fx:Script> + + <js:beads> + <js:ViewDataBinding /> + </js:beads> + + <js:VContainer width="100%" height="100%"> + + <js:Container width="100%" height="25%" className="TopContainer"> + <js:Label text="Top Container: 25%" /> + </js:Container> + + <js:Container width="100%" height="50%" className="MidContainer"> + <js:Label text="Middle Container: 50%" /> + </js:Container> + + <js:Container width="100%" height="25%" className="BotContainer"> + <js:Label text="Bottom Container: 25%" /> + </js:Container> + + </js:VContainer> + +</js:View> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e75059f7/examples/flexjs/MobileStocks/src/main/flex/assets/arrow_left_24.png ---------------------------------------------------------------------- diff --git a/examples/flexjs/MobileStocks/src/main/flex/assets/arrow_left_24.png b/examples/flexjs/MobileStocks/src/main/flex/assets/arrow_left_24.png new file mode 100755 index 0000000..a3019ba Binary files /dev/null and b/examples/flexjs/MobileStocks/src/main/flex/assets/arrow_left_24.png differ http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e75059f7/examples/flexjs/MobileStocks/src/main/flex/assets/background.png ---------------------------------------------------------------------- diff --git a/examples/flexjs/MobileStocks/src/main/flex/assets/background.png b/examples/flexjs/MobileStocks/src/main/flex/assets/background.png new file mode 100755 index 0000000..87bbd59 Binary files /dev/null and b/examples/flexjs/MobileStocks/src/main/flex/assets/background.png differ http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e75059f7/examples/flexjs/MobileStocks/src/main/flex/assets/logo.png ---------------------------------------------------------------------- diff --git a/examples/flexjs/MobileStocks/src/main/flex/assets/logo.png b/examples/flexjs/MobileStocks/src/main/flex/assets/logo.png new file mode 100755 index 0000000..0fb0f21 Binary files /dev/null and b/examples/flexjs/MobileStocks/src/main/flex/assets/logo.png differ http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e75059f7/examples/flexjs/MobileStocks/src/main/flex/controller/LaunchViewController.as ---------------------------------------------------------------------- diff --git a/examples/flexjs/MobileStocks/src/main/flex/controller/LaunchViewController.as b/examples/flexjs/MobileStocks/src/main/flex/controller/LaunchViewController.as new file mode 100644 index 0000000..2b88d26 --- /dev/null +++ b/examples/flexjs/MobileStocks/src/main/flex/controller/LaunchViewController.as @@ -0,0 +1,150 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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 controller +{ + import models.ProductsModel; + import models.Stock; + + import org.apache.flex.core.IBeadController; + import org.apache.flex.core.IBeadModel; + import org.apache.flex.core.IStrand; + import org.apache.flex.events.Event; + import org.apache.flex.events.EventDispatcher; + import org.apache.flex.utils.Timer; + import org.apache.flex.collections.ArrayList; + + import views.LaunchView; + + public class LaunchViewController extends EventDispatcher implements IBeadController + { + public function LaunchViewController() + { + super(); + + timer = new Timer(updateInterval, 0); + timer.addEventListener("timer", timerHandler); + } + + public var updateInterval:Number = 5000; + + protected var timer:Timer; + + private var index:Number = 0; + private var selectedStock:Stock; + private var _strand:IStrand; + + public function set strand(value:IStrand):void + { + _strand = value; + + var view:LaunchView = value as LaunchView; + view.addEventListener("addSymbol", handleAddSymbol); + view.addEventListener("removeSymbol", handleRemoveSymbol); + view.addEventListener("symbolSelected", handleGridSelection); + } + + private var _model:IBeadModel; + public function set model(value:IBeadModel):void + { + _model = value; + } + public function get model():IBeadModel + { + return _model; + } + + private function handleAddSymbol(event:Event):void + { + var view:LaunchView = _strand as LaunchView; + var symbol:String = view.symbolInput.text.toUpperCase(); + var shares:Number = Number(view.sharesInput.text); + if (isNaN(shares) || shares < 0) shares = 0; + + (model as ProductsModel).addStockToAssetList(symbol, shares); + (model as ProductsModel).saveDataToStorage(); + + subscribe(); + + view.symbolInput.text = ""; + view.sharesInput.text = ""; + view.addButton.text = "Add"; + } + + private function handleGridSelection(event:Event):void + { + var view:LaunchView = _strand as LaunchView; + var index:int = view.assetGrid.selectedIndex; + var data:Object = (model as ProductsModel).assetList.getItemAt(index); + view.symbolInput.text = data.symbol; + view.sharesInput.text = String(data.shares); + + view.addButton.text = "Change"; + } + + public function handleRemoveSymbol(event:Event):void + { + var view:LaunchView = _strand as LaunchView; + var index:int = view.assetGrid.selectedIndex; + if (index < 0) return; + + (model as ProductsModel).removeStockFromAssetListAtIndex(index); + + view.symbolInput.text = ""; + view.sharesInput.text = ""; + + view.addButton.text = "Add"; + } + + public function subscribe():void + { + if (!timer.running) + { + timer.start(); + } + } + + public function unsubscribe():void + { + if (timer.running) + { + timer.stop(); + } + } + + /** + * Each time the handler goes off a different stock in the list + * is updated. This keeps the app from sending too many requests + * all at once. + */ + protected function timerHandler(event:*):void + { + var stockList:ArrayList = (model as ProductsModel).assetList; + + if (stockList.length == 0) return; + + if (index >= stockList.length) index = 0; + + (model as ProductsModel).updateStockData(stockList.getItemAt(index) as Stock); + index++; + + var newEvent:Event = new Event("update"); + model.dispatchEvent(newEvent); + } + } +}
