我使用功能拖放的还原对象之一在 Adobe Edge Animate 中出错了一半
One of my revert objects for drag n drop with function is half way wrong in Adobe Edge Animate
我在此线程 (Adding a function to jQuery draggable revert "event") 上应用了此处的还原答案,但我仍然遇到问题。
当放置在错误的 drappable 中时,管理器图标出于某种原因而不是恢复到它的位置,只是隐藏并显示正确的图标,如果它没有恢复并且是正确的。反馈是错误的,这是应该的。如果我将它们放在错误的 droppable 中,所有其他人都会按预期恢复并显示反馈。一个人会采取不同的行动,这很奇怪。所有正确的人都做他们应该做的事。
设置:我有一个带有图标的长背景,可以通过按键事件移动。
在顶部,我有一个(固定的)栏,其中包含可放置的和隐藏的图标,它们将出现在正确的可拖动对象上,而实际的可拖动对象将隐藏。这是因为否则 draggables 会随着背景移动,因为 if 与 droppable 所在的栏不同 div。
希望这是有道理的。
var icons = ['GOALS','CUSTOMER','MANAGER','PRODUCT','PRICE','DELIVER','BALANCE'];
for(j=0;j<icons.length;j++){
sym.$(icons[j]).addClass('drag'+j);
// each draggable corresponds to a droppable
// by class name indexed
sym.$('.drag'+j).draggable({
revert: function(obj){
if(obj===false){
// add feedback screen and sound and revert icon
sym.$('wrong').attr('src',"images/wrongSpot.png");
sym.$('wrong').animate({'top': 23},1000);
sym.$("incorrectFX")[0].play();
return true;
}else{
return false;
}// end if else statement
}// end revert
});// end draggable
sym.$('d'+j).droppable({
accept: ".drag"+j,
drop: dropEvent
}); // end droppable
} // end for loop
k = 0;
function dropEvent(event, ui){
ui.draggable.position( { of: $(this), my: 'center', at: 'center' } );
ID = ui.draggable.attr("id").replace('Stage_','');
console.log('this is the id name: ' + ID);
sym.$('wrong').animate({'top': 23},1000);
// replace wrong image with goodJob image since it is correct
sym.$('wrong').attr('src',"images/goodJob.png");
if (music.paused ) {
sym.$("correctFX")[0].pause();
} else {
sym.$("correctFX")[0].currentTime = 0;
sym.$("correctFX")[0].play();
}
// since the droppable area is independant of the bg which move
// I implemented a substitute icon in the fixed area
sym.$(""+ID+"Copy").css({'opacity':1.0}); // show icon on the bar
sym.$(""+ID+"").css({'opacity': 0}); // hide the draggable icon
// count the number of correct to show feedback
k++;
if(k==7){
sym.$('complete').animate({"left":0},700);
sym.$("completionFX")[0].play();
sym.$('wrong').animate({'top':450},1000);
}
} // end dropevent function
如果您只遇到包含 MANAGER
的数组索引 2 的问题,这将创建以下代码:
sym.$('MANAGER').addClass('drag2');
如果您有任何其他 类,即 drag2
,这将导致选择冲突。检查您的代码中是否有任何 类 或可能匹配
以外的 ID
我在此线程 (Adding a function to jQuery draggable revert "event") 上应用了此处的还原答案,但我仍然遇到问题。
当放置在错误的 drappable 中时,管理器图标出于某种原因而不是恢复到它的位置,只是隐藏并显示正确的图标,如果它没有恢复并且是正确的。反馈是错误的,这是应该的。如果我将它们放在错误的 droppable 中,所有其他人都会按预期恢复并显示反馈。一个人会采取不同的行动,这很奇怪。所有正确的人都做他们应该做的事。
设置:我有一个带有图标的长背景,可以通过按键事件移动。
在顶部,我有一个(固定的)栏,其中包含可放置的和隐藏的图标,它们将出现在正确的可拖动对象上,而实际的可拖动对象将隐藏。这是因为否则 draggables 会随着背景移动,因为 if 与 droppable 所在的栏不同 div。
希望这是有道理的。
var icons = ['GOALS','CUSTOMER','MANAGER','PRODUCT','PRICE','DELIVER','BALANCE'];
for(j=0;j<icons.length;j++){
sym.$(icons[j]).addClass('drag'+j);
// each draggable corresponds to a droppable
// by class name indexed
sym.$('.drag'+j).draggable({
revert: function(obj){
if(obj===false){
// add feedback screen and sound and revert icon
sym.$('wrong').attr('src',"images/wrongSpot.png");
sym.$('wrong').animate({'top': 23},1000);
sym.$("incorrectFX")[0].play();
return true;
}else{
return false;
}// end if else statement
}// end revert
});// end draggable
sym.$('d'+j).droppable({
accept: ".drag"+j,
drop: dropEvent
}); // end droppable
} // end for loop
k = 0;
function dropEvent(event, ui){
ui.draggable.position( { of: $(this), my: 'center', at: 'center' } );
ID = ui.draggable.attr("id").replace('Stage_','');
console.log('this is the id name: ' + ID);
sym.$('wrong').animate({'top': 23},1000);
// replace wrong image with goodJob image since it is correct
sym.$('wrong').attr('src',"images/goodJob.png");
if (music.paused ) {
sym.$("correctFX")[0].pause();
} else {
sym.$("correctFX")[0].currentTime = 0;
sym.$("correctFX")[0].play();
}
// since the droppable area is independant of the bg which move
// I implemented a substitute icon in the fixed area
sym.$(""+ID+"Copy").css({'opacity':1.0}); // show icon on the bar
sym.$(""+ID+"").css({'opacity': 0}); // hide the draggable icon
// count the number of correct to show feedback
k++;
if(k==7){
sym.$('complete').animate({"left":0},700);
sym.$("completionFX")[0].play();
sym.$('wrong').animate({'top':450},1000);
}
} // end dropevent function
如果您只遇到包含 MANAGER
的数组索引 2 的问题,这将创建以下代码:
sym.$('MANAGER').addClass('drag2');
如果您有任何其他 类,即 drag2
,这将导致选择冲突。检查您的代码中是否有任何 类 或可能匹配