Software can also play - MM's display layer solution: flex (4)

zhaozj2021-02-16  60

data access

Macromedia Flex is developed for a server architecture (SOA - Service-Oriented Architecture). In this model, the application interacts with the services that are dispersed to complete their own tasks. For example, if you create an online travel app, you need to interact with different services: Global hotel reservation services, destination information services, weather services, etc. These services may be available in different mechanisms and come from different places. Flex allows you to collect information on the client, and provide three different data service components to meet the requirements for service providers: WebService components, HTTPService components (usually using XML via HTTP) and RemoteObject Component. MXML allows you to set up the service with the service with the corresponding WebService, HttpService, and RemoteObject tags.

Data binding

In many languages, how to display the background data in the user interface control, it is a distressing thing, and it is very easy to make mistakes. Collect the data entered in the control and pass to remote services is often tedious.

One of the Features of Flex provides a two-way data binding mechanism: you can bind the user interface control to the data result set of the service call, in turn, can also bind the parameters of the service to the user interface control. On the value.

Below is a simple stock quotation application. Examples use the WebService tag to set the share price Web service provided by XMMethods. This example clarifies the two-way binding function of Flex.

The Symbol input parameter of the getQuote method is bound to the Symbol TextInput component.

The Quote tag is bound to the call result of the getQute method.

WSDL = "http://services.xmethods.net/soap/urn: xmethods-delayed-quotes.wsdl">

{Symbol.Text}

{wsstock.getquote.result}

Figure 4. Application of share price

In fact, the Flex data binding mechanism is more than the traditional retrieve / display method: in the Flex application, you can bind any property of any property to any property value of another object. . Using Hierarchical Style (CSS)

Flex uses a hierarchical table criteria to ensure the consistency of the user interface and make the app more easily maintained. Just like in HTML, you can embed a style sheet points to the outside in your application, or define a certain style as its properties under a specific tag element. Style sheet also allows definition fonts. In the desired font definition, in the bytecode embedded in the application, even if there is such a font on the machine, it can also be rendered.

Below is an external style table named main.css.

@ font-face {

SRC: URL ("LucidasansRegular.ttf");

Font-family: mainfont;

}

{

Color: # ff0000;

FONT-SIZE: 12;

}

.title {

Font-Family: mainfontbold;

FONT-SIZE: 18;

}

TEXTAREA {

BackgroundColor: # Eef5ee;

}

The following example declares an external style sheet by using the tag, and uses a different style for different controls.

This is a Textarea

Figure 5. Application using external style sheet

Special effects

Complex Internet applications are often compared to client / server applications. Because they provide the same level of user experience. However, the difference that is easy to ignore is that the users of the two have characteristics. Users using the client / server app usually have torture, and finally adapt to the user interface they need to face. The complex Internet applications are usually temporary users. Under such conditions, an inappropriate user interface will lose opportunities.

Appropriate use effects, such as floating tips and progress conditions, help customers understand the current content. In MXML, you can reach this by setting animation.

The following example uses the Prebuilt effect in the Flex Terminus, in this example, when the Square component is displayed, WiPeright effects are used, and the WiPEleFT effect is used when disappearing.

to sum up

The Flex language contains a rich user interface component library, MXML (a XML-based tag language) and ActionScript (based on ECMA 262, strong type object-oriented programming language). MXML is used to arrange problems in other aspects of user interfaces and processing applications, while ActionScript is used to process user interaction logic. Due to the popularity of the Flash platform, Flex enables developers to develop a wide range of applications. Developers can create applications using industrial standards such as XML, CSS, and SVCs and the models and examples they are familiar with. The Flex separation collaboration and the Macromedia utility model also enables developers and interface designers to better collaborate, produce breakthrough products in user experience in reliable, easy-to-maintain architecture.

About author

From 1994-2000, Christophe Coenra Ts served from PowerSoft, and the company has now been acquired by Sybase. He started with Java in 1996 and became the technical commissioner of the company's Java and Internet Application Department. Christophe later joined Macromedia Company to become a technical specialist of company J2EE application server JRUN. Christophe starts to study complex Internet applications in this position, starting to integrate Flash front ends with J2EE backends, CHRISTOPHE is currently a high-level specialist for Macromedia's New Developer-Centric Rich Internet Applications Initiative. In the past ten years, Christophe often speaks in a global seminar.

转载请注明原文地址:https://www.9cbs.com/read-24945.html

New Post(0)