Lingo Dictionary > D-F > on EvalScript

 

on EvalScript

Syntax

on EvalScript aParam
	statement(s)
end

Description

System message and event handler; in a Shockwave movie, contains statements that run when the handler receives an EvalScript message from a browser. The parameter is a string passed in from the browser.

The EvalScript message can include a string that Director can interpret as a Lingo statement. Lingo cannot accept nested strings. If the handler you are calling expects a string as a parameter, pass the parameter as a symbol.

The on EvalScript handler is called by the EvalScript() scripting method from JavaScript or VBScript in a browser.

The Director player for Java doesn't support the on EvalScript handler. To enable communication between an applet and a browser, use Java, JavaScript, or VBScript.

Include only those behaviors in on EvalScript that you want users to control; for security reasons, don't give complete access to behaviors.

Note: If you place a return at the end of your EvalScript handler, the value returned can be used by JavaScript in the browser.

Example

This shows how to make the playback head jump to a specific frame depending on what frame is passed in as the parameter:

on EvalScript aParam
	go frame aParam
end

Example

This handler runs the statement go frame aParam if it receives an EvalScript message that includes dog, cat, or tree as an argument:

on EvalScript aParam
	case aParam of 
		"dog", "cat", "tree": go frame aParam
	end case
end

A possible calling statement for this in JavaScript would be EvalScript ("dog").

Example

This handler takes an argument that can be a number or symbol:

on EvalScript aParam
	if word 1 of aParam = "myHandler" then
		do aParam
	end if
end

Example

This handler normally requires a string as its argument. The argument is received as a symbol and then converted to a string within the handler by the string function:

on myHandler aParam
	go to frame string(aParam)
end

See also

externalEvent, return (keyword)