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