How to change a property of an object in an array list



  • Hi Qt Hackers
    in this example ( http://harmattan-dev.nokia.com/docs/library/html/qt4/declarative-tutorials-samegame-samegame2.html ) an array is used to store the objects of the gamefield. When they restart the game all the objects going to be deleted. My question is: Is there a way to change the properties of an single oject in this array? I've tried this:
    @board[0].visible = false@

    But all I get is a type error: Cannot set property "visible" of undefined

    Thanks
    Eli



  • Maybe that will give you some hints. This is output from node.js but javascript is javascript. Actually download node.js and try to play around with it a little bit:

    @> a = new Array(10)
    [ , , , , , , , , , ]

    a[0]
    undefined
    a[0].visible
    TypeError: Cannot read property 'visible' of undefined
    at repl:1:6
    at REPLServer.eval (repl.js:80:21)
    at Interface.<anonymous> (repl.js:182:12)
    at Interface.emit (events.js:67:17)
    at Interface._onLine (readline.js:162:10)
    at Interface._line (readline.js:426:8)
    at Interface._ttyWrite (readline.js:603:14)
    at ReadStream.<anonymous> (readline.js:82:12)
    at ReadStream.emit (events.js:88:20)
    at ReadStream._emitKey (tty.js:327:10)
    a[0] = {visible: 'hi'}
    { visible: 'hi' }
    a[0].visible
    'hi'
    a[0].visible = 'bye'
    'bye'
    a[0].visible
    'bye'
    @


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.