好了,最簡單的方法是這樣的:
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);
}
奇怪的網站,它不接受我的FF13爲「合格瀏覽器」,和NO,我不希望更新爲FF只有鐘聲和口哨。 ...實際上,每個單點的921600 MC都是巨大的矯枉過正,使用一個BitmapData(使用位圖封裝)並使用'setPixel32()'來更改它的顏色。 – Vesper 2013-02-21 05:17:23
@Vesper這是在一個保管箱鏈接。我不認爲這個文件是非常有用的,除了看看它應該是什麼樣子。我知道我得到的是超級笨重的瘋狂矯枉過正,但是我不知道如何使用這個位圖包裝器。但是,謝謝你的方向。 https://dl.dropbox.com/u/753249/exposure7_2.fla https://dl.dropbox.com/u/753249/exposure7_2.swf – Rollin 2013-02-21 05:22:07
首先看一下BitmapData類:http:// help。 adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/BitmapData.html – mitim 2013-02-21 05:39:26