0

我在标注中有这个 ViewNavigator,标注使用 firstView="views.ListMenusHomeView" 在其中显示一个视图。现在如何关闭 ListMenusHomeView 的标注?希望有人可以提供帮助。

这是我的标注代码:

<?xml version="1.0" encoding="utf-8"?>
<s:Callout xmlns:fx="http://ns.adobe.com/mxml/2009" 
           xmlns:s="library://ns.adobe.com/flex/spark"
           contentBackgroundAppearance="none"
           height="300" width="300"> 
    <fx:Declarations>
        <fx:XML id="menu" source="xmldata/menu2.xml" /> 
    </fx:Declarations>

    <fx:Script>
        <![CDATA[

            import spark.events.PopUpEvent;
            protected function back(event:MouseEvent):void {

                if(viewNav.length>1)
                    viewNav.popView();
            }


        ]]>
    </fx:Script>

    <s:ViewNavigator id="viewNav" width="100%" height="100%" firstView="views.ListMenusHomeView">
        <s:navigationContent>
            <s:Button label="Back" click="back(event)"/>
        </s:navigationContent>
        <s:actionContent>
            <s:Button label="Cancel" click="close(false)"  emphasized="true"/>
        </s:actionContent>
    </s:ViewNavigator>

</s:Callout>

您会看到有一个 ViewNavigator 包含 ListMenusHomeView。这是 ListMenusHomeView 的代码。

<?xml version="1.0" encoding="utf-8"?>
<s:View xmlns:fx="http://ns.adobe.com/mxml/2009" 
    xmlns:s="library://ns.adobe.com/flex/spark" title="Main Menu" creationComplete="onCreationComplete()">

<fx:Declarations>
    <fx:XML id="menu" source="xmldata/menu2.xml" /> 
</fx:Declarations>

<fx:Script>
    <![CDATA[

        import com.adobe.serializers.xml.XMLDecoder;

        import mx.collections.ArrayCollection;

        import spark.events.IndexChangeEvent;

        [Bindable]
        private var dataArray:ArrayCollection = new ArrayCollection();  

        private var object:DataArray = new DataArray();

        private function onCreationComplete() : void{

            var decoder:XMLDecoder = new XMLDecoder();
            var resultObj:Object = decoder.decode(menu);    

            dataArray = object.onCreationComplete(menu, menu.menuitem, resultObj, resultObj.menuitem); 

        }

        protected function list1_changeHandler(event:IndexChangeEvent):void
        {

        }



    ]]>
</fx:Script>

<s:List id="tileLayout"
        width="100%" height="100%"
        verticalScrollPolicy="off" horizontalScrollPolicy="on"
        pageScrollingEnabled="true" dataProvider="{dataArray}"
        itemRenderer="renderers.iconList2" change="list1_changeHandler(event)">
    <s:layout>
        <s:TileLayout orientation="columns" requestedRowCount="3" 

                      verticalGap="20" horizontalGap="20"/>

    </s:layout>

</s:List>

现在,每当我单击 ListMenusHomeView 中的图标时,我都想关闭 MyCallout。函数 list1_changeHandler(event:IndexChangeEvent) 负责那个。

我该怎么办?

4

1 回答 1

0

该类Callout有一个close()方法,因此您基本上只需要访问ListMenusHomeViews parentDocument(这将是您的“viewNav” ViewNavigator)及其parentDocument应该是您的 ListMenusHomeView。

我尚未对其进行测试,但您可能会摆弄parentDocument,parentowner属性来访问正确的对象。通过简单的跟踪尝试它们,您将立即启动并运行。

于 2012-08-16T06:30:06.697 回答