Flex中如何通过在全局selector中设置不同的样式(如:modalTransparencyBlur, modalTransparency, modalTransparencyColor以及modalTransparencyDuration)使其应用于Alert和PopUpManager的对话框的例子
By Minidxer | October 19, 2008
接下来的例子演示了Flex中如何通过在全局selector中设置不同的样式(如:modalTransparencyBlur, modalTransparency, modalTransparencyColor以及modalTransparencyDuration),使其应用于Alert和PopUpManager的对话框。
让我们先来看一下Demo(可以右键View Source或点击这里察看源代码):
下面是完整代码(或点击这里察看):
Download: main.mxml
- <?xml version="1.0" encoding="utf-8"?>
- <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
- layout="vertical"
- verticalAlign="middle"
- backgroundColor="white">
- <mx:Style>
- global {
- modalTransparencyBlur: 0;
- modalTransparency: 0.8;
- modalTransparencyColor: black;
- modalTransparencyDuration: 500;
- }
- </mx:Style>
- <mx:Script>
- <![CDATA[
- import mx.controls.Alert;
- import mx.managers.PopUpManager;
- private function showAlert():void {
- Alert.show("hello", "world");
- }
- private function showContactForm():void {
- var contactForm:ContactForm = new ContactForm();
- PopUpManager.addPopUp(contactForm, this, true);
- }
- ]]>
- </mx:Script>
- <mx:ApplicationControlBar dock="true">
- <mx:Button label="Alert" click="showAlert();" />
- <mx:Button label="ContactForm" click="showContactForm();" />
- </mx:ApplicationControlBar>
- </mx:Application>
下面是ContactForm.mxml的代码:
Download: main.mxml
- <?xml version="1.0" encoding="utf-8"?>
- <mx:TitleWindow xmlns:mx="http://www.adobe.com/2006/mxml"
- width="320"
- height="240"
- showCloseButton="true"
- close="titleWindow_close();"
- creationComplete="titleWindow_creationComplete();">
- <mx:Script>
- <![CDATA[
- import mx.controls.Alert;
- import mx.managers.PopUpManager;
- private function titleWindow_close():void {
- PopUpManager.removePopUp(this);
- }
- private function titleWindow_creationComplete():void {
- PopUpManager.centerPopUp(this);
- }
- private function sendButton_click():void {
- Alert.show("Thanks for the feedback");
- titleWindow_close();
- }
- ]]>
- </mx:Script>
- <mx:Form styleName="plain" width="100%" height="100%">
- <mx:FormHeading label="Contact Us" />
- <mx:FormItem label="Name:" width="100%">
- <mx:TextInput id="feedbackName" width="100%" />
- </mx:FormItem>
- <mx:FormItem label="Email:" width="100%">
- <mx:TextInput id="feedbackEmail" width="100%" />
- </mx:FormItem>
- <mx:FormItem label="Comments:" width="100%" height="100%">
- <mx:TextArea id="feedbackComments" width="100%" height="100%" />
- </mx:FormItem>
- </mx:Form>
- <mx:ControlBar horizontalAlign="right">
- <mx:Button id="sendButton"
- label="Send"
- click="sendButton_click();" />
- </mx:ControlBar>
- </mx:TitleWindow>
代码:Peter deHaan 翻译/整理/编译:中文Flex例子
Topics:
Alert, PopUpManager |
No Comments » |
Tags: Alert, modalTransparency, modalTransparencyBlur, modalTransparencyColor, modalTransparencyDuration, PopUpManager