Converting AS2 to AS3!

Hello!

I am a newbie when it comes to AS3, but I’m gradually picking up things here and there. I really don’t know how to convert the code below to AS3. If someone could please help me, I would greatly appreciate it! I understand that the underscores are no longer used in AS3. Thanks in advance!


 
numOfMask = 4;
// number of mask 
numOfImage = 3;
// number of images
gap1 = 300;
// interval between one mask appearing and the next one(0.3 second)
gap2 = 3000;
// interval between the background image and the next one(3 second)
gap3 = 200;
// distance between one mask and the other
gap4 = 5000;
// looping time after all images displayed(5 second)
current = 1;
back.swapDepths(1);
front.swapDepths(3);
back.gotoAndStop(1);
front.gotoAndStop(1);
front.setMask(mask);
//
for (i=1; i<=numOfMask; i++) {
   mask.attachMovie("rectMoveSet", i, i);
   mask*._x = (gap3/2+gap3*(i-1));
}
counter = 1;
id = setInterval(mask, "aa", gap1);
//
mask.aa = function() {
   for (temp in mask[counter]) {
      mask[counter][temp].gotoAndPlay(2);
   }
   if (counter>numOfMask) {
      clearInterval(id);
      id = setInterval(bb, 1000);
   }
   counter++;
};
function bb() {
   clearInterval(id);
   _root.textMove.removeMovieClip();
   _root.attachMovie("textMove"+current, "textMove", 4);
   back.gotoAndStop(current+1);
   for (temp in mask) {
      mask[temp].removeMovieClip();
   }
   if (current == numOfImage) {
      current = 1;
      id = setInterval(cc, gap4);
   } else {
      current++;
      id = setInterval(cc, gap2);
   }
   front.gotoAndStop(current);
}
//
function cc() {
   _root.textMove.swapDepths(2);
   for (i=1; i<=numOfMask; i++) {
      mask.attachMovie("rectMoveSet", i, i);
      mask*._x = (gap3/2+gap3*(i-1));
      if (i%2) {
         mask*._y = 0;
      } else {
         mask*._y = 0;
      }
   }
   counter = 1;
   clearInterval(id);
   id = setInterval(mask, "aa", gap1);
}