// main_init function

main_init = function(mc){
 box = function ( mc, tl_x, tl_y, br_x, br_y ){
  mc.lineStyle();
  mc.beginFill(0);
  mc.moveTo (tl_x,tl_y);
  mc.lineTo (br_x,tl_y);
  mc.lineTo (br_x,br_y);
  mc.lineTo (tl_x,br_y);
  mc.endFill();
 }
 q = Math.floor ((direction % 360)/ 90);
 t = Math.tan ((direction % 90)/ 180 * Math.PI);
}


// main_effect function

main_effect = function(mc,frame){
 if (subs_done) end_effect = true;
}

// sub_init function

sub_init = function(mc){
 b = mc.getBounds(mc);

 // calculate initial position

 if (q==0) {

  dx1 = b.xMax - b.xMin;
  dy1 = -dx1 * t;
  dy = b.yMin - b.yMax;
  dx = -dy / t;

 } else if (q==1) {

  dx1 = b.xMin - b.xMax;
  dy1 = dx1 / t;
  dy = b.yMin - b.yMax;
  dx = dy * t;

 } else if (q==2) {

  dx1 = b.xMin - b.xMax;
  dy1 = -dx1 * t;
  dy = b.yMax - b.yMin;
  dx = -dy / t;

 
 } else if (q==3) {

  dx1 = b.xMax - b.xMin;
  dy1 = dx1 / t;
  dy = b.yMax - b.yMin;
  dx = dy * t;

 }

 if (dx*dx + dy*dy > dx1*dx1 + dy1*dy1) { dx = dx1; dy = dy1; }

 mc._parent.createEmptyMovieClip("m"+mc._i,mc._i*10+6);
 msk = mc._parent["m"+mc._i];
 mc.setMask(msk);
 box (msk,b.xMin,b.yMin,b.xMax,b.yMax);
 msk._x = mc._x;
 msk._y = mc._y;

 mc.sx = mc.__x + dx;
 mc.sy = mc.__y + dy;
 if (!out_effect){
  mc._x = mc.sx;
  mc._y = mc.sy;
 }

}

// sub_effect function

sub_effect = function(mc,frame){
 perc = frame / lastsubframe;
 if (!linear_speed) perc = Math.sin(perc*deg90);
 if (out_effect) perc = 1 - perc;
 mc._x = perc * mc.__x + (1-perc) * mc.sx;
 mc._y = perc * mc.__y + (1-perc) * mc.sy;
 if (frame == lastsubframe){
  mc._parent["m"+mc._i].removeMovieClip();
  if (out_effect) mc._alpha=0;
  mc.done=true;
 }
}
