
// main_init function

main_init = function(mc){

 subs_done = true;
 b = mc.getBounds(mc);

 // get stage bounaries

 sb = o = new Object();
 o.x = 0;
 o.y = 0;
 mc.globalToLocal(o);
 sb.xMin = o.x;
 sb.yMin = o.y;
 o.x = Stage.width;
 o.y = Stage.height;
 mc.globalToLocal(o);
 sb.xMax = o.x;
 sb.yMax = o.y;

 q = Math.floor ((direction % 360)/ 90);
 t = Math.tan ((direction % 90)/ 180 * Math.PI);

 // calculate initial position

 if (q==0) {

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

 } else if (q==1) {

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

 } else if (q==2) {

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

 
 } else if (q==3) {

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

 }

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

 if (!out_effect) {
  mc._x = dx;
  mc._y = dy;
 }

 ra = -180*Math.round(rotations*2);
 if (reverse_rotation) ra *=-1;
}


// main_effect function

main_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) * dx;
 mc._y = perc * mc.__y + (1-perc) * dy;
 mc._rotation = (1-perc) * ra;
 if (fade) mc._alpha = perc * 100;
 if (scale) mc._xscale = mc._yscale = perc * 100;
 if (frame == lastsubframe) end_effect=true;
}

// sub_init function

sub_init = function(mc){
}

// sub_effect function

sub_effect = function(mc,frame){
}
