@Override
	public void initFromFields(Object[] fields) {
		name = (String) fields[6];
		ArrayList<Costume> c = new ArrayList<Costume>();
		ArrayList<Sound> s = new ArrayList<Sound>();
		Object[] media = (Object[]) fields[10];
		for (int i = 0; i < media.length; i++) {
			if (media[i] instanceof Costume) {
				c.add((Costume) media[i]);
			}
			if (media[i] instanceof Sound) {
				s.add((Sound) media[i]);
			}
		}
		costumes = c.toArray(new Costume[0]);
		sounds = s.toArray(new Sound[0]);
		
		costumeIndex = Arrays.asList(costumes).indexOf(fields[11]);
		
		Object[] scripts = (Object[]) fields[8];
		
		ArrayList<Object> hats = new ArrayList<Object>();
		hats.add("EventHatMorph");
		hats.add("KeyEventHatMorph");
		hats.add("MouseClickEventHatMorph");
		
		ArrayList<Thread> list = new ArrayList<Thread>();
		
		for (int i = 0; i < scripts.length; i++) {
			Object[] script = (Object[]) ((Object[]) scripts[i])[1];
			if (hats.indexOf(((Object[]) script[0])[0]) != -1) {
				Thread thread = new Thread(this, (Object[]) script);
				list.add(thread);
				//if (script[]) {
				thread.start();
				//}
			}
		}
		
		threads = list.toArray(new Thread[0]);
	}