Nondescribedomainactionscript 3.0

Source: Internet
Author: User

Due to work needs, it is possible to take over the previous flashProgramStaff and colleaguesCodeToday, I read Action Script 3.0 and found that this is something really interesting...

Open Flash CS 4, create a new action script3.0 file, and write several lines of code in the first frame:

Code 1:

 
VaR o = "123"; trace (typeof (O) // output stringo = 123; trace (typeof (O) // output number

It seems pretty good. It's a bit of VaR in C #3.0. The variable type can be automatically inferred based on the value assignment.

Write a few more lines that are enjoyable:

Code 2:

 
VaR citys: array = ["Shanghai", "Beijing", "Wuhan", "Guangzhou", "Shenzhen"] For (var I in citys) {trace ("I =" + I + ", type:" + typeof (I) + ", element:" + citys [I])}

Output:
I = 0, type: Number, element: Shanghai
I = 1, type: Number, element: Beijing
I = 2, type: Number, element: Wuhan
I = 3, type: Number, element: Guangzhou
I = 4, type: Number, element: Shenzhen

It seems like the same thing, similar to that in C #, I is used as the numerical subscript of the array for element access (for example: citys [1]).

(Specifically, the type of the cyclic variable is defined as string ):

Code 3:

For (var j: String in citys ){
Trace ("J =" + J + ", type:" + typeof (j) + ", element:" + citys [J])
}

Output:
J = 0, type: String, element: Shanghai
J = 1, type: String, element: Beijing
J = 2, type: String, element: Wuhan
J = 3, type: String, element: Guangzhou
J = 4, type: String, element: Shenzhen

This seems to be quite awkward. If you explain it as an index reload (that is, citys ["1"]), then the J output value seems to be "1" more reasonable, the output result is 1 (without quotation marks, misleading beginners)

 

According to the test result in section 2, the loop variable is number by default, so let's try it like this:

For (var k: Number in citys ){
Trace ("type:" + typeof (k) + ", element:" + citys [k])
}

The irony is that it cannot be compiled! (In Code 2, the system automatically deduced the number type. Now I define it as number type but cannot compile it)

Maybe I am too simple to understand Adobe's xuanjicang.

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.