dcsimg
A Flash Developer Resource Site

Results 1 to 10 of 10

Thread: getBytesTotal doesnt return any value??

  1. #1
    setVariable kinx's Avatar
    Join Date
    Oct 2000
    Location
    Scotland
    Posts
    239

    getBytesTotal doesnt return any value??

    Hi

    I am loading an image into a holder clip (holder2) off stage and then loading it into a display clip (holder) when fully loaded

    here is the code
    Code:
    function imageLoader(image2load) {
    	//load image into holder clip
    	holder2.loadMovie(image2load);
    	//show loader mc
    	_root.loader.gotoAndStop("on");
    	_root.loader.indicator.onEnterFrame = function() {
    		bytesLoaded = holder2.getBytesLoaded()/1024;
    		//this is not returning any value
    		bytesTot = holder2.getBytesTotal()/1024;
    		//if I specify the bytesTotal it works
    		//bytesTot = 340;
    		if (bytesTot>5) {
    			percent = int((bytesLoaded/bytesTot)*100);
    			_root.loader.indicator.percent.text = percent+"%";
    		}
    		if (bytesLoaded>=bytesTot && bytesTot>1) {
    			//place image into display clip
    			holder.loadMovie(image2load);
    			//hide loader
    			_root.loader.play()
    			delete this.onEnterFrame;
    		}
    	};
    }
    imageLoader("images/home.jpg")
    The getBytesTotal request does not return any value, the code works cos if I hard code the value the loading works???

    Any ideas? is there a setting on the server that needs to be set to allow this to work??

  2. #2
    Senior Member Branny's Avatar
    Join Date
    Feb 2001
    Location
    Manchester/UK
    Posts
    512
    bytesLoaded is a resered word in flash try using something else like
    bytes_loaded = holder2.getBytesLoaded()/1024;

  3. #3
    setVariable kinx's Avatar
    Join Date
    Oct 2000
    Location
    Scotland
    Posts
    239
    tried that and it still doesnt work, its the value of getBytesTotal that is not returning UNTIL the end of the load.

    Any Ideas why?

  4. #4
    setVariable kinx's Avatar
    Join Date
    Oct 2000
    Location
    Scotland
    Posts
    239
    Anybody any ideas, getting in a bit of a panic

  5. #5
    Senior Member
    Join Date
    Aug 2000
    Location
    Montréal
    Posts
    14,141
    code:
    function imageLoader(image2load) {
    // load image into holder clip
    holder2.loadMovie(image2load);
    // show loader mc
    _root.loader.gotoAndStop("on");
    _root.loader.indicator.onEnterFrame = function() {
    bytesLoaded = Math.round(holder2.getBytesLoaded()/1024);
    // this is not returning any value
    bytesTot = Math.round(holder2.getBytesTotal()/1024);
    // if I specify the bytesTotal it works
    // bytesTot = 340;
    if (bytesTot>5) {
    percent = int((bytesLoaded/bytesTot)*100);
    _root.loader.indicator.percent.text = percent+"%";
    }
    if (bytesLoaded>=bytesTot && bytesTot>1) {
    // place image into display clip
    holder.loadMovie(image2load);
    // hide loader
    _root.loader.play();
    delete _root.loader.indicator.onEnterFrame;
    }
    };
    }
    imageLoader("images/home.jpg");



    Your vars needed some rounding. I also deleted the same object.onEnterFrame that you opened.

    gparis

  6. #6
    setVariable kinx's Avatar
    Join Date
    Oct 2000
    Location
    Scotland
    Posts
    239
    Still doesnt work, it is the value of getBytesTotal that is not being returned until the image is fully loaded

    I can send you the file if you email me, but it is definately getbytesTotal

    the file is up on www.setvariable.com/thelab that will show you the value not being received till the end

  7. #7
    Senior Member
    Join Date
    May 2001
    Posts
    1,838
    For my browser, the preloader seems to work well. It did show percentage progressively till 100% before I see the yellow picture.

  8. #8
    Senior Member
    Join Date
    Aug 2000
    Location
    Montréal
    Posts
    14,141
    Also, I don't know if you pasted 'exactly' what i posted, but i tested that script before posting it, and i get a return value for all variables, bytesTotal included.

    gparis

  9. #9
    setVariable kinx's Avatar
    Join Date
    Oct 2000
    Location
    Scotland
    Posts
    239
    weird, I pasted exactly as you posted! This problem happened before and it has only ever happened after I installed xp pro's service pack 2, could that have a bearing on it?

    I wondered because I have searched all over the place and never found anyone with a similar problem! Bizarre! So it is my machine / browser / something?

    I swear I am still not getting the incremental value until the end of the load!

    Thanks for the input, I will have to get hold of another machine and test on that.

    Thanks again (but very strange)

  10. #10
    Senior Member
    Join Date
    Aug 2000
    Location
    Montréal
    Posts
    14,141
    I'm looking at your url and % goes smoothly from 0% to 100%. Using Firefox. With cache set at 0
    Empty your cache. Check your plugin.

    gparis

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