Actionscript 3-first Steps Xi__actionscript

Source: Internet
Author: User
Actionscript 2 wasn ' t, but a few things drove some developers. For example if you initialized A is variable with an Object, which is magically behaved like a static classmember, Due to the storage of the prototype. In ActionScript 3 The works just like expected, as you can.
//////////
The old problems in the AS2 were solved in the AS3. Initializes arrays and objects inline, and properties can become static members. (See Luar's book "ACTIONSCRIPT 2.0 vs. RIA application Development", page 80)

Inside the AS2.
Test1.as
Import Test2;
Class Test1 extends MovieClip
{
Public Function Test1 ()
{
var t1:test2 = new Test2 ();
var t2:test2 = new Test2 ();
}
}

Test2.as
Class Test2
{
private var A:array = new Array ();
function Test2 ()
{
A.push (a.length);
Trace (a);
}
}

The array becomes a static member, inconsistent with the expected result
Output
0
0,1

In the AS3

Package {

Import Flash.util.trace;
Import Flash.display.MovieClip;

public class Test1 extends MovieClip {

Public Function Test1 () {
var t1:test2 = new Test2 ();
var t2:test2 = new Test2 ();
}

}

Private class Test2 {

private var A:array = new Array ();

Public Function Test2 () {
A.push (a.length);
Trace (a);
}

}

}

Output a normal result
0
0

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.