Hi,
this if my first post and i’m relatively new to actionscript 3 but i’ve done some 2 in the past. so far it hasnt been much fun
what i’m trying to do is create lots of instances of the movie clip, ball, from the left side of the screen at random y positions, then move them across the screen, and those balls that hit the rectangle will add to a text field called score, and will be removed. those who arent, will disappear after they exit the screen but won’t affect score or anything like that.
this is the code i’ve got so far… but i spose it will help if you have the flash file (cs4)
Thanks for any help
//move the ball
addEventListener(Event.ENTER_FRAME, moveball);
function moveball(evt:Event):void {
ball.x +=5;
}
//hit test
addEventListener(Event.ENTER_FRAME, hitrect);
function hitrect(evt:Event):void {
if(ball.hitTestObject(rect)){
trace("hit");
}
}
//make some duplicates
function duplicates() {
var newball:ball = new ball();
this.addChild(newCircle);
newball.x = Math.random()*300;
newball.y = Math.random()*200;
}
duplicates();