« Apple Leopard (Mac OSX 10.5) for Indian users | Main | Adobe Buzzword »

November 02, 2007

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: , , ,

Posted by Abdul Qabiz at November 2, 2007 06:33 PM

Comments

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.

Posted by: John at November 2, 2007 11:47 PM

@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

Posted by: Abdul Qabiz at November 3, 2007 02:51 AM

Hi!
I solved the problem with
myControl=myControlClass(PopUpManager.createPopUp(DisplayObject(Application.application.parentDocument),intervalSelector,true));
PopUpManager.centerPopUp(myControl);

Posted by: fabio at November 13, 2007 09:05 PM

Post a comment




Remember Me?


Please enter the security code you see here

(you may use HTML tags for style)