I have something like
public class Controller {
[Observer("fetchEmployeesEvent")]
public function 开发者_开发百科fetchEmployees() : void {
//doSomething
}
}
and I want something like
public class Controller {
public static const FETCH_EMPLOYEES_EVENT : String = "fetchEmployeesEvent";
[Observer(FETCH_EMPLOYEES_EVENT)]
public function fetchEmployees() : void {
//doSomething
}
}
My problem is that only the first code snippet works. Flex seems to ignore the constant FETCH_EMPLOYEES_EVENT
in the metadata-tag.
My question is: Is it somehow possible to use constant strings in metadata?
It's a pain: there's no way using Flex to do what you're trying to do.
If you're able to add some kind of pre-processor to your compile (which I don't think is possible if you're using FlexBuilder) then you could resolve the constant strings there, otherwise I'm afraid you're out of luck.
精彩评论