Copy link to clipboard
Copied
Hello
I'm trying to assign a number to a object property and I get the following error:
ReferenceError: Error #1056: Cannot create property choice on String. ...at Main.as:791
Line 791 is: customClass.redirectionUnre.choice = 2;
Before I try to overwrite the property, it is a string ("2" instead of 2). Does this matter? If so, what workaround do I have to use?
unless your customClass instance is a singleton you probably are using different customClass instances to define redirectionUnre.
Copy link to clipboard
Copied
what type of object is customClass.redirectionUnre?
that's the issue.
Copy link to clipboard
Copied
Im not quite sure, does this help?:
public var redirectionUnre:Object = {};
Copy link to clipboard
Copied
it helps if that line of code is in your customClass'es class file.
if it is, what is choice?
Copy link to clipboard
Copied
Yes, its in the customClass. I define the choice like this:
var result:Array = choiceSniffer.exec(redirectionData);
redirectionUnre.choice = result[2];
redirectionData is a string and choice equals a match from a capture group.
Copy link to clipboard
Copied
unless your customClass instance is a singleton you probably are using different customClass instances to define redirectionUnre.
Copy link to clipboard
Copied
My bad, i mistakenly redefined the Object a few lines prior:
redirectionUnre = 1;
not defining a property, just the object. Problem fixed, but shouldn't the debugger notify me of this? As it does if I try to define String vars with Arrays?
Copy link to clipboard
Copied
no, not with an object.
this would probably pass the compiler:
var obj:Object={};
obj=1;
Find more inspiration, events, and resources on the new Adobe Community
Explore Now