Why Does The Flex Compiler Get Confused If a Property Name Matches A Class Type?
This is more of a rant than a question; but I am curious to know if anyone has some insight for me. The application I am working on deals with a C# .NET backend; communication is achieved via a socket over which we push AMF objects. The AMF object class definitions are generated by the server side team and I just have to use registerClassAlias
on the flash side to link them up - pretty standard; the only difference being that as they come from a C# background they prefer to use UpperCammelCasing instead of lowerCamelCasing for property names.
Today I got a bunch of updated AMF objects which I dropped into the project; but I noticed that after updating my project would no longer compile - here are the class definitions in question:
LeaderboardInfo.as Generated Class
package com.generated {
public class LeaderboardInfo {
public var IsTied : Boolean;
}
}
GameResult.as Generated Class
package com.generated {
public class GameResult {
public var LeaderboardInfo : Leade开发者_如何学CrboardInfo;
}
}
MXMLC error
[mxmlc] .../GameResult.as(27): col: 32 Error: Type was not found or was not a compile-time constant: LeaderboardInfo. [mxmlc] public var LeaderboardInfo : LeaderboardInfo; [mxmlc] ^
If I change the property name from LeaderboardInfo
to SomethingElse
then it compiles fine; my only guess would be that the Compiler can not distinguish between the property name and the type attribute, but is that really the case?!
I think it's because you've just overwritten the "definition" of LeaderboardInfo
to be a property and not a class, so when it's looking for the class, the property definition takes precedence, which breaks it.
I'd imagine you'd get the same result if you tried to do something like public var return:int = 0;
精彩评论