var chk = false;
var myNum = 4;
for (var i=1; i<8; i++) {
this["btn"+i].trgScale =100;
this["btn" + i].addEventListener(MouseEvent.ROLL_OVER,onOver);
this["btn" + i].addEventListener(MouseEvent.ROLL_OUT,onOut);
}
function onOver(e:MouseEvent)
{
chk=true;
var myNum:Number=Number(e.target.name.substring(4));
}
function onOut(e:MouseEvent)
{
chk=false;
reset();
}
var center = btn4.x;
function reset() {
for (i=1; i<8; i++)
{
this["btn" + i].trgScale=100;
}
myNum = 4;
btn4.addEventListener(Event.ENTER_FRAME,onEnter);
function onEnter(e:Event) {
var speed = (center-e.target.x)*0.0001;
if (Math.abs(speed)<0.0001) {
e.target.removeEventListener(Event.ENTER_FRAME,onEnter);
}
}
}
for (var j=1; j<8; j++) {
this["btn" + j].addEventListener(Event.ENTER_FRAME,thisEnter);
}
addEventListener(Event.ENTER_FRAME,thisEnter);
function thisEnter(e:Event) {
for (j=1; j<8; j++) {
this["btn"+j].scaleX = this["btn"+j].scaleY=(this
["btn"+j].trgScale-this["btn"+j].scaleX)*0.01;
if (chk) {
var distance = Math.abs(this["btn"+j].x-this.mouseX)/2;
this["btn"+j].trgScale = 200-distance;
if (this["btn" + j].trgScale<100) {
this["btn"+j].tgScale = 100;
}
}
}
for (j=myNum+1; j<8; j++) {
this["btn"+j].x = this["btn"+(j-1)].x+this["btn"+(j-1)].width/2
+this["btn"+j].width/2-5;
}
for (j=myNum-1; j>0; j--) {
this["btn"+j].x = this["btn"+(j+1)].x-this["btn"+(j+1)].width/2
-this["btn"+j].width/2+5;
}
}
测试影片,输出中显示:ReferenceError: Error #1056: 无法为 flash.display.SimpleButton 创建属性 trgScale。
at 02_fla::MainTimeline/02_fla::frame1()
什么原因啊? 谢谢