我正在尝试将一堆产品细节加载到List组件的canvas组件中。
每次用户点击我的列表中的产品时,产品详细信息都将显示在画布组件中。产品详细信息可能包含null,我想在显示在canvas组件中之前检查它。
在我的canvas组件中,我使用createcomplete检查productDetail == null然后执行某些操作。我的问题是,如果用户第一次点击非空详细信息的产品,如果用户单击一个空产品详细信息,因为画布组件已被删除,语句“if(productDetail == null)然后执行某些操作”将不起作用用户第一次单击非空产品详细信息时创建。
我想在每次用户点击产品时检查productDetail == null ...我希望我能很好地解释我的问题并感谢任何帮助。
我的代码..
AS
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
感谢帮助..