If you want to set a default value, your code needs to look like this:
public var foo:String = "Hello World"
Otherwise, you'll need some type of even handler:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml
<http://www.adobe.com/2006/mxml>" layout="absolute"
creationComplete="init()">
<mx:Script>
<![CDATA[
public var foo:String;
public function init():void {
foo = "Hello World";
}
]]>
</mx:Script>
</mx:Application>
Shan
jmerrill_2001 wrote:
my entire MXML & Actionscript, which I can't see any errors with:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml
<http://www.adobe.com/2006/mxml>"
layout="absolute">
<mx:Script>
<![CDATA[
public var foo:String;
foo = "Hello World";
]]>
</mx:Script>
</mx:Application>
I am getting this error on that second line in the script:
"1120: Access of undefined property foo."
??? Any ideas? Haven't I already defined the variable "foo"???
Thanks,
Jason