0

4 개의 드래그 앤 드롭 항목이 있고 대상에 모든 드래그 앤 드롭이 적용되지만 '웰던'이벤트가 시작되고 그 부분이 작동하지 않아야합니다 . 나는 약간의 도움을 받았지만 할 수있다,이 일을하게, 내가 뭘 잘못하고 있니?JqueryUI 항목 그룹이 드롭 가능 대상 영역에있을 때 감지

// insert code to be run when the symbol is created here 
yepnope({nope:['scripts/jquery-ui-1.10.3.custom.min.js','scripts/jquery.ui.touch-punch.min.js'], complete: init}) 

// Initial state: not dropped 
sym.setVariable("dropped", "false"); 

function init(){ 
//Use Jquery code for draggable and droppable 

//Drag it 
sym.$('scrambled_egg').draggable({opacity:.5, revert:'invalid'}); 

//Drop it on the target 
sym.$('scrambled_target').droppable({ 
    accept:sym.$("scrambled_egg"), 
    drop: function() { 
    sym.getSymbol("scrambled_egg").play(); 

// Store that you dropped it 
    sym.setVariable("dropped", "true"); 
    // Call a function to check if all the symbols are dropped 
    // and fire event "done" 
    checkIfAllDropped(); 
    } 
    } 
); 

//Snap back to default state 
sym.$('scrambled_default').droppable({ 
accept:sym.$("scrambled_target"), 
drop: function() { 
    // Back to not dropped state 
    sym.setVariable("dropped", "false"); 
} 
} 
); 

//End code chunk 



//Use Jquery code for draggable and droppable 
//Drag it 
sym.$('fried_egg').draggable({opacity:.5, revert:'invalid'}); 

//Drop it on the target 
sym.$('fried_target').droppable({ 
    accept:sym.$("fried_egg"), 
    drop: function() { 
    sym.getSymbol("fried_egg").play(); 

    // Store that you dropped it 
    sym.setVariable("dropped", "true"); 
    // Call a function to check if all the symbols are dropped 
    // and fire event "done" 
    checkIfAllDropped(); 
    } 
    } 
); 
//Snap back to default state 
sym.$('fried_default').droppable({ 
accept:sym.$("fried_target"), 
drop: function() { 
    // Back to not dropped state 
    sym.setVariable("dropped", "false"); 
} 
} 
); 
//End code chunk 

    //Use Jquery code for draggable and droppable 
//Drag it 
sym.$('poached_egg').draggable({opacity:.5, revert:'invalid'}); 

//Drop it on the target 
sym.$('poached_target').droppable({ 
    accept:sym.$("poached_egg"), 
    drop: function() { 
    sym.getSymbol("poached_egg").play(); 

    // Store that you dropped it 
    sym.setVariable("dropped", "true"); 
    // Call a function to check if all the symbols are dropped 
    // and fire event "done" 
    checkIfAllDropped(); 
    } 
    } 
); 
//Snap back to default state 
sym.$('poached_default').droppable({ 
accept:sym.$("poached_target"), 
drop: function() { 
    // Back to not dropped state 
    sym.setVariable("dropped", "false"); 
} 
} 
); 
//End code chunk 

//Use Jquery code for draggable and droppable 

//Drag it 
sym.$('boiled_egg').draggable({opacity:.5, revert:'invalid'}); 

//Drop it on the target 
sym.$('boiled_target').droppable({ 
    accept:sym.$("boiled_egg"), 
    drop: function() { 
    sym.getSymbol("boiled_egg").play(); 

    // Store that you dropped it 
    sym.setVariable("dropped", "true"); 
    // Call a function to check if all the symbols are dropped 
    // and fire event "done" 
    checkIfAllDropped(); 
    } 
    } 
); 

//Snap back to default state 
sym.$('boiled_default').droppable({ 
accept:sym.$("boiled_target"), 
drop: function() { 
    // Back to not dropped state 
    sym.setVariable("dropped", "false"); 
} 
} 
); 
//End code chunk 
} 

checkIfAllDropped = function(){ 
var stage = AdobeEdge.getComposition("How_do_you_eat_yours").getStage(); 
var sym1 = stage.getSymbol("scrambled_target"); 
var sym2 = stage.getSymbol("fried_target"); 
var sym2 = stage.getSymbol("boiled_target"); 
var sym2 = stage.getSymbol("poached_target"); 
if(sym1.getVariable("dropped") === "true" && 
    sym2.getVariable("dropped") === "true" && 
    sym3.getVariable("dropped") === "true" && 
    sym4.getVariable("dropped") === "true"){ 
    // Fire event done! 
    stage.play("welldone"); 
} 
}; 
+0

답변 주셔서 감사합니다. Ena, 구현하려고하지만 많은 성공을 거두지 않았습니다. –

답변

0

이렇게하면됩니다 : 요소를 놓을 때마다이 이벤트를 어딘가에 저장하고 모든 요소가 삭제되었는지 확인합니다. 예를 들어 는 :

// Initial state: not dropped 
sym.setVariable("dropped", "false"); 

sym.$('scrambled_target').droppable({ 
    accept:sym.$("scrambled_egg"), 
    drop: function() { 
     sym.getSymbol("scrambled_egg").play(); 

     // Store that you dropped it 
     sym.setVariable("dropped", "true"); 
     // Call a function to check if all the symbols are dropped 
     // and fire event "done" 
     checkIfAllDropped(); 
    } 
    } 
); 

sym.$('scrambled_default').droppable({ 
    accept:sym.$("scrambled_egg"), 
    drop: function() { 
     // Back to not dropped state 
     // EDIT HERE! Dind't get that sym was your stage. 
     // AND EDIT EVERYWHERE ELSE. 
     sym.getSymbol("scrambled_egg").setVariable("dropped", "false"); 
    } 
    } 
); 

checkIfAllDropped() 함수는 다음과 같이 보일 것입니다 : 당신의 checkIfAllDropped 당신이 var에 sym2 여러 번 할당하는 기능에

checkIfAllDropped = function(){ 
    var stage = AdobeEdge.getComposition("COMPOSITION_CLASS_NAME").getStage(); 
    var sym1 = stage.getSymbol("sym1"); 
    var sym2 = stage.getSymbol("sym2"); 
    if(sym1.getVariable("dropped") === "true" && 
     sym2.getVariable("dropped") === "true"){ 
     // Fire event done! 
     stage.play("done"); 
    } 
}; 

은주의해야합니다.

checkIfAllDropped = function(){ 
var stage = AdobeEdge.getComposition("How_do_you_eat_yours").getStage(); 
var sym1 = stage.getSymbol("scrambled_target"); 
// Here... 
var sym2 = stage.getSymbol("fried_target"); 
// Here... 
var sym2 = stage.getSymbol("boiled_target"); 
// Here... 
var sym2 = stage.getSymbol("poached_target"); 
if(sym1.getVariable("dropped") === "true" && 
    sym2.getVariable("dropped") === "true" && 
    sym3.getVariable("dropped") === "true" && 
    sym4.getVariable("dropped") === "true"){ 
    // Fire event done! 
    stage.play("welldone"); 
} 
}; 

코드를 다시 게시하기 전에 디버깅하십시오!

+0

여기 코드가 있습니다. 나는 4 개의 아이템을 가지고 있지만, 목표에 모두 떨어졌을 때 'welldone'이벤트를 발사하지 않습니다. 내가 도대체 ​​뭘 잘못하고있는 겁니까? –

+0

작동하지 않습니다. ( –