I have been engaged in C # programming for several years, but I have never been in touch with Flex. I am studying it myself,
First, open Vs and use version 2005 + SP1 to create a web application.
Add the page_load method to default. aspx on the dimensions page.
Protected void page_load (Object sender, eventargs e) <br/>{< br/> string STR = "helloworld"; <br/> response. write (STR); <br/>}
Okay. After the server is created, let's make it simple. Next we will create the flex program client.
1. Open flash Builder 4, file → new → flex Project
Project name: custom
Application Type: Web (run in Adobe Flash Player)
Flex SDK version: use the default SDK (currently "flex4.0 ")
Application Server Type: ASP. NET
2. Next Step
Server Type: use ASP. NET development server
3. Next Step
4. Complete without modification
Now a new Flex project has been created.
Add a label.
5. Add <mx: Label id = "lbltest"> </MX: Label> in <s: Application>.
6. Open vs, debug and run the web application, and record the path of default. aspx, such as http: // localhost: 2717/default. aspx.
7. add "<mx: httpservice id =" ws "url =" http: // localhost: 2717/default. aspx "result =" resulthello (event) "> </MX: httpservice>", result indicates that when httpservice accesses default. function called after aspx
8. Go to the design page and select the entire felx workspace. The "Event" in the attribute Bar contains the creationcomplete method (equivalent to page_load in aspx). Add this event to the button on the right of the standalone.
Protected function applicationappscreationcompletehandler (Event: flexevent): void <br/>{< br/> ws. Send (); <br/>}
9. added the resulthello (event) method:
Public Function resulthello (Event: resultevent): void <br/>{< br/> this.txt test. Text = event. Result. tostring (); <br/>}
10. resultevent will produce a compilation error. Add a package reference: Import MX. rpc. Events. resultevent;
11. All flex code is as follows:
<? XML version = "1.0" encoding = "UTF-8"?> <Br/> <s: Application xmlns: FX = "http://ns.adobe.com/mxml/2009" <br/> xmlns: S = "Library: // ns.adobe.com/flex/spark" <br/> xmlns: MX = "Library: // ns.adobe.com/flex/mx" minwidth = "955" minheight = "600" creationcomplete = "application1_1_creationcompletehandler (event)"> <br/> <FX: SCRIPT> <br/> <! -- [CDATA [<br/> Import MX. events. flexevent; <br/> Import MX. RPC. events. resultevent; </P> <p> protected function application1_creationcompletehandler (Event: flexevent): void <br/>{< br/> ws. send (); <br/>}< br/> Public Function resulthello (Event: resultevent): void {<br/> This. lbltest. TEXT = event. result. tostring (); <br/>}</P> <p>] --> <br/> </FX: SCRIPT> <br/> <FX: declarations> <br/> <! -- Place non-visual elements (such as services and value objects) Here --> <br/> <mx: httpservice id = "ws" url = "http: // localhost: 2717/default. aspx "result =" resulthello (event) "> </P> <p> </MX: httpservice> <br/> </FX: declarations> </P> <p> <mx: Label id = "lbltest"> </P> <p> </MX: Label> <br/> </s: application>
12. Run Ctrl + F11. A webpage is displayed, which contains a flash with the words "helloworld"