Learn to as3:* new variable types

Source: Internet
Author: User
Tags integer
There are many new data types in the variable AS3. Some of these types are not previously present. The basic data types in AS3 are as follows:

Simple data type:

Boolean
Int
Null
Number
String
UInt
Undefined complex data types:

Object
Array
Date
Error
Function
Regexp
Xml
XMLList new data types are defined by classes, for example, Matrix (Flash.geom.Matrix)
Shape (Flash.display.Shape) urlrequest (flash.net.URLRequest)
Wait a minute.

Attention:

Special type void was changed to full lowercase: void in AS3.

"*" can be used to represent all data types. As follows:

var anything:*; XML in AS3 is completely different from AS1 and AS2. The previous XML type (object) was defined as Xmlobject. The XML in AS3 is a standard e4x-based XML object.

int and UINT are new extensions of number type, int denotes integer (no decimal), Unit is unsigned integer (cannot be decimal, cannot be negative). Using the int type is slightly more efficient than using number, and the uint type should only be used where necessary, such as color values.

* Display Objects

AS3 has a new collection: the Display object. This collection contains all the objects that can be seen on the stage or can be added to the display list, including the previous Movieclip,button and TextField objects. The AS3 display objects are:

Avm1movie
Bitmap
Loader
morphshape*
MovieClip
Shape
SimpleButton
Sprite
statictext*
TextField
The video has a * representation that this object must be created manually on the stage and cannot be created directly through as.

Avm1movie is created by using AS1 and AS2 MOVIE,AS3 movie to be played by AVM2. Therefore, the movie created with AS1 and AS2 is played as a display object in AVM2. However, it cannot be used with the as combination.

Bitmaps is a bitmap object. You can specify the display effect by bitmapdata the object, or you can set it by using a bitmap file.

The loader object is used to load and display external image and SwF movie files.

Morphshapes is a graphic that is created on the timeline. Although it cannot be created through as, it can be referenced and controlled by as.

MovieClips everyone will use

The shapes are separated from the MovieClip a graphics container with only graphics objects. In shape, you can use the drawing API to draw various graphics through the Graphics object. Using shape instead of MovieClip can reduce the memory burden.

Sprite are movieclip that do not have a timeline, and in AS3 use, Sprite may be used in place of movieclip in many places, especially when creating custom display components.

Statictext, like Morphshapes, cannot be created through as, which is a text object created on the timeline.

TextField, text object.

Video objects, play flash videos.

* New Import identification

There are some differences in the import logos and AS2 in AS3. In AS2, the import is used to proxy the long name of the class, which is not required in the class. So in AS2, if you don't use import, you can also use the long name of the class to refer to, for example:

ActionScript 2
var myPoint:flash.geom.Point = new Flash.geom.Point (0,0); in AS3, the import identity is the must identity to access the class. The long name of the class can also be used when using other classes, but import cannot be omitted. For example:

ActionScript 3
Import Flash.geom.Point;
var myPoint:flash.geom.Point = new Flash.geom.Point (0,0); As with AS2, a wildcard character (*) can be used to import an entire package in import:

Import flash.geom.*;

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.