var sp:Sprite = new Sprite();
sp.graphics.beginFill(0,0.8)
sp.graphics.drawCircle(0,0,10);
sp.graphics.endFill();
sp.x=stage.stageWidth/2;
sp.y=stage.stageHeight/2;
addChild(sp);
var mousex:int;
var mousey:int;
mousex = mouseX;
mousey = mouseY;
stage.addEventListener(MouseEvent.MOUSE_MOVE,MouseMove);
function MouseMove(e:MouseEvent)
{
(sp.x > 0) ? sp.x -= mouseX-mousex : sp.x = 0;
(sp.x
(sp.y < stage.stageHeight) ? sp.y -= mouseY-mousey : sp.y = stage.stageHeight;
mousex = mouseX;
mousey = mouseY;
}
package {
import flash.events.MouseEvent;
import flash.events.Event;
import fl.transitions.Tween;
import fl.transitions.easing.*;
public class bgControl {
public var _mouseX:uint;
public var _mouseY:uint;
public var _followSpList:Array=new Array;
public var pic:Object;
public var bloone:Boolean=false;
public var canshu:uint;
private var Boolean_chu:Boolean
private var stageW:uint;
private var stageH:uint;
private var picW:uint;
private var picH:uint;
public function bgControl() {
Boolean_chu=false;
Theinit(pic)//舞台创建图片实例,pic图片超大
}
public function Theinit(pic) {
pic.addEventListener(MouseEvent.MOUSE_MOVE,mousemove);
}
public function mousemove(e) {
var _l0=e.target.parent
if (Boolean_chu==false) {
stageW=e.target.root.stage.stageWidth;
stageH=e.target.root.stage.stageHeight;
picW=_l0.width;
picH=_l0.height;
Boolean_chu=true;
}
var xTween:Tween = new Tween(_l0, "x", Regular.easeOut, _l0.x,-e.target.root.mouseX / stageW * (picW - stageW), 0.5, true);
var yTween:Tween = new Tween(_l0, "y", Regular.easeOut, _l0.y,-e.target.root.mouseY / stageH * (picH - stageH), 0.5, true);
e.updateAfterEvent();
}
}
}