我找到了一个执行我要做的事情的SWF文件。因此,我将其加载并进行了分配,因此我可以学习正确执行的操作。然后将其应用于我正在从事的工作。应该有很多项目,个人将其拖入正确的类似物中。如果释放时正确,则保持原状,如果Incorect将其移回开始。看起来
我已经对原始文件进行了几次更改,因为它无法正常工作。您可以看到(OnClipeVent)中的原始代码。我似乎已经解决了大多数问题,但是我无法将拖动的项目释放到正确的位置。我还为精灵添加了动作脚本。每个彩色三角形从左到右将它们从一个到5号(希望这是正确的)感谢您的帮助。沮丧的科学老师。
// Action script…
// [onClipEvent of sprite 2 in]
//onClipEvent (load)
this.addEventListener(Event.ENTER_FRAME, this.loading);
function loading(e:Event)
{
this.numItems = 2;
}
// [onClipEvent of sprite 2 in]
//onClipEvent (load)
this.addEventListener(Event.ENTER_FRAME, loading);
function loading(event:Event){
this.numItems = 3;
}
// [onClipEvent of sprite 2 in]
//onClipEvent (load)
this.addEventListener(Event.ENTER_FRAME, loading);
function loading(event:Event){
this.numItems = 3;
}
// [onClipEvent of sprite 8 in]
//onClipEvent (load)
this.addEventListener(Event.ENTER_FRAME, loading);
function loading(event:Event){
this.defx = _x;
this.defy = _y;
if (this.theText.text.length > 20)
{
this.theText._height = 31;
this.theBox._height = 27;
}
else
{
this.theText._height = 19;
this.theBox._height = 19;
} // end else if
}
// [onClipEvent of sprite 8 in frame 1]
//on (press)
this.addEventListener(MouseEvent.MOUSE_DOWN, pressed);
function pressed(event:Event){
if (this.noDrag != true)
{
startDrag (this, false);
} // end if
}
// [onClipEvent of sprite 8 in frame 1]
//on (release)
this.addEventListener(MouseEvent.MOUSE_UP, relea);
function relea(event:Event){
if (this.noDrag != true)
{
stopDrag ();
if(this.hitTest(_root["dz" + this.answer]))
{
totalHeight = 0;
for (v = 0; v < _root.dbCount; v++)
{
if (_root["dbutton" + v].answer == this.answer)
{
totalHeight = totalHeight + _root["button" + v].theBox._height ;
} // end if
} // end of for
++_root.dbCount;
this .duplicateMovieClip("dbutton" + _root.dbCount, _root.dbCount * 100);
_root["dbutton" + _root.dbCount]._x = this.defX;
_root["dbutton" + _root.dbCount]._y = this.defY;
_root["dbutton" + _root.dbCount].answer = _root.answerdest[_root.dbCount + 1];
_root["dbutton" + _root.dbCount].theText.text = _root.answername[_root.dbCount +1];
if (_root["dbutton" + _root.dbCount].theText.text == "undefined")
{
_root["dbutton" + _root.dbCount].theText.text = "Finished!";
_root["dbutton" + _root.dbCount].noDrag = true;
} // end if
this.noDrag = true;
this._y = _root["dz" + this.answer]._y + totalHeight;
this._x = _root["dz" + this.answer]._x - _root["dz" + this.answer]._width / 2;
++_root["dz" + this.answer].numItems;
_root.glamp1.gotoAndPlay (1);
}
else
{
this.x = this.defX;
this._y = this.defY;
_root.rlamp1.gotoAndPlay(1);
} // end if
} // end else if
}
// [onClipEvent of sprite 2 in frame 1]
//onClipEvent (load)
this.addEventListener(Event.ENTER_FRAME, loading);
function loading(event:Event){
this.numItems = 2;
}
// [onClipEvent of sprite 2 in frame 1]
//onClipEvent (load)
this.addEventListener(Event.ENTER_FRAME, loading);
function loading(event:Event){
this.numItems = 3;
}
// [Action in Frame 1]
answername = Array();
answerdest = Array();
answername[0] = "gravel";
answerdest[0] = "1";
answername[1] = "water";
answerdest[1] = "2";
dbCount = 0;
dbutton.duplicateMovieClip("dbutton" + dbCount,dbCount * 100);
dbutton.visible = false;
dbutton0.answer = answerdest[dbCount];
dbutton0.theText.text = answername[dbCount];
//on (release)
this.addEventListener(MouseEvent.MOUSE_UP, relea);
function relea(event:Event){
应该是
//on (release)
this.addEventListener(MouseEvent.MOUSE_UP, relea);
function relea(event:MouseEvent){ // **** MouseEvent, not Event
你看到了吗?您告诉relea
功能期望Event
。应该期望MouseEvent
。是否修复?
感谢您的帮助,我发现这个问题的答案是,我最终将相同的代码放置在"精灵"动作框架中,并且在主要时间线行动框架中,只能是在精灵中。