我想從一個列表組件中加載一堆產品詳細信息到一個畫布組件。替代方法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