如何触发 YesNo 警报框事件?
这是非常基本的,有示例在那里,但我仍在挣扎。
我需要使用是/否选项触发警报。
我需要在动作脚本中执行此操作。
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");
}
}
这会返回闪存调试播放器的异常:
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()
我尝试了代码的几种变体,但仍然出现错误。 对于这样一个微不足道的问题表示歉意,但感谢您指出问题所在以及最优雅的方法的帮助。
This is very basic and there are samples out there, but I am still struggling.
I need to fire an alert with a yes/no option.
I need to do this in actionscript.
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");
}
}
This returns an exception with the flash debug player:
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()
I have tried several variations of the code, but still get errors.
Apologies for such a trivial Q, but appreciate any help on pointing out whats wrong and the most elegant way of doing this.
Here is the code in its fuller context at pastebin (line 31).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我应该自己再坚持一点。
代码修复如下:
I should have persevered on my own a bit more.
Code fix below: