所以我对actionscript 3相当陌生,为了练习,我制作了一个脚本,当单击数组中的三个方块之一时,它将把它移动到一个随机点。没有任何编译器错误,但输出显示:
ReferenceError: Error #1069: Property x not found on String and there is no default value.
at trying_Scene1_fla::MainTimeline/move_sq()
单击其中一个方块时。继承人的脚本:
import flash.events.MouseEvent;
import flash.events.Event;
var squares:Array=[ square_1, square_2, square_3]
var low:Number=1;
var high:Number=100;
var chosen:Number=Math.floor(Math.random()* (1+ high - low))+low;
for(var i=0; i<squares.length; i++){
squares[i].addEventListener(MouseEvent.CLICK, move_sq);
}
function move_sq(e:MouseEvent):void{
var square_num = e.target.name;
if (chosen>50) {
square_num.x -= Math.random()* 10
square_num.y -= Math.random()* 10
}
else {
square_num.x += Math.random()* 10
square_num.y += Math.random()* 10
}
}
enter code here
我希望这只是一个小错误或我不知道的事情,如果你能帮忙,请做。谢谢!