我有一個高大的Flex應用程序,它使用Alert.show()顯示錯誤/警告消息。當錯誤消息集中在屏幕上時,這會產生問題,但當屏幕位於極端滾動位置(頂部或底部)時不可見。有什麼方法可以在用戶的可查看頁面的中心顯示警報。我試過以下,但沒有奏效。如何在flex中居中對齊Alert.show()
var errorMsg:Alert = Alert.show("Error message");
PopUpManager.centerPopUp(errorMsg);
在此先感謝。
我有一個高大的Flex應用程序,它使用Alert.show()顯示錯誤/警告消息。當錯誤消息集中在屏幕上時,這會產生問題,但當屏幕位於極端滾動位置(頂部或底部)時不可見。有什麼方法可以在用戶的可查看頁面的中心顯示警報。我試過以下,但沒有奏效。如何在flex中居中對齊Alert.show()
var errorMsg:Alert = Alert.show("Error message");
PopUpManager.centerPopUp(errorMsg);
在此先感謝。
這是我的問題的解決方案,我用JavaScript調用來實現這一點。
var viewPoint:Number = ExternalInterface.call("eval", "window.pageYOffset");
var browserHeight:Number = ExternalInterface.call("eval", "window.innerHeight");
//the following calculation finds the center y coordinate in user's viewable page.
var viewableY : Number = ((browserHeight/2)+viewPoint-50);
var alert : Alert = Alert.show("Error Msg");
PopUpManager.centerPopUp(alert);
alert.move(400,viewableY);
我希望這可以幫助別人......
Alert通常以您在參數中提供的父母爲中心。
在以下靜態方法父參數中使用(FlexGlobal.topLevelApplication as parent)
作爲參數。
Alert.show(text:String = "", title:String = "", flags:uint = 0x4, parent:Sprite = null, closeHandler:Function = null, iconClass:Class = null, defaultButtonFlag:uint = 0x4, moduleFactory:IFlexModuleFactory = null);
嘿宙斯,感謝您的回覆,但我的主要應用高度高一點,所以上述的解決方案並沒有幫助我。但是,通過使用JavaScript調用,我現在可以在中心顯示警報。再次感謝您的回覆。 – Ramesh