for some reason this flex 4 code gives me an error but I can't figure out why. In my WindowedApplication I have:
var prefs:Object = fs.readObject();
var rect:Rectangle = new Rectangle();
rect = prefs.bounds as Rectangle;
this.bounds = rect; // error here
ArgumentError: Error #2007: Parameter rect must be non-null.
I originally also tried it without the rect object and just did:
this.bounds = prefs.bounds as Rectangle;
which gives me the following error:
TypeError: Error #1034: Type Coercion failed: cannot convert Object@1dbbe1f1 to flash.geom.Rectangle.
That seems like a bogus error since I can assign pref.bounds to rect without an error. I don't know why this isn't working. It works under flex 3 compatibility mode but that also breaks a lot of my spark components so I can't use it.