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 the Flex pop-up window

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

Share

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

This article mainly introduces how to use the Flex pop-up window, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let Xiaobian take you to understand.

Pop-up window in Flex

Recently, when I modified the project, I learned something about pop-up windows in Flex and found it very useful. There are two pop-up windows 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 Flex 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 pop up a 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.

◆, let's describe these parameters of createPopUp in detail:

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

The second parameter is the class name of the Flex 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.

Thank you for reading this article carefully. I hope the article "how to use Flex Pop-up window" shared by the editor will be helpful to you. At the same time, I also hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

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