Flex Development Project Summary

Source: Internet
Author: User
1. A new window is displayed.
Flex uses the popupmanager class to bring up a new window:
First, set the page for the window to be popped up. Then, the new window object is displayed in the main window. Then, you can assign values to the properties of the window,
VaR genggai: genggaiwindow = new genggaiwindow ();
Genggai. logid = ADG. selecteditem. ID; use the following two methods in the popupmanager class to bring up the window:
Popupmanager. addpopup (genggai, this );
Popupmanager. centerpopup (genggai); Use the following method in the popupmanager class to close the pop-up window: popupmanager. removepopup (this );

2. page Jump-multi-view Switch
In a flex application, you can switch between different views based on your needs. In this process, only one view is displayed on the top layer, and other views are hidden in the form of stacks. This function is implemented by the viewstack container. The containers in viewstack are all in one view. switching between views can be achieved through other components or by writing ActionScript.
In this example, the view under the <mx: viewstack> label is as follows:
<Mx: canvas id = "view1"> View view1 </MX: canvas>
<Mx: canvas id = "view1"> View view2 </MX: canvas>
Switch between views: viewstack1.selectedchild = view2; 3. Use flex to access the Java application on the server.
The most powerful feature of LCDs-based flex applications is the ability to directly call the Java code of the server side through LCDs (by using the remoting Service ):
When used, the back-end Java class is described in the remoting-config.xml configuration file, and the alias in the configuration file is called as a remote object through flex. Configuration file:
<Destination ID = "userservice">
<Properties> <source> service. userservice </source> </Properties>
</Destination>
On the page, use the following tags to directly call remote objects using only class libraries:
<Mx: remoteobject id = "userservice" Destination = "userservice"/>
Declare the remoteobject class instance and specify the alias of the Java class declared in the remoting-config.xml configuration file, so that you can call the remote Java class:
Userservice. login (strname, strpwd); 4. The flex page receives the return value of the Java class.
Flex cannot directly receive the return values of the Java class. You need to use the following methods:
First, when declaring a remote Java class and specifying a method to call the Java class, the returned value is processed through an ActionScript:
<Mx: remoteobject id = "logservice" Destination = "logservice">
<Mx: method name = "gettotalpages" result = "gettotelresult (event)"/>
</MX: remoteobject>
Next, we will receive the values of the Java class in ActionScript:
Private function gettotelresult (EVT: resultevent): void {
Totlepage = EVT. Result As int ;}
The first step of the above process can also be placed in ActionScript, for example, in a certain ActionScript:
Logservice. addeventlistener (resultevent. Result, functionresult); 5. The page is displayed dynamically in real time.
List and arraylist in Java correspond to arraycollection in flex. To dynamically display the list, first bind the arraycollection class on the page: [Bindable]
Public var logac: arraycollection = new arraycollection ();
Then, you need to dynamically refresh the list. When you delete an item:
Call this. initwindow () to refresh the page;
When adding a new log:
Call mmm. initwindow () refreshes the home page, where Mmm is the main page type object (VAR Mmm: flextest;). When the Add window is displayed, on the home page, add the mmm attribute of the window to be added,
Public Function gotodetail3 (): void {
VaR Tianjia: tianjiawindow = new tianjiawindow ();
Tianjia. Mmm = this;
Popupmanager. addpopup (Tianjia, this );
Popupmanager. centerpopup (Tianjia);} 6. hyperlink-like implementation in flex
There is no hyperlink in flex. You can implement hyperlinks in disguise. First, define the link address:
Public var U: URLRequest = new URLRequest ("http: // localhost: 8080/flextest/bin/flextest.html"); write an ActionScript and use navigatetoURL (u, '_ Self ') method link to the above address:
Private function clickttselectresult (Event: closeevent): void
{NavigatetoURL (u, '_ Self');} The link button on the page, which calls the above ActionScript:
<Mx: linkbutton x = "508" Y = "405" label = "exit" width = "66" Height = "20" fontsize = "11" Click = "poptalert () "/> 7. use filereference to upload files
The file to be uploaded is declared as the filereference class.
Open the file browsing window and use file. Browse (alltypes). Pay attention to the usage of filefilter. It cannot be directly used as a parameter of the Browse member function of the filereference class and should be placed in the array alltypes. Upload code:
VaR request: URLRequest = new URLRequest ("http: // localhost: 8080/flextest/fileuploadservlet? Userid = "+ userid );
// Request. Data = "userid =" + userid;
File. Upload (request );

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.