【问题标题】:How to Push a View Based on a selected Array Collection? (Flash Builder 4.6 , Flex)如何根据选定的数组集合推送视图? (Flash Builder 4.6,Flex)
【发布时间】:2012-10-14 16:11:08
【问题描述】:

我有一个具有计算器名称数组集合的应用程序。选择后,我想为该项目推送计算器的实际视图。

这是我的代码,有人可以帮我编写一个允许我这样做的函数吗?

<?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>

【问题讨论】:

  • 你试过什么;你用这种方法有什么问题?我们不是来为你写代码的;而是帮助您解决编写代码时遇到的问题。
  • 我尝试了一个数组列表,其中包含 flex 对象列表 SD 视图。在我无法弄清楚如何解释对象的搜索过滤器之后,我使用了这种方法。现在我再次无法执行推送视图。无论如何,我并不是在要求某人编写我的代码。我只是要求某人提出建议,为我指明正确的方向。

标签: apache-flex list pushviewcontroller flash-builder arraycollection


【解决方案1】:

这是我用来解决此问题的代码。在 flex 应用程序中,有一个可以使用的 navigator.pushView 组件。我遇到的问题是我没有为每个计算器分配视图 ID。这必须在 ArrayCollection 容器中完成。

navigator.pushview(ViewID)

【讨论】:

    猜你喜欢
    • 2013-10-22
    • 1970-01-01
    • 2012-03-28
    • 1970-01-01
    • 1970-01-01
    • 2012-11-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多