burtonrider1983
09-01-2006, 01:36 AM
I used to always use this to initialize a class with certain variables.
var test:myClass = new myClass("test", {_x:20, _y:20});
When I try to do this in AS3.0, it tells me that only 1 parameter was expected...or however many that constructor expects.
I was wondering, did they completely get rid of the object initializer? Is there a slightly different syntax to achieve the same functionality? Yes I know I could use getter/setters functions to change the properties, or I could add parameters to the constructor to substitute this, but I would like to know if the object initializer is removed. I know that you can use ... to signify that you are accepting zero or more parameters more, I will try and get it working this way in the meantime. I assume that this was the replacement for the makeshift way the object initializer used to.
var test:myClass = new myClass("test", {_x:20, _y:20});
When I try to do this in AS3.0, it tells me that only 1 parameter was expected...or however many that constructor expects.
I was wondering, did they completely get rid of the object initializer? Is there a slightly different syntax to achieve the same functionality? Yes I know I could use getter/setters functions to change the properties, or I could add parameters to the constructor to substitute this, but I would like to know if the object initializer is removed. I know that you can use ... to signify that you are accepting zero or more parameters more, I will try and get it working this way in the meantime. I assume that this was the replacement for the makeshift way the object initializer used to.