Get the App
SLTechnology News&Howtos  ›  Development  › 

How to convert AS2 and AS3 variables in Flex3

Shulou Source: shulou.com Published: 2022-06-02 08:03:58 09月11日 Update

Xiaobian to share with you how to convert AS2 and AS3 variables in Flex3, I believe most people still do not know how to, so share this article for your reference, I hope you have a lot of harvest after reading this article, let's go to understand it together!

Flex3 Tutorial AS2 and AS3 Variable Conversion

Conversion of variables

Similar to the changes in classes and methods, the protected,internal modifier has also been added to variables, which has the same effect as the same name modification of classes and methods, so it will not be repeated here. The final keyword cannot be used to modify variables, unlike Java, but instead a const keyword instead of var is used to identify constants, such as constN:int=100; similar to C/C++.

Another change is that AS3 introduces a new type *, * stands for arbitrary type (i.e. no type checking), although in AS3, variables and method return types can also be set undeclared, but FlexBuilder will warn, because AS3 is more static than AS2, so it is not recommended to omit type declaration, if you really need to do no type checking, then use *, such as vardynamicProperty:*;dynamicProperty will be assigned any type of value, functionmethod():* will be able to return any type of value.

◆ Another important point is that the initial values of variables in Flex3 tutorial are different from AS2, which should be careful when converting. For AS2, variables are equal to undefined before assignment, while in AS3, the initial values of different types are as follows:

Datatype

Defaultvalue

Boolean

false

int

0

Number

NaN

Object

null

String

null

uint

0

◆Flex3 tutorial does not declare the type (equivalent to * type)

undefined

Other types include user-defined classes.

null

Therefore, be careful here, int,Number,uint,Boolean and other variables will not have null or undefined values.

The above is "How to convert AS2 and AS3 variables in Flex3" all the content of this article, thank you for reading! I believe that everyone has a certain understanding, hope to share the content to help everyone, if you still want to learn more knowledge, welcome to pay attention to the industry information channel!

Tags: Types variables different tutorials methods articles roles keywords content changes checks same important instead less representative local most constant Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Huawei Shulou Information Microsoft Redmi macOS