Domanda

I have a tall Flex application that uses Alert.show( ) to display error/warning messages. This created problems when the error messages were centered on the screen, but not visible when the screen was at an extreme scroll position (top or bottom). is there any way that i can display the Alert in the center of the user's viewable page. I've tried the following, but didn't work.

var errorMsg:Alert = Alert.show("Error message");
PopUpManager.centerPopUp(errorMsg);

Thanks in advance.

È stato utile?

Soluzione 2

Here is the solutions for my problem, i've used javascript calls to achieve this.

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);

I hope this helps someone...

Altri suggerimenti

Alert usually centers on the parent which you provide in the params.

Use (FlexGlobal.topLevelApplication as parent) as parameter in the following static method parent param.

Alert.show(text:String = "", title:String = "", flags:uint = 0x4, parent:Sprite = null, closeHandler:Function = null, iconClass:Class = null, defaultButtonFlag:uint = 0x4, moduleFactory:IFlexModuleFactory = null);
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top