dcsimg
A Flash Developer Resource Site

Results 1 to 15 of 15

Thread: flash 8 file upload, tracking up/down rate?

  1. #1
    AKA [ Paul Bainbridge] webdreamer's Avatar
    Join Date
    Aug 2001
    Location
    Glasgow, Scotland, UK
    Posts
    3,320

    flash 8 file upload, tracking up/down rate?

    Is it possible with the new upload feature in flash it to measure and display the transfer rate just like the OS window?
    .: To me AS is like LEGO, Only for the big Kids :.
    - Site - Blog - Twitter - Linkedin
    bringmadeleinehome.com

  2. #2
    Senior Member EQFlash's Avatar
    Join Date
    Jun 2002
    Location
    where i'm at
    Posts
    2,735
    try this.
    create a progress bar movieclip
    and instance name it pbar
    add this code to the script that uploads the file.
    Code:
    pbar._width = 0
    listener.onProgress = function(selectedFile:FileReference, bytesLoaded:Number, bytesTotal:Number):Void  {
    	pbar._width = (bytesLoaded/bytesTotal)*100
    };
    If you don't think you're going to like the answer, then don't ask the question.

  3. #3
    AKA [ Paul Bainbridge] webdreamer's Avatar
    Join Date
    Aug 2001
    Location
    Glasgow, Scotland, UK
    Posts
    3,320
    Thanks but not quite want i ment.
    Attached Images Attached Images
    .: To me AS is like LEGO, Only for the big Kids :.
    - Site - Blog - Twitter - Linkedin
    bringmadeleinehome.com

  4. #4
    Flash Gordon McUsher's Avatar
    Join Date
    Mar 2001
    Location
    Krautland
    Posts
    1,560
    Well why not simply use getTimer() at start and end of down/upload
    and calculate speed with the FileReference.size property?

  5. #5
    AKA [ Paul Bainbridge] webdreamer's Avatar
    Join Date
    Aug 2001
    Location
    Glasgow, Scotland, UK
    Posts
    3,320
    I am looking to display the current transfer rate. What your suggesting can only be done one upload/download is complete.
    .: To me AS is like LEGO, Only for the big Kids :.
    - Site - Blog - Twitter - Linkedin
    bringmadeleinehome.com

  6. #6
    Flash Gordon McUsher's Avatar
    Join Date
    Mar 2001
    Location
    Krautland
    Posts
    1,560
    Well no,...

    Check FlashHelp for the FileReference
    there is the
    onProgress (FileReference.onProgress-Ereignis-Listener)
    onProgress = function(fileRef:FileReference, bytesLoaded:Number, bytesTotal:Number) {}

    event, combined with the getTimer() you can achieve, what you want.

  7. #7
    AKA [ Paul Bainbridge] webdreamer's Avatar
    Join Date
    Aug 2001
    Location
    Glasgow, Scotland, UK
    Posts
    3,320
    code:

    pbar._width = 0
    listener.onProgress = function(selectedFile:FileReference, bytesLoaded:Number, bytesTotal:Number):Void {
    pbar._width = (bytesLoaded/bytesTotal)*100
    };



    This i know. But to then take that and use getTimer() in some way to get current transfer rate i dont.
    .: To me AS is like LEGO, Only for the big Kids :.
    - Site - Blog - Twitter - Linkedin
    bringmadeleinehome.com

  8. #8
    Flash Gordon McUsher's Avatar
    Join Date
    Mar 2001
    Location
    Krautland
    Posts
    1,560
    PHP Code:
    import flash.net.FileReference;

    var 
    listener:Object = new Object();
    var 
    startTime:Number;

    listener.onOpen = function(file:FileReference):Void  {
        
    startTime getTimer();
        
    trace("download of "+file.name+" started at "+startTime);
    };

    listener.onProgress = function(file:FileReferencebytesLoaded:NumberbytesTotal:Number):Void  {
        var 
    millisecsPassed:Number getTimer()-startTime;
        var 
    rate:Number Math.round(bytesLoaded/millisecsPassed*1000);
        
    // rate will be bytes per second average during the whole download
        
    trace("bytesLoaded: "+bytesLoaded+" bytesTotal: "+bytesTotal+" @ "+rate+" bytes/sec");
    };

    listener.onComplete = function(file:FileReference):Void  {
        var 
    millisecsPassed:Number getTimer()-startTime;
        var 
    rate:Number Math.round(file.size/millisecsPassed*1000);

        
    trace("onComplete: "+file.name);
        
    trace("total Time: "Math.round(millisecsPassed/1000)+ " seconds ");
        
    trace("Overall Performance: "+rate+" bytes/sec");
    };

    var 
    fileRef:FileReference = new FileReference();
    fileRef.addListener(listener);
    var 
    url:String "http://www.macromedia.com/platform/whitepapers/platform_overview.pdf";
    if (!
    fileRef.download(url"FlashPlatform.pdf")) {
        
    trace("dialog box failed to open.");

    ... just because i feel happy today...

  9. #9
    AKA [ Paul Bainbridge] webdreamer's Avatar
    Join Date
    Aug 2001
    Location
    Glasgow, Scotland, UK
    Posts
    3,320
    You should be happy more often

    Cheers man....
    .: To me AS is like LEGO, Only for the big Kids :.
    - Site - Blog - Twitter - Linkedin
    bringmadeleinehome.com

  10. #10
    Flash Gordon McUsher's Avatar
    Join Date
    Mar 2001
    Location
    Krautland
    Posts
    1,560
    To be honest, it was just the MM Demo code in
    the AS-Reference help section + this getTimer() thingy

  11. #11
    AKA [ Paul Bainbridge] webdreamer's Avatar
    Join Date
    Aug 2001
    Location
    Glasgow, Scotland, UK
    Posts
    3,320
    lol. I did a lot of reading of the helps files regarding this issue. dont know how i missed it.

    thanks again.

    worked a treat
    .: To me AS is like LEGO, Only for the big Kids :.
    - Site - Blog - Twitter - Linkedin
    bringmadeleinehome.com

  12. #12
    Member
    Join Date
    Sep 2006
    Posts
    44
    how about the decrementing time left? how is it done? thanks..

  13. #13
    AKA [ Paul Bainbridge] webdreamer's Avatar
    Join Date
    Aug 2001
    Location
    Glasgow, Scotland, UK
    Posts
    3,320
    Quote Originally Posted by shendel101
    how about the decrementing time left? how is it done? thanks..
    Whats the question?
    this thread is nearly two years old.
    .: To me AS is like LEGO, Only for the big Kids :.
    - Site - Blog - Twitter - Linkedin
    bringmadeleinehome.com

  14. #14
    Member
    Join Date
    Sep 2006
    Posts
    44
    i made search of my problem.. and i got this post same as my problem.. i am wondering if you could help me as you already figure out how, two years ago..lol.. My problem is to display time left of download and upload time.. In this example it is incrementing.. what i need is decrementing.. Hope you could help me please.

  15. #15
    Member
    Join Date
    Sep 2006
    Posts
    44
    thanks for the help.. i was counting you could help me..

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center