Skip to content

PropertyMapUtil doesn't work for raw public variables #15

@Glidias

Description

@Glidias

The var access:String equates to an empty string when casting from the item.@access attribute. Thus, the conditional value of "access==null" is not met, preventing properties from being applied to public variables in a class.

for each( item in list )
 {
    access = item.@access;
    if( access == "readwrite" || access == "writeonly" || access == null ) {
                   // access isn't null, it's an empty string
             } 
}

My quick-fix version at the moment:

 for each( item in list )
{
    access = item.@access;
    if( access === "readwrite" || access === "writeonly" || access === "" )
}

Last I checked this with Flash CS4 compiler. I'm not sure though as casted string results might differ on different platforms . It might be better to do something like "item.@access == undefined" as the first condition...Or perhaps, simply check that the "item.name()=="variable", and if so, don't even bother with checking the "access" attribute, since there's won't be such an attribute anyway.

The old legacy Camo v2 implementation uses switch case(), which (though may be slower), clearly identifies two different cases for accessor vs. variable situations;

for each (item in list) {
                var itemName : String = item.name().toString();
                switch(itemName) {
                    case "variable":
                        propMap[item.@name.toString()] = item.@type.toString();
                        break;
                    case "accessor":
                        var access : String = item.@access;
                        if ((access == "readwrite") || (access == "writeonly")) {
                            propMap[item.@name.toString()] = item.@type.toString();
                        }
                        break;
                }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions