여러 대상이 같은 대상에 배치되는 끌어서 놓기 작업을 만들고 있습니다. 주 타임 라인에 액션 코드가 있고 스프라이트에 코드가 첨부되어 있습니다.해제 할 때 개체가 원래 위치로 돌아 가지 않습니다. cs4
문제 :이 맞다면 나는 물체를 놓으면
는 해당 섹션의 상단에 스냅합니다. 올바르지 않으면 원래 방향으로 돌아와서 다시 주워 야합니다. 불행히도 그것은 놓은 곳에 머물러 있으며 잘못되었을 때 원래 위치로 돌아 가지 않습니다. 코드가 기본 타임 라인이나 스프라이트에 있다고 가정하면이 플래시 파일과 관련된 다른 문제가 수정되었지만 객체를 릴리스 한 후에는 영향을 미치지 않는 것으로 보입니다. 스크립트 끝 부분에
_root.rlamp1.gotoAndPlay(1)
이 있습니다.이 대답은 잘못된 경우 울리는 부저입니다. 이것은 올바르게 작동하고 있습니다.관련 항목인지 잘 모르겠지만 정확한 위치를 지정하면 다음 항목이 원래 위치로 시작되지만 원래 위치 대신 내 마우스가 시작됩니다. 나는 상대적으로 코딩에 익숙하지 않고 과학 수업을위한 활동을 만들어 개념에 대해 이해하는지 즉시 피드백을 얻으려고 노력하고 있습니다.
도움 주셔서 감사합니다.
// [Action in Frame 1]
answername = Array();
answerdest = Array();
answername[0] = "gravel";
answerdest[0] = "1";
answername[1] = "nuts and bolts";
answerdest[1] = "1";
answername[2] = "oxygen";
answerdest[2] = "2";
answername[3] = "helium";
answerdest[3] = "2";
answername[4] = "gold";
answerdest[4] = "2";
dbCount = 0;
dbutton.duplicateMovieClip("dbutton" + dbCount,dbCount * 100);
dbutton.visible = false;
dbutton0.answer = answerdest[dbCount];
dbutton0.theText.text = answername[dbCount];
// This code is on the sprite and not on the main actionscript
onClipEvent (load)
{
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
}
on (press)
{
if (this.noDrag !=true)
{
startDrag (this,false);
}
}
on (release)
{
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
}
정말 액션 스크립트 3입니까? –
특히 물고기처럼 보이는 코드는'onClipEvent (load)'와'on (press)'와'on (release)'입니다. 그것은 AS3 구문이 아닙니다. 어디서 났어? 그 줄들이 미친 실수를 저 지르지 않니?! AS2에서 기억하는 것처럼 보입니다. 오류가 발생하지 않으므로 디버거 버전의 플래시를 사용하지 않는 것으로 추측됩니다. 디버그 모드에서 실행하려면 Ctrl + Shift + Enter를 사용하여 코드를 실행하고 어떤 오류가 발생했는지 알려주십시오. –
Ctrl + Shift + Enter 키를 사용하여 실행 했으므로 오류가 발생하지 않습니다. 이 코드는 swf 파일을 디 컴파일하여 얻을 수 있습니다. 원하는대로 수행하면 코드를 이해하고 코드를 변경하여 내 용도에 맞게 사용할 수 있습니다. – user7259892