String to enum

Can I make my string into a enum in javascript>

it would make this switch function unnessesary and I won;t have to edit it when i possibly add an element to an enum.

function SetStation(setToo :String) :void
			currentUpgrade = Upgrades.Jump;

Upgrades is my enum and I wonder if I could have something like Upgrades. + the jump string = Upgrades.Jump

Google says this:

var value : Upgrades = (Upgrades) Enum.Parse(typeof(Upgrades), setToo );

The traditional method is to treat enums as ints, when needed. Say the enum is {“walk”, “run”, “jump”}. That’s just a fancy way so we don’t have to write if(up==0) and have to remember that upgrade #0 is walk. But when you write up=Upgrade.walk to computer really stores it as up=0.

So you’d send the RPC: int upNum = (int)setToo, which would send a 2 for “jump”. Then translate back using Upgrade up=(Upgrades)upNum.

The funny thing is, the number will have been a 2 the entire time. All the castes are doing is telling the computer that it’s OK to use the “real” 0,1,2 code numbers.

But an RPC is already so slow and uses a minimum 4K(?) anyway, that sending “the long way” as a string isn’t going to matter unless you send hundreds each frame.