Flex/actionscript assignment failing?

Casting using the as keyword returns null when it fails. In this case, the first item in the array collection may not be an object of type Bar as you expect; it could be a Foo or something else. You can cast subclass object to base-class but not the other way Use the parenthesis syntax for casting - it'll throw an exception if cast fails and thus you can figure out the type of arr.

GetItemAt(0) Change var tempBar:Bar = arr. GetItemAt(0) as Bar; //to var tempBar:Bar = Bar(arr. GetItemAt(0)) to make sure that the first item in the array collection is indeed a Bar instance (and not Foo or something else) Otherwise you can find the type using trace(flash.utils.

GetQualifiedClassName(arr. GetItemAt(0))) if(tempBar! = null) { tempBar.

SomeProp++; f = tempBar; // f is now null } By the way, I believe the posted code is not the exact code you ran because for f to be null tempBar should be null as you assigning it to f In that case the code inside if should not be executed as you're checking for null inside if Even if it enters the if block, it will throw a null pointer error (#1009) in the first line where you're trying to increment tempBar.someProp.

Casting using the as keyword returns null when it fails. In this case, the first item in the array collection may not be an object of type Bar as you expect; it could be a Foo or something else. You can cast subclass object to base-class but not the other way.

Use the parenthesis syntax for casting - it'll throw an exception if cast fails and thus you can figure out the type of arr. GetItemAt(0). //Change var tempBar:Bar = arr.

GetItemAt(0) as Bar; //to var tempBar:Bar = Bar(arr. GetItemAt(0)); to make sure that the first item in the array collection is indeed a Bar instance (and not Foo or something else). Otherwise you can find the type using trace(flash.utils.

GetQualifiedClassName(arr. GetItemAt(0))); if(tempBar! = null) { tempBar.

SomeProp++; f = tempBar; // f is now null } By the way, I believe the posted code is not the exact code you ran because for f to be null, tempBar should be null as you assigning it to f. In that case the code inside if should not be executed as you're checking for null inside if. Even if it enters the if block, it will throw a null pointer error (#1009) in the first line where you're trying to increment tempBar.someProp.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions