Why does URLStream complete event get dispatched when the file is not finished loading?

I'm writing an AIR kiosk app that every night connects to a WordPress server, gets a JSON file with paths to all the content, and then downloads that content and saves it to the kiosk hard drive. 
There's several hundred files (jpg, png, f4v, xml) and most of them download/save with no problems.  However, there are two f4v files that never get downloaded completely.  The complete event does get dispatched, but if I compare the bytesTotal (from the progress event) vs bytesAvailable (from the complete event) they don't match up; bytesTotal is larger.  The bytesTotal (from the progress event) matches the bytes on the server. 
The bytesLoaded in the progress event never increases to the point that it matches the bytesTotal so I can't rely on the progress event either.  This seems to happen on the same two videos every time. The videos are not very large, one is 13MB and the other is 46MB.  I have larger videos that download without any problems.  
[edit] After rebooting the compter, the two videos that were failing now download correctly, and now it's a 300kb png file that is not downloading completely.  I'm only getting 312889 of 314349 bytes.
If I paste the url into Firefox it downloads correctly, so it appears to be a problem with Flash/AIR.
[edit] I just wrote a quick C# app to download the file and it works as expected, so it's definitely a problem with Flash/AIR. 
Here's the code I'm using:
package  {
    import flash.display.Sprite;
    import flash.events.Event;
    import flash.events.ProgressEvent;
    import flash.net.URLRequest;
    import flash.net.URLStream;
    [SWF(backgroundColor="#000000", frameRate="24", width="640", height="480")]
    public class Test extends Sprite {
        private var fileSize:Number;
        private var stream : URLStream;
        private var url:String = "http://192.168.150.219/wordpress2/wp-content/uploads/2012/12/John-Butler-clip1.f4v";
        public function Test() {
            if (stage)
                init();
            else
                this.addEventListener(Event.ADDED_TO_STAGE, init);
        private function init(e:Event=null):void {
            this.removeEventListener(Event.ADDED_TO_STAGE, init);
            stream = new URLStream();
            stream.addEventListener(ProgressEvent.PROGRESS, onLoadProgress);
            stream.addEventListener(Event.COMPLETE, onLoadComplete);
            stream.load(new URLRequest(url));
        private function onLoadProgress(event:ProgressEvent):void {
            fileSize = event.bytesTotal;
            var percent:Number = event.bytesLoaded / event.bytesTotal * 100;
            trace(percent + "%");
        private function onLoadComplete(event:Event):void {
            trace("loaded", stream.bytesAvailable, "of", fileSize);
            // outputs "loaded 13182905 of 13184365"
            // so why is it "complete" when it isn't finished downloading?

Thanks for your quick reply !
I am relatively new to programming so please bear with me on this as I still haven't managed to grasp some of those things that "make perfect sense". If I am setting mouseEnabled to false doesn't that mean that the object no longer gets MouseEvents ?
If I have understood you correctly then once the mouseEnabled is set to false the btn object is removed from the objects recognizable by the mouse - hence dispatching a mouseout event (and I am guessing here) from the mouse?
I still don't get it though, if the listeners are set to the object and the object is no longer accessible to the mouse why is the event still being dispatched ?
I get it that the making of the object unavailable to the mouse causes the "removing" (deactivating) of the object from under the mouse,
  step 1. deactivate object, and  step 2. (as a result of step 1) register the removal of the object.
but why is the mouse still listening after step 1?
Even if the action is that of "out" (as in the object is no longer under the mouse) it still is an action isn't it ? so haven't we turned off the listening for actions ?
I promise I am not trying to drive you crazy here, this is just one of those things that I really want to get to the root of !
Thanks,

Similar Messages

  • Why does my iphone 4s gets really hot even though im not using it, battery drain's 2% every 5 minutes.. and its just in my pocket,. what will i do?

    why does my iphone 4s gets really hot even though im not using it, battery drain's 2% every 5 minutes.. and its just in my pocket,. what will i do?

    some thing is runnng in the back ground. Or your email is struck. Deleted all emails and reboot phone and add them one by one. Or your sim cards has problem. Replace sim card. If nothing works drain battery then recharge battery to 100% full charge.

  • The words in the .docx (MSWord 2010) file are getting merged when the file is transferred to another computer for printing. What could be the reason?

     The words in my .docx file are getting merged when the file is transferred to another computer for printing. For eg. the sentence "rate of success ......"  is displayed as "rateof success" on the other computer. What could
    be the reason for this? How to solve this issue?  

    Have you checked that the document is using the exact same font on both machines? If the second machine doesn't have the font installed that's used in the original document on the first machine, Word will pick the closest matching font, and that may
    display slightly differently.

  • TS3771 Why can't I select "get info" from the file area so I can change the setting to "open in 32-bit mode" ?

    Why can't I select "get info" from the file area so I can change the setting to "open in 32-bit mode" ?

    It may be because of your settings. You can modify that setting in System Preferences > Trackpad. Another way of making right-click is to click the app icon while holding the Control key

  • JSF error handling when the bean is not correctly loaded

    Hi,
    I am doing some error handling in JSF and I want to do it in an elegant way. I have the following scenario for error handling.
    When the bean is initialized I load the bean with values from DAO which give SQL Exceptions.
    Since the bean is not loaded I properly I have to send the user to an error page showing the error message why I am sending the user to this page.
    I can do it by [ FacesContext.getCurrentInstance.redirect("/error.jsf") ] doing so I will loose all the FacesMessages that are added by the exceptions.
    Instead I want to use the [ FacesContext.getCurrentInstance.dispatch("url") ] which will allow the transfer of the user but I get the following
    16:59:39,341 WARN [lifecycle] executePhase(RESTORE_VIEW 1,com.sun.faces.context.FacesContextImpl@8537f9) threw exception
    java.lang.ClassCastException: javax.faces.component.UIViewRoot
    and the method that I am calling is
    public static void programErrorEnd() {
    logger.info("in the prgmErrorEnd mehod");
    //intializing the contex object
    FacesContext ctx = FacesContext.getCurrentInstance();
    try {
    //ready to dispatch the url.
    //ctx.getExternalContext().redirect("app/error/prgmerror.jsf");
    ctx.getExternalContext().dispatch("error/prgmerror.jsf");
    } catch (IOException e) {
    //TODO what to do when there is an error at this stage.
    finally {
    ctx.responseComplete();
    }Thanks and Regarding
    Edited by: sgatl2 on Aug 28, 2008 2:32 PM
    Edited by: sgatl2 on Aug 28, 2008 2:45 PM

    Just let it throw the exception and define an error-page entry in the web.xml which catches the specified exception (or a superclass of it or a HTTP status code) and displays the error.jsf page accordingly.

  • Why does my ITunes now get stuck when it can't find the album art?

    I've noticed since yesterday when I bought my new IPod Touch my ITunes on my computer gets stuck when it can't find the album art for some music I have. It gets to that album and won't do anything, won't let me skip it or anything ... Anyone else having similar issues and if so any workaround?

    Hi joanhello,
    I understand that you are seeing an issue with iTunes fetching information about CDs you are importing. Here is an article for you that explains how to troubleshoot this issue:
    iTunes 11 for Windows: If you don’t see song information
    http://support.apple.com/kb/PH12488
    Thanks for coming to the Apple Support Communities!
    Regards,
    Braden

  • Why does my macbook only turn on when the power adapter is plugged in?

    The battery life says its at 73% and climbing but whenever I unplug my power adapter the mac automatically shuts down and if I try to turn on the macbook without my power adapter plugged in, it wont turn on. How do I make it go back to where I can turn the mac on without it being plugged in? Thank you for your help!

    I would try two things the first being resetting the System Management Controller:
    1) If the computer is on, turn it off.
    2) Disconnect the AC Adapter and remove the computer's battery.
    3) Press and hold down the power button for 5 seconds and then release the button.
    4) Reconnect the battery and AC Adapter.
    5) Press the Power button to restart the computer.
    If that doesn't work I would recalibrate the battery.
    To calibrate the battery:
    1) Plug in the MagSafe power adapter and fully charge the MacBook or MacBook Pro battery until the light on the MagSafe connector changes to green and the Battery icon in the menu bar indicates that the battery is fully charged.
    2) Allow the battery to rest in the fully charged state for two hours or longer. You may use your computer during this time as long as the power adapter is plugged in.
    3) Disconnect the power adapter with the computer on and start using it with battery power. When the battery's charge gets low, you’ll see the low battery warning dialog on the screen.
    4) Continue to keep your computer turned on until it goes to sleep. Save your work and close all applications when the battery's charge gets low and before the computer goes to sleep.
    5) Turn off the computer or allow it to sleep for five hours or longer.
    6) Reconnect the power adapter and leave it connected until the battery is fully charged. You may use your computer during this time.

  • Why does system suite pro 12 crash when running file cleaner is running while firefox is installed? If I uninstall firefox then system suite pro 12 won't crash.

    When I downloaded the newest version of firefox system suite pro 12 crashes when running file cleaner after I uninstall firefox system suite pro 12 doesn't crash. I have window 7 premium home edition 64 bit.

    You should know a few things before before getting started:
    1. Registry "cleaners" and "system optimizers" like SystemSuite are very unreliable, cause more problems then they propose to fix, have little to no benefit, and are somewhat of a scam. Running them on a system is almost guaranteeing a crash or hiccups somewhere along the process. running them is never a good idea. all you need is a good, simple, free anti-virus (like Microsoft Security Essentials), and use the built in Windows Utilities to clean and sped up your computer if needed.
    2. This is a Firefox forum, so if you are having a problem with SystemSuite, we might not be able to help you.
    I'll give you a few things you can do to see if this is just a Windows problem:
    Run all Windows Updates, install all needed service packs, etc.
    Update your graphics driver (Firefox uses your graphics card for some rendering, and an out of date graphics card driver can cause problems. [https://support.mozilla.org/en-US/kb/how-do-i-upgrade-my-graphics-drivers https://support.mozilla.org/en-US/kb/how-do-i-upgrade-my-graphics-drivers].
    Update all your plugins (Flash, Java, etc.): [http://www.mozilla.org/plugincheck/ http://www.mozilla.org/plugincheck/].
    Download and Install MalwareBytes Anti-Malware, run a full Scan. [http://www.malwarebytes.org/ http://www.malwarebytes.org/]. This helps check that there are no viruses on your computer causing issues. You can uninstall this program after you clean off any infections.
    Plus, I'd strongly recommend removing systemsuite and any other "optimizers" you might have.

  • Why does my iPhone 3GS turn off when the battery charge is only as low as 70%?

    After my iPhone 3Gs has been fully charged, whenever that charge drops to the 50% to 70% range, the phone turns off.  When I try to turn it on again, the Apple icon appears the first few times, followed only by a blank screen each time -- the home button does nothing.  Beyond those times, when I try to awaken it, I can see a faint design that includes a plug, a red battery and suggests it is out of charge.  This also happens if I depress the awake and home buttons concurrently.

    Let me know if I should start a new discussion instead of opening a new topic here.
    My wife's iPhone is the same vintage as mine 3Gs, but has never had the battery problem.  Its affliction instead is that it cannot detect WiFi networks unless it is quite close to the source.  Often, when my iPhone not only detects but shows a maximum cells connection with a network, hers cannot detect the network at all.  In contrast, her iPhone seems to detect ourcellular carrier just as well as mine does.
    Is there any help for this affliction?

  • Why does my iMessage always get stuck in the sending mode?

    Whenever I try to send an iMessage it gets stuck in the sending mode and just sits there and in hardly receive my messages because of it, please make this stop. My parents both have iPhones and theirs don't do it.

    The sending and receiving of iMessages is dependent on an active data connection. If you are sending, the recipient has to have an active connection as well, and this can result in the behavior that you are describing. Try double tapping on the home button and finding the Messages app in the multi-tasking tray. Touch and hold the icon until it starts to wiggle. Tap on the minus sign to close it. Do a reset on the phone. Hold the sleep/wake and home buttons together until you see the Apple logo and then release. After the phone restarts, open the Messages app and try messaging again. You can try to message with one of your parents right there with you and see how that works.

  • Why does my iphone 5 get hot on the sides and back ???

    Hi ,
    I got a iphone 5 on contract with 3 in august /september time my phones hardly been used its used rarely by my self and just gets hot on the sides and back ive reset my phone to see if any difference and there is none
    how can i fix this???
    thanks
    Gazza

    I would contact applecare about this issue. a hot phone is not normal , a warm phone is.
    but if you contact applecare that way you have a record of the issue incase it gets worse in the future.

  • Why does my Keynote size get reformated on the IPad when PPT files do not.

    When I import a Keynote presentation in HD format dimensions (1920 x 1080) into my IPad Keynote folder, it reformats the entire presentation to 800 x 600 which defeats the whole purpose. I don't have this issue when I import a PPT presentation in QuickOffice Pro HD. So what's up, all the boasting of being ahead of everyone only to have a critical piece of software behind the times. I wondering if I am missing something and not using the IPad Keynote properly. Please advise.

    Your css link is looking for a file on your local machine so when you upload to the remote server the link is broken:
    <link href="file:///Macintosh HD/Users/KellysHomeFolder/Documents/btd-innovations/btdstyle.css" rel="stylesheet" type="text/css">
    Have you defined a folder for your site at the begining of the project?
    The link should look more like: (assuming btd-innovations is your site folder)
    <link href="btdstyle.css" rel="stylesheet" type="text/css">

  • Why does my Twitter Account get suspended when I try sending Army of Awesome tweets?

    Okay, so I recently joined army of awesome. I would reply to people's tweets, changing a word here and there to make the message more personal and human, and eventually I would lose access to my twitter account because it got suspended. This has happened twice and now Twitter is threatening to suspend my twitter account permanently. I don't understand what I am doing wrong. I have enjoyed sending out the tweets. So maybe it's because I have been sending out too many tweets on behalf of Army of Awesome? Please help me figure this problem out. Thanks!

    Yeah it's because Twitter feels you've sent too many tweets so it thinks you're spamming.
    I don't think it's worth losing your twitter account permanently for this. I'd stop for now and possibly create a 2nd twitter account for Army of Awesome if you still really want to help.
    What a headache Twitter & Army of Awesome has created.

  • Why does my iPhone 5 get hot when I am using facetime?

    I notice that after I have been using facetime for calls for about 5 minutes, my phone gets really hot. Anyone notice this issue? Should I replace my device?

    you could set up a genius bar appointment, but this may happen, are you using wifi or 3g/lte? is it plugged in while you FaceTime?

  • Why does Firefox create a folder "~/Download" when the "General" tab of the preferences window is selected in Linux?

    This bug exists in 3.6 (and perhaps earlier) and 4.0. Simply selecting the General preferences tab creates folder ~/Download no matter what option is currently set for the download directory.

    Try disabling hardware acceleration. Many visual bugs can be attributed to issues with graphics drivers.
    (Firefox -> Options -> Advanced -> General -> [ ] Use hardware acceleration when available)

Maybe you are looking for