# Preloading contents loaded by LoadVars Object

**URL:** <https://forum.kirupa.com/t/preloading-contents-loaded-by-loadvars-object/137965>\
**Category:** Uncategorized\
**Created:** [February 18, 2005, 6:56pm UTC](https://forum.kirupa.com/t/preloading-contents-loaded-by-loadvars-object/137965 "2005-02-18T18:56:27Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![silverType](https://avatars.discourse-cdn.com/v4/letter/s/ac91a4/32.png) [@silverType](https://forum.kirupa.com/u/silverType)\
**Post date:** [February 18, 2005, 6:56pm UTC](https://forum.kirupa.com/t/preloading-contents-loaded-by-loadvars-object/137965/1 "2005-02-18T18:56:27Z")

</div>

Hi guys,  
I was trying to create a preloader that preloads content loaded by the LoadVars() Object. For some reason, the getBytesLoaded and getByetesTotal variables of the LoadVars object kept retuning a null value. Below’s how I do it:

```php

var news_lv = new LoadVars();
var url = "news.aspx"
news_lv.load(url);

//////////////////////Preload Content///////////////////////////
var bytes_loaded = news_lv.getBytesLoaded();
var bytes_total = news_lv.getBytesTotal();
var getPercent = bytes_loaded/bytes_total;

this.loadBar._width = getPercent*100;

//loadText is the variable name of a textfield that 
//resides within the loadText_mov mc

loadtext_mov.loadText = Math.round(getPercent*100)+"% Loaded";

if ( Math.round(getPercent*100) >= 50 ) {
	my_color = new Color(loadBar);
	my_color.setRGB(0xFF0000);
}
if (bytes_loaded == bytes_total) {
	this.gotoAndPlay(3);
}
//////////////////////////////////////////////////////////////
news_lv.onLoad = function(success)
{
          if ( success )
         {	
           //some other codes
          }
}

```

Any clue what’s wrong? Thanks in advance.
