我要做一个益智游戏。 当我克服拼图时,它无法移动并显示输出错误。
TypeError: Error #1006: value is not a function.
at Puzzles_fla::MainTimeline/dragObjek()
at Puzzles_fla::MainTimeline/frame2()
at flash.display::MovieClip/gotoAndStop()
at Puzzles_fla::MainTimeline/btn_1()
我的代码是
var ypos:int;
var xpos:int;
dragObjek(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12); // definisi bagian" dari puzzle
menu1.addEventListener(MouseEvent.CLICK, btn_menu1);
function btn_menu1(e:MouseEvent):void{
gotoAndStop(1); // untuk kembali ke menu
}
function getPos(target:Object){
xpos = target.x;
ypos = target.y;
}
function startdrag(event:MouseEvent){
event.target.startDrag(true);
getPos(event.target);
}
function stopdrag(event:MouseEvent){
if(event.target.hitTestObject(getChildByName(event.target.name+"Target"))){
event.target.x = getChildByName(event.target.name+"Target").x;
event.target.y = getChildByName(event.target.name+"Target").y;
}else{
event.target.x = xpos;
event.target.y = ypos;
}
event.target.stopDrag();
}
function dragObjek(... objects){
for (var i:int = 0; i < objects.length; i++){
objects[i].addEventListener(MouseEvent.MOUSE_DOWN, startdrag);
objects[i].addEventListener(MouseEvent.MOUSE_UP, stopdrag);
}
我在Adobe Flash CS6上使用AS3。 拼图无法拖动,我无法返回菜单框架。