Some of the less common wording in AS3

Source: Internet
Author: User


Mc.gotoandplay (Math.random () *>>0);
View Code

Math.random () *10 takes a random number with a decimal within 10.
the >>0 function removes the number after the decimal point, so Math.random () *10>>0 gets a random integer within 10

if (i&1) {}
View Code

I&1 means to judge whether I is an odd number or an even number.
Odd 2 binary last one 1, i&1=1 true
Even 2 binary last one 0, i&1=0 fake

var New Array ();  for (var i:int=0; i<; A.push (i++)) {//...}
View Code

After this loop executes, the value of the A array is 0,1,2,3,4,5,6,7,8,9

var temp:number=Mousex;stage.addeventlistener (mouseevent.mouse_move,movehandler); function Movehandler (e:mouseevent):void  {var d:number= (-temp+ (temp=mousex));}
View Code

Get mouse Move distance D
Use the mouse to drag the form or drag the game on the mouse
The code can be changed completely to

mouse.hide (); var temp:number=Mousex;stage.addeventlistener (mouseevent.mouse_move,movehandler); function Movehandler (e:mouseevent):void  {var d:number= (-temp+ (temp=+ = D; E.updateafterevent ();}
Alternative

So spritemouse this movie clip becomes a mouse

function fn1 () {Trace ("1");} function fn2 () {Trace ("2");} ([Fn1,fn2][math.random ()*2>>0]) ();
View Code

This is a random execute function command.

var a:int=3; if (a>0&& (Trace ("A is positivenumber"),a&1)Trace (  "A is positive oddnumber");
View Code

First Execute a>0 True
Execute trace again ("A is positive number")
Finally judge A is not an odd number
The comma expression here is executed from left to right
Mainly used to determine if there are any statements executed.

var a:int=+; var b:int=-; if ((a^b) >0| | (b*=-1,a>)) trace (b);
View Code

Again a comma expression
A^b =-7
B*=-1 b=12
A>10
Output b=12

Some of the less common wording in AS3

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.