# How to avoid progress bar flashing quickly in cached scenes?

**URL:** https://phaser.discourse.group/t/how-to-avoid-progress-bar-flashing-quickly-in-cached-scenes/9937
**Category:** Phaser 3
**Created:** [July 12, 2021, 7:50pm UTC](https://phaser.discourse.group/t/how-to-avoid-progress-bar-flashing-quickly-in-cached-scenes/9937 "2021-07-12T19:50:39Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![YanKleber](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/yankleber/32/5152_2.png) [@YanKleber](https://phaser.discourse.group/u/YanKleber)
#### Post date: [July 12, 2021, 7:50pm UTC](https://phaser.discourse.group/t/how-to-avoid-progress-bar-flashing-quickly-in-cached-scenes/9937/1 "2021-07-12T19:50:39Z")

</div>

Hi!

I implemented a progress bar in the preload function of my scenes and it’s working fine. However as I move back and forth among the scenes every time I enter a cached scene the progress bar flashes quickly. I would like to know how to avoid it.

Here the code I am using for the progress bar:

```javascript
        var width = this.cameras.main.width;
        var height = this.cameras.main.height;
        var loadingText = this.make.text({
            x: width / 2,
            y: height / 2 - 50,
            text: 'Loading...',
            style: {
                font: '20px monospace',
                fill: '#ffffff'
            }
        });

        loadingText.setOrigin(0.5, 0.5);
        var progressBar = this.add.graphics();
        var progressBox = this.add.graphics();
        progressBox.fillStyle(0x4a7128, 0.8);
        progressBox.fillRect(352, 359, 320, 50);

        this.load.on('progress', function (value) {
            progressBar.clear();
            progressBar.fillStyle(0xffffff, 1);
            progressBar.fillRect(362, 369, 300 * value, 30);
        });
                    
        this.load.on('complete', function () {
            progressBar.destroy();
            progressBox.destroy();
        });

```

Thanks!

---

<div class="post-metadata">

### Author: ![samme](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/samme/32/5275_2.png) [@samme](https://phaser.discourse.group/u/samme)
#### Post date: [July 13, 2021, 3:19pm UTC](https://phaser.discourse.group/t/how-to-avoid-progress-bar-flashing-quickly-in-cached-scenes/9937/2 "2021-07-13T15:19:04Z")

</div>

I don’t expect that would happen unless you’re loading new files after restarting the scene.

Try logging the start, progress, and complete events.

---

<div class="post-metadata">

### Author: ![YanKleber](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/yankleber/32/5152_2.png) [@YanKleber](https://phaser.discourse.group/u/YanKleber)
#### Post date: [July 13, 2021, 7:38pm UTC](https://phaser.discourse.group/t/how-to-avoid-progress-bar-flashing-quickly-in-cached-scenes/9937/3 "2021-07-13T19:38:50Z")

</div>

> [@samme](#):
>
> Try logging the start, progress, and complete events.

Good idea, thanks! 🙂
