Flex learning Summary: Flex changes the font size and style of the alert prompt box.

Source: Internet
Author: User

After recent speculation, Flex is still very useful and solves the difficulties that have plagued my web development front-end for a long time. Its AMF communication protocol uses binary stream to transmit data based on HTTP, high efficiency. Combined with blazeds and Ro, It is very convenient to Implement Asynchronous HTTP Communication Between the frontend and the backend. The standard port 80 is nice. The only unpleasant thing is that it takes some time to map the as object and the Java object. You have not found any tools to make up for it. You have to do it manually for the time being.

If necessary, you can also use flex-related technologies to synchronize real-time client data with the server. However, you need to open a new port. Otherwise, how can the client listen to the data update message on the server end? You need to study this later.

Since then, the web development front-end can be the same as the desktop development, but the back-end can follow the J2EE architecture that has been used for a long time.

Record several recently solved problems:

1. Alert font size change

Alert fonts are so difficult to modify. There are a lot of related web pages on the Internet, but few matching paths are not found. It took some time to find the correct idea. The following are my solutions.

Create a cssfile first. Here I name global.css, and the path is flex_src/CSS/global.css.

. Alerttitle
{
Font-size: 12pt;
Font-weight: normal;
Font-style: normal;
}
. Alertmessage
{
Font-size: 12pt;
Font-weight: normal;
Font-style: normal;
}

Then write a tool class, use popupmanager to manage an alert instance, and no longer use its static show method. For example:

Public static function prompt (MSG: String, parent: displayobject): void {
VaR alert: Alert = new alert ();
Alert. setstyle ("messagestylename", "alertmessage ");
Alert. setstyle ("titlestylename", "alerttitle ");
Alert. Title = "prompt ";
Alert. Text = MSG;
Popupmanager. addpopup (alert, parent, true );
Popupmanager. centerpopup (alert );
}

Public static function confirm (MSG: String, parent: displayobject, closehandler: function ){
VaR alert: Alert = new alert ();
Alert. setstyle ("messagestylename", "alertmessage ");
Alert. setstyle ("titlestylename", "alerttitle ");
Alert. Title = "Operation confirmation ";
Alert. Text = MSG;
Alert. addeventlistener (event. Close, closehandler );
Alert. buttonflags = alert. OK | alert. Cancel;
Alert. defaultbuttonflag = alert. OK;
Popupmanager. addpopup (alert, parent, true );
Popupmanager. centerpopup (alert );
}

Finally, reference the CSS where you want to use alert. <mx: style source = "CSS/global.css"/>

Then you can call the above static methods prompt and confirm to bring up a prompt box and a confirmation box. Do you want to modify the font style? You can change the CSS file. The compilation tool class can also better unify the prompt box style of the entire application. The above method has just been tested in my project.

2. Use the release mode to compile the SWF file and compress the volume.

Fb3 put the function of compiling mxml in the release Mode Under the file-> export-> flex builder-> release build menu. After testing, my SWF is compressed nearly twice.

 

Continued:

The latest version shows that the default font of the entire application can be changed as long as the style of the entire application is added to the application. Let's take a look at the above solution. I think it is really troublesome. I don't know before. I should be innocent. Haha.

Application {
Font-size: 12px;
Font-style: normal;
Font-weight: normal;
}

Set it in the style file. Tooltip alert fonts are all set. Now, you can directly use alert. Show.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.