2012-10-14 55 views
0

我有一個具有計算器名稱數組集合的應用程序。在選擇時,我想推動該項目的計算器的實際視圖。如何根據選定的數組集合推送視圖? (Flash Builder 4.6,Flex)

這裏是我的代碼有人可以幫我寫一個函數,這將允許我這樣做嗎?

<?xml version="1.0" encoding="utf-8"?> 
    <s:View xmlns:fx="http://ns.adobe.com/mxml/2009" 
title="iCalculate" 
xmlns:s="library://ns.adobe.com/flex/spark" 
xmlns:mx="library://ns.adobe.com/flex/mx" 
creationComplete="creationCompleted(event)" 
width="100%" height="100%"> 

     <s:layout> 
    <s:VerticalLayout paddingTop="10"/> 
    </s:layout> 
<fx:Script> 
    <![CDATA[ 
     import com.Watts.collections.filter.Evaluator; 
     import com.Watts.demo.Album; 

     import mx.collections.ArrayCollection; 
     import mx.events.CollectionEvent; 
     import mx.events.FlexEvent; 
     import mx.rpc.http.Operation; 

     import spark.components.Image; 
     import spark.components.ViewMenu; 
     import spark.components.gridClasses.GridColumn; 
     import spark.events.IndexChangeEvent; 
     import spark.events.TextOperationEvent; 

// Everything Below this line holds information specifically relating to Beta 2 

// Below this line is the coding for the search bar or filter bar 
     private var _collection:ArrayCollection; 
     private var _evaluator:Evaluator = new Evaluator(); 

     private function creationCompleted(event:FlexEvent):void 
     { 
      _collection = Album.collection; 
      _collection.filterFunction = filterCollection; 

      _evaluator.synonyms["four"] = new ArrayCollection(["4"]); 

      grid.dataProvider = _collection; 
     } 

     private function filterChanged(event:Event):void 
     { 
      update(); 


     } 

     private function update():void 
     { 
      _evaluator.prepare(filter.text); 
      _collection.refresh(); 

      formula.text = (_evaluator.tree) ?        _evaluator.tree.toString() : ""; 

     } 

     private function filterCollection(data:Object):Boolean 
     { 
      var labels:ArrayCollection = new ArrayCollection(); 
      for (var i:int; i < grid.columns.length; i++) 
      { 
       labels.addItem((grid.columns.getItemAt(i) as GridColumn).itemToLabel(data)); 
      } 
      return _evaluator.evaluate(labels); 
     } 

    ]]> 
</fx:Script> 


    <s:VGroup left="5" right="-9" top="5" bottom="5" width="100%" height="100%" textAlign="center"> 
    <s:TextInput id="filter" width="100%" change="filterChanged(event)"/> 
    <s:DataGrid id="grid" width="100%" height="100%" textAlign="left"> 
    </s:DataGrid> 
    <s:Label id="formula" /> 
    </s:VGroup> 
    <s:Label id="lblWattsMessage" click="navigator.pushView(views.CompanyDetail)" color="#1021C7" 
     fontFamily="_typewriter" fontSize="12" text="Powered by WATTS Professionals" 
     textAlign="center" verticalAlign="middle"/> 



</s:View> 
+0

你嘗試過什麼;你用這種方法遇到了什麼問題?我們不是在這裏爲你寫代碼;而是幫助您解決編寫代碼時遇到的問題。 – JeffryHouser

+0

我嘗試了一個列表的Flex對象列表的視圖。在我無法弄清楚如何解釋這個對象的搜索過濾器之後,我產生了這個方法。現在我再次執行推送視圖時遇到問題。盡我所能不要求別人寫我的代碼。我只是要求某人提出一個建議,讓我指出正確的方向。 –

回答

2

這是我用來解決這個問題的代碼。在flex應用程序中有一個可以使用的navigator.pushView組件。我遇到的問題是我沒有將視圖ID分配給每個計算器。這必須在ArrayCollection容器中完成。

navigator.pushview(ViewID

相關問題