How do I access a variable declared outside a class?

right now im doing

#pragma strict
var objects = [];

function Start () {}

function Update () {}

class objHandle {
	var id : int;
	var updatelist : Array;
	function objHandle(position,velocity,shapestr,localscale) { = objects.length;
		this.updatelist = new Array();


and I get Unknown identifier: ‘objects’.

The “objects” variable is not accessible to your objHandle class since it’s completely unrelated. There’s no way to access it unless you make it part of the objHandle class.

Some additional things: you must always define the type of variables, either explicitly or by supplying a value. Therefore “var objects = ” will not work since there is no type available. Same goes for “function objHandle(position,velocity,shapestr,localscale)”. Also, do not use the Array class, it’s slow and obsolete. For dynamic arrays, use a generic List.