Address: http://weijie.blog.51cto.com/340746/76060
Author: What is Wei Jie Flex? We can simply understand it as a general term for many technical and service products. It can also be seen as Adobe's J2EE application. Program A Presentation Server provided. It is mainly used to integrate with a development kit (WAR) in our J2EE environment ). It can also be understood as an application mainly composed of two languages: ActionScript and mxml. From the framework perspective, Flex is an open-source framework. Just like spring and hibernate. In a word, Flex is used to develop a new generation of "RIAS-rich Internet applications ). A complex Internet application is developed based on the availability of desktop applications and the ease of management of web applications. It inherits the timeliness of traditional desktop applications and gives full play to the advantages of easy deployment and management of popular web applications. Flex is a display server installed on the J2EE application server or servlet container. It has rich user interface components, XML-based markup language used to deploy these components, and object-oriented processing for user interaction. Programming Language . What these technologies bring to us is: Using Flash Player to render complex Internet applications, using industry standards and familiar development methods. A simple understanding of the composition of flex mainly contains two types of files, one is the mxml file and the other is the ActionScript file. The mxml file is based on XML, which indicates that it is scalable and customizable. A large number of rich tag sets are introduced in mxml. It accelerates development and is mainly used to display the page of the presentation layer. One of the AS files is mainly used to control some simple programming logic and user interaction requirements. As is a familiar object-oriented language that supports the three main features of object-oriented, for our background programmers, it is simpler. Its syntax is similar to that of Java, C #, and JS. In fact, the syntax of all object-oriented languages is similar. A simple understanding of the working principles of flex allows you to quickly understand its working principles through a simple comparison. Let's look back at the working principle of JSP. It is first pre-compiled into servlet, that is, the familiar Java class, and then compiled into the class bytecode that JVM can execute. The working principle of mxml files is similar to that of JSP files. mxml is first pre-compiled into as intermediate files and compiled into SWF bytecode that can be executed by Adobe Flash Player. Adobe Flash Player is like a Java virtual machine. However, the difference is that the execution of JSP bytecode is performed on the server, while the SWF bytecode of Flex is sent from the server to the client (browser) on Adobe Flash Player. In this case, you may see the advantages of FLEX, at least to reduce the pressure on the server. For better image, we can compare mxml to JSP, while as may be easier to understand as servlet (Java. The above is a very close analogy in terms of working principles. If we look at the metaphor, we can regard mxml as HTML and as JavaScript. In this way, we may better understand that mxml (HTML) is mainly used for display, while as (JavaScript) is mainly used to control some programming logic and user interaction requirements. Through the metaphor of these two images, you should understand flex.
The simple implementation of helloworld will allow you to thoroughly understand the operating principles of flex through a simple helloworld example. Write an mxml file or an as file. Open notepad and write Code . <? XML version = "1.0" encoding = "UTF-8"?>
<Mx: Application xmlns: MX = "http://www.adobe.com/2006/mxml" layout = "absolute">
<Mx: Label text = "Hello World"/>
</MX: Application> save it as helloword. mxml. I saved it in D: \ flex \ helloword. mxml. helloworld and wrote it. How can we run it through the command line now? First, make sure that the SDK has been installed on your computer, just as you must install JDK when running Java. Generally, we are configuring the environment variable path, which is a command that can be directly used without switching to the bin directory of the SDK in the command line. You should be familiar with this. Configure the SDK according to the installed SDK. Open a command window: switch to the folder where your file is located. For example, when you see that a helloworld.swf file is generated in the same directory as helloworld.mxml, this is what we call the SWF file. It can be run in Adobe Flash Player. Double-click the file to see the effect. You can also run the command: D: \ flex \ helloworld.swf in the Command window. Make sure that the Adobe Flash Player is installed on your computer. As I said above, mxml will generate an intermediate file as. Why didn't we see it? We know the JSP page we wrote, and we use the class file. We didn't put the file in the middle of the Step into our project. This is actually the same, it only generates the SWF file, but does not see the as file. What if we want to see it? In this case, we will use this command to execute: mxmlc-keep-generated-ActionScript helloworld. mxml
A generated folder will be generated under the same directory of the hello. mxml file, which is the intermediate file generated during the compilation of the mxml file as. generated file, which is the as intermediate code: