# Two Preload Bars

**URL:** <https://forum.kirupa.com/t/two-preload-bars/307616>\
**Category:** flash\
**Created:** [April 7, 2010, 12:23am UTC](https://forum.kirupa.com/t/two-preload-bars/307616 "2010-04-07T00:23:01Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![bballfan19](https://avatars.discourse-cdn.com/v4/letter/b/cdc98d/32.png) [@bballfan19](https://forum.kirupa.com/u/bballfan19)\
**Post date:** [April 7, 2010, 12:23am UTC](https://forum.kirupa.com/t/two-preload-bars/307616/1 "2010-04-07T00:23:01Z")

</div>

This is my preloader code from [www.playbball.com](http://www.playbball.com/).

It was kind of a fluke but neat to use two bars. One’s motion is smoothed and the other’s motion isn’t:

```
	private function progress(e:ProgressEvent):void // update preloader
	{
		var temp:int;
		temp = (e.bytesLoaded / e.bytesTotal) * 100;
		m_textfield.text = temp + " / 100";
		
		mysquare.width = 700 - (700 * (e.bytesLoaded / e.bytesTotal));
		mysquare.x = mysquarex + (700 * (e.bytesLoaded / e.bytesTotal));
		
		progressWidth2 = 700 - (7 * (temp));
		
		triangleShape.x = mysquarex + (680 * (e.bytesLoaded / e.bytesTotal));
		
		if (e.bytesLoaded / e.bytesTotal == 1) {
			//removeEventListener(Event.ENTER_FRAME, checkFrame);
			boolLoaded = true;
			}
	}

```

private function doFrame(e:Event):void  
{  
var time2:int = getTimer();  
var timeDelta:int = time2 - time;  
time = time2;

```
        triangleShape.rotation = triangleShape.rotation + (timeDelta &gt;&gt; 3);
    
        var tempMovement:int; var distanceMultiplier:int;
        distanceMultiplier = (mysquare2.width - progressWidth2) / 5
        tempMovement = (timeDelta &gt;&gt; 5) * distanceMultiplier;
        
        if(mysquare2.width - tempMovement &lt; progressWidth2)
        {
            mysquare2.width = progressWidth2;
        }
        else
        {
            mysquare2.width -= tempMovement;
        }
        
    }
```
