Hey there! I am trying to serialize data in AS3, but I ran into a frustrating problem. Initially, I had problems with "myObjClass" that were not convertible, but after I discovered "registerClassAlias", everything worked out fine for me.
After some time, I added vectors to myObjClass. I used to run into problems with Vector Strings, as reported here:
https://bugs.adobe.com/jira/browse/FP-6693
Therefore, I know that a workaround is to enable:
registerClassAlias("String", String);
I just don't know how to register an alias for a subvector inside a vector (along with other variables). Here is my code:
var newObj:myObjClass = new myObjClass(); newObj.mySubXML = new Vector.<XML>(); newObj.mySubString = new Vector.<String>(); var myObj:Vector.<myObjClass> = new Vector.<myObjClass>(); myObj.push(newObj); registerClassAlias("String", String);
Problem # 1: When these two lines are included in my compilation, the last line (bytes.readObject ()) fails with an error:
Error #1034: Type Coercion failed: cannot convert __AS3__.vec::Vector.<Object>@42edb21 to __AS3__.vec.Vector.<myObjClass>.
This is really weird. It is as if the first two registerClassAlias have canceled the third.
Problem # 2: If I comment on two lines of the first problem (registering string / xml classes), it will perfectly convert myObj to myObjClass; an internal error does not occur and the application does not stop. However, it cannot convert the internal String and XML vectors, and this error appears in the Output application (without stopping):
TypeError: Error #1034: Type Coercion failed: cannot convert __AS3__.vec::Vector.<Object>@3aabc11 to __AS3__.vec.Vector.<XML>. TypeError: Error #1034: Type Coercion failed: cannot convert __AS3__.vec::Vector.<Object>@3aabc41 to __AS3__.vec.Vector.<String>.
So my question is: how can I register a class alias for:
- Vector. (MyObjClass)
- A vector of strings as a Vector property. (myObjClass)
- An XML vector as a Vector property. (myObjClass)
In the same time?