How do you download a static file using a FileReference and URLRequest and show the progress?

All,
   I'm trying to download static content (PDFs) off of my server using tutorials from adobe's site and some online as well and i'm having no luck showing an updated progress bar.  I attached the meat of my code below.  If a user clicks a hyperlink, it calls the downloadPDF method passing in a constant url defined.
  When debugging, i can see that the event.bytesLoaded is incrementing on each call to the progress method, however the bytesTotal is only set to the intitial number of bytes transferred on the first pass through the method.  (Ex:  First time the method is called, bytesLoaded and bytesTotal will be 4,000... which i dont understand... the bytesTotal should be the total size of the file being downloaded.. definitely not the case...  the next time the method is called, bytesLoaded will increases to some number while bytesTotal will remain at 4,000).  This happens during the entire file transfer.
Am i missing something? Are the examples incorrect?  Also to note, i'm using sdk 3.2 (Not sure if that makes a difference.)
Thanks for any response or insight.
Damian
<mx:Script>
        <![CDATA[
            import com.ctc.fema.resources.Buttons;
            import flash.net.FileReference;
            private var fileRef:FileReference;
            private var urlReq:URLRequest;
             * Constant values for user manual pdfs
            private static const PDF_STRING:String = "blahblahblah.pdf";
            private function init():void
                /* Define file reference object and add a bunch of event listeners. */
                fileRef = new FileReference();
                fileRef.addEventListener(Event.COMPLETE, completeHandler);
                fileRef.addEventListener(Event.OPEN, openHandler);
                fileRef.addEventListener(ProgressEvent.PROGRESS, progressHandler);
            private function doEvent(evt:Event):void
                /* Create shortcut to the FileReference object. */
                var fr:FileReference = evt.currentTarget as FileReference;
                try
                    /* Update the Model. */
                    fileRefModel.creationDate = fr.creationDate;
                    fileRefModel.creator = fr.creator;
                    fileRefModel.modificationDate = fr.modificationDate;
                    fileRefModel.name = fr.name;
                    fileRefModel.size = fr.size;
                    fileRefModel.type = fr.type;
                    /* Display the Text control. */
                catch (err:*)
                    /* uh oh, an error of sorts. */
            private function downloadPDF(url:String):void
                /* Begin download. */
                urlReq = new URLRequest(url);
                fileRef.download(urlReq);
             * When the OPEN event has dispatched, change the progress bar's label
             * and enable the "Cancel" button, which allows the user to abort the
             * download operation.
            private function openHandler(event:Event):void
                downloadStatusContainer.visible = true;
                downloadStatusContainer.includeInLayout = true;
                downloadProgressBar.label = "DOWNLOADING %3%%";
                cancelButton.enabled = true;
             * While the file is downloading, update the progress bar's status.
            private function progressHandler(event:ProgressEvent):void
                downloadProgressBar.setProgress(event.bytesLoaded, event.bytesTotal);
             * Once the download has completed, change the progress bar's label one
             * last time and disable the "Cancel" button since the download is
             * already completed.
            private function completeHandler(event:Event):void
                downloadStatusContainer.visible = false;
                downloadStatusContainer.includeInLayout = false;
                downloadProgressBar.label = "DOWNLOAD COMPLETE";
                cancelButton.enabled = false;
             * Cancel the current file download.
            public function cancelDownload():void
                fileRef.cancel();
                downloadProgressBar.label = "DOWNLOAD CANCELLED";
                cancelButton.enabled = false;
                downloadStatusContainer.visible = false;
                downloadStatusContainer.includeInLayout = false;
        ]]>
    </mx:Script>

The tick counter has a resolution of 1 ms.  Resolution, accuracy, and the responsiveness of the OS are three different things.  The issue is that OS latency can be 10s of milliseconds or occasionally longer.  If the OS decides to index the hard drive between the time you read the tick count and send the start audio command, your tone could be quite late. Sending the TTL pulse is a third call to the OS.  So you have two latency times for each trial. Unless you have a real-time operating system, this latency issue will introduce randomness into your data.
Try sending TTL pulses of 50 ms duration every 200 ms, software timed, for a few minutes and look at the variation in the edge timing.  Then try it again with tones thrown into the mix and see if the variation changes. 
That is where hardware timing and synchronization pays off. 
Lynn 

Similar Messages

  • If you mac comes preinstalled with Lion, how do you download an installer file

    So if you purchase a mac and obviously it now comes preinstalled with Lion. How can you download a Lion installer?Yes we do have recovery HD and internet recovery to reinstall lion but this heavily relies on the internet. Since the machine comes preinstalled, the Lion installer wouldn't appear in MAS. Aside from cloning the HD what else is our option?

    I've seen this but what this does is to make an exact same replica of the Recovery HD. When you boot to this and go for reinstall OS, it will still download it to the internet. Ultimately its the same method as Recovery HD partition and Internet recovery. They all download the OS and automatically INSTALLS it to the HD. I am looking for a solution that gives us a "download only" option. Basically a Lion installer
    e.g if you purchase Lion from MAS, it gives you that download file. That's what I was looking for, this is not possible for preinstalled Lion machines

  • How can I download a .xlsx file using Numbers?

    I'm new into Mac & I have no clue in how can I open a excel file .xlsx in a Mac...when I tried it showed the file was corrupeted. Anybody? Please.

    It may in fact be a corrupted file, in which case you are out of luck. You could try opening it with LibreOffice and if that works, save the file as .xls and try the saved file with Numbers.
    Jerry

  • How do you download WMA Audiobook files to ipod mini?

    I ahve downloaded some audiobooks from library online and the site says they can be transferred to a portable device, but when I go to make the transfer it says WMA files not compatible with ipod. How do I convert or get around this so I can transfer the WMA files to my ipod mini?

    You cannot. iTunes and iPods do mot play WMA.
    Most libraries use DRM protected WMA files by Overdrive!, which provides the audiobooks.

  • How to download a text file using classes

    Hi Guys
    I want to download a text file using classes.
    Any idea how to do it ?
    Thanks
    Sameer

    HI sameer,
       It is no different from using a Function module.
    example:
      CALL METHOD cl_gui_frontend_services=>gui_download
        EXPORTING
          filename                  = w_fpath
        append                    = SPACE
          write_field_separator     = 'X'
        CHANGING
          data_tab                  = it_download
        EXCEPTIONS
          file_write_error          = 1
          no_batch                  = 2
          gui_refuse_filetransfer   = 3
          invalid_type              = 4
          no_authority              = 5
          unknown_error             = 6
          header_not_allowed        = 7
          separator_not_allowed     = 8
          filesize_not_allowed      = 9
          header_too_long           = 10
          dp_error_create           = 11
          dp_error_send             = 12
          dp_error_write            = 13
          unknown_dp_error          = 14
          access_denied             = 15
          dp_out_of_memory          = 16
          disk_full                 = 17
          dp_timeout                = 18
          file_not_found            = 19
          dataprovider_exception    = 20
          control_flush_error       = 21
          not_supported_by_gui      = 22
          error_no_gui              = 23
          OTHERS                    = 24
    Regards,
    ravi

  • How can you tell if a file is being used in your project or not?

    How can you tell if a file in your bin is being used in your project or not? My director dragged hundreds of reference files into my project and only used a few of them. I'd like to do some house cleaning and delete the ones that are not in use. This project file has 100 sequences in it, so it would be a tough manual hunt to figure this out.
    In Premiere Pro (or Flash for example), where all the information is in the Project Bin such as in/out times and duration, there is where it tells you how many times that piece of media has been used or if it hasn't been used yet.
    Can FCP tell me this info?
    Thanks for yout time!
    -Monty

    Monty,
    Within FCP, there is a menu item called "Media Manager" (depending on what version you are in). This would be worth your while to look into. It basically organizes your project by moving/archiving any used assets of a project and leaving out un-used assets. It saves a ton of disk space.
    For example, say you have a 5 minute clip with an in/out point that is just 30 seconds. Media Manager will "archive" just that 30 seconds, not the entire clip. There is even a setting that you can add additional "handles" time to the front andd back of the clip if you think you may need to add or change transition.
    Do a google search. I was just watching a few Youtube videos on this myself.
    Jonathan

  • How do you download InDesign using the Adobe Download Manager?

    How do you download InDesign using the Adobe Download Manager?

    With the Adobe Download Assistant installed you should be able to initiate the download at http://www.adobe.com/cfusion/tdrc/index.cfm?product=indesign.  If this is not working for you then please try an alternate web browser.

  • How to save downloaded update installer files

    How can I locate a downloaded update installer file so I can save it and use to install on another mac without having to download all over again?  Today I downloaded updates for OS X and also for Office 2011.  The first is over 2GB and the second around 300MB.  I have installed on my Macbook Pro, but I have another 3 units to update. I live in a 3rd world country with very slow internet and it takes me days to download such files.

    Grateful for you having replied but for some reason I seem unable to open your message "Re: How to save downloaded update installer files".  Waikato99

  • How do you download music and burn to a cd so it will play in a car radio

    How do you download music and burn to a cd so it will play in a car radio?

    Download the tracks you want form the iTunes Store, Amazon MP3, or other online music retailer.
    Use iTunes to put them into a playlist.
    Open the playlist and click File > Burn Playlist to Disc.   (Have a blank CD-R ready for this step.)  When the dialog comes up, choose "Audio CD." 
    This will create an audio CD that will play in a normal CD player such as the kind found in cars.

  • How do you open a cs7 file in indesign cc?

    How do you open a cs7 file in indesign cc?

    When you say InDesign CC, doo you mean the InDesign CC release from this year, or are you still using InDesign CS6 through a cloud subscription? There are a lot of users confused by this.
    If you have CS6 through a subscription you are entitield to the new version for free and should go to creative.adobe.com and download the newest version of the Creative Cloud Desktop Application and get the new versions of the applictions you use.

  • How do you download photos ffom memory card tocomputer

    How do you download photos ffom memory card tocomputer. When I insert the card the only destination for the photos is Snapfish. Does not  go directly to my photo files as my previous HP 209 photosmart...thanks, Mark

    An easy solution would be to install Picasa 3. When you load the program, you can import.
    I am a volunteer. I am not an HP employee.
    To say THANK YOU, press the "thumbs up symbol" to render a KUDO. Please click Accept as Solution, if your problem is solved. You can render both Solution and KUDO.
    The Law of Effect states that positive reinforcement increases the probability of a behavior being repeated. (B.F.Skinner). You toss me KUDO and/or Solution, and I perform better.
    (2) HP DV7t i7 3160QM 2.3Ghz 8GB
    HP m9200t E8400,Win7 Pro 32 bit. 4GB RAM, ASUS 550Ti 2GB, Rosewill 630W. 1T HD SATA 3Gb/s
    Custom Asus P8P67, I7-2600k, 16GB RAM, WIN7 Pro 64bit, EVGA GTX660 2GB, 750W OCZ, 1T HD SATA 6Gb/s
    Custom Asus P8Z77, I7-3770k, 16GB RAM, WIN7 Pro 64bit, EVGA GTX670 2GB, 750W OCZ, 1T HD SATA 6Gb/s
    Both Customs use Rosewill Blackhawk case.
    Printer -- HP OfficeJet Pro 8600 Plus

  • How do you download photos w/o iphoto

    how do you download photos w/o iphoto

    If you don't have iPhoto, you can get photos off your camera using the Image Capture utility.
    If you have JPEG photo files in a Finder folder, you can drag and drop them into your iMovie Project from there. TIFF and PNG may also work.

  • How can I download acrobat x standard using my actual licence nr.

    I have my licence with cd included but now I use an HP ps slim with no possibility to insert the cd ... there shoulb be the chance to download adobe and register my licence ... help! giuseppe.

    I knew …
    It is very peculiar … I thought there must be the way to download and add my licence nr. To validate adobe acrobat… as we can do  with many other products …
    Giuseppe Mistroni
    朱塞佩 霧羅尼
    C.F.O.
    Tonino Lamborghini Group
    cid:[email protected]
    Tonino Lamborghini SpA
    Head Office/Sede Commerciale: via Funo, 41 - 40050 Funo di Argelato (BO) - Italy
    Registered Office/Sede Legale: via San Giacomo, 25 - 41121 Modena - Italy
    C.F.: 03139260370 - P.I.: 00865150387
    tel. + 39 051 862628 - fax +39 051 864956
    www.lamborghini.it<http://www.lamborghini.it/> – mail: [email protected]<mailto:[email protected]>
    Follow us on:
    cid:[email protected]<http://www.facebook.com/ToninoLamborghiniGroup>  cid:[email protected] <https://twitter.com/#!/tlamborghini_>   cid:[email protected] <http://www.linkedin.com/company/tonino-lamborghini/products?trk=tabs_biz_product>   cid:[email protected] <http://issuu.com/toninolamborghini>   cid:[email protected] <http://www.youtube.com/user/TLEnergyDrink/videos>
    Shop now at Forzieri.com<http://www.it.forzieri.com/ita/shopping_shop.asp?l=ita&c=eng&brand_id=188> !
    CONFIDENTIALITY NOTICE: This message and any files transmitted with it are legally privileged and confidential. Any unauthorised use or disclosure of the content of this message is strictly prohibited and may be unlawful. If you are not the intended recipient, please notify the sender by reply and delete the message and any attachments from your system. Thank you very much.
    Da: Test Screen Name [email protected]
    Inviato: martedì 25 marzo 2014 12:39
    A: Giuseppe Mistroni
    Oggetto: how can I download acrobat x standard using my actual licence nr.
    Re: how can I download acrobat x standard using my actual licence nr.
    created by Test Screen Name<http://forums.adobe.com/people/TestScreenName> in Acrobat Installation & Update Issues - View the full discussion<http://forums.adobe.com/message/6240076#6240076

  • How do you unzip a Word File on an older MAC mini?

    How do you unzip a Word File on an older MAC mini?

    On older Macs .docx files can look like a zip file. This is because they contain a proprietary form of XML compressed using ZIP.
    If you have an older version of Office for Mac, i.e. Office 2004 which predates .docx format files, then you can install a free addon to allow it to import and export .docx files.
    See http://www.microsoft.com/en-us/download/details.aspx?id=27334

  • I want to download an audiobook, but my daughter has a giftcard credit on the account. How can I download my audiobook without using the money from her giftcard?

    I want to download an audiobook, but my daughter has a gift card on the account.  How can I download my audiobook without using the money from her gift card?

    go directly to your ibook app. and you're going to find it. it's only with ibooks app.
    best
    Olivier
    <Edited by Host>

Maybe you are looking for

  • Integrating XML publisher & OAF Page, Generating output in PDF format

    Query:SELECT empno,ename,job,mgr,hiredate,comm,deptno FROM emp Step 3 : Generating the XML for Template Design Design a OAF Page EmpPG with the Following Code in the Controller EmpCO. EmpCO : public void processRequest(OAPageContext pageContext, OAWe

  • Bandwidth Calculation based on Network IP Address on SNMP Cisco 3750

    Dear All, Instead of getting bandwidth calculation on cisco switch via snmp for total in and out or based on port, is it possible to get the calculation of bandwidth for in and out for the C Class IP on the network ? That mean i can get the calculati

  • Compile error in adjacency matrix

    Hello, I'm getting a strange compile error in my fileStream constructor also I'm having trouble accessing nodes. Any advice is much much appreciated and will be rewarded as such cheers mport java.io.*; import java.util.*; class AdjMatrix      private

  • Content Management In PCUI

    Hi All, I would like to add a folder in the Attachment Tab in an application  to the pre-existing Template. Where can I make the addition? Thanks, Raj

  • Web Page Composer : RSS

    Hello I can't use RSS with Web Page Composer, always the same message : Cannot render container : com.sap.engine.lib.xml.util.NestedException: Function with name 'wpc:getRssContent' not found in context library. I can add a RSS iView and it's work, b