【发布时间】:2010-07-04 20:30:34
【问题描述】:
我正在尝试将一堆产品详细信息从 List 组件加载到画布组件中。
每次用户点击我的列表中的产品时,产品详细信息都会显示在画布组件中。产品详细信息可能包含 null,我想在我的画布组件中显示之前对其进行检查。
在我的画布组件中,我使用 createcomplete 检查 productDetail==null 是否然后执行某些操作。我的问题是,如果用户第一次单击具有非空详细信息的产品,如果用户单击空产品详细信息,则语句“if (productDetail==null) then do something”将不起作用,因为画布组件已在用户第一次单击非空产品详细信息时创建。
我想在每次用户点击产品时检查 productDetail==null...我希望我能很好地解释我的问题并感谢任何帮助。
我的代码..
作为:
protected function changeHandler(event:IndexChangeEvent):void{
compDetailinfoResult.token=getCompList.compDetail(event.target.selectedItem.productId);//get the product detail clicked by the user
}
<s:List dataProvider={productData}/> //when user click a product,
//the canvas will show product detail..
<comp:productDetail productData={compDetailinfoResult.lastResult} //custom property
change="changeHandler"/> //if the product detail is
//null, the statement inside
//the canvas will check via
//creationComplete. but if the
//user click the non-null product,
//the creationComplete check pass. User clicks a null product again,
//the check won't work anymore...
我的 productDetail 组件的代码:
public var productData:arrayCollection
protected function canvas1_creationCompleteHandler(event:FlexEvent):void
{
var undefinedBrand:String=dataFromClick.getItemAt(0).brand;
if(undefinedBrand==null){ // I want to check every time the user click a List item
brand.text="Brand: No Brand";
switchView.enabled=false;
displayPictureBig.source="assets/vacant.jpg";
}
}
<s:Panel>
<label id="brand" text="productDate.getItemAt(0).brand"/>
//I want the brand to be displayed..
//but if brand is null..it will display No Brand..
//see AC above...but createComplete only fire once.
//Anyway to keep tracking if the brand that is sent by List is null?
</s:Panel
感谢您的帮助..
【问题讨论】:
标签: apache-flex