[英]How do I randomly set the color for a MovieClip in actionscript3
[英]How to show a MovieClip randomly in ActionScript 3?
有很多方法可以實現你想要的。 一種解決方案可能是擁有一個不可見的老鼠圖形,並且每隔 X 秒就讓它可見。
// the array has all the hole movieclips
var allHoles:Array = new Array('hole1_mc','hole2_mc', 'hole3_mc');
// show a rat 20 times every 2 seconds
var myTimer:Timer = new Timer(2000,20);
myTimer.addEventListener(TimerEvent.TIMER, showRat);
myTimer.start();
function showRat(e:Event):void{
// choose a random hole
var rand = Math.floor(Math.random()*3);
var randomHole = allHoles[rand];
rat_mc.visible = true;
rat_mc.x = randomHole.x;
rat_mc.y = randomHole.y;
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.