我疯了,我的web应用程序Flex 3.6为基础的错误非错误(使用BlazeDS)。我试着描述我的问题:我有一个java类:
public class User {...}
和。as:
[Bindable]
[RemoteClass(alias="it.dto.User")]
public class User {...}
我也有一个数据管理器。像这样执行异步调用:
public function getUser():void {
var token:AsyncToken = _service.getUser();
token.addResponder(new AsyncResponder(userOnResult,userOnFault));
}
private function userOnFault(event:FaultEvent,token:Object):void {
var _fail:String = "Error";
}
private function socOnResult(event:ResultEvent,token:Object):void {
_resUser = event.result as ArrayCollection;
dispatchEvent(new MyEvent("USER_EVENT",_resUser));
}
现在我在两个不同的.as文件(不同的包)中实现了以下代码,它们引用了两个不同的.mxml:var data:DataManager = new DataManager;
....
data.addEventListener("USER_EVENT",userResult);
....
data.getUser();
....
private function userResult(dataEvent:MyEvent):void {
var user:ArrayCollection = new ArrayCollection;
user = dataEvent.result as ArrayCollection;
for (var i:int = 0;i<user.length; i++) {
var u:User = new User;
u = (User)(user.getItemAt(i));
}
_dm.removeEventListener("USER_EVENT",userResult);
}
戏剧是在第一个,因为它完美地工作,而在第二个,我给我一个错误的强制失败。在第二个文件中,它似乎无法识别User类。你知道吗?我要疯了!!谢谢你
@Stacktrace错误:
TypeError: Error #1034: Type Coercion failed: cannot convert appcode.dto::SocietaDTO@b4dbfc1 to appcode.dto.SocietaDTO.
at modules::ReportIspezioni/onSocResult()[D:workspacemagaagaflex_srcmodulesReportIspezioni_src.as:80]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at appcode.dao::DataManager/socOnResult()[D:workspacemagaagaflex_srcappcodedaoDataManager.as:180]
at mx.rpc::AsyncResponder/result()[C:autobuild3.xframeworksprojectsrpcsrcmxrpcAsyncResponder.as:82]
at mx.rpc::AsyncToken/http://www.adobe.com/2006/flex/mx/internal::applyResult()[C:autobuild3.xframeworksprojectsrpcsrcmxrpcAsyncToken.as:199]
at mx.rpc.events::ResultEvent/http://www.adobe.com/2006/flex/mx/internal::callTokenResponders()[C:autobuild3.xframeworksprojectsrpcsrcmxrpceventsResultEvent.as:172]
at mx.rpc::AbstractOperation/http://www.adobe.com/2006/flex/mx/internal::dispatchRpcEvent()[C:autobuild3.xframeworksprojectsrpcsrcmxrpcAbstractOperation.as:199]
at mx.rpc::AbstractInvoker/http://www.adobe.com/2006/flex/mx/internal::resultHandler()[C:autobuild3.xframeworksprojectsrpcsrcmxrpcAbstractInvoker.as:263]
at mx.rpc::Responder/result()[C:autobuild3.xframeworksprojectsrpcsrcmxrpcResponder.as:46]
at mx.rpc::AsyncRequest/acknowledge()[C:autobuild3.xframeworksprojectsrpcsrcmxrpcAsyncRequest.as:74]
at NetConnectionMessageResponder/resultHandler()[C:autobuild3.xframeworksprojectsrpcsrcmxmessagingchannelsNetConnectionChannel.as:524]
at mx.messaging::MessageResponder/result()[C:autobuild3.xframeworksprojectsrpcsrcmxmessagingMessageResponder.as:199]
显然上面写的User类只是举例,以理解代码逻辑。真正的类是一个名为SocietaDTO的DTO。注:代码在我的项目的另一个模块中完美地工作。我不明白为什么这里不工作。
Thanks to lot
开发时从不保存浏览器缓存。无论如何,我通过添加以下内容解决了这个问题:
registerClassAlias("it.mec.dto.SocietaDTO", SocietaDTO);
在班上有例外。
谢谢