Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use Flex pop-up window

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

Editor to share with you how to use the Flex pop-up window, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!

Pop-up window in Flex

1. The simplest warning window

You need to import the Alert class: importmx.controls.Alert first

Then use Alert.show when you want to pop up a warning ("are you sure you want to exit the system?", "confirm", Alert.YES | Alert.NO,null,logout)

Parameter description: * the parameter is the text to be displayed, and the second parameter is the title of the window. These two parameters are the most frequently used. The third parameter is the button, the default is two: YEW and NO, of course, you can also customize, such as Alert.CANCEL, the fourth parameter is the parent window, the default is null. The fifth parameter is the name of the function to be called after the window closes, which you need to define if you want to click to determine what event to trigger. I'm going to call logout here, and please be careful not to write logout () here. (without parentheses) the logout function is as follows:

Privatefunctionlogout (event:CloseEvent): void {if (event.detail==Alert.YES) {/ / specific operation}}

Because this function is triggered, the parameter is a CloseEvent. The "event.detail==Alert.YES" line determines whether the button is clicked or not. The detail attribute in CloseEvent specifically determines which button is clicked, so that the user's click control code can be used.

This is the simple use of Alert. For more information, please see the help documentation.

2.Flex pop-up window

This is more powerful, you need to use a class, that is, PopUpManager, again, you need to import before using:

Importmx.managers.PopUpManager

Then you have to create a Compoment as a pop-up window, this is nothing special, just create a normal Compoment, here I created a file called PopWindow, which is a simple Canvas, in which there is a picture. The code is as follows:

PopWindow.mxml:

Mx:Script > mx:Canvas >

One of the methods of PopUpManager is removePopUp, which is to remove the current pop-up window. Here I set the Flex pop-up window to be removed when you click on the image. Next, we create and Flex the pop-up window in the main program:

Varpop:PopWindow=PopWindow (PopUpManager.createPopUp (this,PopWindow,true))

This is done. The pop is a variable of type PopWindow (that is, the file name of the Component you just created). Since the createPopUp of PopUpManager returns an IFlexDisplayObject, you need to cast it to the PopWindow type to assign a value to the pop variable. These parameters of createPopUp are described in detail below:

The * parameter is the parent form of the pop-up window, which we all know.

The second parameter is the class name of the pop-up window, that is, the file name of the component, and a MXML file corresponds to a class in Flex. PopUpManager creates pop-up dialogs based on this class.

The third parameter is the modal marker. If it is true, create a modal dialog box; otherwise, create a modeless dialog box.

PopUpManager also has a parameter, but it is not commonly used. Please refer to the help documentation for details.

Then you can operate on the pop-up dialog and use removePopUp (pop) if you want to remove it. In addition, if it is modeless, the window may disappear when you click on the rest of the program, but it has not been removed, so how do you get it out? At this point, you need another method of PopUpManager: bringToFront (), which puts the window at the front. You can control that the program creates a dialog box for the next time, and then puts the window at the front.

The above is all the content of this article "how to use Flex Pop-up window". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report