View Full Version : ReferenceError: str is not defined
as3_novice
09-15-2008, 01:49 AM
Could someone shed some light on why the following code gets this error
trace_btn.addEventListener(MouseEvent.MOUSE_UP, startTrace)
var str:String = "hello world"
function startTrace(evt:MouseEvent):void
{
MMExecute('fl.trace(str);');
}
The code is being used in a WindowSWF
animatorgeek
09-19-2008, 08:03 PM
My best guess is that you don't have a semicolon at the end of your string declaration. The interpreter probably thinks it's part of the the function declaration that follows it. In fact, I notice that your call to addEventListener doesn't have a semicolon either. Frankly, I'm surprised this ran without more errors....
rtsamir
09-22-2008, 07:14 AM
Change the line
MMExecute('fl.trace(str);');
to
MMExecute('fl.trace(' + str + ');');
and it's going to work.
The JSFL don't know your AS variables
as3_novice
09-22-2008, 11:31 PM
Thank you so much, I was starting to give up hope. I knew it had to be something simple I was missing.
as3_novice
09-23-2008, 03:33 AM
The exact code to display the variable is as follows:
MMExecute('fl.trace("' + str+ '");');
|
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.