Current Object

Home Forums Puzzles Current Object

This topic contains 4 replies, has 2 voices, and was last updated by Yuri Kovelenov Yuri Kovelenov 1 month ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #16980
    Avatar
    Sargento
    Newbie

    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_object

    • This topic was modified 1 week ago by Avatar wpadm. Reason: moved to Puzzles forum
    #16981
    Avatar
    Sargento
    Newbie

    Here’s an image of the puzzles used:

    Attachments:
    You must be logged in to view attached files.
    #16985
    Yuri Kovelenov
    Yuri Kovelenov
    Developer

    Hi,

    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:

    Bind html event to child elements.

    (This JavaScript-related gotcha was one of the reasons we didn’t allow event puzzles to be embedable until recently).

    3D Verger, the CEO
    LinkedIn | FB | Twitter | VK | 新浪微博

    #17141
    Avatar
    Sargento
    Newbie

    I 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. :yes:

    Thanks.

    Attachments:
    You must be logged in to view attached files.
    #17160
    Yuri Kovelenov
    Yuri Kovelenov
    Developer

    :good:

    3D Verger, the CEO
    LinkedIn | FB | Twitter | VK | 新浪微博

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.