I have a for loop that creates pickups, and assigns an onEnterFrame to it:
var pickups = 10;
for (var i = 0; i<pickups; i++) {
var mc = _root.attachMovie("pickup", "pickup_"+i, i);
var speed = Math.floor(Math.random()*(20-5))+5;
mc._x = random(Stage.width);
mc.onEnterFrame = function() {
this._y += speed;
};
}
However this doesn’t work, and the speed isn’t randomized. They are all assigned the same speed. I can’t figure it out. Does anyone know why my code won’t work? I really appreciate it.