[AS3]as3下生成随机数random源代码示例
[AS3]as3下生成随机数random源代码示例
用NumberUtilities.random(1,6)方法产生随机数
- package {
- import ascb.util.NumberUtilities;
- import flash.display.Sprite;
- import flash.events.MouseEvent;
- public class Sample1119 extends Sprite
- {
- private var sprite:Sprite;
- public function Sample1119()
- {
- sprite = new Sprite();
- this.addChild(sprite);
- sprite.addEventListener(MouseEvent.CLICK,OnClick);
- OnClick(null); //CuPlayer.com提示第一次显示出来
- }
- private function OnClick(event:MouseEvent):void
- {
- sprite.graphics.clear();
- sprite.graphics.beginFill(0xFFFFFF);
- sprite.graphics.drawRect(0,0,50,50);
- sprite.graphics.endFill();
- var randNum:int = NumberUtilities.random(1,6);
- sprite.graphics.beginFill(0x000000);
- if(randNum==1)
- {
- sprite.graphics.drawCircle(25,25,6);
- }
- else if(randNum!=2)
- {
- sprite.graphics.drawCircle(8,8,6);
- sprite.graphics.drawCircle(42,42,6);
- }
- if(randNum==3||randNum==5)
- {
- sprite.graphics.drawCircle(25,25,6);
- }
- if(randNum==4||randNum==5||randNum==6)
- {
- sprite.graphics.drawCircle(42,8,6);
- sprite.graphics.drawCircle(8,42,6);
- }
- if(randNum==2)
- {
- sprite.graphics.drawCircle(25,8,6);
- sprite.graphics.drawCircle(25,42,6);
- }
- if(randNum==6)
- {
- sprite.graphics.drawCircle(8,25,6);
- sprite.graphics.drawCircle(42,25,6);
- }
- sprite.graphics.endFill();
- }
- }
- }
热门文章推荐
- [HLS]做自己的m3u8点播系统使用HTTP Live Streaming(HLS技术)
- [FMS]FMS流媒体服务器配置与使用相关的介绍
- [AS3]什么是M3U8,与HTML5的区别是什么
- AS2.0 让flash自适应全屏,并且不自动缩放
- [AS3]as3.0的sound类常用技巧整理
- [AS3]as3与ByteArray详解、ByteArray介绍、ByteArray用法
- 关于RTMP,RTMPT,RTMPS,RTMPE,RTMPTE协议的介绍
- [JS]分享浏览器弹出窗口不被拦截JS示例
请稍候...