这是非常基本的,那里有samples,但我仍在努力。
我需要使用是/否选项发出警报 我需要在动作中做到这一点。
Alert.show("Open new tab to search in Google Maps?",
"No places found", Alert.YES | Alert.NO, this, alertListener, null, Alert.NO);
function alertListener(eventObj:CloseEvent):void {
if (eventObj.detail==Alert.YES) {
Alert.show("You clicked yes");
}
}
这会使用flash调试播放器返回异常:
TypeError: Error #1034: Type Coercion failed: cannot convert mx.rpc::AsyncResponder@e31c601 to flash.display.Sprite.
at Function/ExampleCustomTools.Locator:locator/private:doFind/ExampleCustomTools.Locator:onResult()[C:\Users\sjackson\Adobe Flash Builder 4\DekhoSimulator_Profiler\src\ExampleCustomTools\Locator\locator.mxml:142]
at mx.rpc::AsyncResponder/result()[E:\dev\hero_private_beta\frameworks\projects\rpc\src\mx\rpc\AsyncResponder.as:95]
at com.esri.ags.tasks::Locator/handleAddressCandidates()[C:\checkout\flex_api2\api\src\com\esri\ags\tasks\Locator.as:187]
at Function/http://adobe.com/AS3/2006/builtin::call()
at com.esri.ags.tasks::BaseTask/handleResult()[C:\checkout\flex_api2\api\src\com\esri\ags\tasks\BaseTask.as:667]
at Function/com.esri.ags.tasks:BaseTask/esri_internal:sendURLVariables2/com.esri.ags.tasks:result()[C:\checkout\flex_api2\api\src\com\esri\ags\tasks\BaseTask.as:604]
at mx.rpc::Responder/result()[E:\dev\hero_private_beta\frameworks\projects\rpc\src\mx\rpc\Responder.as:56]
at mx.rpc::AsyncToken/http://www.adobe.com/2006/flex/mx/internal::applyResult()[E:\dev\hero_private_beta\frameworks\projects\rpc\src\mx\rpc\AsyncToken.as:239]
at mx.rpc.events::ResultEvent/http://www.adobe.com/2006/flex/mx/internal::callTokenResponders()[E:\dev\hero_private_beta\frameworks\projects\rpc\src\mx\rpc\events\ResultEvent.as:207]
at HTTPOperation/http://www.adobe.com/2006/flex/mx/internal::dispatchRpcEvent()[E:\dev\hero_private_beta\frameworks\projects\rpc\src\mx\rpc\http\HTTPService.as:991]
at mx.rpc::AbstractInvoker/http://www.adobe.com/2006/flex/mx/internal::resultHandler()[E:\dev\hero_private_beta\frameworks\projects\rpc\src\mx\rpc\AbstractInvoker.as:318]
at mx.rpc::Responder/result()[E:\dev\hero_private_beta\frameworks\projects\rpc\src\mx\rpc\Responder.as:56]
at mx.rpc::AsyncRequest/acknowledge()[E:\dev\hero_private_beta\frameworks\projects\rpc\src\mx\rpc\AsyncRequest.as:84]
at DirectHTTPMessageResponder/completeHandler()[E:\dev\hero_private_beta\frameworks\projects\rpc\src\mx\messaging\channels\DirectHTTPChannel.as:451]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at flash.net::URLLoader/onComplete()
我尝试了几种代码变体,但仍然会出错。 为这样一个微不足道的Q道歉,但感谢任何帮助指出什么是错误的,以及最优雅的方式。
Here is the code in its fuller context at pastebin (line 31).
答案 0 :(得分:6)
我应该坚持自己多一点。 代码修复如下:
Alert.show("Open new tab to search in Google Maps?", "No places found", Alert.YES | Alert.NO, null, alertListener, null, Alert.NO);
function alertListener(eventObj:CloseEvent):void {
// Check to see if the OK button was pressed.
if (eventObj.detail==Alert.YES) {
Alert.show("here");
}
}