We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.

Current Object

Home Forums Puzzles Current Object

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

    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

    #16981
    Sargento
    Participant

    Here’s an image of the puzzles used:

    #16985

    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).

    Chief 3D Verger | LinkedIn | Twitter

    #17141
    Sargento
    Participant

    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.

    #17160

    :good:

    Chief 3D Verger | LinkedIn | Twitter

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.