- This topic has 4 replies, 2 voices, and was last updated 5 years, 5 months ago by Yuri Kovelenov.
-
AuthorPosts
-
2019-07-13 at 11:00 pm #16980SargentoParticipant
This is the 5th time that I’m trying to post this comment, hoping this time works:
Hello again.
I’m iterating over a list of Strings to assign some behaviors to some objects.
The list contains: “Amarillo”, “Azul” and “Rojo”.
I’m using the list on a for each to hide the next objects:
– Cubo.Amarillo.001
– Cubo.Azul.001
– Cubo.Rojo.001
using a Create Text puzzle with “Cubo.” + i + “.001” and works perfectly.Inside the same fore each I have a When Hovered puzzle to switch the cursor to pointer (hand) when over and switch back to default when out. That works perfectly too. With objects “Cubo.” + i: ( “Cubo.Amarillo”, “Cubo.Azul” and “Cubo.Rojo” )
But it doesn’t work when enabling/disabling the outline. It works on the three items but all of them show/hide the outline on the last object ( Cubo.Rojo ) as it is the last value assigned to the variable ( j on this case).
Here is the JavaScript code created by the puzzles:
Colores = [‘Amarillo’, ‘Azul’, ‘Rojo’];
for (var i_index in Colores) {
i = Colores[i_index];
j = [‘Cubo.’,i,’.001′].join(”);
changeVis(j, false); // This works
j = String(‘Cubo.’) + String(i);
console.log(j);
registerOnHover(j, function() {
setHTMLElemStyle(‘cursor’, ‘pointer’, [“BODY”], false); // This works
outline(j, “ENABLE”); // This doesn’t work as it uses the last value of the variable
}, function() {
setHTMLElemStyle(‘cursor’, ‘default’, [“BODY”], false); // This works
outline(j, “DISABLE”); // This doesn’t work as it uses the last value of the variable
});
}Is there some kind of Current Object puzzle? That would be a great addition, I guess.
For example when using When Hovered puzzle.
Like:
When Hovered: CUBE
over: do outline ‘enable’ for current_object
out: do outline ‘disable’ for current_object2019-07-13 at 11:00 pm #16981SargentoParticipantHere’s an image of the puzzles used:
2019-07-14 at 10:17 am #16985Yuri KovelenovStaffHi,
Sorry for the inconvenience with the forums. Last week we were attacked by spammers so now we are using an anti-spam system, which sometimes mistakes.
Regarding your question, I think you have the same issue as here:
(This JavaScript-related gotcha was one of the reasons we didn’t allow event puzzles to be embedable until recently).
2019-07-20 at 7:35 pm #17141SargentoParticipantI just noticed the existence of Current Object puzzle. :)
It’s called Hovered Object and Picked Object.
I’m still using the same structure, but instead of using the string generated I’m using the Hovered Object puzzle.It works perfectly inside a foreach loop.
Thanks.
2019-07-22 at 6:50 am #17160Yuri KovelenovStaff -
AuthorPosts
- You must be logged in to reply to this topic.