Danh mục

Flex 3 with Java- P3

Số trang: 50      Loại file: pdf      Dung lượng: 634.57 KB      Lượt xem: 10      Lượt tải: 0    
Thu Hiền

Hỗ trợ phí lưu trữ khi tải xuống: 7,000 VND Tải xuống file đầy đủ (50 trang) 0

Báo xấu

Xem trước 5 trang đầu tiên của tài liệu này:

Thông tin tài liệu:

Tham khảo tài liệu flex 3 with java- p3, công nghệ thông tin, kỹ thuật lập trình phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả
Nội dung trích xuất từ tài liệu:
Flex 3 with Java- P3 Chapter 3The following example shows how to use a custom Error class in your application: try { throw new BreakFailureError(Breaks failure!!, 29); } catch (error:BreakFailureError) { trace(error.errorID + : + error.message) }Reserved words and keywordsReserved words are words that you cannot use as identifiers in your code becausethe words are reserved for use by ActionScript. Reserved words include lexicalkeywords which are removed from the program namespace by the compiler. Thecompiler will report an error if you use a lexical keyword as an identifier. Thefollowing table lists ActionScript 3.0 lexical keywords: as break case catch class const continue default delete do else extends false finally for function If implements import in instanceof interface internal is native new null package private protected public return super switch this throw to true try typeof use var void while withThere is a small set of keywords called syntactic keywords which can be used asidentifiers, but which have special meaning in certain contexts. The following tablelists ActionScript 3.0 syntactic keywords: each get set namespace include dynamic final native override static [ 87 ]Introduction to ActionScript 3.0There are also several identifiers that are sometimes referred to as future reservedwords. These identifiers are not reserved by ActionScript 3.0, though some of themmay be treated as keywords by software that incorporates ActionScript 3.0. Youmight be able to use many of these identifiers in your code, but Adobe recommendsthat you do not use them because they may appear as keywords in a subsequentversion of the language. abstract boolean byte cast char debugger double enum export float goto intrinsic long prototype short synchronized throws to transient type virtual volatileUsing ActionScript 3.0 with MXMLTo build a Flex application, you need to use a combination of MXML andActionScript 3.0 languages. For example, you may use MXML to layout and designyour user interfaces and write business logic in ActionScript. This is a commonpractice followed by Flex developers. In this section, we will see how to mixActionScript and MXML to build Flex applications.There are two ways to include an ActionScript file in your Flex application: • With the help of the tag • With the help of the include statementUsing the tagIn the Flex development environment, you can add ActionScript code in MXML fileby using the tag. See the following example: [ 88 ] Chapter 3 Notice that the above MXML code is using a tag to write ActionScriptcode to declare a variable and a function. You cannot use one script tag to specify asource attribute and include code within its body. The tag should beunder Application or any other top-level component tag. The term CDATA is used to represent the text data (in this case, its ActionScript code) that should not be parsed by the XML parser.This works well if your application requires less ActionScript code. But if yourapplication uses many MXML files and involves significant ActionScript code, thenthe best way is to separate your ActionScript code from MXML files and store it inexternal ActionScript file(s) with the .as extension.The tag lets you specify the source attribute that identifies the externalActionScript file to be included at that point in the application. The source attributesupports both absolute and relative paths. For example, the following script tagwill load an external ActionScript file named Util.as: Util.as: // ActionScript file private var color:String = «red»; private function calculateSum(x:Number, y:Number):Number { return x+y; } [ 89 ]Introduction to ActionScript 3.0The approaches above have no difference except that the second approach improvescode maintainability and readability. At the end of the day, the compiler copies theentire content of the external ActionScript file into the MXML application.Using the include directiveThe include directive is an ActionScript directive that copies the content of anexternal ActionScript file into your MXML application. The include directivecan only be used inside the tag and you can specify only a singleActionScript file for each include directive.Syntax: include file_nameThe following example includes Util.as: To create an ActionScript file to be included in Flex Builder, click on File | New |ActionScript File. This will create a blank file with an .as extension. You can startwriting your ActionScrip ...

Tài liệu được xem nhiều: