| <?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. |
| |
| --> |
| <basic:ViewBase xmlns:fx="http://ns.adobe.com/mxml/2009" |
| xmlns:basic="library://ns.apache.org/flexjs/basic" |
| xmlns:core="library://ns.apache.org/flexjs/core" |
| initComplete="initControls()" xmlns:mx="library://ns.adobe.com/flex/mx"> |
| <fx:Script> |
| <![CDATA[ |
| import models.MyModel; |
| |
| import org.apache.flex.events.CustomEvent; |
| |
| private var _symbol:String; |
| |
| public function get symbol():String |
| { |
| return _symbol; |
| } |
| |
| public function get requestedField():String |
| { |
| return radio1.selectedValue as String; |
| } |
| |
| private function radioChanged(e:org.apache.flex.events.Event):void |
| { |
| dispatchEvent(new CustomEvent("radioClicked")); |
| field.text = RadioButton(e.target).text; |
| } |
| |
| private function initControls():void |
| { |
| list.selectedItem = MyModel(applicationModel).stockSymbol; |
| radio1.selectedValue = MyModel(applicationModel).requestedField; |
| if (radio1.selected) |
| field.text = radio1.text; |
| else if (radio2.selected) |
| field.text = radio2.text; |
| else if (radio3.selected) |
| field.text = radio3.text; |
| else if (radio4.selected) |
| field.text = radio4.text; |
| |
| } |
| |
| private function setState():void |
| { |
| currentState = showAllData.selected ? "showAll" : "hideAll"; |
| } |
| ]]> |
| </fx:Script> |
| <fx:Style> |
| @namespace basic "library://ns.apache.org/flexjs/basic"; |
| |
| .output { |
| font-size: 20px; |
| } |
| |
| .topContainer { |
| padding: 10px; |
| |
| } |
| .leftSide { |
| vertical-align: top; |
| margin-right: 10px; |
| } |
| |
| .rightSide { |
| vertical-align: top; |
| margin-left: 10px; |
| padding-left: 10px; |
| } |
| |
| .quoteButton { |
| margin-top: 10px; |
| margin-bottom: 10px; |
| } |
| </fx:Style> |
| <basic:states> |
| <mx:State name="hideAll" /> |
| <mx:State name="showAll" /> |
| </basic:states> |
| <basic:Container x="0" y="0" className="topContainer" > |
| <basic:beads> |
| <basic:NonVirtualVerticalLayout /> |
| </basic:beads> |
| <basic:Label width="300" text="Enter Stock Symbol or choose from list:" /> |
| <basic:Container> |
| <basic:beads> |
| <basic:NonVirtualHorizontalLayout /> |
| </basic:beads> |
| <basic:Container className="leftSide"> |
| <basic:beads> |
| <basic:NonVirtualVerticalLayout /> |
| </basic:beads> |
| <basic:TextInput id="symbolTI" > |
| <basic:beads> |
| <basic:SimpleBinding eventName="stockSymbolChanged" |
| sourceID="applicationModel" |
| sourcePropertyName="stockSymbol" |
| destinationPropertyName="text" /> |
| </basic:beads> |
| </basic:TextInput> |
| <basic:TextButton text="Get Quote" className="quoteButton" |
| click="_symbol = symbolTI.text; dispatchEvent(new CustomEvent('buttonClicked'))" /> |
| <basic:Label id="field" /> |
| <basic:Label className="output" height="24"> |
| <basic:beads> |
| <basic:SimpleBinding eventName="responseTextChanged" |
| sourceID="applicationModel" |
| sourcePropertyName="responseText" |
| destinationPropertyName="text" /> |
| </basic:beads> |
| </basic:Label> |
| </basic:Container> |
| <basic:Container className="rightSide"> |
| <basic:beads> |
| <basic:NonVirtualVerticalLayout /> |
| </basic:beads> |
| <basic:DropDownList id="list" width="100" height="17" |
| change="_symbol = list.selectedItem as String; dispatchEvent(new CustomEvent('listChanged'))"> |
| <basic:beads> |
| <basic:ConstantBinding |
| sourceID="applicationModel" |
| sourcePropertyName="strings" |
| destinationPropertyName="dataProvider" /> |
| </basic:beads> |
| </basic:DropDownList> |
| <basic:RadioButton id="radio1" text="Price" value="Ask" groupName="group1" change="radioChanged(event)"/> |
| <basic:RadioButton id="radio2" text="Change" value="Change" groupName="group1" change="radioChanged(event)"/> |
| <basic:RadioButton id="radio3" text="Day's High" value="DaysHigh" groupName="group1" change="radioChanged(event)"/> |
| <basic:RadioButton id="radio4" text="Day's Low" value="DaysLow" groupName="group1" change="radioChanged(event)"/> |
| <basic:CheckBox id="showAllData" text="Show All Data" change="setState()" /> |
| </basic:Container> |
| </basic:Container> |
| <basic:Label width="300" text.showAll="110" includeIn="showAll" /> |
| <basic:TextArea id="ta" width="300" height="100" height.showAll="110" |
| includeIn="showAll"> |
| <basic:beads> |
| <basic:SimpleBinding eventName="responseDataChanged" |
| sourceID="applicationModel" |
| sourcePropertyName="allData" |
| destinationPropertyName="text" /> |
| </basic:beads> |
| </basic:TextArea> |
| </basic:Container> |
| </basic:ViewBase> |