Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I would start by adding the combobox dataproviders (a list of the values they contain) to the <code>fx:declarations</code> tag:</p> <pre><code>&lt;fx:Declarations&gt; &lt;s:ArrayList id="height_data"&gt; &lt;fx:int&gt;600&lt;/fx:int&gt; &lt;fx:int&gt;700&lt;/fx:int&gt; &lt;fx:int&gt;800&lt;/fx:int&gt; &lt;fx:int&gt;900&lt;/fx:int&gt; &lt;fx:int&gt;1000&lt;/fx:int&gt; &lt;fx:int&gt;1100&lt;/fx:int&gt; &lt;fx:int&gt;1200&lt;/fx:int&gt; &lt;fx:int&gt;1300&lt;/fx:int&gt; &lt;fx:int&gt;1400&lt;/fx:int&gt; &lt;fx:int&gt;1500&lt;/fx:int&gt; &lt;fx:int&gt;1600&lt;/fx:int&gt; &lt;fx:int&gt;1700&lt;/fx:int&gt; &lt;fx:int&gt;1800&lt;/fx:int&gt; &lt;fx:int&gt;1900&lt;/fx:int&gt; &lt;fx:int&gt;2000&lt;/fx:int&gt; &lt;/s:ArrayList&gt; &lt;!-- similar list for diameter --&gt; &lt;/fx:Declarations&gt; </code></pre> <p>Then add two comboboxes, as well as an area for output to the form (here stacked in a <code>VGroup</code>, but you can arrange them however you want):</p> <pre><code>&lt;s:VGroup&gt; &lt;s:ComboBox id="shape_height" dataProvider="{height_data}" change="calculate_volume()"&gt;&lt;/s:ComboBox&gt; &lt;s:ComboBox id="shape_diameter" dataProvider="{diameter_data}" change="calculate_volume()"&gt;&lt;/s:ComboBox&gt; &lt;s:TextArea id="output"&gt;&lt;/s:TextArea&gt; &lt;/s:VGroup&gt; </code></pre> <p>And then create a function which performs the calculation:</p> <pre><code>&lt;fx:Script&gt; &lt;![CDATA[ public function calculate_volume():void { var height:int = parseInt(shape_height.selectedItem); var diameter:int = parseInt(shape_diameter.selectedItem); if(!isNaN(height) &amp;&amp; !isNaN(diameter)) { // perform calculation // store answer in volume variable output.appendText(volume.toString() + "\n"); } } ]]&gt; &lt;/fx:Script&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload