Today, I am going to post some thing on Popup custom settings. We can change some properties like Popup modal, transparency, color and Blur.
These properties are of style. This has been a very long avaited request from my designer friends. (especially by : Mandu)
In flex ‘<Application />’ tag has mainly four attributes related to modal properties of pop-ups.
- modalTransparency
- modalTransparencyBlur
- modalTransparencyColor
- modalTransparencyDuration
Their default values are “0.5″, “3″, “0xDDDDDD” and “100″ respectively. Changes to these properties are applicable to entire application level.
But, we can do same changes to separate components too. ( As I have shown in my example.)
Let me show… in image (1) We can see the default Alert / Popup window of flex
and in image (2) We can see the customized Alert / Popup window
and in example I have given other two options too check them.
Ya ya, you guys are more eager to see the code. Go ahead…
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="horizontal"
pageTitle="Alert / Popup / Modal Example : Mayur Rami"
modalTransparency="0.5"
modalTransparencyBlur="3"
modalTransparencyColor="0xDDDDDD"
modalTransparencyDuration="100" >
<mx:Script>
<![CDATA[
import mx.containers.TitleWindow;
import mx.managers.PopUpManager;
import mx.core.IFlexDisplayObject;
import mx.controls.Alert;
private function openPopup(eve:MouseEvent):void
{
var titleWin:TitleWindow = new TitleWindow();
titleWin.width = 250;
titleWin.height = 150;
titleWin.showCloseButton = true;
titleWin.addEventListener("close",removePopup);
switch (eve.target.label)
{
case 'Pink popup' :
titleWin.title = "Pink Window";
titleWin.setStyle("modalTrasparancy",1);
titleWin.setStyle("modalTransparencyBlur",100);
titleWin.setStyle("modalTransparencyColor",0xff6789);
titleWin.setStyle("modalTransparencyDuration",2500);
break;
case "Green popup" :
titleWin.title = "Green Window";
titleWin.setStyle("modalTrasparancy",0.2);
titleWin.setStyle("modalTransparencyBlur",5);
titleWin.setStyle("modalTransparencyColor",0x00ff67);
titleWin.setStyle("modalTransparencyDuration",1500);
break;
case 'Quick popup' :
titleWin.title = "Quick Window";
titleWin.setStyle("modalTrasparancy",0.1);
titleWin.setStyle("modalTransparencyBlur",2);
titleWin.setStyle("modalTransparencyColor",0xf0f0f0);
titleWin.setStyle("modalTransparencyDuration",5);
break;
}
PopUpManager.addPopUp(titleWin,this,true);
PopUpManager.centerPopUp(titleWin);
function removePopup():void
{
if(titleWin.title.toString() == 'Quick Window' )
{
titleWin.setStyle("modalTransparencyDuration",5);
}
else
{
titleWin.setStyle("modalTransparencyDuration",750);
}
PopUpManager.removePopUp(titleWin);
}
}
]]>
</mx:Script>
<mx:Label text="Experiments with modal popups and same way can be set custom settings for Alert, too." fontWeight="bold" />
<mx:Button label="Normal Alert" click="mx.controls.Alert.show('Alert !')" />
<mx:Button id="greenBtn" label="Green popup" click="openPopup(event)" />
<mx:Button id="pinkBtn" label="Pink popup" click="openPopup(event)" />
<mx:Button id="quick" label="Quick popup" click="openPopup(event)" />
</mx:Application>
Feel free to share your views regarding this.
Enjoy Flexing…
Filed under: Actionscript 3, Adobe, Alert, Custom Component, Flex, Flex 2, Flex 3, Popup, Transparency | Tagged: Actionscript 3, AIR, Flex 3, Flex Alert


Do you know of any way to size the width and height of the modal window? When I launch my projector file and launch a pop-up, the modal ‘background’ doesn’t cover all of my content and is 1/2 off the screen.
Scott,
Generally, that does not happen in Flex. Because by default model cover entire application ( stage ) of Flex application.
(Note: This may happen in a case, where you have a .swf file in html file. There you may have this kind of situation. But again modal will be covering stage ( entire swf file ) area. )
Even if you have same problem regarding this, send me your code snippet I may give you solution.
I get a Syntax error at line 55:
1084: expecting right paren before src.
Also, what does the do at line 62? There is no anywhere in the code above.
thanks
Declan
Declan,
It was problem of wordpress to show code.
But now it has been rectified.
Thanks for suggestion.
Congratulations for this example !!!
Looks relly skillfully, nice work!
how would I add that to this script, to change it to kool colors…
alert(“Longsuffering.org – The Greatness all around. xoHUGGSxo”)
Please help me with this, I will love you forever (probably not true love though) xD
Irish,
code / snippet for is already given in this post.
Event though, you can’t get through – let me know your requirements precisely. I will definitely try to give you solution.
Till then, Enjoy Flexing.
Mayur
Cool Example.. I noticed that the modal transparency doesn’t fall below 0.5. Is it possible to lower it down to 0?
got it.. i had set modalTransparency for as 0.5
well.. it’s like I thought!
Esto sirve para eliminar el efecto de transparecia en el Alert
modal-transparency-blur: 0;
modal-transparency: false;
What’s the meaning of ” Esto sirve para eliminar el efecto de transparecia en el Alert ”
seems, it is in a language other than English, please let me know what you want to say.
I will moderate and publish the comment.
Enjoy flexing…
Mayur…i reply in name artanis..his post was in spanish and said something like:
“The following is useful for eliminating the transparency effect in the Alert.”…
cheers.
btw: thx for the tip, just what i was looking for.
Thank you, Christian.