AS1.0 oop vs. AS2.0 OOP

Source: Internet
Author: User
Tags array definition constructor functions variables
AS1.0 OOP, which is constructed with function, is not perfect oop. And AS2.0 is strict when it is defined. This is a great help to write programs ...

When you used AS1.0 as an OOP architecture, you used the function constructor and the definition child (private) functions to display a collection of text by prototype such as creating a TextField.

The first frame of the FLA, the following is the program code:

#include "mytestload.as"  ///If AS2.0 is not required _root.createtextfield ("MyText", 1,50,50,100,20); var Text_arr = new Array ("One", "two", "three"); var txtobj = new Mytextload (Mytext,text_arr);  //Call function

A mytestload.as built with AS1.0

_global.mytestload=function (Txt,txt_arr) {  this.mytext_txt = txt;//definition has public variable  this.mytext_txt_arr = Txt_arr;  This.textload (2); Run child function}mytestload.prototype.textload=function (n) {//construct private function  this.mytext_txt.text = This.mytext_txt_arr[n];}

Let's look at the mytextload.as AS2.0 wrote.

Class Mytextload {  var Tmptxt1:textfield;//public variable  var Tmptext_arr1:array;  function Mytextload (tmptxt:textfield,tmptext_arr:array) {    TMPTXT1 = tmptxt;//define public variable    TMPTEXT_ARR1 = Tmptext_ arr;    Text_load (2);  }  Private Function Text_load (n:number)//Set up proprietary functions {    tmptxt1.text = Tmptext_arr1[n];  }

It is clear that AS2.0 requires syntax in variable and transitive value types to be strict, and also in defining private, public functions, and variables.

And the OOP that AS1.0 uses function constructs is not perfect oop. It is important to understand the strict definition of variables and functions if you have used C#,java. In particular, return and pass types, child functions, Superclass. and AS1.0 to implement this architecture as the as class. It's going to be a little dizzy. For example, the return class is object, array, or MC, and AS2.0 is strictly required when defining. This is a great help for writing programs.

FLASH2004 If you use Function.prototype to construct an OOP structure, publish flash as a flash6.0 AS1.0 format, AS2.0 does not take the function constructor form. This can be seen in the Flash2k4 Help file to find function class, you can learn more.

Of course, AS1.0 exists for a long time, and can also be implemented in OOP. Important understanding and proficiency in fact, understanding OOP,FLASHMX and Flash2k4 are good software. Here is just the main difference between the two.



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.