我到处找其他有这个问题的人,但似乎找不到解决办法,就在这里。
我在教科书中找到了一本关于Flash CS3的关于益智游戏的教程。这是相当直截了当的,如果你抓住一块,它称为startDrag和stopDrag。
于是我开始制作自己的游戏,在游戏中,我创建了一个名为movieClip的puzzleGame。我几乎已经将代码从最初的教程复制到了我的puzzleGame movieClip中,但是当我测试它时,我总是会收到一个错误,说明startDrag和stopDrag不是一个函数。这和我的主要舞台里的电影有关。
如果我将代码更改为this.startDrag,那么它实际上会拖拽整个框架。我认为,不管出于什么原因,它不是钻研到实际的物体,我拖,而只是看到我触摸电影本身。
这有道理吗?
这是我的frame2代码。
stop();
import flash.utils.*;
var mySound:Sound = new correctSound();
var score:Number = 0;
var numClips:Number = 7;
var myClip = new Array(numClips);
myClip[0] = addChild(new a0());
myClip[1] = addChild(new a1());
myClip[2] = addChild(new a2());
myClip[3] = addChild(new a3());
myClip[4] = addChild(new a4());
myClip[5] = addChild(new a5());
myClip[6] = addChild(new a6());
//myClip[7] = addChild(new a7());
//myClip[8] = addChild(new a8());
//myClip[9] = addChild(new a9());
myClip[0].name = "piece0";
myClip[1].name = "piece1";
myClip[2].name = "piece2";
myClip[3].name = "piece3";
myClip[4].name = "piece4";
myClip[5].name = "piece5";
myClip[6].name = "piece6";
//myClip[7].name = "piece7";
//myClip[8].name = "piece8";
//myClip[9].name = "piece9";
var nph = new Array(numClips);
nph[0] = nph0_mc;
nph[1] = nph1_mc;
nph[2] = nph2_mc;
nph[3] = nph3_mc;
nph[4] = nph4_mc;
nph[5] = nph5_mc;
nph[6] = nph6_mc;
//nph[7] = nph7_mc;
//nph[8] = nph8_mc;
//nph[9] = nph9_mc;
var tpg = new Array(numClips);
tpg[0] = tpg0_mc;
tpg[1] = tpg1_mc;
tpg[2] = tpg2_mc;
tpg[3] = tpg3_mc;
tpg[4] = tpg4_mc;
tpg[5] = tpg5_mc;
tpg[6] = tpg6_mc;
//tpg[7] = tpg7_mc;
//tpg[8] = tpg8_mc;
//tpg[9] = tpg9_mc;
var x0 = myClip[0].x = Math.random()*400+50;
var y0 = myClip[0].y = Math.random()*50+50;
var x1 = myClip[1].x = Math.random()*400+50;
var y1 = myClip[1].y = Math.random()*50+50;
var x2 = myClip[2].x = Math.random()*400+50;
var y2 = myClip[2].y = Math.random()*50+50;
var x3 = myClip[3].x = Math.random()*400+50;
var y3 = myClip[3].y = Math.random()*50+50;
var x4 = myClip[4].x = Math.random()*400+50;
var y4 = myClip[4].y = Math.random()*50+50;
var x5 = myClip[5].x = Math.random()*400+50;
var y5 = myClip[5].y = Math.random()*50+50;
var x6 = myClip[6].x = Math.random()*400+50;
var y6 = myClip[6].y = Math.random()*50+50;
/*var x7 = myClip[7].x = Math.random()*400+50;
var y7 = myClip[7].y = Math.random()*50+50;
var x8 = myClip[8].x = Math.random()*400+50;
var y8 = myClip[8].y = Math.random()*50+50;
var x9 = myClip[9].x = Math.random()*400+50;
var y9 = myClip[9].y = Math.random()*50+50;*/
var j:Number;
for (var k:Number = 0; k < numClips; k++) {
myClip[k].addEventListener("mouseDown", pieceMove);
myClip[k].addEventListener("mouseUp", pieceMove);
}
function pieceMove(evt:Event):void {
if (evt.type == "mouseDown") {
//mySound.play();
evt.target.startDrag();
}
else if (evt.type == "mouseUp") {
//mySound.play();
evt.target.stopDrag();
for (j = 0; j < numClips; j++) {
if (evt.target.name == "piece" + j &&
evt.target.hitTestObject(nph[j]) == true) {
removeChild(myClip[j]);
nph[j].alpha = 0;
tpg[j].alpha = 100;
score++;
}
else if (evt.target.name == "piece" + j) {
evt.target.x = Math.random()*400+50;
evt.target.y = Math.random()*50+50;
}
}
scor.text = score.toString();
if (score == 10) {
msgbox.text = "Congratulations !";
}
}
}
I'm using Flash CS3 because it's required by my course I'm taking so a suggestion to use a different version of flash is not helpful. Thanks. 发布于 2014-11-27 00:50:51
所以我所做的不是使用嵌入的电影剪辑,我只是在我的主要时间线内重新制作它,它工作的很好。因为这件事比较麻烦,但它的工作没有问题。不知道为什么第一条路行不通。
https://stackoverflow.com/questions/27094346
复制相似问题