2009年5月6日 星期三
flash homework - random conga
function setup() {
total = 15;
for (i=0; i< total; i++) {
obj = this.attachMovie("weed", "layer"+i, i);
obj._x = random(800);
obj._y = 0;
obj._xscale = obj._yscale=random(100);
obj.xSpd = (random(2)*2-1)*random(10)*5+1;
obj.ySpd = (random(2)*2-1)*random(10)*5+1;
}
}
function runDrum() {
for (i=0; i< total; i++) {
obj._rotation += random(20);
obj._alpha = random(100);
obj = this["layer"+i];
obj._x += obj.xSpd;
obj._y += obj.ySpd;
if (obj.hitTest(hat01) == true) {
obj.xSpd *= -1;
obj.ySpd *= -1;
green._x = obj._x;
green._y = 340;
green._yscale = green._xscale=random(100)+50;
sound = new Sound();
sound.attachSound("con06");
sound.setVolume(100);
sound.start(0,1);
}
if (obj.hitTest(hat02) == true) {
obj.xSpd *= -1;
obj.ySpd *= -1;
red._x = random(800);
red._y = 300;
red._yscale = red._xscale=random(100)+50;
sound = new Sound();
sound.attachSound("con05");
sound.setVolume(100);
sound.start(0,1);
}
if (obj.hitTest(hat03) == true) {
obj.xSpd *= -1;
obj.ySpd *= -1;
green._x = obj._x;
green._y = 340;
green._yscale = green._xscale=random(100)+50;
sound = new Sound();
sound.attachSound("con08");
sound.setVolume(100);
sound.start(0,1);
}
if (obj._x<0) {
obj.xSpd *= -1;
yellow._x = obj._x;
yellow._y = 240;
yellow._yscale = yellow._xscale=random(100)+50;
sound = new Sound();
sound.attachSound("con01");
sound.setVolume(200);
sound.start(0,1);
}
if (obj._x>800) {
obj.xSpd *= -1;
yellow._x = obj._x;
yellow._y = 240;
yellow._yscale = yellow._xscale=random(100)+50;
sound = new Sound();
sound.attachSound("con02");
sound.setVolume(100);
sound.start(0,1);
}
if (obj._y<0) {
obj.ySpd *= -1;
yellow._x = obj._x;
yellow._y = 240;
yellow._yscale = yellow._xscale=random(100)+50;
sound = new Sound();
sound.attachSound("con03");
sound.setVolume(100);
sound.start(0,1);
}
if (obj._y>600) {
obj.ySpd *= -1;
yellow._x = obj._x;
yellow._y = 240;
yellow._yscale = yellow._xscale=random(100)+50;
sound = new Sound();
sound.attachSound("con04");
sound.setVolume(150);
sound.start(0,1);
}
}
}
setup();
this.onEnterFrame = function() {
runDrum();
};
訂閱:
張貼留言 (Atom)
http://www.youtube.com/watch?v=mLjaapUmDcE
回覆刪除