随机像素闪烁白色的第二个1 / 1/60 [英] Random Pixels Blink White for 1/60th of a Second
问题描述
我想使单个像素闪光灯的第二个1/60次,然后消失在时间2秒时间,直到1280×720的屏幕上的每一个像素已经亮出白色。经过2秒后,屏幕全黑再次3秒左右才循环,并再次执行。
I am trying to make single pixels flash for 1/60th of a second and then go away over a 2 second period of time until every single pixel on a 1280x720 screen has flashed white. After 2 seconds have elapsed the screen is all black again for 3 or so seconds before it loops and does it again.
我解决了它就是用这个FLA的拉上计算器用户想出了和我修改,使用影片剪辑。问题是,它不工作得到921600影片剪辑随机启动。它变得非常沉重和缓慢的。请参阅与工作附件
The way I solved it was using this fla another stackoverflow user came up with and I modified that uses movie clips. The problem is it doesn't work to get 921600 movie clips to start randomly. It gets really heavy and slow. See attached file that works with
反正!我敢肯定有这样的一个超级聪明的办法。我是一个新手。感谢您的任何帮助或建议。
Anyway! I'm sure there is a super smart way of doing this. I'm a novice. Thanks for any help or suggestions.
FLA(CS5) https://mega.co.nz/#!ERRFiJBJ!VYSaH164BcjD9QIiSdpk8WxFp68dYDC0vWzKySC8rg0
fla (cs5) https://mega.co.nz/#!ERRFiJBJ!VYSaH164BcjD9QIiSdpk8WxFp68dYDC0vWzKySC8rg0
瑞士法郎 https://mega.co.nz/#!kBoxmJCR!Mx7sHX94-9ch15dKdT8knHRRKRljytZXdOBK -2P-TLQ
最好的, 罗林
有关我链接到上述FLA的原始设计看到这个链接上的解决方案,由马哈茂德·阿卜杜勒 - 法塔赫。 <一href="http://stackoverflow.com/questions/14945698/random-start-times-for-move-clips/14946307#14946307">Random启动时间为移动剪辑
For the original design of the fla I'm linking to above see the solution by Mahmoud Abd El-Fattah on this link. Random Start Times for Move Clips
推荐答案
好了,最简单的方法是这样的:
Okay, the simplest method will be something like this:
static const WIDTH:int=1280;
static const HEIGHT:int=720;
static const WH:int=WIDTH*HEIGHT;
static const FRAMES:int=120; // 2 seconds * 60 frames. Adjust as needed
static var VF:Vector.<int>; // primary randomizer
static var BD:BitmapData; // displayed object
static var curFrame:int; // current frame
static var BDRect:Rectangle;
function init():void {
// does various inits
if (!VF) VF=new Vector.<int>(WH,true); // fixed length to optimize memory usage and performance
if (!BD) BD=new BitmapData(WIDTH,HEIGHT,false,0); // non-transparent bitmap
BDRect=BD.rect;
BD.fillRect(BDRect,0); // for transparent BD, fill with 0xff000000
curFrame=-1;
for (var i:int=0;i<WH;i++) VF[i]=Math.floor(Math.random()*FRAMES); // which frame will have the corresponding pixel lit white
}
function onEnterFrame(e:Event):void {
curFrame++;
BD.lock();
BD.fillRect(BDRect,0);
if ((curFrame>=0)&&(curFrame<FRAMES)) {
// we have a blinking frame
var cw:int=0;
var ch:int=0;
for (var i:int=0;i<WH;i++) {
if (VF[i]==curFrame) BD.setPixel(cw,ch,0xffffff);
cw++; // next column. These are to cache, not calculate
if (cw==WIDTH) { cw=0; ch++; } // next row
}
} else if (curFrame>FRAMES+20) {
// allow the SWF a brief black period. If not needed, check for >=FRAMES
init();
}
BD.unlock();
}
function Main() {
init();
addChild(new Bitmap(BD));
addEventListener(Event.ENTER_FRAME,onEnterFrame);
}
这篇关于随机像素闪烁白色的第二个1 / 1/60的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!