我想从一个列表组件中加载一堆产品详细信息到一个画布组件。替代方法creationcomplete
每次用户点击列表中的产品时,产品详细信息都将显示在画布组件中。产品详细信息可能包含null,我想在显示在我的画布组件中之前检查它。
在我的画布组件中,我使用createcomplete来检查productDetail == null是否执行某些操作。我的问题是,如果用户第一次点击具有非空细节的产品,则如果用户单击空产品细节,则“if(productDetail == null)then do something”语句不起作用,因为画布组件已经创建第一次用户点击非空产品详细信息。
我想检查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...
代码:
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
感谢您的帮助..
对不起,我感到困惑。我只在这里粘贴非常基本的代码。请参阅更新的代码... – FlyingCat 2010-07-05 01:22:20
我确实有主应用程序发送的数据。 productDetail组件接收数据并显示它。产品细节将根据用户在列表中点击的产品而改变。某些产品品牌为空,当用户点击无品牌产品时,我想显示No Brand ...感谢您的帮助...:D – FlyingCat 2010-07-05 01:35:52