我在闪存中使用CalloutButtons和容器时遇到了问题。 我已经成功创建了一个标注按钮,该按钮会显示一个可滚动的项目列表。 选择项目后,相应的图像应显示在主视图中。
但是由于某种原因,似乎有 2 个标注被调出 - 当我向下滚动菜单时,一个实例关闭并传递数据(这是之前存储的数据,因为这次还没有选择任何数据)....当我实际选择一个项目时,列表会关闭,但不会再次调用 closeHandler。
问题似乎是 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>
LoadoutView.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>
感谢您的代码。使用两个标注实例的原因是您使用的是CalloutButton
和单独的Callout
。给定CalloutButton
创建了自己的Callout
实例,您最终会同时拥有CalloutButton
的默认Callout
,以及您自己创建的实例。
您需要更改的是将PrimaryCallout
与通用按钮一起使用(这需要您自己处理打开/关闭操作)或使用CalloutButton
的默认Callout
。