0

我在 Flash 中遇到 CalloutButtons 和容器的问题。我已经成功创建了一个标注按钮,它显示了一个可滚动的项目列表。选择一个项目后,相应的图像应显示在主视图中。

但由于某种原因,似乎出现了 2 个标注 - 当我向下滚动菜单时,一个实例关闭并传递数据(这是以前存储的数据,因为这次还没有选择数据)。 ...当我确实选择了一个项目时,列表会关闭,但不会再次调用 closeHandler。

问题似乎是当单击 calloutButton 时,Flex 会自动创建一个标注容器。我怎样才能禁用它?

或者换成我的...

谢谢

编辑 - 这是我的代码:

PrimaryCallout.mxml

<?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"
           xmlns:weapons="services.weapons.*">
    <fx:Script>
        <![CDATA[
            import mx.events.FlexEvent;
            import assets.dataFiles.Loadout;
            import spark.events.IndexChangeEvent;

            protected function list_creationCompleteHandler(event:FlexEvent):void
            {
                getDataResult.token = weapons.getData();
            }

            protected function list_ChangeHandler(event:IndexChangeEvent):void
            {   
                close(false);
                Loadout.primaryImage    = list.selectedItem.ImgID;
                Loadout.primaryTitle    = list.selectedItem.WeapName;

            }

        ]]>
    </fx:Script>
    <fx:Declarations>
        <s:CallResponder id="getDataResult"/>
        <weapons:Weapons id="weapons"/>
        <!-- Place non-visual elements (e.g., services, value objects) here -->
    </fx:Declarations>

        <s:List id="list" width="240" height="100%" change="list_ChangeHandler(event)"
                creationComplete="list_creationCompleteHandler(event)"
                labelField="WeapName">
            <s:AsyncListView list="{getDataResult.lastResult}"/>
        </s:List>
</s:Callout>

加载视图.mxml

    <?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"
        xmlns:weapons="services.weapons.*"
        xmlns:callouts="views.callouts.*"
        title="Loadout">
    <fx:Script>
        <![CDATA[
            import mx.events.FlexEvent;

            import spark.events.DropDownEvent;

            import assets.dataFiles.Loadout;
            import views.callouts.PrimaryCallout;



            protected function calloutbutton1_openHandler(event:MouseEvent):void
            {
                var primaryCallout:PrimaryCallout = new PrimaryCallout();

                primaryCallout.open(primary, true);
            }


            protected function list_creationCompleteHandler(event:FlexEvent):void
            {
                getDataResult.token = weapons.getData();
                //weaponImage.source = "assets/weapons/{Loadout.primaryImage}";
            }

            protected function primary_closeHandler(event:DropDownEvent):void
            {
                //primary.label = Loadout.primaryTitle;
                weaponImage.source      = "assets/weapons/"+ (Loadout.primaryImage);

            }

        ]]>
    </fx:Script>
    <fx:Declarations>
        <s:CallResponder id="getDataResult"/>
        <weapons:Weapons id="weapons"/>
        <!-- Place non-visual elements (e.g., services, value objects) here -->
    </fx:Declarations>

    <s:Image x="0" y="0" width="100%" height="100%" scaleMode="stretch" smooth="true"
             source="assets/06iOS.jpg"/>
    <s:CalloutButton id="primary" x="10" y="10" height="56" label="Primary" fontStyle="normal"
                     fontWeight="normal" lineThrough="false"
                     click="calloutbutton1_openHandler(event)" textDecoration="none" close="primary_closeHandler(event)"/>
    <s:Image id="weaponImage" x="10" y="74" width="240" height="105"
             source="assets/weapons/{data.ImgID}"/>
</s:View>
4

1 回答 1

1

感谢您的代码。您的两个 Callout 实例的原因是您使用了CalloutButton一个单独的Callout. 鉴于CalloutButton创建自己的实例,Callout你最终会同时拥有CalloutButton's defaultCallout和你自己创建的实例。

您需要更改的是使用您PrimaryCallout的通用按钮(这将需要您自己处理打开/关闭操作)或使用CalloutButton's 默认值Callout

于 2012-09-20T07:40:40.867 回答