@Override
	public void starting(int seed) throws FractalStartFailedException {
		try {
			this.seed = seed;

			cx = Context.enter();

			scriptFile = new File(scriptFileField.getText());

			try {
				scriptReader = new FileReader(scriptFile);
			} catch (FileNotFoundException e) {
				throw new FractalStartFailedException(
						"Could not create script file reader!", e);
			}

			Object obj;

			Logger jsLog = LogManager.getLogger("CustomJsFractal:"
					+ scriptFile.getName());

			scope = new ImporterTopLevel(cx);

			obj = new NativeJavaClass(scope, KColor.class);
			scope.put("KColor", scope, obj);

			jsLogObj = Context.javaToJS(jsLog, scope);

			// register functions
			scope.put("getLogger", scope, js_getLogger);
			scope.put("getWidth", scope, js_getWidth);
			scope.put("getHeight", scope, js_getHeight);
			scope.put("getSeed", scope, js_getSeed);

			try {
				cx.evaluateReader(scope, scriptReader, scriptFile.getName(), 1,
						null);
			} catch (IOException e) {
				throw new FractalStartFailedException(
						"Could not evaluate the script!", e);
			}

			obj = scope.get("functions", scope);
			if (obj == Scriptable.NOT_FOUND) {
				throw new FractalStartFailedException(
						"Could not find functions var!");
			}

			Scriptable functions = Context.toObject(obj, scope);

			obj = functions.get("fileName", functions);
			getFileNameFunc = null;
			if (obj instanceof Function)
				getFileNameFunc = (Function) obj;

			obj = functions.get("pixel", functions);
			getPixelFunc = null;
			if (obj instanceof Function)
				getPixelFunc = (Function) obj;

			obj = functions.get("finish", functions);
			finishFunc = null;
			if (obj instanceof Function)
				finishFunc = (Function) obj;

			log.info("Loaded js: " + scriptFile.getName());
		} catch (Throwable t) {
			throw new FractalStartFailedException(t);
		}
	}