lists in javascript

Apr 17, 2011 at 1:59am

lists in javascript

Hi,

I am not too experienced with JS. I am stuck on using only certain elements from a list. I am trying to take an object’s location (x y width height) and keep it’s current x and y while changing the width and height. I looked at the examples for lists and strings and couldn’t figure this out. Any suggestions on where to look?

Thanks,
Eric

#56381
Apr 17, 2011 at 8:01pm

different ways you could approach this. the easiest would probably be using arrays. for example:

var myBox = new Array(4);

Now you have a myBox with 4 slots for information. Now you can put information into the array by accessing each slot like this: myBox[0], myBox[1], myBox[2] and myBox[3] (arrays are always indexed from 0!!).
To output the entire array out an outlet you simply do: outlet(0, myBox), for individual elements outlet(0, myBox[2]).
Hope this is helpful.

#202220
Apr 17, 2011 at 11:31pm

Great, I think this is exactly what I was after. Thanks!

#202221

You must be logged in to reply to this topic.