Wednesday, May 21, 2003

Pasting ASP source code into Authorware Display


I see this asked occasionally:-

"I am trying to paste ASP source code into an Authorware Display icon. When I close the Display icon I get the error "Where is function blah()?. How do I fix this?"

The answer is surprisingly simple. In JScript (and many other programming languages, for instance ActionScript, C) the code of custom functions is wrapped in curly brackets "{ }". Authorware uses these same characters in Display icons to denote variables or expressions that it is to evaluate at runtime. When Authorware sees these in code that has been pasted into a Display icon, it assumes you want to evaluate what is inside the brackets.

The cure is simple. Just escape the curly brackets. So if you want to paste in this simple JS function:-


function areaOfSphere(radius) {
return 4 * Math.PI * (Math.pow(radius, 2));
}


escape the curly brackets thus:-


function areaOfSphere(radius) \{
return 4 * Math.PI * (Math.pow(radius, 2));
\}

No comments: