Вот весь исходник (математическое округление я использовал для точности позиционирования бокса, иначе расчеты сбивались на миллионные доли и программа переставала работать):

Код AS1/AS2:
Stage.align="TL"
Stage.scaleMode="noScale"
stagelistener = new Object();
speed1 = 1;
speed_angle1 = speed1 / 2;
round_val = 0.01;
i = 1;
this.onEnterFrame=function(){
sw=Stage.width;
sh=Stage.height;
txt_x.text = _root["box" + i]._x;
txt_y.text = _root["box" + i]._y;
txt_angle.text = _root["box" + i]._rotation;
//низ
if ( _root["box" + i]._x > 0 && _root["box" + i]._y == sh && _root["box" + i]._rotation == 0){
stagelistener.onResize=function(){
sw=Stage.width;
sh=Stage.height;
_root["box" + i]._y = sh;
if (_root["box" + i]._x > sw){
_root["box" + i]._x = sw;
}
}
Stage.addListener(stagelistener);
_root["box" + i]._x = Math.round((_root["box" + i]._x - speed1)/round_val)*round_val;
}
//лево_низ
else if( _root["box" + i]._x == 0 && _root["box" + i]._y == sh && _root["box" + i]._rotation < 90){
stagelistener.onResize=function(){
sh=Stage.height;
_root["box" + i]._y = sh;
}
Stage.addListener(stagelistener);
_root["box" + i]._rotation = Math.round((_root["box" + i]._rotation + speed_angle1)/round_val)*round_val;
}
//лево
else if( _root["box" + i]._x == 0 && _root["box" + i]._y > 0 && _root["box" + i]._rotation == 90 ){
stagelistener.onResize=function(){
sh=Stage.height;
if ( _root["box" + i]._y > sh ){
_root["box" + i]._y = sh;
}
}
Stage.addListener(stagelistener);
_root["box" + i]._y = Math.round((_root["box" + i]._y - speed1)/round_val)*round_val;
}
//лево_верх
else if( _root["box" + i]._x == 0 && _root["box" + i]._y == 0 && _root["box" + i]._rotation < 180 ){
_root["box" + i]._rotation = Math.round((_root["box" + i]._rotation + speed_angle1)/round_val)*round_val;
}
//верх
else if( _root["box" + i]._x < sw && _root["box" + i]._y == 0 && _root["box" + i]._rotation == 180 ){
stagelistener.onResize=function(){
sw=Stage.width;
if ( _root["box" + i]._x > sw ){
_root["box" + i]._x = sw;
}
}
Stage.addListener(stagelistener);
_root["box" + i]._x = Math.round((_root["box" + i]._x + speed1)/round_val)*round_val;
}
//верх_право
else if( _root["box" + i]._x == sw && _root["box" + i]._y == 0 && _root["box" + i]._rotation < -90 || _root["box" + i]._rotation == 180){
stagelistener.onResize=function(){
sw=Stage.width;
_root["box" + i]._x = sw;
}
Stage.addListener(stagelistener);
_root["box" + i]._rotation = Math.round((_root["box" + i]._rotation + speed_angle1)/round_val)*round_val;
}
//право
else if( _root["box" + i]._x == sw && _root["box" + i]._y < sh && _root["box" + i]._rotation == -90 ){
stagelistener.onResize=function(){
sw=Stage.width;
sh=Stage.height;
_root["box" + i]._x = sw;
if ( _root["box" + i]._y > sh ){
_root["box" + i]._y = sh;
}
}
Stage.addListener(stagelistener);
_root["box" + i]._y = Math.round((_root["box" + i]._y + speed1)/round_val)*round_val;
}
//право_низ
else if ( _root["box" + i]._x == sw && _root["box" + i]._y == sh && _root["box" + i]._rotation < 0){
stagelistener.onResize=function(){
sw=Stage.width;
sh=Stage.height;
_root["box" + i]._x = sw;
_root["box" + i]._y = sh;
}
Stage.addListener(stagelistener);
_root["box" + i]._rotation = Math.round((_root["box" + i]._rotation + speed_angle1)/round_val)*round_val;
}
}
А проблема в том, что когда я добавляю цикл for - не работает привязка к границам окна. Может я вообще изначально в неверном направлении шёл, и эта задача в принципе решается иначе?