Lottery balls floating, bouncing

Trying to wrap my mind around how lottery balls fly around in those air bubbles. They are pushed up and around I assume, and they bounce off each other and the round sides of the container.

I have been searching for examples but only found a Stringy example from 2005

var r=circle._width/2
for (var i = 0; i<20; i++) {
 var clip = this.attachMovie("mc", "mc"+i, i);
 clip._x = circle._x+Math.random()*50-25;
 clip._y = circle._y+Math.random()*50-25;
 clip.velx =Math.random()*10-5
 clip.vely =Math.random()*10-5
 clip.onEnterFrame =move
}
function move(){
 this._x +=this.velx
 this._y +=this.vely
 this.x = this._x-circle._x
 this.y = this._y-circle._y
 this.d =Math.round(Math.sqrt(this.x*this.x+this.y*this.y))
 if(this.d>r-this._width/2){
  this.velx*=-1
  this.vely*=-1
 }
}