나는 Winforms와 WPF 모두에서 C# 프로그래밍을 많이 해왔다. 현재 크로스 플랫폼 지원을 위해 Flex/Air 앱을 개발하고 있습니다. 하지만 이것은 내 첫 번째 플렉스 프로젝트이므로, 제가 배우는대로 배우고 있습니다.플렉스 : 팝업 창 - [ok] 또는 [취소]
팝업 창이있어서 사용자가 양식을 작성한 다음 OK 또는 CANCEL을 누릅니다. C#에서와 같은 방식으로 설정했지만 작동하지 않으며 실제로 원하는대로 할 수있는 방법을 볼 수 없습니다.
는편집 : 그래서 시도하고 이벤트가 이제 이벤트가 바로 처리하지 않는 것 ...
편집 다시는 : 아, 팝업 관리자의 새 인스턴스를 만들 것으로 보인다 있기 때문에 이미 만든 객체를 사용하는 대신 Form 객체를 사용합니다.
그래서이 ShowWindow 방법에, 나는 팝업 관리자 대신이 코드에 넣어 : 나는 그것을 닫을 때parent.addChild(this);
는 나는 그것을 제거합니다. 유일한 문제는 팝업 관리자처럼 부모의 나머지 부분을 사용 중지하지 않는다는 것입니다. 그것에 관한 어떤 제안?
부모 :
private function btnAdd_Clicked():void
{
var form:Form = new Form();
form.addEventListener(CloseEvent.CLOSE, onFormClosed, false, 0, true);
recipeForm.showWindow(this);
}
private function onFormClosed(e:CloseEvent):void
{
//none of these Alerts are ever shown. I also tried breakpoints in debug to try an follow the code, with no luck
Alert.show("Closed");
if(e.detail == Alert.OK)
{
Alert.show("OK");
}
else if(e.detail == Alert.CANCEL)
{
Alert.show("Cancel");
}
}
아동 :
private function btnCancel_Clicked():void
{
okClicked = false;
closeWindow();
}
public function closeWindow():void
{
var e:CloseEvent = new CloseEvent(CloseEvent.CLOSE);
e.detail = okClicked ? Alert.OK : Alert.CANCEL;
dispatchEvent(e);
PopUpManager.removePopUp(this);
}
public function showWindow(parent:WindowedApplication):void
{
var window:IFlexDisplayObject = PopUpManager.createPopUp(parent, RecipeForm, true);
PopUpManager.centerPopUp(window);
}
이 보인다,하지만 사건은 그냥 ... 처리하지 않는 것 아이 : 공공 기능 closeWindow() : 무효 { \t VAR 전자 : CloseEvent = 새로운 CloseEvent (CloseEvent. 닫기); \t e.detail = okClicked? 알리. 알. 카셀; \t dispatchEvent (e); \t \t PopUpManager.removePopUp (this); } 상위 : btnAddRecipe_Clicked 개인 함수() {공백 \t \t \t \t \t VAR의 recipeForm : RecipeForm = 새로운 RecipeForm(); \t recipeForm.addEventListener (CloseEvent.CLOSE, onRecipeFormClosed, false, 0, true); \t \t recipeForm.showWindow (this); } 개인 기능 onRecipeFormClosed (예 : CloseEvent) : 는 { 가져 결코 // 무효가 여기에 도착 ... :/ } – Joel
오, 코멘트 oopps ... 난거야 ... 줄 바꿈 허용하지 않습니다 그것을 원래 게시물로 편집하십시오. – Joel
showWindow()가 RecipeForm 클래스의 새로운 인스턴스를 반환하는 것처럼 보입니다. 해당 클래스에 이벤트 리스너를 연결하려고합니다. 이벤트를 보낸 객체는 리스너가 등록 된 객체와 동일한 객체 여야합니다. –