Freek
%Europe/Berlin %712 %2005, 18:05
Zie hier de file: test.swf (http://www.inflavor.com/wallframe_10.swf)
Ik ben nu al een tijdje bezig om een fatsoenlijk hitTest vanuit een Array te maken.
Ik krijg nu te zien wanneer er een hit is, maar zou na deze hit als de vlakken elkaar niet meer raken ook een "mis" willen zien.
Heeft er iemand een suggestie?!
Hieronder de code:
dropDepth = 100;
dragCount = 0;
//--------------------------------------------------------------------
clipArray = new Array();
tempClipArray = new Array();
function copyClipArray() {
tempClipArray = clipArray.slice(0);
}
//--------------------------------------------------------------------
hitTester = function () {
copyClipArray();
var arrayNumber = dragTarget.substring(4, dragTarget.length)-1;
tempClipArray.splice(arrayNumber, 1);
checkHitID = setInterval(checkHit, 100, _root[dragTarget]);
};
function checkHit(whichClip) {
for (var i = 0; i<_root.clipArray.length; i++) {
if (whichClip.hitTest(_root[tempClipArray[i]])) {
whichClip._alpha = 50;
_root.hitText.text = "hit";
}
/*else {
_root[dragTarget]._alpha = 100;
_root.hitText.text = "mis";
}*/
}
}
//--------------------------------------------------------------------
drag = function () {
_root.dropDepth++;
_root[dragTarget].swapDepths(dropDepth);
_root[dragTarget].startDrag();
hitTester();
};
drop = function () {
if (_root[dragTarget].hitTest(_root.trashCan)) {
_root[dragTarget]._visible = false;
_root[dragTarget].stopDrag();
clearInterval(checkHitID);
} else if (_root[dragTarget].hitTest(_root.dropZone)) {
_root[dragTarget].stopDrag();
clearInterval(checkHitID);
}
};
//--------------------------------------------------------------------
BGV.useHandCursor = false;
BGV.onPress = function() {
dropDepth++;
dragCount++;
dragTarget = "drag"+dragCount;
_root.clipArray.push(_root.dragTarget);
BGV.duplicateMovieClip(dragTarget, dropDepth);
_root.hitTester();
_root[dragTarget].startDrag(true);
_root[dragTarget].useHandCursor = false;
_root[dragTarget].onPress = function() {
_root.dragTarget = this._name;
_root.drag();
};
_root[dragTarget].onRelease = function() {
_root.drop();
};
};
BGV.onReleaseOutside = function() {
drop();
};
Even als laatste:
Veel dank voor de hulp bij een eerdere test (http://www.flashfocus.nl/forum/showthread.php?t=1637) aan iedereen, helaas moeten de figuren later ook roteren en dus was de getoonde methode niet bruikbaar.
Ik ben nu al een tijdje bezig om een fatsoenlijk hitTest vanuit een Array te maken.
Ik krijg nu te zien wanneer er een hit is, maar zou na deze hit als de vlakken elkaar niet meer raken ook een "mis" willen zien.
Heeft er iemand een suggestie?!
Hieronder de code:
dropDepth = 100;
dragCount = 0;
//--------------------------------------------------------------------
clipArray = new Array();
tempClipArray = new Array();
function copyClipArray() {
tempClipArray = clipArray.slice(0);
}
//--------------------------------------------------------------------
hitTester = function () {
copyClipArray();
var arrayNumber = dragTarget.substring(4, dragTarget.length)-1;
tempClipArray.splice(arrayNumber, 1);
checkHitID = setInterval(checkHit, 100, _root[dragTarget]);
};
function checkHit(whichClip) {
for (var i = 0; i<_root.clipArray.length; i++) {
if (whichClip.hitTest(_root[tempClipArray[i]])) {
whichClip._alpha = 50;
_root.hitText.text = "hit";
}
/*else {
_root[dragTarget]._alpha = 100;
_root.hitText.text = "mis";
}*/
}
}
//--------------------------------------------------------------------
drag = function () {
_root.dropDepth++;
_root[dragTarget].swapDepths(dropDepth);
_root[dragTarget].startDrag();
hitTester();
};
drop = function () {
if (_root[dragTarget].hitTest(_root.trashCan)) {
_root[dragTarget]._visible = false;
_root[dragTarget].stopDrag();
clearInterval(checkHitID);
} else if (_root[dragTarget].hitTest(_root.dropZone)) {
_root[dragTarget].stopDrag();
clearInterval(checkHitID);
}
};
//--------------------------------------------------------------------
BGV.useHandCursor = false;
BGV.onPress = function() {
dropDepth++;
dragCount++;
dragTarget = "drag"+dragCount;
_root.clipArray.push(_root.dragTarget);
BGV.duplicateMovieClip(dragTarget, dropDepth);
_root.hitTester();
_root[dragTarget].startDrag(true);
_root[dragTarget].useHandCursor = false;
_root[dragTarget].onPress = function() {
_root.dragTarget = this._name;
_root.drag();
};
_root[dragTarget].onRelease = function() {
_root.drop();
};
};
BGV.onReleaseOutside = function() {
drop();
};
Even als laatste:
Veel dank voor de hulp bij een eerdere test (http://www.flashfocus.nl/forum/showthread.php?t=1637) aan iedereen, helaas moeten de figuren later ook roteren en dus was de getoonde methode niet bruikbaar.