Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to return a view to a selected index. flex (flash builder )
    primarykey
    data
    text
    <p>I have an ArrayCollection that shows up on the main screen of my app. I previously had my code to push a view upon a selected index. Now that I have implemented my Search Bar for this array collection. The selected index does not match the search index . Ex. selected index == 0 used to be the A1c Calculator, if some one searchs the BMI calculator it then becomes the A1c because it is now in the selected index == 0. </p> <p>How do I approach this by always pulling A1c when A1c is selected and so on and so forth, no matter what index it is. here is the code . </p> <pre><code> '&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;s:View xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" title="iCalculate"&gt; &lt;fx:Declarations&gt; &lt;!-- Place non-visual elements (e.g., services, value objects) here --&gt; &lt;/fx:Declarations&gt; &lt;s:layout&gt; &lt;s:VerticalLayout paddingTop="10"/&gt; &lt;/s:layout&gt; &lt;fx:Script&gt; &lt;![CDATA[ import mx.collections.ArrayCollection; import mx.collections.ArrayList; import mx.events.IndexChangedEvent; import mx.utils.object_proxy; import spark.collections.Sort; import spark.collections.SortField; import spark.components.Image; import spark.components.ViewMenu; import spark.events.IndexChangeEvent; // This method contains the selection assignments for the Calculator Views protected function calcList_changeHandler(event:IndexChangeEvent):void { if (calcList.selectedIndex == 0)//A1c Calculator { navigator.pushView(views.A1CCalculator); } else if (calcList.selectedIndex ==1)//BMI Calculator { navigator.pushView(views.BMI_Calculator); } else if (calcList.selectedIndex ==2)//GPA Calculator { navigator.pushView(views.GPA_Calculator); } else if (calcList.selectedIndex ==3)//TIP Calculator { navigator.pushView(views.TipCalculator); } } //Below This Line is the code for the Filter Feature private function filterList():void{ calcListCollection.filterFunction=searchList; calcListCollection.refresh(); } private function searchList(item:Object):Boolean{ var isMatch:Boolean = false if(item.name.toLowerCase().search(search.text.toLowerCase())!=-1){ isMatch = true } return isMatch; } private function clearSearch():void{ calcListCollection.filterFunction=null; calcListCollection.refresh(); search.text=""; } ]]&gt; &lt;/fx:Script&gt; &lt;s:HGroup width="100%" height="43"&gt; &lt;s:TextInput id="search" width="100%" prompt="Search iCalculate" textAlign="center" change="filterList()"/&gt; &lt;/s:HGroup&gt; &lt;s:List id="calcList" alternatingItemColors="[#e5e4e4,#ffffff]" width="100%" height="98%" labelField="name" change="calcList_changeHandler(event)"&gt; &lt;s:dataProvider&gt; &lt;s:ArrayCollection id="calcListCollection"&gt; &lt;fx:Object name="A1c Calculator" /&gt; &lt;fx:Object name="BMI Calculator" /&gt; &lt;fx:Object name="GPA Calculator" /&gt; &lt;fx:Object name="Tip Calculator" /&gt; &lt;/s:ArrayCollection&gt; &lt;/s:dataProvider&gt; &lt;/s:List&gt; &lt;s:Label width="100%" click="navigator.pushView(views.CompanyDetail)" color="#1021C7" </code></pre> <p> '</p> <p>Thank you in advance. </p> <p>Ryan </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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