如何触发 YesNo 警报框事件?

发布于 2024-12-09 01:07:45 字数 2956 浏览 0 评论 0原文

这是非常基本的,有示例在那里,但我仍在挣扎。

我需要使用是/否选项触发警报。
我需要在动作脚本中执行此操作。

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()

我尝试了代码的几种变体,但仍然出现错误。 对于这样一个微不足道的问题表示歉意,但感谢您指出问题所在以及最优雅的方法的帮助。

以下是 Pastebin 中更完整的代码(第 31 行)。

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

半边脸i 2024-12-16 01:07:45

我应该自己再坚持一点。
代码修复如下:

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"); 
                             }
                         }

I should have persevered on my own a bit more.
Code fix below:

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"); 
                             }
                         }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文