ArrayCollection dataProvider가있는 목록이 있습니다. 내 프로그램에는 사용자가 목록의 selectedIndex에 대한 기능을 수행하기 위해 클릭 할 수있는 버튼이 있지만 먼저 액션을 수행 할 것인지 묻는 경고가 표시됩니다. 사용자가 Alert에 응답하면 해당 목록의 selectedIndex에 대한 작업이 수행됩니다.경고 후 목록의 selectedIndex
내 문제는 selectedItem = -1 명확하게 선택 되었음에도 불구하고 Alert 윈도우 CloseEvent 이후입니다. Alert CloseEvent 코드에서 validateNow()를 수행하여이 문제를 해결했습니다.
내 질문 : 왜이 작업을 수행해야하며 잘못 되었습니까? 또는이 정상/모범 사례입니까? 또한 try-catch를 사용하는 것 외에 어떤 것이 선택되었는지 확인하기 위해 List를 검사하는 것이 더 좋습니다. 아무 것도 선택하지 않으면 최종 사용자가 생성 된 오류를보고 싶지 않습니다.
코드 : 당신이로 validateNow()을 꺼내 경우가 selectedIndex의은 -1 생각하기 때문에
//Note: "fl" is a class with "friendsList" bindable ArrayCollection; for the sake of keeping this short I will not include it
private function _removeFriendClick(event:MouseEvent):void
{
try {
if (this.friendsList.selectedIndex != -1) {
Alert.show("Are you sure you want to remove "+this.fl.friendsList[this.friendsList.selectedIndex].label+" as a friend?", "Remove Friend", Alert.YES | Alert.CANCEL, this, this._removeFriendConfirm, null, Alert.CANCEL);
}
} catch (e:Error) { }
}
private function _removeFriendConfirm(event:CloseEvent):void
{
this.friendsList.validateNow();
trace(this.friendsList.selectedIndex);
}
그래서, 위의 코드와 함께, 예외가 발생합니다.
이것은 정상적인 동작은 아니지만 표시되는 코드는 상황을 평가하는 데 충분하지 않습니다. 함께 일할 수있는 기회를 좀 더 주어야합니다. – RIAstar
경고 창 앞에 선택한 인덱스를 저장하지 않으시겠습니까? – Anton
@RIAstar 포함시킬 항목이 무엇인지 잘 모르겠습니다. – Lyynk424