我在 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>