B@rney,
Если отталкиваться от твоего кода, то можно попробовать вот так:
Code
import com.greensock.*;
import flash.events.MouseEvent;
import flash.events.Event;
import flash.geom.Point;
var wallz:Rectangle = wall.getBounds(this);
var wallzData = new BitmapData(wallz.width, wallz.height, true, 0);
wallzData.draw(wall);
var fishz:Rectangle = fish.getBounds(this);
var fishzData = new BitmapData(fishz.width, fishz.height, true, 0);
fishzData.draw(fish);
var old:Point = new Point(fish.x, fish.y);
fish.addEventListener(MouseEvent.MOUSE_DOWN, onDown);
this.addEventListener(Event.ENTER_FRAME, enterFrameListener);
function enterFrameListener(e:Event):void
{
if(wallzData.hitTest(new Point(wall.x, wall.y),
255,
fishzData,
new Point(fish.x, fish.y),
255
))
{
fish.x = old.x;
fish.y = old.y;
TweenMax.killTweensOf(fish);
}
else
{
old.x = fish.x;
old.y = fish.y;
}
}
function onDown(e:MouseEvent):void
{
stage.addEventListener(MouseEvent.MOUSE_UP, onUp);
stage.addEventListener(MouseEvent.MOUSE_MOVE, update);
}
function update(e:Event):void
{
TweenMax.to(fish, 2 ,{x :mouseX, y: mouseY});
}
function onUp(e:MouseEvent):void
{
stage.removeEventListener(MouseEvent.MOUSE_UP, onUp);
stage.removeEventListener(MouseEvent.MOUSE_MOVE, update);
}