| <?xml version="1.0" encoding="utf-8"?> |
| <!-- |
| |
| Licensed to the Apache Software Foundation (ASF) under one or more |
| contributor license agreements. See the NOTICE file distributed with |
| this work for additional information regarding copyright ownership. |
| The ASF licenses this file to You under the Apache License, Version 2.0 |
| (the "License"); you may not use this file except in compliance with |
| the License. You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
| |
| --> |
| <js:View xmlns:fx="http://ns.adobe.com/mxml/2009" |
| xmlns:js="library://ns.apache.org/flexjs/basic" |
| initComplete="initControls()"> |
| <fx:Script> |
| <![CDATA[ |
| import models.MyModel; |
| |
| import org.apache.flex.events.CustomEvent; |
| |
| private var _symbol:String; |
| |
| public function get symbol():String |
| { |
| return _symbol; |
| } |
| |
| public function get requestedField():String |
| { |
| return radio1.selectedValue as String; |
| } |
| |
| [Bindable] |
| public var fieldText:String; |
| |
| private function radioChanged(e:org.apache.flex.events.Event):void |
| { |
| dispatchEvent(new CustomEvent("radioClicked")); |
| fieldText = RadioButton(e.target).text; |
| } |
| |
| private function initControls():void |
| { |
| list.selectedItem = MyModel(applicationModel).stockSymbol; |
| radio1.selectedValue = MyModel(applicationModel).requestedField; |
| if (radio1.selected) |
| fieldText = radio1.text; |
| else if (radio2.selected) |
| fieldText = radio2.text; |
| else if (radio3.selected) |
| fieldText = radio3.text; |
| else if (radio4.selected) |
| fieldText = radio4.text; |
| |
| } |
| |
| private function setState():void |
| { |
| currentState = showAllData.selected ? "showAll" : "hideAll"; |
| } |
| ]]> |
| </fx:Script> |
| <fx:Style> |
| @namespace basic "library://ns.apache.org/flexjs/basic"; |
| |
| .output { |
| font-size: 20px; |
| } |
| |
| .topContainer { |
| padding: 10px; |
| |
| } |
| .leftSide { |
| vertical-align: top; |
| margin-right: 10px; |
| } |
| |
| .rightSide { |
| vertical-align: top; |
| margin-left: 10px; |
| padding-left: 10px; |
| } |
| |
| .quoteButton { |
| margin-top: 10px; |
| margin-bottom: 10px; |
| } |
| </fx:Style> |
| <js:states> |
| <js:State name="hideAll" /> |
| <js:State name="showAll" /> |
| </js:states> |
| <js:beads> |
| <js:ViewDataBinding /> |
| </js:beads> |
| <js:Container x="0" y="0" className="topContainer" > |
| <js:beads> |
| <js:VerticalLayout /> |
| </js:beads> |
| <js:Label width="300" text="Enter Stock Symbol or choose from list:" /> |
| <js:Container> |
| <js:beads> |
| <js:HorizontalLayout /> |
| </js:beads> |
| <js:Container className="leftSide"> |
| <js:beads> |
| <js:VerticalLayout /> |
| </js:beads> |
| <js:TextInput id="symbolTI" text="{MyModel(applicationModel).stockSymbol}" /> |
| <js:TextButton text="Get Quote" className="quoteButton" |
| click="_symbol = symbolTI.text; dispatchEvent(new CustomEvent('buttonClicked'))" /> |
| <js:Label id="field" text="{fieldText}"/> |
| <js:Label className="output" height="24" text="{MyModel(applicationModel).responseText}" /> |
| </js:Container> |
| <js:Container className="rightSide"> |
| <js:beads> |
| <js:VerticalLayout /> |
| </js:beads> |
| <js:DropDownList id="list" width="100" |
| change="_symbol = list.selectedItem as String; dispatchEvent(new CustomEvent('listChanged'))" |
| dataProvider="{MyModel(applicationModel).strings}" /> |
| <js:RadioButton id="radio1" text="Price" value="Ask" groupName="group1" change="radioChanged(event)"/> |
| <js:RadioButton id="radio2" text="Change" value="Change" groupName="group1" change="radioChanged(event)"/> |
| <js:RadioButton id="radio3" text="Day's High" value="DaysHigh" groupName="group1" change="radioChanged(event)"/> |
| <js:RadioButton id="radio4" text="Day's Low" value="DaysLow" groupName="group1" change="radioChanged(event)"/> |
| <js:CheckBox id="showAllData" text="Show All Data" change="setState()" /> |
| </js:Container> |
| </js:Container> |
| <js:Label id="bindtest" text="{fieldText + ' expression binding'}" /> |
| <js:Label width="300" text.showAll="110" includeIn="showAll" /> |
| <js:TextArea id="ta" width="300" height="100" height.showAll="110" |
| includeIn="showAll" |
| text="{MyModel(applicationModel).allData}" /> |
| </js:Container> |
| </js:View> |