Reputation: 163
could someone explain to me, why the Flash Builder tells me error 1120 Access of undefined property value? Thank you for every advice :-)
<fx:Script>
<![CDATA[
var value:Number = 5;
if(value == 5) {
trace("value is 5");
}
]]>
</fx:Script>
Upvotes: 0
Views: 399
Reputation: 872
You are tracing the value without any method call. You put your "if condition" in a method and call this method. I think it should definitely work.
protected function yourMethod():void{
var value:int = 5;
if(value == 5) {
trace("value is 5");
}
}
]]>
Upvotes: 0
Reputation: 39408
You can't put random ActionScript code in your MXML file. The if statement needs to be moved into a method; kinda like this:
<fx:Script>
<![CDATA[
var value:Number = 5;
protected function myMethod():void{
if(value == 5) {
trace("value is 5");
}
}
]]>
</fx:Script>
I also recommend scoping the value declaration, like this:
public var value:Number = 5;
Upvotes: 1