Я пытаюсь загрузить детали продукта в компонент Canvas из компонента List.
Каждый раз, когда пользователь нажимает на товар в моем Списке, информация о товаре будет отображаться в компоненте Canvas. Сведения о продукте могут содержать ноль, и я хочу проверить его перед отображением в моем компоненте холста.
В моем компоненте canvas я использую createcomplete, чтобы проверить, что productDetail == null, затем что-то сделать. Моя проблема заключается в том, что если пользователь щелкает продукт с ненулевой деталью в первый раз, оператор «если (productDetail == null) затем сделать что-то» не будет работать, если пользователь щелкнет нулевую деталь продукта, поскольку компонент canvas Создан в первый раз, когда пользователь щелкает ненулевую деталь продукта.
Я хочу проверять, равняется ли 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
Спасибо за помощь ..