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.

Unwanted different behaviour using a for loop

Home Forums Puzzles Unwanted different behaviour using a for loop

Viewing 1 post (of 1 total)
  • Author
    Posts
  • #40073
    elie520
    Participant

    Hello,
    I’m trying to have an outline when I hover all the objects of my scene which fit a certain criteria.
    When I do it manually, with

    registerOnHover(obj1,false,function(){outline(obj1, 'ENABLE')},function(){outline(obj1,'DISABLE')});
    registerOnHover(obj2,false,function(){outline(obj2, 'ENABLE')},function(){outline(obj2,'DISABLE')});
    //...

    it works fine. But when I try to use a for loop like this:

    for (var i = 0 ; i < objs.length ; i++) {
    registerOnHover(objs\,false,function(){outline(objs, 'ENABLE')},function(){outline(objs,'DISABLE')});
    }

    whenever I hover one of the objects, it is always the last one of the list that gets outlined.

    If anyone could help, it’d be greatly appreciated :)
    Thanks!

Viewing 1 post (of 1 total)
  • You must be logged in to reply to this topic.