Classes and type casting?

    enum ModTypes {

class Modifier {
    var type = ModTypes.DoT;
    var magnitude : float;
    var duration : float;
    var timer : float = 0.0;    
    var activateTimer = 0.0;
    var activateInterlapse;
public var modifiers = new ArrayList();

function ProcessModifiers()
    for (mod in modifiers)
        mod.timer += Time.deltaTime;
        if (mod.type == ModTypes.DoT) {


On that last line I receive a: "Assets/Scripts/Networking/PlayerScript.js(139,30): BCE0051: Operator '==' cannot be used with a left hand side of type 'System.Object' and a right hand side of type 'ModTypes'." Even though it is obviously the correct type?

When pulling items out of an ArrayList (or a Javascript Array() class), you usually need to re-cast it back to the correct type.

If you're iterating through the array, you can do it by declaring the iterator variable's type explicitly, like this:

for (var mod : Modifier in modifiers) {

or you can cast on-the-fly like this:

if ((mod as Modifier).type == ModTypes.DoT) {

Hopefully one of these will solve your error.

It looks like it's another case of javascript's type inference not being able to determine the type

if you change it to

var type : ModTypes = ModTypes.DoT;

it should work