3-10 线段涂鸦板
paper_mc = new MovieClip();
this.addChild(paper_mc);
Mouse.hide();
paint_mc.startDrag(true);
paper_mc.graphics.lineStyle(10,0xFF0000,1);//用刷子的元件代替鼠标:
stage.addEventListener("mouseDown",movePen);
function movePen(me:MouseEvent){
paper_mc.graphics.moveTo(this.mouseX, this.mouseY);
}
stage.addEventListener("mouseUp",drawPen);
function drawPen(me:MouseEvent){
paper_mc.graphics.lineTo(this.mouseX, this.mouseY);
}
3-11 影片剪辑的拖拽和停止拖拽
tar_mc.alpha = 0.5;
this.addEventListener("mouseDown", godrag);
function godrag(me:MouseEvent){
tar_mc.startDrag(true);
tar_mc.alpha = 1;
}
this.addEventListener("mouseUp", stopdrag);
function stopdrag(me:MouseEvent){
tar_mc.stopDrag();
tar_mc.alpha = 0.5;
}
3-13 判断物体鼠标指针的位置是否和物体重叠
pic_mc.alpha=0.5;
stage.addEventListener("mouseMove",showpic);
function showpic(me:MouseEvent){
var myX = this.mouseX;
var myY = this.mouseY;
var test = pic_mc.hitTestPoint(myX,myY,true);
if (test){
pic_mc.stop();
pic_mc.alpha=1;
}else{
pic_mc.play();
pic_mc.alpha=0.5;
}
}
3-14 可拖拽并放大对象的放大镜
zoom_mc.buttonMode = true;
myX=zoom_mc.x;
myY=zoom_mc.y;
zoom_mc.addEventListener("mouseDown",pickZoom);
function pickZoom(me:MouseEvent){
zoom_mc.startDrag();
}
zoom_mc.addEventListener("mouseUp",putZoom);
function putZoom(me:MouseEvent){
zoom_mc.stopDrag();
if(zoom_mc.dropTarget.name!="instance1"){
zoom_mc.dropTarget.scaleX *=1.1;
zoom_mc.dropTarget.scaleY *=1.1;
}
zoom_mc.x=myX;
zoom_mc.y=myY;
}