Flex and. Net WebService

Source: Internet
Author: User

As a rich Internet application development tool, flex has many advantages over Ajax, and does not even make it easier to connect to WPF. The flex performance layer is based on flash. Therefore, not only the interface is not rich, but also a real cross-platform.
Its disadvantage is that flex2 requires a Flash 9 player.

In the previous discussion, Jin Cai once said that the flash development interface is not suitable.ProgramMember. In essence, the program is a group of people who have a strong desire to learn. Therefore, the flash development interface is not a reason to hinder programmers. However, after all, Flash is designed for animation. Flex2 builder is designed for network application programmers, and its eclipse-based development interface is also very friendly.
This time I will give you a small example. I hope that people who do not know FLEX will be interested in accessing and learning. This makes the development of network applications easier and more colorful, more diversified-not just Ajax.

This is an extremely simple example: finding the perimeter of a circle with a specified radius.
In flex2builder, create an mxml project and drag several tools (such as label, textinput, And button) on the design interface,

Set the ID of the input box to radius, and the ID of the output label to girth. Switch to the source code window:

Now we need to add computing functions. Insert in frontCodeAnd add the click event to the button:

Save and run the following interface:


If you have installed the Flash 9 browser plug-in, perform the following operations:

In fact, flex2builder generates a SWF file that can be executed in any flash 9-enabled browser or Flash Player.

Now, make it more complex. I added an ASP. NET WebService that provides computing functions:

Using System;
Using System. Web;
Using System. Web. Services;
Using System. Web. Services. Protocols;

[WebService (namespace =   " Http://tempuri.org/ " )]
[Webservicebinding (conformsto = Wsiprofiles. basicprofile1_1)]
Public   Class Service: system. Web. Services. WebService
{
Public Service () {
//If you use the designed components, uncomment the following lines:
//Initializecomponent ();
}

[Webmethod]
Public   Double Calc ( Double R) {
Return 2 *R*Math. Pi;
}
}

It is now running on http: // localhost: 2603/calccircleservice/service. asmx.

Go back and modify the above program:

<? XML version = "1.0" encoding = "UTF-8" ?>
< MX: Application Xmlns: MX = "Http://www.adobe.com/2006/mxml" Layout = "Absolute" >
< MX: WebService ID = "Calcservice"  
WSDL = "Http: /localhost: 2603/calccircleservice/service. asmx? WSDL"
Useproxy = "False" >
< MX: Operation Name = "Calc" >
< MX: Request >
< R > {Radius. Text} </ R >
</ MX: Request >
</ MX: Operation >
</ MX: WebService >

< MX: Panel X = "10" Y = "10" Width = "313" Height = "200" Layout = "Absolute" Fontfamily = "Times New Roman" Fontsize = "12" Title = "Calculating the circumference" >
< MX: Label X = "10" Y = "24" Text = "Radius :" />
< MX: textinput X = "53" Y = "22" ID = "Radius" />
< MX: Text X = "10" Y = "74" Text = "Circumference :" />
< MX: Text X = "71" Y = "74" Text = "{Calcservice. Calc. lastresult }" ID = "Girth" />
< MX: button X = "221" Y = "22" Label = "Computing" Click = "Calcservice. Calc. Send ();" />
</ MX: Panel >

</ MX: Application >

This time, all scripts are deleted. A WebService definition is added: calcservice, and an operation calc is defined. It has a parameter R, which is based on the "radius. Text" in the input box ".
Then, change the Click Event of the button to "calcservice. Calc. Send ();" to send a call request.
After the request is returned, the result is automatically displayed on the interface. Because the text content here is defined as the last returned result "calcservice. Calc. lastresult" of calcservice. Calc. calstresult ". This is equivalent to Data Binding in. net.

As for the interface effects, flex still maintains the flash advantage. If needed, you can add multiple special effects to all interface elements-just as beautiful as WPF (but only 2D effects ).

It's very simple, isn't it? Try it.

----
The Adobe website provides all downloads:
Http://www.adobe.com/products/flex/
Http://www.adobe.com/cn/products/flex/

Among them, flex2 SDK is free. Of course, it only has a live development environment.

Click the following link to select whether to install the flah9 Player Plug-in. After installing the plug-in, restart the browser.
Compile and operate the SWF program.

Http://www.adobe.com/shockwave/download/download.cgi? P1_prod_version = shockwaveflash & promoid = biow

After installing the Flash 9 plug-in, you can go:
Http://www.adobe.com/devnet/flex? Tab: samples = 1
Try various examples written by flex2. However, some domestic networks may be slow because the sites are outside China.

Yahoo map is a typical application example of flex2. You can experience:
http://maps.yahoo.com/beta/index.php#mvt=m&maxp=search&trf=0&lon=-98.393555&lat=37.405074&mag=14

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.