Setting position of Alert control in Flex
It seems, there is no direct way of setting position (x, y) of Alert control in Flex 2. The trivial method (setting x, y) is either buggy or there must be some official way, which I am not aware of.
I found some different ways to do that:-
var alert:Alert = Alert.show("Can you see me on random positions?",
"I am an Alert box", Alert.YES | Alert.NO,
this, alertClickHandler, null, Alert.NO);
PopUpManager.centerPopUp (alert);
var newX:Number = 200;
var newY:Number = 200;
alert.move (newX, newY)
var alert:Alert = Alert.show("Can you see me on random positions?",
"I am an Alert box", Alert.YES | Alert.NO,
this, alertClickHandler, null, Alert.NO);
var newX:Number = 200;
var newY:Number = 200;
callLater (alert.move, [newX, newY]);
Following, to me, sounds like a little expensive because we are asking for the immediate validation.
var alert:Alert = Alert.show("Can you see me on random positions?",
"I am an Alert box", Alert.YES | Alert.NO,
this, alertClickHandler, null, Alert.NO);
var newX:Number = 200;
var newY:Number = 200;
alert.validateNow ();
alert.move (newX, newY);
Technorati tags: flex, alert, position, actionscript



Hello,
Cool stuff…
The centerPopUp method centers the popup relative to it’s parent so another way to place it at certain position is by setting a specific parent component.
@John: Right, that’s a workaround to invoke validate the Alert before setting the properties. All of the above methods invalidate and set the property and invalidate…
I am still trying to figure out the reason, I am looking into the code to find the issue with it…
-abdul
Hi!
I solved the problem with
myControl=myControlClass(PopUpManager.createPopUp(DisplayObject(Application.application.parentDocument),intervalSelector,true));
PopUpManager.centerPopUp(myControl);
Thanks! I struggled with this, appreciate it!