天道酬勤,学无止境

How to handle Unhandled #2044 errors from Flash tilelist when changing dataprovider?

I have a tilelist component using a custom ImageCell based item renderer. I know that at times some of the images it is trying to retrieve will not be found and I am able to handle this via an IEOrror listener on the custom ImageCell loader.

However, if I set the data provider, then it is changed before all images have completed their loading or error process, the flash debug player throws up an unhandled #2044 error in firefox stating that an image could not be found. In opera with the debug player it throws a #2044 stating that a load never completed.

I can't find a way to trap and ignore these errors so they don't throw the debugger player dialogue up. Also, when using the Flash Builder IDE to debug, the debugger doesn't break on these errors at all - it's only in the player while I'm able to break on other errors without problem.

It is as if the error listener is being disposed of when the dataprovider changes, but the loader continues and throws an unhandled #2044.

Any ideas on how to handle effectivel? Thanks in advance for your time and assistance -

b

评论

In the constructor of your Custom Cell Renderer, you need to add an event listener to the protected loader instance and handle the IOError.

Here's an example:

package
{
    import fl.controls.listClasses.ICellRenderer;
    import fl.controls.listClasses.ImageCell;
    import fl.controls.TileList;
    import fl.data.DataProvider;
    import fl.managers.StyleManager;
    import flash.events.EventDispatcher;
    import flash.events.*;
    import fl.containers.UILoader;

    public class CustomImageCell extends ImageCell implements ICellRenderer
    {  

        public function CustomImageCell() 
        {
            super();

            //do other stuff here

            loader.scaleContent = false;
            loader.addEventListener(IOErrorEvent.IO_ERROR, handleErrorEvent, false, 0, true);

            useHandCursor = true;
        }

        override protected function drawLayout():void
        {
            var imagePadding:Number = getStyleValue("imagePadding") as Number;
            loader.move(11, 5);

            var w:Number = width-(imagePadding*2);
            var h:Number = height-imagePadding*2;
            if (loader.width != w && loader.height != h)
            {
                loader.setSize(w,h);
            }
            loader.drawNow(); // Force validation!

        }
        override protected function handleErrorEvent(event:IOErrorEvent):void {
            trace('ioError: ' + event);
            //dispatchEvent(event);
        }
    }
}

here is a simple test I did to see what happens when the data provider gets updated:

import fl.controls.*;
import fl.data.DataProvider;
import fl.controls.listClasses.CellRenderer;

stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;

var tileList:TileList = new TileList ();
tileList.move(220,40);
tileList.setSize(215, 400);
tileList.columnWidth = 215;
tileList.rowHeight = 86;
tileList.direction = ScrollBarDirection.VERTICAL;
tileList.setStyle("cellRenderer", CustomImageCell);
addChild(tileList);

tileList.dataProvider = getRandomDP(10);
setTimeout(resetDP,3000);

function resetDP():void {
    tileList.dataProvider = getRandomDP(10);
}
function getRandomDP(size:int):DataProvider {
    var result:DataProvider = new DataProvider();
    for(var i:int = 0; i < size; i++)   result.addItem({label:'item'+i,source:'wrong.url/'+Math.random()});
    return result;
}

HTH

受限制的 HTML

  • 允许的HTML标签:<a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id>
  • 自动断行和分段。
  • 网页和电子邮件地址自动转换为链接。

相关推荐
  • Actionscript Error #2044: Unhandled SecurityErrorEvent:. text=Error #2047: Security sandbox violation: LocalConnection.send: 127.0.0.1 cannot access
    When running flash components that use localConnection within an HTML container, I get the following error in a popup box (flash player is the debug version): Error #2044: Unhandled SecurityErrorEvent:. text=Error #2047: Security sandbox violation: LocalConnection.send: 127.0.0.1 cannot access
  • Flash policy file not working (same domain, different port)
    I'm at a loss. I can't figure out why Flash is not loading my policy file properly. I'm testing this from the Flash Debugger. I've also tried from http://127.0.0.1:80/game (it sends a request to http://127.0.0.1:3014/socket.io/1/). Security.loadPolicyFile('xmlsocket://127.0.0.1:843'); var r:URLRequest = new URLRequest(); r.url = httpProtocal+"://" + domain + "/socket.io/1/?time=" + new Date().getTime(); r.method = URLRequestMethod.POST; var ul:URLLoader = new URLLoader(r); ul.addEventListener(Event.COMPLETE, onDiscover); ul.addEventListener(HTTPStatusEvent.HTTP_STATUS, onDiscoverError); ul
  • Flash 策略文件不起作用(相同的域,不同的端口)(Flash policy file not working (same domain, different port))
    问题 我不知所措。 我不明白为什么 Flash 没有正确加载我的策略文件。 我正在从 Flash Debugger 测试这个。 I've also tried from http://127.0.0.1:80/game (it sends a request to http://127.0.0.1:3014/socket.io/1/). Security.loadPolicyFile('xmlsocket://127.0.0.1:843'); var r:URLRequest = new URLRequest(); r.url = httpProtocal+"://" + domain + "/socket.io/1/?time=" + new Date().getTime(); r.method = URLRequestMethod.POST; var ul:URLLoader = new URLLoader(r); ul.addEventListener(Event.COMPLETE, onDiscover); ul.addEventListener(HTTPStatusEvent.HTTP_STATUS, onDiscoverError); ul.addEventListener(IOErrorEvent.IO_ERROR , onDiscoverError); 错误: >
  • Catching an unhandled IOErrorEvent in Flash AS3
    Error #2044: Unhandled IOErrorEvent:. text=Error #2036: Load Never Completed. That's what I see every time I try to load an image that doesn't exist using a Loader. I'm getting a list of URLs and can't validate if they're pointing to anything useful. Whenever it encounters a 404 it gives me that error. I have tried to catch the error with every available IOErrorEvent there is (there are 7 of them),but none of them seem to capture the 404. Is there some other network event that I can be looking for to catch this condition?! I feel like I'm missing something obvious. What I'd really like is to
  • 如何为 Flash 中的平铺列表创建自定义单元格渲染器(how to create a custom cell renderer for a tile list in flash)
    问题 我需要在我的一个项目中实现一个自定义cell renderer ,我在谷歌上做了一些搜索,但找不到我需要的东西。 我需要tile list中的每个cell显示 2 个带有几个labels图标。 我需要一个很好的例子来启动它。 如果可能,我需要一种将模板设计为MovieClip并将其传递给 tilelist 以呈现单元格的方法。 回答1 要构建自定义单元格渲染器,您需要从可用的 listClasses 中扩展一个选择类。 ImageCell 看起来是您项目的良好开端。 你会: 扩展列表类在(标签/文本字段等)中添加您自己的位覆盖受保护的函数以根据您的需要调整新单元格(一个示例是 drawLayout 方法,您需要在其中整齐地放置您的项目)。 这是一个非常基本的例子: package { import fl.controls.listClasses.ICellRenderer; import fl.controls.listClasses.ImageCell; import fl.controls.TileList; import fl.data.DataProvider; import fl.managers.StyleManager; import flash.events.EventDispatcher; import flash.events.*; import fl
  • Flash As3 Streaming player - onBWDone
    I got this error when tring to implement Stream connection with meta info Error #2044: Unhandled AsyncErrorEvent:. text=Error #2095: flash.net.NetConnection was unable to invoke callback onBWDone. error=ReferenceError: Error #1069: Property onBWDone not found on flash.net.NetConnection and there is no default value. at SS4uOpenplayer_fla::MainTimeline/frame2() I implemented onBWDone function as like meta.onBWDone=function(meta:Object){ } meta.onMetaData = function(meta:Object) { } But stil am getting the same error
  • 为什么Flash Media Server不调用application.onDisconnect处理程序?(Why Flash Media Server does not call application.onDisconnect handler?)
    问题 我在Flex / Flashcom应用程序中遇到了一个奇怪的问题。 如果客户端应用程序意外地与服务器断开连接,则不会调用application.onDisconnect处理函数。 我应该朝女巫的方向看吗? 谢谢你。 更新我没有使用服务器组件,但确实在Linux上托管了该组件。 回答1 正如Artem Tikhomirov(问题的作者)在他自己的回答中提到的那样,我的回答没有帮助(我将其作为维基百科保存在下面,以供存档)。 Ric Tokyo已针对Linux上的错误给出了真正的答案,并在此线程中进行了记录。 我的答案是“选择”的唯一原因是因为Artem在7天的限制之前没有选择任何其他答案(或他自己的答案),因此给了我(第一个也是最受好评的答案)一半的悬赏分(超过75分) 150)会自动按照此SO博客条目中的说明进行操作。 第一线: 如果客户端是基于组件的应用程序,则它需要[正确处理连接事件] [9]。 在开发应用程序时,请注意,使用组件会引入显式的onConnectAccept和onConnectReject事件。 您需要包括代码来处理这些事件。 使用组件时,必须在服务器端代码中修改application.onConnect语句,以包括application.onConnectAccept和application.onConnectReject事件处理程序。
  • 显示来自 Google Finance 或 Yahoo! 的股票数据金融(Display stocks data from Google Finance or Yahoo! Finance)
    问题 我可以使用 Google Finance API 获取股票数据吗? 如果有此类股票数据的 Flash 或 Javascript 查看器,那就太好了。 我发现了一些可用于相同目的的图表组件: 图表打开 Flash 图表 回答1 Google 的一名员工 Dion Loy 最近确认,在商业网站上使用 Finance API是完全合法的。 “您可以将我们的 API 用于商业或非商业目的。” 使用 Google Finance Portfolio Data javascript API,通过 MarkMail。 “是的,在商业应用程序中使用投资组合 API 很好。” 在商业应用中使用 Google Finance API?,通过 MarkMail。 回答2 雅虎! Finance为您提供实时股票报价。 数据以 CSV 格式返回。 请参阅位于 http://finance.yahoo.com/q?s=^IXIC 的纳斯达克页面 单击“下载数据”按钮以访问实时数据单击“下载到电子表格”按钮以访问历史数据 您可以使用 LoadVars 或 URLLoader 类从 Flash 访问该数据。 使用 unescape() 从其 URL 编码格式解码字符串。 回答3 作为 Google 财经的替代方案,请考虑 http://www.mergent.com/servius(历史证券数据 API)
  • loading swf from AmazonS3 - crossdomain policy
    I have a flash app sitting in domainA which needs to load a swf which comes from an Amazon S3 bucket. On load I get the following error. "Error #2044: Unhandled securityError:. text=" I have put a crossdomain file in the bucket and presumed that would do the trick. How can i fix this?
  • AS3 Using a Loader to load a file protected by htaccess
    I'm attempting to load an external SWF that's hosted on a site into a local SWF file. The external SWF is in a password-protected directory using htaccess. Here is the code I'm currently trying to use: var loaderUrlRequest:URLRequest = new URLRequest("http://www.my-website.com/externalFlashFile.swf"); loaderUrlRequest.requestHeaders.push(new URLRequestHeader("Authorization", "Basic " + $Base64.encode("username:password"))); loaderUrlRequest.method = URLRequestMethod.POST; loaderUrlRequest.data = true; var loader:Loader = new Loader(); addChildAt(loader, 0); loader.load(loaderUrlRequest); The
  • Trouble adding search widget to ArcGIS Shortlist Story App
    I 'm having issues adding in a search widget to a shortlist application. I have included the code below. The search bar shows up, but is not functional. I am needing to have this to where it can search business names that are included within the application. <html> <head> <title>ChahtaPreneur</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1"> <meta name="apple-mobile-web-app-capable" content="yes"> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
  • 将搜索微件添加到 ArcGIS Shortlist Story App 时遇到问题(Trouble adding search widget to ArcGIS Shortlist Story App)
    问题 我在将搜索小部件添加到候选列表应用程序时遇到问题。 我已经包含了下面的代码。 搜索栏出现,但不起作用。 我需要把它放在可以搜索应用程序中包含的企业名称的地方。 <html> <head> <title>ChahtaPreneur</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1"> <meta name="apple-mobile-web-app-capable" content="yes"> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0"> <link type="image/ico" rel="shortcut icon" href="//resources.esri.com/favicon.ico"> <link type="image/ico" rel="icon" href="//resources.esri.com/favicon.ico"> <link rel=
  • AS3 Pass FlashVars to loaded swf
    I have a A.swf which loads B.swf onto a movieclip and needs to pass it some FlashVars. When loading B.swf with html, I can pass FlashVars fine. When passing from A.swf, it gets a Error #2044: Unhandled ioError:. text=Error #2032: Stream Error. URL: file: The code in A.swf is var request:URLRequest = new URLRequest ("B.swf"); var variables : URLVariables = new URLVariables(); variables.xml = "test.xml"; // This line causes the error 2044, else B.swf loads fine with FlashVars request.data = variables; loader.load (request); In B.swf, it is checking the Flashvars like so. It works fine from html
  • How to prevent an item being dropped into one TileList from another using Flex?
    I would like to prevent a user dragging certain items from one TileList to another. Whether or not they can be dropped into the TileList should be determined based on data associated with the item. To show that the item cannot be dragged into the TileList I would like to show the normal white cross in red circle icon next to the cursor. If a drop is attempted when it has been determined that drop should not occur I would like to show an alert message explaining why this item could not be dropped.
  • Passing score variable to another swf with LocalConnection using as3
    I have three games - swf1, swf2 and swf3. I need to pass the score variable from swf1 into swf2 in order to combine those scores. Then, I need to pass the swf1 & swf2 newly combined scores into swf3 so that I can total scores from all three games combined. I am using a Loader class to link the swfs together and I am attempting to use LocalConnection to pass the score variables with no luck. Swf1: (sending swf) package { import flash.display.*; import flash.events.*; import flash.net.URLLoader; import flash.net.navigateToURL; import flash.net.URLRequest; import flash.net.URLRequestMethod
  • 我应该避免异步处理Promise拒绝吗?(Should I refrain from handling Promise rejection asynchronously?)
    问题 我刚刚安装了Node v7.2.0,并了解了以下代码: var prm = Promise.reject(new Error('fail')); 产生此消息: (node:4786) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: fail (node:4786) DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code. 我理解这背后的原因,因为许多程序员可能经历过一个Error最终被Promise吞没了,这令人沮丧。 但是然后我做了这个实验: var prm = Promise.reject(new Error('fail')); setTimeout(() => { prm.catch((err) => { console.log(err.message); }) }, 0) 结果是: (node:4860)
  • 光栅之外的Java getSubimage()(Java getSubimage() outside of raster)
    问题 我正在尝试拍摄图像并将其存储在16x16子图像的数组中。 我使用的图像是512x512像素。 但是,在遍历循环时,getSubimage()被Raster异常停止。 这是代码: public class TileList extends JPanel { private static final int width = 16; //width of a tile private static final int height = width; private int col = 1; private int row = 1; private BufferedImage image; File tilesetImage = new File("image.png"); BufferedImage tileset[]; public void loadAndSplitImage (File loadImage) { try{ image = ImageIO.read(loadImage); }catch(Exception error) { System.out.println("Error: cannot read tileset image."); }// end try/catch col = image.getWidth()/width; row = image
  • Java getSubimage() outside of raster
    I'm trying to take an image and store it in an array of 16x16 subimages. The image I am using is 512x512 pixels. However, while iterating through the loop, getSubimage() is stopped by a Raster exception. Here is the code: public class TileList extends JPanel { private static final int width = 16; //width of a tile private static final int height = width; private int col = 1; private int row = 1; private BufferedImage image; File tilesetImage = new File("image.png"); BufferedImage tileset[]; public void loadAndSplitImage (File loadImage) { try{ image = ImageIO.read(loadImage); }catch(Exception
  • 使用任务并行库时如何处理所有未处理的异常?(How to handle all unhandled exceptions when using Task Parallel Library?)
    问题 我在.NET 4.0中使用TPL(任务并行库)。 我想通过使用Thread.GetDomain().UnhandledException事件集中所有未处理的异常的处理逻辑。 但是,在我的应用程序中,对于以TPL代码Task.Factory.StartNew(...)线程,例如Task.Factory.StartNew(...) ,永远不会触发该事件。 如果使用诸如new Thread(threadStart).Start()类的东西,则确实会触发该事件。 该MSDN文章建议在使用TPL时使用Task.Wait()来捕获AggregateException ,但这不是我想要的,因为此机制不够“集中”。 有人遇到过同样的问题吗?还是只有我一个人? 您对此有什么解决方案吗? 回答1 我认为TaskScheduler.UnobservedTaskException事件是您想要的: 当有故障的任务的未观察到的异常即将触发异常升级策略时发生,默认情况下,该策略将终止该进程。 因此,此事件类似于您在问题中提到的DomainUnhandledException ,但仅在任务中发生。 顺便说一句,未观察到的例外策略(是的,这不是不可观察到的例外,MS专家又发明了一个新词……)从.NET 4.0更改为.NET 4.5。 在.NET 4.0中,未观察到的异常导致进程终止,但在.NET 4.5中
  • how to create a custom cell renderer for a tile list in flash
    I need to implement a custom cell renderer in a project of mine, I have done some search on google but couldn't find what I need. I need each cell in the tile list to display 2 icons with couple of labels. I need a good example to start it. If possible I need a way to design the template as a MovieClip and pass it to the tilelist for rendering the cells.