This video tutorial will help you to create a random number generator to generate number between two specific values.
Website: http://samsolomonprabu.com/
Code:
import flash.events.MouseEvent;
text1.restrict = -0-9-;
text2.restrict = -0-9-;
btnGenerate.addEventListener(MouseEvent.CLICK, generateRandom);
function generateRandom(event:MouseEvent):void{
var min:Number = Number(text1.text);
var max:Number = Number(text2.text);
var rand:Number = Math.floor(Math.random() * (max-min+1)) + min;
result.text = rand.toString();
}
Website: http://samsolomonprabu.com/
Code:
import flash.events.MouseEvent;
text1.restrict = -0-9-;
text2.restrict = -0-9-;
btnGenerate.addEventListener(MouseEvent.CLICK, generateRandom);
function generateRandom(event:MouseEvent):void{
var min:Number = Number(text1.text);
var max:Number = Number(text2.text);
var rand:Number = Math.floor(Math.random() * (max-min+1)) + min;
result.text = rand.toString();
}
Random Number Generator in Flash using AS 3.0 - Flash Tutorials | |
1,512 views views | followers |
13 Likes | 13 Dislikes |
People & Blogs | Upload TimePublished on 10 Apr 2015 |
Không có nhận xét nào:
Đăng nhận xét