/ Published in: ActionScript 3
URL: http://movielibrary.lynda.com/html/modPage.asp?ID=423
maths functions in actionscript
Expand |
Embed | Plain Text
//simple calculations trace(2+4); trace(2-4); trace(2*4); trace(2/4); //generate random number trace(Math.random(); trace(Math.random( * 10); // for numbers bigger than 1 // rounding number techniques die1_mc.gotoAndStop(Math.round(Math.random() * 6)); // round die1_mc.gotoAndStop(Math.floor(Math.random() * 6)); // round down die1_mc.gotoAndStop(Math.ceil(Math.random() * 6));// round up // random dice movie function random_mc.addEventListener(MouseEvent.CLICK; onClick); function onClick(event:MouseEvent):void { die1_mc.gotoAndStop(Math.ceil(Math.random() * 6)); }
You need to login to post a comment.
