Drag and Drop for simple Quiz

The problem you have here is that on the other scenes you have Rects with the same class name 'square'

This is fine until you want to gather all elements with the class name 'square'

The other scenes rects will be picked up and instead of iterating over 4 items you will be iterating over 12.

I wrote a work around for situations like this which has been included in an extension that gathers scene info.

The extension is placed in your head file.

You can then query the current scene element only instead of all of the scenes by using the extension like so.

var sceneInfo = hypeDocument.sceneInfo()
var currentSceneElement  = sceneInfo.sceneElement;
 
var theSquareClass =  currentSceneElement.querySelectorAll('.square');
var thefigClass = document.getElementsByClassName('fig');

dragdrop1_MHv1.hype.zip (47.4 KB)

3 Likes